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 package com.android.adservices.mockito; 17 18 import android.content.Context; 19 20 import com.android.adservices.shared.common.ApplicationContextSingleton; 21 import com.android.adservices.shared.spe.logging.JobServiceLogger; 22 import com.android.adservices.shared.testing.JobServiceLoggingCallback; 23 import com.android.adservices.shared.util.Clock; 24 25 /** Helper interface providing common expectations for methods on shared classes. */ 26 public interface SharedMocker { 27 28 /** 29 * Not an expectation itself, but it sets a mock as the application context on {@link 30 * ApplicationContextSingleton}, and returns it. 31 */ setApplicationContextSingleton()32 Context setApplicationContextSingleton(); 33 34 /** Mocks {@link ApplicationContextSingleton#get()}. */ mockSetApplicationContextSingleton(Context context)35 void mockSetApplicationContextSingleton(Context context); 36 37 /** 38 * Mocks {@link android.app.job.JobService}'s execution to wait until {@link 39 * JobServiceLogger#recordOnStopJob(android.app.job.JobParameters, int, boolean)} is called. 40 */ syncRecordOnStopJob(JobServiceLogger logger)41 JobServiceLoggingCallback syncRecordOnStopJob(JobServiceLogger logger); 42 43 /** Mocks calls to {@link Clock#currentTimeMillis()}. */ mockCurrentTimeMillis(Clock mockClock, long... mockedValues)44 void mockCurrentTimeMillis(Clock mockClock, long... mockedValues); 45 46 /** Mocks calls to {@link Clock#elapsedRealtime()}. */ mockElapsedRealtime(Clock mockClock, long... mockedValues)47 void mockElapsedRealtime(Clock mockClock, long... mockedValues); 48 } 49