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

Side by Side Diff: chrome/test/android/javatests/src/org/chromium/chrome/test/ChromeInstrumentationTestRunner.java

Issue 1761383002: [Android] Restrict tests inheriting from DocumentModeTestBase to phones. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/document/DocumentModeTestBase.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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; 5 package org.chromium.chrome.test;
6 6
7 import android.content.Context;
7 import android.os.Bundle; 8 import android.os.Bundle;
8 import android.text.TextUtils; 9 import android.text.TextUtils;
9 import android.util.Log; 10 import android.util.Log;
10 11
11 import com.google.android.gms.common.ConnectionResult; 12 import com.google.android.gms.common.ConnectionResult;
12 import com.google.android.gms.common.GoogleApiAvailability; 13 import com.google.android.gms.common.GoogleApiAvailability;
13 14
14 import junit.framework.TestCase; 15 import junit.framework.TestCase;
15 16
16 import org.chromium.base.test.BaseInstrumentationTestRunner; 17 import org.chromium.base.test.BaseInstrumentationTestRunner;
17 import org.chromium.base.test.BaseTestResult; 18 import org.chromium.base.test.BaseTestResult;
19 import org.chromium.base.test.util.RestrictionSkipCheck;
18 import org.chromium.base.test.util.SkipCheck; 20 import org.chromium.base.test.util.SkipCheck;
19 import org.chromium.chrome.browser.util.FeatureUtilities; 21 import org.chromium.chrome.browser.util.FeatureUtilities;
20 import org.chromium.chrome.test.util.ChromeRestriction; 22 import org.chromium.chrome.test.util.ChromeRestriction;
21 import org.chromium.chrome.test.util.DisableInTabbedMode; 23 import org.chromium.chrome.test.util.DisableInTabbedMode;
22 import org.chromium.policy.test.annotations.Policies; 24 import org.chromium.policy.test.annotations.Policies;
23 import org.chromium.ui.base.DeviceFormFactor; 25 import org.chromium.ui.base.DeviceFormFactor;
24 26
25 import java.lang.reflect.Method; 27 import java.lang.reflect.Method;
26 28
27 /** 29 /**
28 * An Instrumentation test runner that optionally spawns a test HTTP server. 30 * An Instrumentation test runner that optionally spawns a test HTTP server.
29 * The server's root directory is the device's external storage directory. 31 * The server's root directory is the device's external storage directory.
30 * 32 *
31 * TODO(jbudorick): remove uses of deprecated org.apache.* crbug.com/488192 33 * TODO(jbudorick): remove uses of deprecated org.apache.* crbug.com/488192
32 */ 34 */
33 @SuppressWarnings("deprecation") 35 @SuppressWarnings("deprecation")
34 public class ChromeInstrumentationTestRunner extends BaseInstrumentationTestRunn er { 36 public class ChromeInstrumentationTestRunner extends BaseInstrumentationTestRunn er {
35 37
36 private static final String TAG = "ChromeInstrumentationTestRunner"; 38 private static final String TAG = "ChromeInstrumentationTestRunner";
37 39
38 @Override 40 @Override
39 public void onCreate(Bundle arguments) { 41 public void onCreate(Bundle arguments) {
40 super.onCreate(arguments); 42 super.onCreate(arguments);
41 } 43 }
42 44
43 @Override 45 @Override
44 protected void addTestHooks(BaseTestResult result) { 46 protected void addTestHooks(BaseTestResult result) {
45 super.addTestHooks(result); 47 super.addTestHooks(result);
46 result.addSkipCheck(new DisableInTabbedModeSkipCheck()); 48 result.addSkipCheck(new DisableInTabbedModeSkipCheck());
47 result.addSkipCheck(new ChromeRestrictionSkipCheck()); 49 result.addSkipCheck(new ChromeRestrictionSkipCheck(getTargetContext()));
48 50
49 result.addPreTestHook(Policies.getRegistrationHook()); 51 result.addPreTestHook(Policies.getRegistrationHook());
50 } 52 }
51 53
52 private class ChromeRestrictionSkipCheck extends RestrictionSkipCheck { 54 private class ChromeRestrictionSkipCheck extends RestrictionSkipCheck {
53 55
56 public ChromeRestrictionSkipCheck(Context targetContext) {
57 super(targetContext);
58 }
59
54 @Override 60 @Override
55 protected boolean restrictionApplies(String restriction) { 61 protected boolean restrictionApplies(String restriction) {
56 if (TextUtils.equals(restriction, ChromeRestriction.RESTRICTION_TYPE _PHONE) 62 if (TextUtils.equals(restriction, ChromeRestriction.RESTRICTION_TYPE _PHONE)
57 && DeviceFormFactor.isTablet(getTargetContext())) { 63 && DeviceFormFactor.isTablet(getTargetContext())) {
58 return true; 64 return true;
59 } 65 }
60 if (TextUtils.equals(restriction, ChromeRestriction.RESTRICTION_TYPE _TABLET) 66 if (TextUtils.equals(restriction, ChromeRestriction.RESTRICTION_TYPE _TABLET)
61 && !DeviceFormFactor.isTablet(getTargetContext())) { 67 && !DeviceFormFactor.isTablet(getTargetContext())) {
62 return true; 68 return true;
63 } 69 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 104 }
99 } 105 }
100 } catch (NoSuchMethodException e) { 106 } catch (NoSuchMethodException e) {
101 Log.e(TAG, "Couldn't find test method: " + e.toString()); 107 Log.e(TAG, "Couldn't find test method: " + e.toString());
102 } 108 }
103 109
104 return false; 110 return false;
105 } 111 }
106 } 112 }
107 } 113 }
OLDNEW
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/document/DocumentModeTestBase.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698