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 8a10e7a68eb493cb1a39f0fd3d3e2100e2683fb4..6170f8a96fc4eb09dc80c6d973543083051a0c32 100644 |
--- a/chrome/browser/resources/google_now/utility_unittest.gtestjs |
+++ b/chrome/browser/resources/google_now/utility_unittest.gtestjs |
@@ -768,9 +768,20 @@ var testMaximumDelaySeconds = 2239; |
// the moment. |
var testRandomValue = 0.31415926; |
-function createTestAttempStorageEntry(delaySeconds) { |
- // Creates a test storage object that attempt manager uses to store current |
- // delay. |
+/** |
+ * Creates a default storage current delay object. |
+ */ |
+function createTestAttemptStorageEntryRequest() { |
+ var storageObject = {}; |
+ storageObject[testAttemptStorageKey] = testMaximumDelaySeconds; |
+ return storageObject; |
+} |
+ |
+/** |
+ * Creates a test storage object that attempt manager uses to store current |
+ * delay. |
+ */ |
+function createTestAttemptStorageEntry(delaySeconds) { |
var storageObject = {}; |
storageObject[testAttemptStorageKey] = delaySeconds; |
return storageObject; |
@@ -789,8 +800,8 @@ function setupAttemptManagerTest(fixture) { |
'chrome.alarms.create', |
'chrome.storage.local.remove', |
'chrome.storage.local.set', |
- 'instrumented.alarms.get', |
- 'instrumented.storage.local.get' |
+ 'fillFromChromeLocalStorage', |
+ 'instrumented.alarms.get' |
]); |
var testAttempts = buildAttemptManager( |
@@ -836,7 +847,7 @@ TEST_F('GoogleNowUtilityUnitTest', 'AttemptManagerStartStop', function() { |
periodInMinutes: testMaximumDelaySeconds / 60 |
})); |
this.mockApis.expects(once()).chrome_storage_local_set( |
- eqJSON(createTestAttempStorageEntry(expectedRetryDelaySeconds))); |
+ eqJSON(createTestAttemptStorageEntry(expectedRetryDelaySeconds))); |
// Invocation. |
test.attempts.start(); |
Mock4JS.verifyAllMocks(); |
@@ -902,21 +913,17 @@ TEST_F('GoogleNowUtilityUnitTest', 'AttemptManagerExponGrowth', function() { |
// Expectations. |
var expectedRetryDelaySeconds = |
testStoredRetryDelay * 2 * (1 + testRandomValue * 0.2); |
- var storageGetSavedArgs = new SaveMockArguments(); |
- this.mockApis.expects(once()).instrumented_storage_local_get( |
- storageGetSavedArgs.match(eq(testAttemptStorageKey)), |
- storageGetSavedArgs.match(ANYTHING)). |
- will(invokeCallback( |
- storageGetSavedArgs, |
- 1, |
- createTestAttempStorageEntry(testStoredRetryDelay))); |
+ expectChromeLocalStorageGet( |
+ this, |
+ createTestAttemptStorageEntryRequest(), |
+ createTestAttemptStorageEntry(testStoredRetryDelay)); |
this.mockApis.expects(once()).chrome_alarms_create( |
testAttemptAlarmName, |
eqJSON({ |
delayInMinutes: expectedRetryDelaySeconds / 60, |
periodInMinutes: testMaximumDelaySeconds / 60})); |
this.mockApis.expects(once()).chrome_storage_local_set( |
- eqJSON(createTestAttempStorageEntry(expectedRetryDelaySeconds))); |
+ eqJSON(createTestAttemptStorageEntry(expectedRetryDelaySeconds))); |
this.mockLocalFunctions.expects(once()).planForNextCallback(); |
// Invocation. |
test.attempts.planForNext( |
@@ -934,15 +941,11 @@ TEST_F('GoogleNowUtilityUnitTest', 'AttemptManagerGrowthLimit', function() { |
// is greater than 1/2 of the maximum delay. |
// Expectations. |
var expectedRetryDelaySeconds = testMaximumDelaySeconds; |
- var storageGetSavedArgs = new SaveMockArguments(); |
- this.mockApis.expects(once()). |
- instrumented_storage_local_get( |
- storageGetSavedArgs.match(eq(testAttemptStorageKey)), |
- storageGetSavedArgs.match(ANYTHING)). |
- will(invokeCallback( |
- storageGetSavedArgs, |
- 1, |
- createTestAttempStorageEntry(testStoredRetryDelay))); |
+ expectChromeLocalStorageGet( |
+ this, |
+ createTestAttemptStorageEntryRequest(), |
+ createTestAttemptStorageEntry(testStoredRetryDelay) |
+ ); |
this.mockApis.expects(once()).chrome_alarms_create( |
testAttemptAlarmName, |
eqJSON({ |
@@ -950,7 +953,7 @@ TEST_F('GoogleNowUtilityUnitTest', 'AttemptManagerGrowthLimit', function() { |
periodInMinutes: testMaximumDelaySeconds / 60 |
})); |
this.mockApis.expects(once()).chrome_storage_local_set( |
- eqJSON(createTestAttempStorageEntry(expectedRetryDelaySeconds))); |
+ eqJSON(createTestAttemptStorageEntry(expectedRetryDelaySeconds))); |
this.mockLocalFunctions.expects(once()).planForNextCallback(); |
// Invocation. |
test.attempts.planForNext( |