Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 939a9a3d authored by Bryce Lee's avatar Bryce Lee
Browse files

Allow package local mocking for ActivityManager Unit Tests.

Test: bit FrameworksServicesTests:com.android.server.am.ActivityRecordTests
Change-Id: I0d1c807681e945b65e2dd9a7d0baa5fc59c8d259
parent 1eb19a3b
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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 {
        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();
    }