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

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

Issue 2089563002: [Polymer] update polymer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: polymer update Created 4 years, 6 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
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 android.content.Context; 7 import android.content.Context;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.content.SharedPreferences.Editor; 9 import android.content.SharedPreferences.Editor;
10 import android.test.InstrumentationTestCase; 10 import android.test.InstrumentationTestCase;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 } 65 }
66 66
67 static class MockPrecacheTaskScheduler extends PrecacheTaskScheduler { 67 static class MockPrecacheTaskScheduler extends PrecacheTaskScheduler {
68 public int schedulePeriodicCnt = 0; 68 public int schedulePeriodicCnt = 0;
69 public int scheduleContinuationCnt = 0; 69 public int scheduleContinuationCnt = 0;
70 public int cancelPeriodicCnt = 0; 70 public int cancelPeriodicCnt = 0;
71 public int cancelContinuationCnt = 0; 71 public int cancelContinuationCnt = 0;
72 72
73 @Override 73 @Override
74 boolean canScheduleTasks(Context context) {
75 return false;
76 }
77
78 @Override
74 boolean scheduleTask(Context context, Task task) { 79 boolean scheduleTask(Context context, Task task) {
80 if (!canScheduleTasks(context)) return true;
75 if (PrecacheController.PERIODIC_TASK_TAG.equals(task.getTag())) { 81 if (PrecacheController.PERIODIC_TASK_TAG.equals(task.getTag())) {
76 schedulePeriodicCnt++; 82 schedulePeriodicCnt++;
77 } else if (PrecacheController.CONTINUATION_TASK_TAG.equals(task.getT ag())) { 83 } else if (PrecacheController.CONTINUATION_TASK_TAG.equals(task.getT ag())) {
78 scheduleContinuationCnt++; 84 scheduleContinuationCnt++;
79 } 85 }
80 return true; 86 return true;
81 } 87 }
82 88
83 @Override 89 @Override
84 boolean cancelTask(Context context, String tag) { 90 boolean cancelTask(Context context, String tag) {
(...skipping 18 matching lines...) Expand all
103 PrecacheController.setTaskScheduler(mPrecacheTaskScheduler); 109 PrecacheController.setTaskScheduler(mPrecacheTaskScheduler);
104 RecordHistogram.disableForTests(); 110 RecordHistogram.disableForTests();
105 Editor editor = ContextUtils.getAppSharedPreferences().edit(); 111 Editor editor = ContextUtils.getAppSharedPreferences().edit();
106 editor.putBoolean(PrecacheController.PREF_IS_PRECACHING_ENABLED, false); 112 editor.putBoolean(PrecacheController.PREF_IS_PRECACHING_ENABLED, false);
107 editor.apply(); 113 editor.apply();
108 } 114 }
109 115
110 protected void verifyScheduledAndCanceledCounts( 116 protected void verifyScheduledAndCanceledCounts(
111 int expectedPeriodicScheduled, int expectedContinuationScheduled, 117 int expectedPeriodicScheduled, int expectedContinuationScheduled,
112 int expectedPeriodicCanceled, int expectedContinuationCanceled) { 118 int expectedPeriodicCanceled, int expectedContinuationCanceled) {
113 // This experimental feature should not run on Chrome Stable. 119 if (!mPrecacheTaskScheduler.canScheduleTasks(mContext)) {
114 if (!PrecacheController.canScheduleTasks(mContext)) {
115 expectedPeriodicScheduled = 0; 120 expectedPeriodicScheduled = 0;
116 expectedContinuationScheduled = 0; 121 expectedContinuationScheduled = 0;
117 } 122 }
118 assertEquals(expectedPeriodicScheduled, mPrecacheTaskScheduler.scheduleP eriodicCnt); 123 assertEquals(expectedPeriodicScheduled, mPrecacheTaskScheduler.scheduleP eriodicCnt);
119 assertEquals(expectedContinuationScheduled, mPrecacheTaskScheduler.sched uleContinuationCnt); 124 assertEquals(expectedContinuationScheduled, mPrecacheTaskScheduler.sched uleContinuationCnt);
120 assertEquals(expectedPeriodicCanceled, mPrecacheTaskScheduler.cancelPeri odicCnt); 125 assertEquals(expectedPeriodicCanceled, mPrecacheTaskScheduler.cancelPeri odicCnt);
121 assertEquals(expectedContinuationCanceled, mPrecacheTaskScheduler.cancel ContinuationCnt); 126 assertEquals(expectedContinuationCanceled, mPrecacheTaskScheduler.cancel ContinuationCnt);
122 } 127 }
123 128
124 protected void verifyLockCounts(int expectedAcquired, int expectedReleased) { 129 protected void verifyLockCounts(int expectedAcquired, int expectedReleased) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 verifyScheduledAndCanceledCounts(1, 0, 0, 0); 267 verifyScheduledAndCanceledCounts(1, 0, 0, 0);
263 268
264 // Disabling will cancel periodic and one-off tasks. 269 // Disabling will cancel periodic and one-off tasks.
265 PrecacheController.setIsPrecachingEnabled(mContext, false); 270 PrecacheController.setIsPrecachingEnabled(mContext, false);
266 verifyScheduledAndCanceledCounts(1, 0, 1, 1); 271 verifyScheduledAndCanceledCounts(1, 0, 1, 1);
267 // Subsequent disable will not schedule or cancel tasks. 272 // Subsequent disable will not schedule or cancel tasks.
268 PrecacheController.setIsPrecachingEnabled(mContext, false); 273 PrecacheController.setIsPrecachingEnabled(mContext, false);
269 verifyScheduledAndCanceledCounts(1, 0, 1, 1); 274 verifyScheduledAndCanceledCounts(1, 0, 1, 1);
270 } 275 }
271 } 276 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698