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