Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: base/android/javatests/src/org/chromium/base/test/ScalableTimeout.java

Issue 10802036: Not to be submitted yet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/android/javatests/src/org/chromium/base/test/ScalableTimeout.java
diff --git a/base/android/javatests/src/org/chromium/base/test/ScalableTimeout.java b/base/android/javatests/src/org/chromium/base/test/ScalableTimeout.java
new file mode 100644
index 0000000000000000000000000000000000000000..d502aaacbde2e6ee915da6c78635454260a17d09
--- /dev/null
+++ b/base/android/javatests/src/org/chromium/base/test/ScalableTimeout.java
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.base.test;
+
+/**
+ * Utility class for scaling various timeouts by a common factor.
+ * For example, to run tests under Valgrind, you might want the following:
+ * adb shell "echo 20.0 > /data/local/tmp/chrome_timeout_scale"
+ */
+public class ScalableTimeout {
+ private static Double sTimeoutScale = null;
+ private static final String PROPERTY_FILE = "/data/local/tmp/chrome_timeout_scale";
+
+ public static long ScaleTimeout(long timeout) {
+ if (sTimeoutScale == null) {
+ try {
+ char[] data = TestFileUtil.readUtf8File(PROPERTY_FILE, 32);
+ sTimeoutScale = Double.parseDouble(new String(data));
+ } catch (Exception e) {
+ // NumberFormatException, FileNotFoundException, IOException
+ sTimeoutScale = 1.0;
+ }
+ }
+ return (long)(timeout * sTimeoutScale);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698