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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/precache/PrecacheLauncherTest.java

Issue 2643393003: Disable precache on svelte. (Closed)
Patch Set: Created 3 years, 11 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/java/src/org/chromium/chrome/browser/precache/PrecacheLauncher.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 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.browser.precache; 5 package org.chromium.chrome.browser.precache;
6 6
7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E ND_DEVICE;
8
7 import android.content.Context; 9 import android.content.Context;
8 import android.support.test.filters.SmallTest; 10 import android.support.test.filters.SmallTest;
9 11
10 import com.google.android.gms.gcm.Task; 12 import com.google.android.gms.gcm.Task;
11 13
12 import org.chromium.base.ContextUtils; 14 import org.chromium.base.ContextUtils;
13 import org.chromium.base.ThreadUtils; 15 import org.chromium.base.ThreadUtils;
14 import org.chromium.base.test.util.Feature; 16 import org.chromium.base.test.util.Feature;
17 import org.chromium.base.test.util.Restriction;
18 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager ;
15 import org.chromium.chrome.browser.sync.ProfileSyncService; 19 import org.chromium.chrome.browser.sync.ProfileSyncService;
16 import org.chromium.content.browser.test.NativeLibraryTestBase; 20 import org.chromium.content.browser.test.NativeLibraryTestBase;
17 21
18 import java.util.EnumSet; 22 import java.util.EnumSet;
19 import java.util.concurrent.Callable; 23 import java.util.concurrent.Callable;
20 24
21 /** 25 /**
22 * Unit tests for {@link PrecacheLauncher}. 26 * Unit tests for {@link PrecacheLauncher}.
23 * 27 *
24 * setUp/tearDown code was inspired by org.chromium.chrome.browser.sync.ui.Passp hraseActivityTest. 28 * setUp/tearDown code was inspired by org.chromium.chrome.browser.sync.ui.Passp hraseActivityTest.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 105
102 // ProfileSyncService must be initialized on the UI thread. Oddly, even though 106 // ProfileSyncService must be initialized on the UI thread. Oddly, even though
103 // ThreadUtils.runningOnUiThread() is true here, it's, no, not really, n o. 107 // ThreadUtils.runningOnUiThread() is true here, it's, no, not really, n o.
104 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 108 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
105 @Override 109 @Override
106 public void run() { 110 public void run() {
107 // The StubProfileSyncService stubs out isEngineInitialized so w e can change that 111 // The StubProfileSyncService stubs out isEngineInitialized so w e can change that
108 // on the fly. 112 // on the fly.
109 mSync = new StubProfileSyncService(); 113 mSync = new StubProfileSyncService();
110 ProfileSyncService.overrideForTests(mSync); 114 ProfileSyncService.overrideForTests(mSync);
115 // This is currently the default, but let's verify that, lest it ever change and we
116 // get confusing test failures later.
117 assertTrue(PrivacyPreferencesManager.getInstance().shouldPrerend er());
111 } 118 }
112 }); 119 });
113 } 120 }
114 121
115 @Override 122 @Override
116 protected void tearDown() throws Exception { 123 protected void tearDown() throws Exception {
117 ProfileSyncService.overrideForTests(null); 124 ProfileSyncService.overrideForTests(null);
118 PrecacheController.setIsPrecachingEnabled(getTargetContext(), false); 125 PrecacheController.setIsPrecachingEnabled(getTargetContext(), false);
119 super.tearDown(); 126 super.tearDown();
120 } 127 }
121 128
122 @SmallTest 129 @SmallTest
130 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
123 @Feature({"Precache"}) 131 @Feature({"Precache"})
124 public void testUpdateEnabled_SyncNotReady_ThenDisabled() { 132 public void testUpdateEnabled_SyncNotReady_ThenDisabled() {
125 mLauncher.updateEnabled(getTargetContext()); 133 mLauncher.updateEnabled(getTargetContext());
126 waitUntilUiThreadIdle(); 134 waitUntilUiThreadIdle();
127 135
128 assertEquals(false, isPrecachingEnabled()); 136 assertEquals(false, isPrecachingEnabled());
129 assertEquals(EnumSet.of(FailureReason.SYNC_NOT_INITIALIZED, 137 assertEquals(EnumSet.of(FailureReason.SYNC_NOT_INITIALIZED,
130 FailureReason.PRERENDER_PRIVACY_PREFERENCE_NOT_ENAB LED, 138 FailureReason.PRERENDER_PRIVACY_PREFERENCE_NOT_ENAB LED,
131 FailureReason.NATIVE_SHOULD_RUN_IS_FALSE), 139 FailureReason.NATIVE_SHOULD_RUN_IS_FALSE),
132 failureReasons()); 140 failureReasons());
133 141
134 setEngineInitialized(true); 142 setEngineInitialized(true);
135 assertEquals(false, isPrecachingEnabled()); 143 assertEquals(false, isPrecachingEnabled());
136 assertEquals(EnumSet.of(FailureReason.NATIVE_SHOULD_RUN_IS_FALSE), failu reReasons()); 144 assertEquals(EnumSet.of(FailureReason.NATIVE_SHOULD_RUN_IS_FALSE), failu reReasons());
137 } 145 }
138 146
139 @SmallTest 147 @SmallTest
148 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
140 @Feature({"Precache"}) 149 @Feature({"Precache"})
141 public void testUpdateEnabled_SyncNotReady_ThenEnabled() { 150 public void testUpdateEnabled_SyncNotReady_ThenEnabled() {
142 mLauncher.updateEnabled(getTargetContext()); 151 mLauncher.updateEnabled(getTargetContext());
143 waitUntilUiThreadIdle(); 152 waitUntilUiThreadIdle();
144 153
145 assertEquals(false, isPrecachingEnabled()); 154 assertEquals(false, isPrecachingEnabled());
146 assertEquals(EnumSet.of(FailureReason.SYNC_NOT_INITIALIZED, 155 assertEquals(EnumSet.of(FailureReason.SYNC_NOT_INITIALIZED,
147 FailureReason.PRERENDER_PRIVACY_PREFERENCE_NOT_ENAB LED, 156 FailureReason.PRERENDER_PRIVACY_PREFERENCE_NOT_ENAB LED,
148 FailureReason.NATIVE_SHOULD_RUN_IS_FALSE), 157 FailureReason.NATIVE_SHOULD_RUN_IS_FALSE),
149 failureReasons()); 158 failureReasons());
150 159
151 mLauncher.setShouldRun(true); 160 mLauncher.setShouldRun(true);
152 setEngineInitialized(true); 161 setEngineInitialized(true);
153 assertEquals(true, isPrecachingEnabled()); 162 assertEquals(true, isPrecachingEnabled());
154 assertEquals(EnumSet.noneOf(FailureReason.class), failureReasons()); 163 assertEquals(EnumSet.noneOf(FailureReason.class), failureReasons());
155 } 164 }
156 165
157 @SmallTest 166 @SmallTest
167 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
158 @Feature({"Precache"}) 168 @Feature({"Precache"})
159 public void testUpdateEnabled_Disabled_ThenEnabled() { 169 public void testUpdateEnabled_Disabled_ThenEnabled() {
160 setEngineInitialized(true); 170 setEngineInitialized(true);
161 mLauncher.updateEnabled(getTargetContext()); 171 mLauncher.updateEnabled(getTargetContext());
162 waitUntilUiThreadIdle(); 172 waitUntilUiThreadIdle();
163 173
164 assertEquals(false, isPrecachingEnabled()); 174 assertEquals(false, isPrecachingEnabled());
165 assertEquals(EnumSet.of(FailureReason.NATIVE_SHOULD_RUN_IS_FALSE), failu reReasons()); 175 assertEquals(EnumSet.of(FailureReason.NATIVE_SHOULD_RUN_IS_FALSE), failu reReasons());
166 176
167 mLauncher.setShouldRun(true); 177 mLauncher.setShouldRun(true);
168 assertEquals(true, isPrecachingEnabled()); 178 assertEquals(true, isPrecachingEnabled());
169 assertEquals(EnumSet.noneOf(FailureReason.class), failureReasons()); 179 assertEquals(EnumSet.noneOf(FailureReason.class), failureReasons());
170 } 180 }
171 181
172 @SmallTest 182 @SmallTest
183 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
173 @Feature({"Precache"}) 184 @Feature({"Precache"})
174 public void testUpdateEnabled_Enabled_ThenDisabled() { 185 public void testUpdateEnabled_Enabled_ThenDisabled() {
175 mLauncher.setShouldRun(true); 186 mLauncher.setShouldRun(true);
176 setEngineInitialized(true); 187 setEngineInitialized(true);
177 mLauncher.updateEnabled(getTargetContext()); 188 mLauncher.updateEnabled(getTargetContext());
178 waitUntilUiThreadIdle(); 189 waitUntilUiThreadIdle();
179 190
180 assertEquals(true, isPrecachingEnabled()); 191 assertEquals(true, isPrecachingEnabled());
181 assertEquals(EnumSet.noneOf(FailureReason.class), failureReasons()); 192 assertEquals(EnumSet.noneOf(FailureReason.class), failureReasons());
182 193
183 mLauncher.setShouldRun(false); 194 mLauncher.setShouldRun(false);
184 assertEquals(false, isPrecachingEnabled()); 195 assertEquals(false, isPrecachingEnabled());
185 assertEquals(EnumSet.of(FailureReason.NATIVE_SHOULD_RUN_IS_FALSE), failu reReasons()); 196 assertEquals(EnumSet.of(FailureReason.NATIVE_SHOULD_RUN_IS_FALSE), failu reReasons());
186 } 197 }
187 198
188 @SmallTest 199 @SmallTest
200 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
189 @Feature({"Precache"}) 201 @Feature({"Precache"})
190 public void testUpdateEnabledNullProfileSyncService() { 202 public void testUpdateEnabledNullProfileSyncService() {
191 ProfileSyncService.overrideForTests(null); 203 ProfileSyncService.overrideForTests(null);
192 204
193 mLauncher.updateEnabled(getTargetContext()); 205 mLauncher.updateEnabled(getTargetContext());
194 waitUntilUiThreadIdle(); 206 waitUntilUiThreadIdle();
195 207
196 assertEquals(false, isPrecachingEnabled()); 208 assertEquals(false, isPrecachingEnabled());
197 assertEquals(EnumSet.of(FailureReason.SYNC_NOT_INITIALIZED, 209 assertEquals(EnumSet.of(FailureReason.SYNC_NOT_INITIALIZED,
198 FailureReason.PRERENDER_PRIVACY_PREFERENCE_NOT_ENAB LED, 210 FailureReason.PRERENDER_PRIVACY_PREFERENCE_NOT_ENAB LED,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 /** Notify listeners that sync preferences have changed. This is run by setS houldRun. */ 250 /** Notify listeners that sync preferences have changed. This is run by setS houldRun. */
239 private void notifySyncChanged() { 251 private void notifySyncChanged() {
240 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 252 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
241 @Override 253 @Override
242 public void run() { 254 public void run() {
243 mSync.syncStateChanged(); 255 mSync.syncStateChanged();
244 } 256 }
245 }); 257 });
246 } 258 }
247 } 259 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/precache/PrecacheLauncher.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698