Reverted the ScreenOff CUJ to the one prior to using test options.
Test: Manual
Bug: 138154796
Change-Id: Ibfa66c8d2898c10663f0d9b70435aa1a96f12681
diff --git a/tests/health/scenarios/Android.bp b/tests/health/scenarios/Android.bp
index 3afce78..289287c 100644
--- a/tests/health/scenarios/Android.bp
+++ b/tests/health/scenarios/Android.bp
@@ -18,7 +18,6 @@
srcs: [ "src/**/*.java" ],
libs: [
"androidx.test.runner",
- "junit",
"platform-test-options",
"ub-uiautomator",
],
diff --git a/tests/health/scenarios/src/android/platform/test/scenario/system/ScreenOff.java b/tests/health/scenarios/src/android/platform/test/scenario/system/ScreenOff.java
index cf6ea9e..d3dc780 100644
--- a/tests/health/scenarios/src/android/platform/test/scenario/system/ScreenOff.java
+++ b/tests/health/scenarios/src/android/platform/test/scenario/system/ScreenOff.java
@@ -18,13 +18,11 @@
import android.os.RemoteException;
import android.os.SystemClock;
-import android.platform.test.option.LongOption;
import android.platform.test.scenario.annotation.Scenario;
import android.support.test.uiautomator.UiDevice;
import androidx.test.InstrumentationRegistry;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -35,19 +33,29 @@
@Scenario
@RunWith(JUnit4.class)
public class ScreenOff {
- @Rule
- public final LongOption mDurationMs = new LongOption("screenOffDurationMs").setDefault(1000L);
+ private static final String DURATION_OPTION = "screenOffDurationMs";
+ private static final String DURATION_DEFAULT = "1000";
+ private long mDurationMs = 0L;
private UiDevice mDevice;
@Before
public void setUp() {
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+ String durationMsString =
+ InstrumentationRegistry.getArguments().getString(DURATION_OPTION, DURATION_DEFAULT);
+ try {
+ mDurationMs = Long.parseLong(durationMsString);
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException(
+ String.format(
+ "Failed to parse option %s: %s", DURATION_OPTION, durationMsString));
+ }
}
@Test
public void testScreenOff() throws RemoteException {
mDevice.sleep();
- SystemClock.sleep(mDurationMs.get());
+ SystemClock.sleep(mDurationMs);
}
}