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

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

Issue 27030012: Restoring notifications on startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More rgustafson's comments Created 7 years, 2 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
« no previous file with comments | « chrome/browser/resources/google_now/cards.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 731b1fc3aeba352ee9038bc3ddf75020330dbed2..d4cb578e1154d79b3a7d5fdf6e6ecef0868c59f6 100644
--- a/chrome/browser/resources/google_now/cards_unittest.gtestjs
+++ b/chrome/browser/resources/google_now/cards_unittest.gtestjs
@@ -155,6 +155,41 @@ TEST_F('GoogleNowCardsUnitTest', 'CreateCardHideTime', function() {
JSON.stringify(notificationData));
});
+TEST_F('GoogleNowCardsUnitTest', 'CreateCardHideTimeExpired', function() {
+ // Creates a new card with trigger specifying hide time which is in the past.
+
+ // Setup and expectations.
+ var test = setUpCardManagerTest(this);
+ this.mockApis.expects(once()).
+ chrome_alarms_clear(expectedHideAlarmId);
+ this.mockApis.expects(once()).
+ chrome_alarms_clear(expectedShowAlarmId);
+ this.mockApis.expects(once()).
+ chrome_alarms_create(expectedHideAlarmId, eqJSON({when: 299999}));
+
+ // Call tested method.
+ var notificationData = test.cardSet.update(testCardId, {
+ notification: testNotification,
+ actionUrls: testActionUrls,
+ dismissals: testDismissals,
+ groupRank: testGroupRank,
+ version: 0,
+ trigger: {hideTime: 299999}});
+
+ // Check the return value.
+ assertEquals(
+ JSON.stringify({
+ actionUrls: testActionUrls,
+ cardCreateInfo: {
+ notification: testNotification,
+ hideTime: 299999,
+ version: 0
+ },
+ dismissals: testDismissals
+ }),
+ JSON.stringify(notificationData));
+});
+
TEST_F('GoogleNowCardsUnitTest', 'UpdateCardSameVersion', function() {
// Updates a card with another card with same version.
@@ -322,6 +357,14 @@ TEST_F('GoogleNowCardsUnitTest', 'onAlarmUnrecognized', function() {
TEST_F('GoogleNowCardsUnitTest', 'onAlarmShowNoData', function() {
// Tests onAlarm for the 'show' alarm when there is no data for the card.
var test = setUpCardManagerTest(this);
+
+ var tasksAddSavedArgs = new SaveMockArguments();
+ this.mockApis.expects(once()).
+ tasks_add(
+ tasksAddSavedArgs.match(eq(SHOW_CARD_TASK_NAME)),
+ tasksAddSavedArgs.match(ANYTHING)).
+ will(invokeCallback(tasksAddSavedArgs,1));
+
var storageGetSavedArgs = new SaveMockArguments();
this.mockApis.expects(once()).
instrumented_storage_local_get(
@@ -337,6 +380,14 @@ TEST_F('GoogleNowCardsUnitTest', 'onAlarmShowHasDataCreate', function() {
// Tests onAlarm for the 'show' alarm when there is data for the card. The
// notification will be created because there is no previous version.
var test = setUpCardManagerTest(this);
+
+ var tasksAddSavedArgs = new SaveMockArguments();
+ this.mockApis.expects(once()).
+ tasks_add(
+ tasksAddSavedArgs.match(eq(SHOW_CARD_TASK_NAME)),
+ tasksAddSavedArgs.match(ANYTHING)).
+ will(invokeCallback(tasksAddSavedArgs,1));
+
var storageGetSavedArgs = new SaveMockArguments();
this.mockApis.expects(once()).
instrumented_storage_local_get(
@@ -371,6 +422,14 @@ TEST_F('GoogleNowCardsUnitTest', 'onAlarmShowHasDataUpdate', function() {
// Tests onAlarm for the 'show' alarm when there is data for the card. The
// notification will be updated because previous version is same as current.
var test = setUpCardManagerTest(this);
+
+ var tasksAddSavedArgs = new SaveMockArguments();
+ this.mockApis.expects(once()).
+ tasks_add(
+ tasksAddSavedArgs.match(eq(SHOW_CARD_TASK_NAME)),
+ tasksAddSavedArgs.match(ANYTHING)).
+ will(invokeCallback(tasksAddSavedArgs,1));
+
var storageGetSavedArgs = new SaveMockArguments();
this.mockApis.expects(once()).
instrumented_storage_local_get(
« no previous file with comments | « chrome/browser/resources/google_now/cards.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698