1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.adservices.mockito; 18 19 import com.android.adservices.service.Flags; 20 21 /** 22 * Helper interface providing expectations to set the most common AdService flags / features. 23 * 24 * <p>A "feature" could require setting a combo of flags - adding that logic here would make the 25 * tests less verbose and easier to maintain (for example, when a flag is not needed by a feature 26 * anymore, only the implementation of this interface would need to be changed, not individual 27 * tests). 28 */ 29 public interface AdServicesFlagsMocker { 30 31 // TODO(b/358120731): rename some methods below, like: 32 // - mockGetBackgroundJobsLoggingKillSwitch -> mockGetBackgroundJobsLoggingFeature 33 // would need to negate previous 34 // - mockAllCobaltLoggingFlags -> mockCobaltLoggingFeature 35 // Or create a convention: the "mockGet" is "as-is", while a "mockFeature" is a combo 36 37 // TODO(b/354932043): it might make more sense to move this one to AdServicesJobMocker instead 38 /** 39 * Mocks a call to {@link Flags#getBackgroundJobsLoggingKillSwitch()}, returning {@code value}. 40 */ mockGetBackgroundJobsLoggingKillSwitch(boolean value)41 void mockGetBackgroundJobsLoggingKillSwitch(boolean value); 42 43 /** Mocks a call to {@link Flags#getCobaltLoggingEnabled()}, returning {@code value}. */ mockGetCobaltLoggingEnabled(boolean value)44 void mockGetCobaltLoggingEnabled(boolean value); 45 46 /** Mocks a call to {@link Flags#getAppNameApiErrorCobaltLoggingEnabled()}. */ mockGetAppNameApiErrorCobaltLoggingEnabled(boolean value)47 void mockGetAppNameApiErrorCobaltLoggingEnabled(boolean value); 48 49 /** Mocks a call to {@link Flags#getCobaltEnableApiCallResponseLogging()}. */ mockGetEnableApiCallResponseLoggingEnabled(boolean value)50 void mockGetEnableApiCallResponseLoggingEnabled(boolean value); 51 52 /** Mocks calls to override Cobalt app name api error logging related flags. */ mockAllCobaltLoggingFlags(boolean enabled)53 void mockAllCobaltLoggingFlags(boolean enabled); 54 55 /** 56 * Mocks a call to {@link Flags#getAdservicesReleaseStageForCobalt()}, returning the proper code 57 * for the testing release stage. 58 */ mockGetAdservicesReleaseStageForCobalt(String stage)59 void mockGetAdservicesReleaseStageForCobalt(String stage); 60 } 61