| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.test.util; | 5 package org.chromium.chrome.test.util; |
| 6 | 6 |
| 7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
| 8 import android.app.Activity; | 8 import android.app.Activity; |
| 9 import android.app.ActivityManager; | 9 import android.app.ActivityManager; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 import java.util.concurrent.Callable; | 28 import java.util.concurrent.Callable; |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * Methods used for testing Chrome at the Application-level. | 31 * Methods used for testing Chrome at the Application-level. |
| 32 */ | 32 */ |
| 33 public class ApplicationTestUtils { | 33 public class ApplicationTestUtils { |
| 34 private static final String TAG = "ApplicationTestUtils"; | 34 private static final String TAG = "ApplicationTestUtils"; |
| 35 private static final float FLOAT_EPSILON = 0.001f; | 35 private static final float FLOAT_EPSILON = 0.001f; |
| 36 | 36 |
| 37 private static PowerManager.WakeLock sWakeLock = null; | 37 private static PowerManager.WakeLock sWakeLock; |
| 38 | 38 |
| 39 // TODO(jbudorick): fix deprecation warning crbug.com/537347 | 39 // TODO(jbudorick): fix deprecation warning crbug.com/537347 |
| 40 @SuppressWarnings("deprecation") | 40 @SuppressWarnings("deprecation") |
| 41 public static void setUp(Context context, boolean clearAppData) | 41 public static void setUp(Context context, boolean clearAppData) |
| 42 throws Exception { | 42 throws Exception { |
| 43 if (clearAppData) { | 43 if (clearAppData) { |
| 44 // Clear data and remove any tasks listed in Android's Overview menu
between test runs. | 44 // Clear data and remove any tasks listed in Android's Overview menu
between test runs. |
| 45 clearAppData(context); | 45 clearAppData(context); |
| 46 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | 46 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| 47 finishAllChromeTasks(context); | 47 finishAllChromeTasks(context); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 if (activity.getCurrentContentViewCore() == null) return false; | 215 if (activity.getCurrentContentViewCore() == null) return false; |
| 216 | 216 |
| 217 updateFailureReason("Expecting scale factor of: " + expectedScal
e + ", got: " | 217 updateFailureReason("Expecting scale factor of: " + expectedScal
e + ", got: " |
| 218 + activity.getCurrentContentViewCore().getScale()); | 218 + activity.getCurrentContentViewCore().getScale()); |
| 219 return Math.abs(activity.getCurrentContentViewCore().getScale()
- expectedScale) | 219 return Math.abs(activity.getCurrentContentViewCore().getScale()
- expectedScale) |
| 220 < FLOAT_EPSILON; | 220 < FLOAT_EPSILON; |
| 221 } | 221 } |
| 222 }, waitTimeInMs, CriteriaHelper.DEFAULT_POLLING_INTERVAL); | 222 }, waitTimeInMs, CriteriaHelper.DEFAULT_POLLING_INTERVAL); |
| 223 } | 223 } |
| 224 } | 224 } |
| OLD | NEW |