diff options
author | mikecase <mikecase@chromium.org> | 2015-12-09 17:16:13 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-10 01:16:51 +0000 |
commit | 37b3817940096f8dd593cb32eabb3774f2302d7b (patch) | |
tree | c519d05fa0002162e3c81a1d0728b5594bf1f244 /testing | |
parent | f09e500334a9c5867b7f93ecf984c2448296f37f (diff) | |
download | chromium_src-37b3817940096f8dd593cb32eabb3774f2302d7b.zip chromium_src-37b3817940096f8dd593cb32eabb3774f2302d7b.tar.gz chromium_src-37b3817940096f8dd593cb32eabb3774f2302d7b.tar.bz2 |
[Android] Add support for timeouts scaling for OnDevice instrumentation.
This adds support for using the test_runner --timeout-scale arg.
However, the TimeoutScale annotation still currently doesn't
work for remote instrumentation tests.
BUG=
Review URL: https://codereview.chromium.org/1493953002
Cr-Commit-Position: refs/heads/master@{#364238}
Diffstat (limited to 'testing')
3 files changed, 25 insertions, 0 deletions
diff --git a/testing/android/driver/BUILD.gn b/testing/android/driver/BUILD.gn index 436ac63..e99e350 100644 --- a/testing/android/driver/BUILD.gn +++ b/testing/android/driver/BUILD.gn @@ -11,6 +11,7 @@ android_apk("driver_apk") { testonly = true deps = [ + "//base:base_java_test_support", "//testing/android/appurify_support:appurify_support_java", "//testing/android/broker:broker_java", "//testing/android/reporter:reporter_java", diff --git a/testing/android/driver/java/src/org/chromium/test/driver/OnDeviceInstrumentationDriver.java b/testing/android/driver/java/src/org/chromium/test/driver/OnDeviceInstrumentationDriver.java index c209ac7..f9b31b0 100644 --- a/testing/android/driver/java/src/org/chromium/test/driver/OnDeviceInstrumentationDriver.java +++ b/testing/android/driver/java/src/org/chromium/test/driver/OnDeviceInstrumentationDriver.java @@ -13,6 +13,7 @@ import android.os.Environment; import android.test.InstrumentationTestRunner; import android.util.Log; +import org.chromium.base.test.util.ScalableTimeout; import org.chromium.test.broker.OnDeviceInstrumentationBroker; import org.chromium.test.reporter.TestStatusReceiver; import org.chromium.test.reporter.TestStatusReporter; @@ -21,8 +22,10 @@ import org.chromium.test.support.RobotiumBundleGenerator; import java.io.BufferedReader; import java.io.File; +import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; +import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -44,6 +47,8 @@ public class OnDeviceInstrumentationDriver extends Instrumentation { "org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetPackage"; private static final String EXTRA_TARGET_CLASS = "org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetClass"; + private static final String EXTRA_TIMEOUT_SCALE = + "org.chromium.test.driver.OnDeviceInstrumentationDriver.TimeoutScale"; private static final Pattern COMMA = Pattern.compile(","); private static final int TEST_WAIT_TIMEOUT = 5 * TestStatusReporter.HEARTBEAT_INTERVAL_MS; @@ -54,6 +59,7 @@ public class OnDeviceInstrumentationDriver extends Instrumentation { private String mTargetClass; private String mTargetPackage; private List<String> mTestClasses; + private String mTimeoutScale; /** Parse any arguments and prepare to run tests. @@ -101,6 +107,18 @@ public class OnDeviceInstrumentationDriver extends Instrumentation { mTargetArgs.remove(EXTRA_TEST_LIST_FILE); } + mTimeoutScale = arguments.getString(EXTRA_TIMEOUT_SCALE); + if (mTimeoutScale != null) { + try { + OutputStreamWriter outputStreamWriter = new OutputStreamWriter( + new FileOutputStream(ScalableTimeout.PROPERTY_FILE)); + outputStreamWriter.write(mTimeoutScale); + outputStreamWriter.close(); + } catch (IOException e) { + Log.e(TAG, "Error writing " + ScalableTimeout.PROPERTY_FILE, e); + } + } + if (mTestClasses.isEmpty()) { fail("No tests."); return; @@ -129,6 +147,11 @@ public class OnDeviceInstrumentationDriver extends Instrumentation { @Override public void onDestroy() { super.onDestroy(); + if (mTimeoutScale != null) { + if (!new File(ScalableTimeout.PROPERTY_FILE).delete()) { + Log.e(TAG, "Error deleting " + ScalableTimeout.PROPERTY_FILE); + } + } } private class Driver implements Runnable { diff --git a/testing/android/on_device_instrumentation.gyp b/testing/android/on_device_instrumentation.gyp index 12e0f35..0828559 100644 --- a/testing/android/on_device_instrumentation.gyp +++ b/testing/android/on_device_instrumentation.gyp @@ -38,6 +38,7 @@ 'broker_java', 'reporter_java', 'appurify_support.gyp:appurify_support_java', + '../../base/base.gyp:base_java_test_support', ], 'variables': { 'apk_name': '<(driver_apk_name)', |