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

Side by Side Diff: chrome/browser/resources/google_now/cards_unittest.gtestjs

Issue 25097002: Cleaning data associated with the card upon deletion. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cosmetics 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 /** 5 /**
6 * Test fixture for cards.js. 6 * Test fixture for cards.js.
7 * @constructor 7 * @constructor
8 * @extends {testing.Test} 8 * @extends {testing.Test}
9 */ 9 */
10 function GoogleNowCardsUnitTest () { 10 function GoogleNowCardsUnitTest () {
(...skipping 18 matching lines...) Expand all
29 {testDismissalField: 'TEST DISMISSAL VALUE 1'}, 29 {testDismissalField: 'TEST DISMISSAL VALUE 1'},
30 {testDismissalField: 'TEST DISMISSAL VALUE 2'} 30 {testDismissalField: 'TEST DISMISSAL VALUE 2'}
31 ]; 31 ];
32 var testGroupRank = 271; 32 var testGroupRank = 271;
33 33
34 function setUpCardManagerTest(fixture) { 34 function setUpCardManagerTest(fixture) {
35 fixture.makeAndRegisterMockApis([ 35 fixture.makeAndRegisterMockApis([
36 'chrome.alarms.clear', 36 'chrome.alarms.clear',
37 'chrome.alarms.create', 37 'chrome.alarms.create',
38 'chrome.notifications.clear', 38 'chrome.notifications.clear',
39 'chrome.storage.local.set',
39 'instrumented.alarms.onAlarm.addListener', 40 'instrumented.alarms.onAlarm.addListener',
40 'instrumented.notifications.create', 41 'instrumented.notifications.create',
41 'instrumented.notifications.update', 42 'instrumented.notifications.update',
42 'instrumented.storage.local.get' 43 'instrumented.storage.local.get',
44 'tasks.add'
43 ]); 45 ]);
44 46
45 chrome.runtime = {}; // No error. 47 chrome.runtime = {}; // No error.
46 48
47 var onAlarmSavedArgs = new SaveMockArguments(); 49 var onAlarmSavedArgs = new SaveMockArguments();
48 fixture.mockApis.expects(once()). 50 fixture.mockApis.expects(once()).
49 instrumented_alarms_onAlarm_addListener( 51 instrumented_alarms_onAlarm_addListener(
50 onAlarmSavedArgs.match(ANYTHING)); 52 onAlarmSavedArgs.match(ANYTHING));
51 53
52 var cardSet = buildCardSet(); 54 var cardSet = buildCardSet();
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 instrumented_notifications_update( 393 instrumented_notifications_update(
392 testCardId, eqJSON(testNotification), ANYTHING); 394 testCardId, eqJSON(testNotification), ANYTHING);
393 395
394 // Call tested method. 396 // Call tested method.
395 test.alarmCallback({name: expectedShowAlarmId}); 397 test.alarmCallback({name: expectedShowAlarmId});
396 }); 398 });
397 399
398 TEST_F('GoogleNowCardsUnitTest', 'onAlarmHide', function() { 400 TEST_F('GoogleNowCardsUnitTest', 'onAlarmHide', function() {
399 // Tests onAlarm for the 'hide' alarm. 401 // Tests onAlarm for the 'hide' alarm.
400 var test = setUpCardManagerTest(this); 402 var test = setUpCardManagerTest(this);
403 var tasksAddSavedArgs = new SaveMockArguments();
404 this.mockApis.expects(once()).
405 tasks_add(tasksAddSavedArgs.match(eq(CLEAR_CARD_TASK_NAME)), tasksAddSaved Args.match(ANYTHING)).
robliao 2013/09/27 19:47:11 Linebreak
vadimt 2013/09/27 20:10:56 Done.
406 will(invokeCallback(tasksAddSavedArgs,1));
401 this.mockApis.expects(once()). 407 this.mockApis.expects(once()).
402 chrome_notifications_clear(testCardId, ANYTHING); 408 chrome_notifications_clear(testCardId, ANYTHING);
403 this.mockApis.expects(once()). 409 this.mockApis.expects(once()).
404 chrome_alarms_clear(expectedShowAlarmId); 410 chrome_alarms_clear(expectedShowAlarmId);
405 this.mockApis.expects(once()). 411 this.mockApis.expects(once()).
406 chrome_alarms_clear(expectedHideAlarmId); 412 chrome_alarms_clear(expectedHideAlarmId);
407 413 var storageGetSavedArgs = new SaveMockArguments();
414 this.mockApis.expects(once()).
415 instrumented_storage_local_get(
416 storageGetSavedArgs.match(
417 eqJSON(['notificationsData', 'notificationGroups'])),
418 storageGetSavedArgs.match(ANYTHING)).
419 will(invokeCallback(
420 storageGetSavedArgs,
421 1,
422 {
423 notificationsData: {
424 'TEST CARD ID': {testField: 'TEST VALUE'},
425 'TEST CARD ID 1': {testField: 'TEST VALUE 1'}
426 },
427 notificationGroups: {
428 groupA: {
429 cards: [
430 {
431 chromeNotificationId: 'TEST CARD ID',
432 testField: 'TEST VALUE',
433 },
434 {
435 chromeNotificationId: 'TEST CARD ID 1',
436 testField: 'TEST VALUE 1',
437 }
438 ]
439 },
440 groupB: {
441 cards: [
442 {
443 chromeNotificationId: 'TEST CARD ID 0',
444 testField: 'TEST VALUE 0',
445 },
446 {
447 chromeNotificationId: 'TEST CARD ID',
448 testField: 'TEST VALUE',
449 }
450 ]
451 }
452 }}));
453 this.mockApis.expects(once()).
454 chrome_storage_local_set(eqJSON({
455 notificationsData: {
456 'TEST CARD ID 1': {testField: 'TEST VALUE 1'}
457 },
458 notificationGroups: {
459 groupA: {
460 cards: [
461 {
462 chromeNotificationId: 'TEST CARD ID 1',
463 testField: 'TEST VALUE 1',
464 }
465 ]
466 },
467 groupB: {
468 cards: [
469 {
470 chromeNotificationId: 'TEST CARD ID 0',
471 testField: 'TEST VALUE 0',
472 }
473 ]
474 }
475 }
476 }));
408 477
409 // Call tested method. 478 // Call tested method.
410 test.alarmCallback({name: expectedHideAlarmId}); 479 test.alarmCallback({name: expectedHideAlarmId});
411 }); 480 });
OLDNEW
« chrome/browser/resources/google_now/cards.js ('K') | « 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