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

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

Issue 166033010: Convert Google Now's use of chrome.local.storage.get to use Promises (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR Feedback Created 6 years, 10 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/cards_unittest.gtestjs
diff --git a/chrome/browser/resources/google_now/cards_unittest.gtestjs b/chrome/browser/resources/google_now/cards_unittest.gtestjs
index a55a91d5717b3d7e4f5bd92ad0f26cd3608bcce0..e50a5e04add11b887e58663b9649fbf4ae0c0443 100644
--- a/chrome/browser/resources/google_now/cards_unittest.gtestjs
+++ b/chrome/browser/resources/google_now/cards_unittest.gtestjs
@@ -53,13 +53,13 @@ function setUpCardManagerTest(fixture) {
fixture.makeAndRegisterMockApis([
'chrome.alarms.clear',
'chrome.alarms.create',
- 'instrumented.notifications.clear',
'chrome.storage.local.set',
'countExplanatoryCard',
+ 'fillFromChromeLocalStorage',
'instrumented.alarms.onAlarm.addListener',
+ 'instrumented.notifications.clear',
'instrumented.notifications.create',
'instrumented.notifications.update',
- 'instrumented.storage.local.get',
'tasks.add'
]);
@@ -510,37 +510,34 @@ TEST_F('GoogleNowCardsUnitTest', 'onAlarmClear', function() {
tasksAddSavedArgs.match(eq(UPDATE_CARD_TASK_NAME)),
tasksAddSavedArgs.match(ANYTHING)).
will(invokeCallback(tasksAddSavedArgs,1));
- var storageGetSavedArgs = new SaveMockArguments();
- this.mockApis.expects(once()).
- instrumented_storage_local_get(
- storageGetSavedArgs.match(
- eqJSON(['notificationsData', 'notificationGroups'])),
- storageGetSavedArgs.match(ANYTHING)).
- will(invokeCallback(
- storageGetSavedArgs,
- 1,
- {
- notificationsData: {
- 'TEST CARD ID': {
- actionUrls: testActionUrlsA,
- timestamp: 299998,
- combinedCard: [testUncombinedNotification]
- },
- 'TEST CARD ID 1': {testField: 'TEST VALUE 1'}
- },
- notificationGroups: {
- A: {
- cards: [
- {chromeNotificationId: 'ID1'},
- {chromeNotificationId: testCardId}
- ]
- },
- B: {
- cards: [
- {chromeNotificationId: testCardId},
- {chromeNotificationId: 'ID2'}
- ]
- }}}));
+ expectChromeLocalStorageGet(
+ this,
+ {
+ notificationsData: {},
+ notificationGroups: {}
+ },
+ {
+ notificationsData: {
+ 'TEST CARD ID': {
+ actionUrls: testActionUrlsA,
+ timestamp: 299998,
+ combinedCard: [testUncombinedNotification]
+ },
+ 'TEST CARD ID 1': {testField: 'TEST VALUE 1'}
+ },
+ notificationGroups: {
+ A: {
+ cards: [
+ {chromeNotificationId: 'ID1'},
+ {chromeNotificationId: testCardId}
+ ]
+ },
+ B: {
+ cards: [
+ {chromeNotificationId: testCardId},
+ {chromeNotificationId: 'ID2'}
+ ]
+ }}});
this.mockApis.expects(once()).
instrumented_notifications_clear(testCardId, ANYTHING);
this.mockApis.expects(once()).
@@ -585,22 +582,21 @@ TEST_F('GoogleNowCardsUnitTest', 'onAlarmUpdate', function() {
tasksAddSavedArgs.match(eq(UPDATE_CARD_TASK_NAME)),
tasksAddSavedArgs.match(ANYTHING)).
will(invokeCallback(tasksAddSavedArgs,1));
- var storageGetSavedArgs = new SaveMockArguments();
- this.mockApis.expects(once()).
- instrumented_storage_local_get(
- storageGetSavedArgs.match(
- eqJSON(['notificationsData', 'notificationGroups'])),
- storageGetSavedArgs.match(ANYTHING)).
- will(invokeCallback(
- storageGetSavedArgs,
- 1,
- {
- notificationsData: {
- 'TEST CARD ID': {
- actionUrls: testActionUrlsA,
- timestamp: 299998,
- combinedCard: [testUncombinedNotification]
- }}}));
+ expectChromeLocalStorageGet(
+ this,
+ {
+ notificationsData: {},
+ notificationGroups: {}
+ },
+ {
+ notificationsData: {
+ 'TEST CARD ID': {
+ actionUrls: testActionUrlsA,
+ timestamp: 299998,
+ combinedCard: [testUncombinedNotification]
+ }},
+ notificationGroups: {}
+ });
this.mockApis.expects(once()).
chrome_alarms_clear(expectedAlarmId);
var chromeNotificationsUpdateSavedArgs = new SaveMockArguments();
« no previous file with comments | « chrome/browser/resources/google_now/cards.js ('k') | chrome/browser/resources/google_now/common_test_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698