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.DebugFlags; 20 import com.android.adservices.service.FakeFlagsFactory; 21 import com.android.adservices.service.Flags; 22 import com.android.adservices.service.FlagsFactory; 23 import com.android.adservices.service.stats.AdServicesLoggerImpl; 24 import com.android.adservices.spe.AdServicesJobScheduler; 25 import com.android.adservices.spe.AdServicesJobServiceFactory; 26 27 /** Helper interface providing common expectations for static methods on AdServices APIs. */ 28 public interface AdServicesStaticMocker { 29 30 /** 31 * Mocks a call of {@link FlagsFactory#getFlags()} to return the passed-in mocking {@link Flags} 32 * object. 33 * 34 * @throws IllegalStateException if test didn't call {@code spyStatic} / {@code mockStatic} (or 35 * equivalent annotations) on {@link FlagsFactory}. 36 */ mockGetFlags(Flags mockedFlags)37 void mockGetFlags(Flags mockedFlags); 38 39 /** 40 * Mocks a call to {@link FlagsFactory#getFlags()}, returning {@link 41 * FakeFlagsFactory#getFlagsForTest()} 42 * 43 * @throws IllegalStateException if test didn't call {@code spyStatic} / {@code mockStatic} (or 44 * equivalent annotations) on {@link FlagsFactory}. 45 */ mockGetFlagsForTesting()46 void mockGetFlagsForTesting(); 47 48 /** 49 * Mocks a call of {@link DebugFlags#getInstance()} to return the passed-in mocking {@link 50 * DebugFlags} object. 51 * 52 * @throws IllegalStateException if test didn't call {@code spyStatic} / {@code mockStatic} (or 53 * equivalent annotations) on {@link DebugFlags}. 54 */ mockGetDebugFlags(DebugFlags mockedDebugFlags)55 void mockGetDebugFlags(DebugFlags mockedDebugFlags); 56 57 /** 58 * Mocks a call to {@link AdServicesJobScheduler#getInstance()}. 59 * 60 * @throws IllegalStateException if test didn't call {@code spyStatic} / {@code mockStatic} (or 61 * equivalent annotations) on {@link AdServicesJobScheduler}. 62 */ mockSpeJobScheduler(AdServicesJobScheduler mockedAdServicesJobScheduler)63 void mockSpeJobScheduler(AdServicesJobScheduler mockedAdServicesJobScheduler); 64 65 /** 66 * Mocks a call to {@link AdServicesJobServiceFactory#getInstance()}. 67 * 68 * @throws IllegalStateException if test didn't call {@code spyStatic} / {@code mockStatic} (or 69 * equivalent annotations) on {@link AdServicesJobServiceFactory}. 70 */ mockAdServicesJobServiceFactory( AdServicesJobServiceFactory mockedAdServicesJobServiceFactory)71 void mockAdServicesJobServiceFactory( 72 AdServicesJobServiceFactory mockedAdServicesJobServiceFactory); 73 74 /** 75 * Mocks a call to {@link AdServicesLoggerImpl#getInstance()}. 76 * 77 * @throws IllegalStateException if test didn't call {@code spyStatic} / {@code mockStatic} (or 78 * equivalent annotations) on {@link AdServicesLoggerImpl}. 79 */ mockAdServicesLoggerImpl(AdServicesLoggerImpl mockedAdServicesLoggerImpl)80 void mockAdServicesLoggerImpl(AdServicesLoggerImpl mockedAdServicesLoggerImpl); 81 82 } 83