summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Bryce Lee <brycelee@google.com> 2017-10-23 20:07:42 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-10-23 20:07:42 +0000
commit4a09e4c11e11fc6ce6d05970fe372bbee3d2c0f5 (patch)
treed6dcb111dae1c8ff9f7e3554a43850faa094fed0
parent20aa00fef7c44e49a84c2385ebcbc7a8c763a841 (diff)
parent939a9a3d4f1049b5dd257324bcfd0ef49ff54788 (diff)
Merge "Allow package local mocking for ActivityManager Unit Tests."
-rw-r--r--services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
index 20077f3e94b0..d36f9d3505b2 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
@@ -52,12 +52,20 @@ import org.mockito.MockitoAnnotations;
* A base class to handle common operations in activity related unit tests.
*/
public class ActivityTestsBase {
+ private static boolean sOneTimeSetupDone = false;
+
private final Context mContext = InstrumentationRegistry.getContext();
private HandlerThread mHandlerThread;
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
+ if (!sOneTimeSetupDone) {
+ sOneTimeSetupDone = true;
+
+ // Allows to mock package local classes and methods
+ System.setProperty("dexmaker.share_classloader", "true");
+ MockitoAnnotations.initMocks(this);
+ }
mHandlerThread = new HandlerThread("ActivityTestsBaseThread");
mHandlerThread.start();
}