| OLD | NEW |
| 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.content.Context; |
| 8 import android.os.Build; | 8 import android.os.Build; |
| 9 import android.os.Bundle; | 9 import android.os.Bundle; |
| 10 import android.text.TextUtils; | 10 import android.text.TextUtils; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 @Override | 51 @Override |
| 52 protected void addTestHooks(BaseTestResult result) { | 52 protected void addTestHooks(BaseTestResult result) { |
| 53 super.addTestHooks(result); | 53 super.addTestHooks(result); |
| 54 result.addSkipCheck(new ChromeRestrictionSkipCheck(getTargetContext())); | 54 result.addSkipCheck(new ChromeRestrictionSkipCheck(getTargetContext())); |
| 55 result.addSkipCheck(new ChromeDisableIfSkipCheck(getTargetContext())); | 55 result.addSkipCheck(new ChromeDisableIfSkipCheck(getTargetContext())); |
| 56 | 56 |
| 57 result.addPreTestHook(Policies.getRegistrationHook()); | 57 result.addPreTestHook(Policies.getRegistrationHook()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 private class ChromeRestrictionSkipCheck extends RestrictionSkipCheck { | 60 static class ChromeRestrictionSkipCheck extends RestrictionSkipCheck { |
| 61 private VrDaydreamApi mDaydreamApi; | 61 private VrDaydreamApi mDaydreamApi; |
| 62 private boolean mAttemptedToGetApi; | 62 private boolean mAttemptedToGetApi; |
| 63 | 63 |
| 64 public ChromeRestrictionSkipCheck(Context targetContext) { | 64 public ChromeRestrictionSkipCheck(Context targetContext) { |
| 65 super(targetContext); | 65 super(targetContext); |
| 66 } | 66 } |
| 67 | 67 |
| 68 @SuppressWarnings("unchecked") | 68 @SuppressWarnings("unchecked") |
| 69 private VrDaydreamApi getDaydreamApi() { | 69 private VrDaydreamApi getDaydreamApi() { |
| 70 if (!mAttemptedToGetApi) { | 70 if (!mAttemptedToGetApi) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 @Override | 121 @Override |
| 122 protected boolean restrictionApplies(String restriction) { | 122 protected boolean restrictionApplies(String restriction) { |
| 123 if (TextUtils.equals(restriction, ChromeRestriction.RESTRICTION_TYPE
_PHONE) | 123 if (TextUtils.equals(restriction, ChromeRestriction.RESTRICTION_TYPE
_PHONE) |
| 124 && DeviceFormFactor.isTablet(getTargetContext())) { | 124 && DeviceFormFactor.isTablet(getTargetContext())) { |
| 125 return true; | 125 return true; |
| 126 } | 126 } |
| 127 if (TextUtils.equals(restriction, ChromeRestriction.RESTRICTION_TYPE
_TABLET) | 127 if (TextUtils.equals(restriction, ChromeRestriction.RESTRICTION_TYPE
_TABLET) |
| 128 && !DeviceFormFactor.isTablet(getTargetContext())) { | 128 && !DeviceFormFactor.isTablet(getTargetContext())) { |
| 129 return true; | 129 return true; |
| 130 } | 130 } |
| 131 if (TextUtils.equals(restriction, | 131 if (TextUtils.equals( |
| 132 ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES) | 132 restriction, ChromeRestriction.RESTRICTION_TYPE_GOOGLE_P
LAY_SERVICES) |
| 133 && (ConnectionResult.SUCCESS != GoogleApiAvailability.getIns
tance() | 133 && (ConnectionResult.SUCCESS |
| 134 .isGooglePlayServicesAvailable(getTargetContext()))) { | 134 != GoogleApiAvailability.getInstance().isGooglePl
ayServicesAvailable( |
| 135 getTargetContext()))) { |
| 135 return true; | 136 return true; |
| 136 } | 137 } |
| 137 if (TextUtils.equals(restriction, | 138 if (TextUtils.equals(restriction, |
| 138 ChromeRestriction.RESTRICTION_TYPE_OFFICIAL_BUILD) | 139 ChromeRestriction.RESTRICTION_TYPE_OFFICIAL_BUILD) |
| 139 && (!ChromeVersionInfo.isOfficialBuild())) { | 140 && (!ChromeVersionInfo.isOfficialBuild())) { |
| 140 return true; | 141 return true; |
| 141 } | 142 } |
| 142 if (TextUtils.equals(restriction, ChromeRestriction.RESTRICTION_TYPE
_DEVICE_DAYDREAM) | 143 if (TextUtils.equals(restriction, ChromeRestriction.RESTRICTION_TYPE
_DEVICE_DAYDREAM) |
| 143 || TextUtils.equals(restriction, | 144 || TextUtils.equals(restriction, |
| 144 ChromeRestriction.RESTRICTION_TYPE_DEVICE_NON_DAY
DREAM)) { | 145 ChromeRestriction.RESTRICTION_TYPE_DEVICE_NON_DAY
DREAM)) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } else if (TextUtils.equals(restriction, | 179 } else if (TextUtils.equals(restriction, |
| 179 ChromeRestriction.RESTRICTION_TYPE_WEBVR_UNSU
PPORTED) | 180 ChromeRestriction.RESTRICTION_TYPE_WEBVR_UNSU
PPORTED) |
| 180 && webvrSupported) { | 181 && webvrSupported) { |
| 181 return true; | 182 return true; |
| 182 } | 183 } |
| 183 } | 184 } |
| 184 return false; | 185 return false; |
| 185 } | 186 } |
| 186 } | 187 } |
| 187 | 188 |
| 188 private class ChromeDisableIfSkipCheck extends DisableIfSkipCheck { | 189 static class ChromeDisableIfSkipCheck extends DisableIfSkipCheck { |
| 189 | |
| 190 private final Context mTargetContext; | 190 private final Context mTargetContext; |
| 191 | 191 |
| 192 public ChromeDisableIfSkipCheck(Context targetContext) { | 192 public ChromeDisableIfSkipCheck(Context targetContext) { |
| 193 mTargetContext = targetContext; | 193 mTargetContext = targetContext; |
| 194 } | 194 } |
| 195 | 195 |
| 196 @Override | 196 @Override |
| 197 protected boolean deviceTypeApplies(String type) { | 197 protected boolean deviceTypeApplies(String type) { |
| 198 if (TextUtils.equals(type, ChromeDisableIf.PHONE) | 198 if (TextUtils.equals(type, ChromeDisableIf.PHONE) |
| 199 && !DeviceFormFactor.isTablet(getTargetContext())) { | 199 && !DeviceFormFactor.isTablet(mTargetContext)) { |
| 200 return true; | 200 return true; |
| 201 } | 201 } |
| 202 if (TextUtils.equals(type, ChromeDisableIf.TABLET) | 202 if (TextUtils.equals(type, ChromeDisableIf.TABLET) |
| 203 && DeviceFormFactor.isTablet(getTargetContext())) { | 203 && DeviceFormFactor.isTablet(mTargetContext)) { |
| 204 return true; | 204 return true; |
| 205 } | 205 } |
| 206 if (TextUtils.equals(type, ChromeDisableIf.LARGETABLET) | 206 if (TextUtils.equals(type, ChromeDisableIf.LARGETABLET) |
| 207 && DeviceFormFactor.isLargeTablet(getTargetContext())) { | 207 && DeviceFormFactor.isLargeTablet(mTargetContext)) { |
| 208 return true; | 208 return true; |
| 209 } | 209 } |
| 210 return false; | 210 return false; |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 } | 213 } |
| OLD | NEW |