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.util.Log; 19 20 import com.android.adservices.shared.testing.TestNamer; 21 22 import com.google.common.collect.ImmutableSet; 23 24 /** Helper class use to check if a class is statically spied / mocked. */ 25 public interface StaticClassChecker extends TestNamer { 26 27 @Override getTestName()28 default String getTestName() { 29 return TestNamer.DEFAULT_TEST_NAME; 30 } 31 32 /** 33 * Checks whether the given class is spied or mocked. 34 * 35 * @return {@code true} by default. 36 */ isSpiedOrMocked(Class<?> clazz)37 default boolean isSpiedOrMocked(Class<?> clazz) { 38 Log.d( 39 "StaticClassChecker", 40 "isSpiedOrMocked(" 41 + clazz.getSimpleName() 42 + "): always returning true on default StaticClassChecker"); 43 return true; 44 } 45 46 /** 47 * Gets the classes that are spied or mocked. 48 * 49 * @return empty list by default. 50 */ getSpiedOrMockedClasses()51 default ImmutableSet<Class<?>> getSpiedOrMockedClasses() { 52 Log.d( 53 "StaticClassChecker", 54 "getSpiedOrMockedClasses(): always returning empty on default" 55 + " StaticClassChecker"); 56 return ImmutableSet.of(); 57 } 58 } 59