1 /*
2  * Copyright (C) 2019 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.modules.utils.testing;
18 
19 
20 import com.android.dx.mockito.inline.extended.StaticMockitoSession;
21 import com.android.dx.mockito.inline.extended.StaticMockitoSessionBuilder;
22 
23 /**
24  * Provides support for a set of static mocks for use within a single shared
25  * {@link StaticMockitoSession}.
26  */
27 public interface StaticMockFixture {
28     /**
29      * Adds any required mock or spy classes managed by this {@link StaticMockFixture} to the
30      * {@link StaticMockitoSessionBuilder} provided.
31      *
32      * Call this to set up the classes that this expects to be mocked, by adding them to the
33      * {@link StaticMockitoSessionBuilder} using
34      * {@link StaticMockitoSessionBuilder#mockStatic(Class)},
35      * {@link StaticMockitoSessionBuilder#spyStatic(Class)} or similar as appropriate.
36      *
37      * @param sessionBuilder the {@link StaticMockitoSessionBuilder} to which the classes should be
38      *                       added to mock, spy, or otherwise as required
39      * @return sessionBuilder, to allow for fluent programming
40      */
setUpMockedClasses(StaticMockitoSessionBuilder sessionBuilder)41     StaticMockitoSessionBuilder setUpMockedClasses(StaticMockitoSessionBuilder sessionBuilder);
42 
43     /**
44      * Configures the behaviours of any mock or spy classes managed by this
45      * {@link StaticMockFixture}.
46      *
47      * Call this after {@link StaticMockitoSessionBuilder#startMocking()} has been called.
48      * This sets up any default behaviors for the mocks, spys, etc.
49      */
setUpMockBehaviors()50     void setUpMockBehaviors();
51 
52     /**
53      * Tear everything down.
54      */
tearDown()55     void tearDown();
56 }
57