Merge "Snap for 5328068 from 3284bb52c7e3d4b660e76ab1254400d37711dd60 to pie-cts-release" into pie-cts-release
diff --git a/Android.mk b/Android.mk
index a5b52c7..05e805a 100644
--- a/Android.mk
+++ b/Android.mk
@@ -127,9 +127,8 @@
 
 ########################################################
 # Zip up the built files and dist it as tradefed.zip
-ifneq (,$(filter tradefed tradefed-all, $(TARGET_BUILD_APPS)))
 
-tradefed_dist_host_jars := tradefed tradefed-tests tf-prod-tests tf-prod-metatests emmalib jack-jacoco-reporter loganalysis loganalysis-tests tf-remote-client tradefed-contrib
+tradefed_dist_host_jars := tradefed tradefed-tests tf-prod-tests tf-prod-metatests emmalib jack-jacoco-reporter loganalysis loganalysis-tests tf-remote-client tradefed-contrib tools-common-prebuilt
 tradefed_dist_host_jar_files := $(foreach m, $(tradefed_dist_host_jars), $(HOST_OUT_JAVA_LIBRARIES)/$(m).jar)
 
 tradefed_dist_host_exes := tradefed.sh tradefed_win.bat script_help.sh verify.sh run_tf_cmd.sh atest_tradefed.sh
@@ -151,6 +150,4 @@
 	$(hide) cp -f $^ $(dir $@)
 	$(hide) cd $(dir $@) && zip -q $(notdir $@) $(notdir $^)
 
