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

Unified Diff: chrome/browser/resources/google_now/utility_unittest.gtestjs

Issue 248473003: Attempt Manager Refactor and Opt-In Pipeline Refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Quick Comment Fix Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/google_now/utility_unittest.gtestjs
diff --git a/chrome/browser/resources/google_now/utility_unittest.gtestjs b/chrome/browser/resources/google_now/utility_unittest.gtestjs
index f3552c4d3730ea2d5dcd9363ba346f5e96bef2b1..834e6a1c62005980042dbaf1bbf42ad4e5a0685b 100644
--- a/chrome/browser/resources/google_now/utility_unittest.gtestjs
+++ b/chrome/browser/resources/google_now/utility_unittest.gtestjs
@@ -792,7 +792,6 @@ function setupAttemptManagerTest(fixture) {
fixture.makeMockLocalFunctions([
'attempt',
- 'planForNextCallback',
'isRunningCallback'
]);
fixture.makeAndRegisterMockApis([
@@ -908,8 +907,8 @@ TEST_F('GoogleNowUtilityUnitTest', 'AttemptManagerExponGrowth', function() {
var test = setupAttemptManagerTest(this);
var testStoredRetryDelay = 433;
- // Call planForNext, which prepares next attempt. Current retry time
- // is less than 1/2 of the maximum delay.
+ // Call scheduleRetry, which schedules a retry.
+ // Current retry time is less than 1/2 of the maximum delay.
// Expectations.
var expectedRetryDelaySeconds =
testStoredRetryDelay * 2 * (1 + testRandomValue * 0.2);
@@ -925,10 +924,16 @@ TEST_F('GoogleNowUtilityUnitTest', 'AttemptManagerExponGrowth', function() {
periodInMinutes: testMaximumDelaySeconds / 60}));
this.mockApis.expects(once()).chrome_storage_local_set(
eqJSON(createTestAttemptStorageEntry(expectedRetryDelaySeconds)));
- this.mockLocalFunctions.expects(once()).planForNextCallback();
// Invocation.
- test.attempts.planForNext(
- this.mockLocalFunctions.functions().planForNextCallback);
+ var thenCalled = false;
+ var catchCalled = false;
+ test.attempts.scheduleRetry().then(function(request) {
+ thenCalled = true;
+ }).catch(function(request) {
+ catchCalled = true;
+ });
+ assertTrue(thenCalled);
+ assertFalse(catchCalled);
});
TEST_F('GoogleNowUtilityUnitTest', 'AttemptManagerGrowthLimit', function() {
@@ -938,8 +943,8 @@ TEST_F('GoogleNowUtilityUnitTest', 'AttemptManagerGrowthLimit', function() {
var test = setupAttemptManagerTest(this);
var testStoredRetryDelay = 1500;
- // Call planForNext, which prepares next attempt. Current retry time
- // is greater than 1/2 of the maximum delay.
+ // Call scheduleRetry, which schedules a retry.
+ // Current retry time is greater than 1/2 of the maximum delay.
// Expectations.
var expectedRetryDelaySeconds = testMaximumDelaySeconds;
expectChromeLocalStorageGet(
@@ -955,10 +960,16 @@ TEST_F('GoogleNowUtilityUnitTest', 'AttemptManagerGrowthLimit', function() {
}));
this.mockApis.expects(once()).chrome_storage_local_set(
eqJSON(createTestAttemptStorageEntry(expectedRetryDelaySeconds)));
- this.mockLocalFunctions.expects(once()).planForNextCallback();
// Invocation.
- test.attempts.planForNext(
- this.mockLocalFunctions.functions().planForNextCallback);
+ var thenCalled = false;
+ var catchCalled = false;
+ test.attempts.scheduleRetry().then(function(request) {
+ thenCalled = true;
+ }).catch(function(request) {
+ catchCalled = true;
+ });
+ assertTrue(thenCalled);
+ assertFalse(catchCalled);
});
TEST_F('GoogleNowUtilityUnitTest', 'AttemptManagerAlarm', function() {

Powered by Google App Engine
This is Rietveld 408576698