1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.base.test.util;
8 * Utility class for scaling various timeouts by a common factor.
9 * For example, to run tests under Valgrind, you might want the following:
10 * adb shell "echo 20.0 > /data/local/tmp/chrome_timeout_scale"
12 public class ScalableTimeout {
13 private static Double sTimeoutScale = null;
14 private static final String PROPERTY_FILE = "/data/local/tmp/chrome_timeout_scale";
16 public static long scaleTimeout(long timeout) {
17 if (sTimeoutScale == null) {
19 char[] data = TestFileUtil.readUtf8File(PROPERTY_FILE, 32);
20 sTimeoutScale = Double.parseDouble(new String(data));
21 } catch (Exception e) {
22 // NumberFormatException, FileNotFoundException, IOException
26 return (long)(timeout * sTimeoutScale);