-$(call dist-for-goals, apps_only, $(tradefed_dist_zip))
-
-endif  # tradefed in $(TARGET_BUILD_APPS)
+$(call dist-for-goals, tradefed-all, $(tradefed_dist_zip))
diff --git a/prod-tests/res/config/framework/preloaded-classes.xml b/prod-tests/res/config/framework/preloaded-classes.xml
deleted file mode 100644
index 2a4dde1..0000000
--- a/prod-tests/res/config/framework/preloaded-classes.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<configuration description="Runs tests to report preloaded classes information">
-    <!-- Provide account sign-in -->
-    <target_preparer class="com.google.android.tradefed.targetprep.GoogleAccountPreparer">
-        <option name="account-sync" value="true" />
-    </target_preparer>
-    <!-- Disable auto-updates -->
-    <target_preparer class="com.google.android.tradefed.targetprep.GoogleAppsSetup">
-        <option name="vending-auto-update" value="OFF" />
-    </target_preparer>
-    <!-- Download preload tool -->
-    <option name="device-launch-control:additional-files-filter" value=".*preload2.jar" />
-    <!-- Install test apps -->
-    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup" />
-    <!-- Preload test configuration -->
-    <option name="test-tag" value="preloaded-classes" />
-    <test class="com.android.framework.tests.PreloadedClassesTest" />
-</configuration>
diff --git a/prod-tests/res/config/performance/app-transitions.xml b/prod-tests/res/config/performance/app-transitions.xml
deleted file mode 100644
index c2041e8..0000000
--- a/prod-tests/res/config/performance/app-transitions.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<configuration description="Testing the transition delay performance" >
-
-    <option name="test-tag" value="AppTransitionTests" />
-
-    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup" >
-        <option name="test-file-name" value="AppTransitionTests.apk" />
-    </target_preparer>
-
-    <target_preparer class="com.google.android.tradefed.targetprep.GoogleAccountPreparer">
-        <option name="account-sync" value="true" />
-        <option name="wait-for-sync" value="true" />
-    </target_preparer>
-
-    <target_preparer class="com.google.android.tradefed.targetprep.DismissDialogsPreparer" >
-        <option name="test-file-name" value="DialogDismissalUtil.apk" />
-    </target_preparer>
-
-    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer" />
-
-    <test class="com.android.performance.tests.AppTransitionTests" />
-
-</configuration>
diff --git a/src/com/android/tradefed/targetprep/SwitchUserTargetPreparer.java b/src/com/android/tradefed/targetprep/SwitchUserTargetPreparer.java
new file mode 100644
index 0000000..9b4fe49
--- /dev/null
+++ b/src/com/android/tradefed/targetprep/SwitchUserTargetPreparer.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tradefed.targetprep;
+
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.Option;
+import com.android.tradefed.config.OptionClass;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.LogUtil.CLog;
+
+/**
+ * A {@link ITargetPreparer} that switches to the specified user kind in setUp. By default it
+ * remains in the current user, and no switching is performed.
+ *
+ * <p>Tries to restore device user state by switching back to the pre-execution current user.
+ */
+@OptionClass(alias = "switch-user-target-preparer")
+public class SwitchUserTargetPreparer extends BaseTargetPreparer implements ITargetCleaner {
+    private static final int USER_SYSTEM = 0; // From the UserHandle class.
+
+    /** Parameters that specify which user to run the test module as. */
+    public enum UserType {
+        // TODO:(b/123077733) Add support for guest and secondary.
+
+        /** current foreground user of the device */
+        CURRENT,
+        /** user flagged as primary on the device; most often primary = system user = user 0 */
+        PRIMARY,
+        /** system user = user 0 */
+        SYSTEM
+    }
+
+    @Option(
+        name = "user-type",
+        description = "The type of user to switch to before the module run."
+    )
+    private UserType mUserToSwitchTo = UserType.CURRENT;
+
+    private int mPreExecutionCurrentUser;
+
+    @Override
+    public void setUp(ITestDevice device, IBuildInfo buildInfo)
+            throws TargetSetupError, DeviceNotAvailableException {
+
+        mPreExecutionCurrentUser = device.getCurrentUser();
+
+        switch (mUserToSwitchTo) {
+            case SYSTEM:
+                switchToUser(USER_SYSTEM, device);
+                break;
+            case PRIMARY:
+                switchToUser(device.getPrimaryUserId(), device);
+                break;
+        }
+    }
+
+    private static void switchToUser(int userId, ITestDevice device)
+            throws TargetSetupError, DeviceNotAvailableException {
+        if (device.getCurrentUser() == userId) {
+            return;
+        }
+
+        // Otherwise, switch to user with userId.
+        if (device.switchUser(userId)) {
+            // Successful switch.
+            CLog.i("Switched to user %d.", userId);
+        } else {
+            // Couldn't switch, throw.
+            throw new TargetSetupError(
+                    String.format("Failed switch to user %d.", userId),
+                    device.getDeviceDescriptor());
+        }
+    }
+
+    @Override
+    public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)
+            throws DeviceNotAvailableException {
+        // Restore the previous user as the foreground.
+        if (!device.switchUser(mPreExecutionCurrentUser)) {
+            CLog.w("Could not switch back to the user id: %d", mPreExecutionCurrentUser);
+        }
+    }
+}
diff --git a/src/com/android/tradefed/testtype/AndroidJUnitTest.java b/src/com/android/tradefed/testtype/AndroidJUnitTest.java
index cdcbc9f..db50108 100644
--- a/src/com/android/tradefed/testtype/AndroidJUnitTest.java
+++ b/src/com/android/tradefed/testtype/AndroidJUnitTest.java
@@ -47,8 +47,6 @@
         ITestFileFilterReceiver, ITestFilterReceiver, ITestAnnotationFilterReceiver,
         IShardableTest, IStrictShardableTest {
 
-    protected static final String AJUR = "android.support.test.runner.AndroidJUnitRunner";
-
     /** instrumentation test runner argument key used for including a class/test */
     private static final String INCLUDE_CLASS_INST_ARGS_KEY = "class";
     /** instrumentation test runner argument key used for excluding a class/test */
@@ -143,8 +141,6 @@
 
     public AndroidJUnitTest() {
         super();
-        // Set the runner to AJUR, this can still be overwritten by the optionsetter/optioncopier
-        setRunnerName(AJUR);
         setEnforceFormat(true);
     }
 
diff --git a/src/com/android/tradefed/testtype/GTestListTestParser.java b/src/com/android/tradefed/testtype/GTestListTestParser.java
index 894010e..216f4e0 100644
--- a/src/com/android/tradefed/testtype/GTestListTestParser.java
+++ b/src/com/android/tradefed/testtype/GTestListTestParser.java
@@ -45,7 +45,7 @@
     // example: <line start>  emptyPlayback<line end>
     // example parameterized: <line start>  emptyPlayback/0 # GetParam() = (object 1)<line end>
     private static final Pattern TEST_METHOD =
-            Pattern.compile("\\s+([a-zA-Z]+[\\S]*)(.*)?(\\s+.*)?$");
+            Pattern.compile("\\s+([a-zA-Z_]+[\\S]*)(.*)?(\\s+.*)?$");
 
     // exposed for unit testing
     protected List<TestDescription> mTests = new ArrayList<>();
diff --git a/src/com/android/tradefed/testtype/InstrumentationTest.java b/src/com/android/tradefed/testtype/InstrumentationTest.java
index d3f3102..3406dd2 100644
--- a/src/com/android/tradefed/testtype/InstrumentationTest.java
+++ b/src/com/android/tradefed/testtype/InstrumentationTest.java
@@ -702,7 +702,12 @@
     public void run(final ITestInvocationListener listener) throws DeviceNotAvailableException {
         checkArgument(mDevice != null, "Device has not been set.");
         checkArgument(mPackageName != null, "Package name has not been set.");
-
+        // Install the apk before checking the runner
+        if (mInstallFile != null) {
+            Assert.assertNull(
+                    mDevice.installPackage(
+                            mInstallFile, true, mInstallArgs.toArray(new String[] {})));
+        }
         if (mRunnerName == null) {
             setRunnerName(queryRunnerName());
             checkArgument(
@@ -710,13 +715,9 @@
                     "Runner name has not been set and no matching instrumentations were found.");
             CLog.i("No runner name specified. Using: %s.", mRunnerName);
         }
-
         mRunner = createRemoteAndroidTestRunner(mPackageName, mRunnerName, mDevice.getIDevice());
         setRunnerArgs(mRunner);
-        if (mInstallFile != null) {
-            Assert.assertNull(mDevice.installPackage(mInstallFile, true,
-                    mInstallArgs.toArray(new String[]{})));
-        }
+
         doTestRun(listener);
         if (mInstallFile != null) {
             mDevice.uninstallPackage(mPackageName);
diff --git a/src/com/android/tradefed/util/ListInstrumentationParser.java b/src/com/android/tradefed/util/ListInstrumentationParser.java
index 0f92307..5369045 100644
--- a/src/com/android/tradefed/util/ListInstrumentationParser.java
+++ b/src/com/android/tradefed/util/ListInstrumentationParser.java
@@ -44,8 +44,11 @@
     // Instrumentation is shardable. A workaround is to have a list of shardable instrumentation
     // runners, and check if a target uses that particular runner, although this means that any
     // subclasses or other custom runner classes won't be acknowledged as shardable.
-    public static final Set<String> SHARDABLE_RUNNERS = new HashSet<>(Arrays.asList(
-                "android.support.test.runner.AndroidJUnitRunner"));
+    public static final Set<String> SHARDABLE_RUNNERS =
+            new HashSet<>(
+                    Arrays.asList(
+                            "android.support.test.runner.AndroidJUnitRunner",
+                            "androidx.test.runner.AndroidJUnitRunner"));
 
     private List<InstrumentationTarget> mInstrumentationTargets = new ArrayList<>();
 
diff --git a/tests/res/config/tf/unit-runner.xml b/tests/res/config/tf/unit-runner.xml
new file mode 100644
index 0000000..8c11a96
--- /dev/null
+++ b/tests/res/config/tf/unit-runner.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<configuration description="Executes the TF unit tests, and reports results using provided build details">
+    <option name="loop" value="false" />
+    <option name="null-device" value="true" />
+    <build_provider class="com.android.tradefed.build.StubBuildProvider" />
+    <!-- Use HostTest runner to have JUnit3 and JUnit4 Suite support -->
+    <test class="com.android.tradefed.testtype.HostTest" >
+        <option name="class" value="com.android.loganalysis.UnitTests" />
+        <option name="class" value="com.android.tradefed.UnitTests" />
+        <option name="class" value="com.android.tradefed.prodtests.UnitTests" />
+    </test>
+    <logger class="com.android.tradefed.log.FileLogger" />
+    <result_reporter class="com.android.tradefed.result.SubprocessResultsReporter">
+        <option name="output-test-log" value="true" />
+    </result_reporter>
+</configuration>
diff --git a/tests/res/testtype/gtest_list1.txt b/tests/res/testtype/gtest_list1.txt
index 0cce19e..1ef5287 100644
--- a/tests/res/testtype/gtest_list1.txt
+++ b/tests/res/testtype/gtest_list1.txt
@@ -8,7 +8,7 @@
   drawText
   drawText_strikeThruAndUnderline
   drawText_forceAlignLeft
-  drawColor
+  __drawColor
   backgroundAndImage
   saveLayer_simple
   saveLayer_missingRestore
diff --git a/tests/src/com/android/tradefed/UnitTests.java b/tests/src/com/android/tradefed/UnitTests.java
index d3e733d..2cd4e0b 100644
--- a/tests/src/com/android/tradefed/UnitTests.java
+++ b/tests/src/com/android/tradefed/UnitTests.java
@@ -467,6 +467,7 @@
     TestAppInstallSetupTest.class,
     TestFilePushSetupTest.class,
     TimeSetterTargetPreparerTest.class,
+    SwitchUserTargetPreparerTest.class,
 
     // targetprep.multi
     MergeMultiBuildTargetPreparerTest.class,
diff --git a/tests/src/com/android/tradefed/targetprep/SwitchUserTargetPreparerTest.java b/tests/src/com/android/tradefed/targetprep/SwitchUserTargetPreparerTest.java
new file mode 100644
index 0000000..6b55093
--- /dev/null
+++ b/tests/src/com/android/tradefed/targetprep/SwitchUserTargetPreparerTest.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tradefed.targetprep;
+
+import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.android.tradefed.config.ConfigurationException;
+import com.android.tradefed.config.OptionSetter;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/** Unit tests for {@link SwitchUserTargetPreparer}. */
+@RunWith(JUnit4.class)
+public class SwitchUserTargetPreparerTest {
+    private static final int USER_SYSTEM = 0; // From the UserHandle class.
+
+    @Mock private ITestDevice mMockDevice;
+
+    private SwitchUserTargetPreparer mSwitchUserTargetPreparer;
+    private OptionSetter mOptionSetter;
+
+    @Before
+    public void setUp() throws ConfigurationException {
+        MockitoAnnotations.initMocks(this);
+        mSwitchUserTargetPreparer = new SwitchUserTargetPreparer();
+        mOptionSetter = new OptionSetter(mSwitchUserTargetPreparer);
+    }
+
+    @Test
+    public void testSetUpRunAsPrimary_ifAlreadyInPrimary_noUserSwitch()
+            throws DeviceNotAvailableException, TargetSetupError, ConfigurationException {
+        // setup
+        mockUsers(/* primaryUserId= */ 11, /* currentUserId= */ 11);
+        mOptionSetter.setOptionValue("user-type", "primary");
+
+        // act
+        mSwitchUserTargetPreparer.setUp(mMockDevice, /* buildInfo= */ null);
+
+        // assert
+        verify(mMockDevice, never()).switchUser(anyInt());
+    }
+
+    @Test
+    public void testSetUpRunAsSystem_ifAlreadyInSystem_noUserSwitch()
+            throws DeviceNotAvailableException, TargetSetupError, ConfigurationException {
+        // setup
+        mockUsers(/* primaryUserId= */ 11, /* currentUserId= */ USER_SYSTEM);
+        mOptionSetter.setOptionValue("user-type", "system");
+
+        // act
+        mSwitchUserTargetPreparer.setUp(mMockDevice, /* buildInfo= */ null);
+
+        // assert
+        verify(mMockDevice, never()).switchUser(anyInt());
+    }
+
+    @Test
+    public void testSetUpRunAsPrimary_ifNotInPrimary_switchToPrimary()
+            throws DeviceNotAvailableException, TargetSetupError, ConfigurationException {
+        // setup
+        mockUsers(/* primaryUserId= */ 10, /* currentUserId= */ 11);
+        mOptionSetter.setOptionValue("user-type", "primary");
+
+        // act
+        mSwitchUserTargetPreparer.setUp(mMockDevice, /* buildInfo= */ null);
+
+        // assert it switches to primary in setUp
+        verify(mMockDevice, times(1)).switchUser(10);
+    }
+
+    @Test
+    public void testSetUpRunAsSystem_ifNotInSystem_switchToSystem()
+            throws DeviceNotAvailableException, TargetSetupError, ConfigurationException {
+        // setup
+        mockUsers(/* primaryUserId= */ 10, /* currentUserId= */ 11);
+        mOptionSetter.setOptionValue("user-type", "system");
+
+        // act
+        mSwitchUserTargetPreparer.setUp(mMockDevice, /* buildInfo= */ null);
+
+        // assert it switches to primary in setUp
+        verify(mMockDevice, times(1)).switchUser(USER_SYSTEM);
+    }
+
+    @Test
+    public void testTearDown_ifStartedInSecondary_switchesBackToSecondary()
+            throws DeviceNotAvailableException, TargetSetupError, ConfigurationException {
+        // setup
+        mockUsers(/* primaryUserId= */ 0, /* currentUserId= */ 10);
+        mOptionSetter.setOptionValue("user-type", "primary");
+
+        // first switches to primary
+        mSwitchUserTargetPreparer.setUp(mMockDevice, /* buildInfo= */ null);
+        verify(mMockDevice, times(1)).switchUser(0);
+
+        // then switches back to secondary
+        mSwitchUserTargetPreparer.tearDown(mMockDevice, /* buildInfo= */ null, null);
+        verify(mMockDevice, times(1)).switchUser(10);
+    }
+
+    @Test
+    public void testSetUp_ifNoSwitchToSpecified_noUserSwitch()
+            throws DeviceNotAvailableException, TargetSetupError {
+        // setup
+        mockUsers(/* primaryUserId= */ 0, /* currentUserId= */ 10);
+
+        // act
+        mSwitchUserTargetPreparer.setUp(mMockDevice, /* buildInfo= */ null);
+
+        // assert
+        verify(mMockDevice, never()).switchUser(anyInt());
+    }
+
+    @Test
+    public void testSetUp_ifSwitchFails_throwsTargetSetupError()
+            throws DeviceNotAvailableException, ConfigurationException {
+        // setup
+        mockUsers(/* primaryUserId= */ 0, /* currentUserId= */ 11);
+        mOptionSetter.setOptionValue("user-type", "primary");
+        when(mMockDevice.switchUser(0)).thenReturn(false);
+
+        // act
+        try {
+            mSwitchUserTargetPreparer.setUp(mMockDevice, /* buildInfo= */ null);
+            fail("Should have thrown TargetSetupError exception.");
+        } catch (TargetSetupError e) {
+            // do nothing
+        }
+    }
+
+    private void mockUsers(int primaryUserId, int currentUserId)
+            throws DeviceNotAvailableException {
+        when(mMockDevice.getCurrentUser()).thenReturn(currentUserId);
+        when(mMockDevice.getPrimaryUserId()).thenReturn(primaryUserId);
+        when(mMockDevice.switchUser(anyInt())).thenReturn(true);
+    }
+}
diff --git a/tests/src/com/android/tradefed/testtype/AndroidJUnitTestTest.java b/tests/src/com/android/tradefed/testtype/AndroidJUnitTestTest.java
index 93f4d11..aaefa60 100644
--- a/tests/src/com/android/tradefed/testtype/AndroidJUnitTestTest.java
+++ b/tests/src/com/android/tradefed/testtype/AndroidJUnitTestTest.java
@@ -40,6 +40,7 @@
  */
 public class AndroidJUnitTestTest extends TestCase {
 
+    private static final String AJUR = "android.support.test.runner.AndroidJUnitRunner";
     private static final int TEST_TIMEOUT = 0;
     private static final long SHELL_TIMEOUT = 0;
     private static final String TEST_PACKAGE_VALUE = "com.foo";
@@ -73,6 +74,7 @@
                 return mMockRemoteRunner;
             }
         };
+        mAndroidJUnitTest.setRunnerName(AJUR);
         mAndroidJUnitTest.setPackageName(TEST_PACKAGE_VALUE);
         mAndroidJUnitTest.setDevice(mMockTestDevice);
         // default to no rerun, for simplicity
@@ -370,14 +372,15 @@
      * Test that {@link AndroidJUnitTest#split()} returns null if no shards have been requested.
      */
     public void testSplit_noShardRequested() {
-        assertEquals(AndroidJUnitTest.AJUR, mAndroidJUnitTest.getRunnerName());
+        assertEquals(AJUR, mAndroidJUnitTest.getRunnerName());
         assertNull(mAndroidJUnitTest.split());
     }
 
     /** Test that {@link AndroidJUnitTest#split(int)} returns 3 shards when requested to do so. */
     public void testSplit_threeShards() throws Exception {
         mAndroidJUnitTest = new AndroidJUnitTest();
-        assertEquals(AndroidJUnitTest.AJUR, mAndroidJUnitTest.getRunnerName());
+        mAndroidJUnitTest.setRunnerName(AJUR);
+        assertEquals(AJUR, mAndroidJUnitTest.getRunnerName());
         OptionSetter setter = new OptionSetter(mAndroidJUnitTest);
         setter.setOptionValue("runtime-hint", "60s");
         List<IRemoteTest> res = (List<IRemoteTest>) mAndroidJUnitTest.split(3);
@@ -397,7 +400,8 @@
      */
     public void testSplit_maxShard() throws Exception {
         mAndroidJUnitTest = new AndroidJUnitTest();
-        assertEquals(AndroidJUnitTest.AJUR, mAndroidJUnitTest.getRunnerName());
+        mAndroidJUnitTest.setRunnerName(AJUR);
+        assertEquals(AJUR, mAndroidJUnitTest.getRunnerName());
         OptionSetter setter = new OptionSetter(mAndroidJUnitTest);
         setter.setOptionValue("runtime-hint", "60s");
         setter.setOptionValue("ajur-max-shard", "2");