diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-01-17 23:53:00 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-01-17 23:53:00 +0000 |
commit | 646a892c3baae52b40e808b3e37d599b3956e362 (patch) | |
tree | 3bec6ef8382c4809416a53c5673cc7b10f1b9735 | |
parent | f4a3eaef0a3a7877152221d7684bd156ffa0b38b (diff) | |
parent | 559a44ab98ab4a23898ae442f2d032fbe3c6e613 (diff) | |
download | csuite-646a892c3baae52b40e808b3e37d599b3956e362.tar.gz |
Merge "Replace use of deprecated TradeFed run method"
-rw-r--r-- | harness/src/main/java/com/android/compatibility/testtype/AppLaunchTest.java | 15 | ||||
-rw-r--r-- | harness/src/test/java/com/android/compatibility/testtype/AppLaunchTestTest.java | 23 |
2 files changed, 23 insertions, 15 deletions
diff --git a/harness/src/main/java/com/android/compatibility/testtype/AppLaunchTest.java b/harness/src/main/java/com/android/compatibility/testtype/AppLaunchTest.java index 3852b4b..e54df32 100644 --- a/harness/src/main/java/com/android/compatibility/testtype/AppLaunchTest.java +++ b/harness/src/main/java/com/android/compatibility/testtype/AppLaunchTest.java @@ -26,6 +26,7 @@ import com.android.tradefed.config.Option; import com.android.tradefed.device.DeviceNotAvailableException; import com.android.tradefed.device.ITestDevice; import com.android.tradefed.device.LogcatReceiver; +import com.android.tradefed.invoker.TestInformation; import com.android.tradefed.log.LogUtil.CLog; import com.android.tradefed.metrics.proto.MetricMeasurement.Metric; import com.android.tradefed.result.ByteArrayInputStreamSource; @@ -128,7 +129,8 @@ public class AppLaunchTest * {@inheritDoc} */ @Override - public void run(ITestInvocationListener listener) throws DeviceNotAvailableException { + public void run(final TestInformation testInfo, final ITestInvocationListener listener) + throws DeviceNotAvailableException { CLog.d("Start of run method."); Assert.assertNotNull("Package name cannot be null", mPackageName); @@ -148,7 +150,7 @@ public class AppLaunchTest mLogcat.start(); try { - testPackage(listener); + testPackage(testInfo, listener); } catch (InterruptedException e) { CLog.e(e); throw new RuntimeException(e); @@ -165,7 +167,7 @@ public class AppLaunchTest * @param listener The {@link ITestInvocationListener}. * @throws DeviceNotAvailableException */ - private void testPackage(ITestInvocationListener listener) + private void testPackage(final TestInformation testInfo, ITestInvocationListener listener) throws DeviceNotAvailableException, InterruptedException { CLog.d("Started testing package: %s.", mPackageName); @@ -180,7 +182,7 @@ public class AppLaunchTest result.status = null; result.message = null; // Clear test result between retries. - launchPackage(result); + launchPackage(testInfo, result); if (result.status == CompatibilityTestResult.STATUS_SUCCESS) { return; } @@ -209,7 +211,8 @@ public class AppLaunchTest * @param result the {@link CompatibilityTestResult} containing the package info. * @throws DeviceNotAvailableException */ - private void launchPackage(CompatibilityTestResult result) throws DeviceNotAvailableException { + private void launchPackage(final TestInformation testInfo, CompatibilityTestResult result) + throws DeviceNotAvailableException { CLog.d("Launching package: %s.", result.packageName); CommandResult resetResult = resetPackage(); @@ -222,7 +225,7 @@ public class AppLaunchTest InstrumentationTest instrTest = createInstrumentationTest(result.packageName); FailureCollectingListener failureListener = createFailureListener(); - instrTest.run(failureListener); + instrTest.run(testInfo, failureListener); CLog.d("Stack Trace: %s", failureListener.getStackTrace()); if (failureListener.getStackTrace() != null) { diff --git a/harness/src/test/java/com/android/compatibility/testtype/AppLaunchTestTest.java b/harness/src/test/java/com/android/compatibility/testtype/AppLaunchTestTest.java index fd41ee9..c1da259 100644 --- a/harness/src/test/java/com/android/compatibility/testtype/AppLaunchTestTest.java +++ b/harness/src/test/java/com/android/compatibility/testtype/AppLaunchTestTest.java @@ -33,6 +33,7 @@ import static org.mockito.Mockito.when; import com.android.tradefed.device.DeviceNotAvailableException; import com.android.tradefed.device.ITestDevice; +import com.android.tradefed.invoker.TestInformation; import com.android.tradefed.metrics.proto.MetricMeasurement.Metric; import com.android.tradefed.result.ITestInvocationListener; import com.android.tradefed.result.TestDescription; @@ -55,13 +56,14 @@ public final class AppLaunchTestTest { private final ITestInvocationListener mMockListener = mock(ITestInvocationListener.class); private static final String TEST_PACKAGE_NAME = "package_name"; + private static final TestInformation NULL_TEST_INFORMATION = null; @Test public void run_testFailed() throws DeviceNotAvailableException { InstrumentationTest instrumentationTest = createFailingInstrumentationTest(); AppLaunchTest appLaunchTest = createLaunchTestWithInstrumentation(instrumentationTest); - appLaunchTest.run(mMockListener); + appLaunchTest.run(NULL_TEST_INFORMATION, mMockListener); verifyFailedAndEndedCall(mMockListener); } @@ -71,7 +73,7 @@ public final class AppLaunchTestTest { InstrumentationTest instrumentationTest = createPassingInstrumentationTest(); AppLaunchTest appLaunchTest = createLaunchTestWithInstrumentation(instrumentationTest); - appLaunchTest.run(mMockListener); + appLaunchTest.run(NULL_TEST_INFORMATION, mMockListener); verifyPassedAndEndedCall(mMockListener); } @@ -83,7 +85,7 @@ public final class AppLaunchTestTest { .thenReturn(new CommandResult(CommandStatus.SUCCESS)); AppLaunchTest appLaunchTest = createLaunchTestWithMockDevice(mMockDevice); - appLaunchTest.run(mMockListener); + appLaunchTest.run(NULL_TEST_INFORMATION, mMockListener); verifyPassedAndEndedCall(mMockListener); } @@ -95,7 +97,7 @@ public final class AppLaunchTestTest { .thenReturn(new CommandResult(CommandStatus.FAILED)); AppLaunchTest appLaunchTest = createLaunchTestWithMockDevice(mMockDevice); - appLaunchTest.run(mMockListener); + appLaunchTest.run(NULL_TEST_INFORMATION, mMockListener); verifyFailedAndEndedCall(mMockListener); } @@ -105,7 +107,7 @@ public final class AppLaunchTestTest { InstrumentationTest instrumentationTest = createPassingInstrumentationTestAfterFailing(2); AppLaunchTest appLaunchTest = createLaunchTestWithRetry(instrumentationTest, 2); - appLaunchTest.run(mMockListener); + appLaunchTest.run(NULL_TEST_INFORMATION, mMockListener); verifyPassedAndEndedCall(mMockListener); } @@ -115,7 +117,7 @@ public final class AppLaunchTestTest { InstrumentationTest instrumentationTest = createPassingInstrumentationTestAfterFailing(3); AppLaunchTest appLaunchTest = createLaunchTestWithRetry(instrumentationTest, 2); - appLaunchTest.run(mMockListener); + appLaunchTest.run(NULL_TEST_INFORMATION, mMockListener); verifyFailedAndEndedCall(mMockListener); } @@ -330,7 +332,8 @@ public final class AppLaunchTestTest { InstrumentationTest instrumentation = new InstrumentationTest() { @Override - public void run(final ITestInvocationListener listener) + public void run( + final TestInformation testInfo, final ITestInvocationListener listener) throws DeviceNotAvailableException { listener.testFailed(new TestDescription("", ""), "test failed"); } @@ -342,7 +345,8 @@ public final class AppLaunchTestTest { InstrumentationTest instrumentation = new InstrumentationTest() { @Override - public void run(final ITestInvocationListener listener) + public void run( + final TestInformation testInfo, final ITestInvocationListener listener) throws DeviceNotAvailableException {} }; return instrumentation; @@ -354,7 +358,8 @@ public final class AppLaunchTestTest { private int retryCount = 0; @Override - public void run(final ITestInvocationListener listener) + public void run( + final TestInformation testInfo, final ITestInvocationListener listener) throws DeviceNotAvailableException { if (retryCount < failedCount) { listener.testFailed(new TestDescription("", ""), "test failed"); |