1 /*
2  * Copyright (C) 2023 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.common;
17 
18 import android.content.Context;
19 
20 import org.junit.Rule;
21 import org.mockito.Mock;
22 import org.mockito.Spy;
23 import org.mockito.junit.MockitoJUnit;
24 import org.mockito.junit.MockitoRule;
25 import org.mockito.quality.Strictness;
26 
27 /**
28  * Base class for all unit tests that use "regular Mockito" (i.e., not {@code ExtendedMockito} - for
29  * those, use {@link AdServicesExtendedMockitoTestCase} instead)
30  */
31 public abstract class AdServicesMockitoTestCase extends AdServicesUnitTestCase {
32 
33     @Mock protected Context mMockContext;
34 
35     /** Spy the {@link AdServicesUnitTestCase#sContext} */
36     @Spy protected final Context mSpyContext = sContext;
37 
38     @Rule(order = 10)
39     public final MockitoRule mockito = MockitoJUnit.rule().strictness(Strictness.LENIENT);
40 
41     // TODO(b/314969513): add Mocker that implements mocker interfaces needed by subclasses so we
42     // can deprecate MockitoExpectations - see example on AdServicesExtendedMockitoTestCase
43 }
44