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

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

Issue 22912021: Handling errors from chrome APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 7 years, 4 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 background.js. 6 * Test fixture for background.js.
7 * @constructor 7 * @constructor
8 * @extends {testing.Test} 8 * @extends {testing.Test}
9 */ 9 */
10 function GoogleNowBackgroundUnitTest () { 10 function GoogleNowBackgroundUnitTest () {
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 storageGetSavedArgs.match(ANYTHING)). 438 storageGetSavedArgs.match(ANYTHING)).
439 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData)); 439 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData));
440 440
441 // Invoking the tested function. 441 // Invoking the tested function.
442 onNotificationClicked( 442 onNotificationClicked(
443 testNotificationId, this.mockLocalFunctions.functions().selector); 443 testNotificationId, this.mockLocalFunctions.functions().selector);
444 }); 444 });
445 445
446 TEST_F( 446 TEST_F(
447 'GoogleNowBackgroundUnitTest', 447 'GoogleNowBackgroundUnitTest',
448 'OnNotificationClicked_UrlNotString',
449 function() {
450 // Tests the case when selector returns a non-string, probably because of
451 // a malformed server response.
452 // In this case, the function should do nothing.
453
454 // Setup and expectations.
455 var testActionUrls = {testField: 'TEST VALUE'};
456 var testNotificationId = 'TEST_ID';
457 var testNotificationData = {
458 notificationsData: {'TEST_ID': {actionUrls: testActionUrls}}
459 };
460 var testActionUrl = {};
461
462 mockOnNotificationClickedDependencies(this);
463 this.makeMockLocalFunctions(['selector']);
464
465 var storageGetSavedArgs = new SaveMockArguments();
466 this.mockApis.expects(once()).
467 instrumented_storage_local_get(
468 storageGetSavedArgs.match(eq('notificationsData')),
469 storageGetSavedArgs.match(ANYTHING)).
470 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData));
471 this.mockLocalFunctions.expects(once()).selector(testActionUrls).will(
472 returnValue(testActionUrl));
473
474 // Invoking the tested function.
475 onNotificationClicked(
476 testNotificationId, this.mockLocalFunctions.functions().selector);
477 });
478
479 TEST_F(
480 'GoogleNowBackgroundUnitTest',
481 'OnNotificationClicked_TabCreateSuccess', 448 'OnNotificationClicked_TabCreateSuccess',
482 function() { 449 function() {
483 // Tests the selected URL is OK and crome.tabs.create suceeds. 450 // Tests the selected URL is OK and crome.tabs.create suceeds.
484 451
485 // Setup and expectations. 452 // Setup and expectations.
486 var testActionUrls = {testField: 'TEST VALUE'}; 453 var testActionUrls = {testField: 'TEST VALUE'};
487 var testNotificationId = 'TEST_ID'; 454 var testNotificationId = 'TEST_ID';
488 var testNotificationData = { 455 var testNotificationData = {
489 notificationsData: {'TEST_ID': {actionUrls: testActionUrls}} 456 notificationsData: {'TEST_ID': {actionUrls: testActionUrls}}
490 }; 457 };
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 chromeTabsCreateSavedArgs.match(eqJSON({url: testActionUrl})), 518 chromeTabsCreateSavedArgs.match(eqJSON({url: testActionUrl})),
552 chromeTabsCreateSavedArgs.match(ANYTHING)). 519 chromeTabsCreateSavedArgs.match(ANYTHING)).
553 will(invokeCallback(chromeTabsCreateSavedArgs, 1, testCreatedTab)); 520 will(invokeCallback(chromeTabsCreateSavedArgs, 1, testCreatedTab));
554 this.mockApis.expects(once()).chrome_windows_create( 521 this.mockApis.expects(once()).chrome_windows_create(
555 eqJSON({url: testActionUrl, focused: true})); 522 eqJSON({url: testActionUrl, focused: true}));
556 523
557 // Invoking the tested function. 524 // Invoking the tested function.
558 onNotificationClicked( 525 onNotificationClicked(
559 testNotificationId, this.mockLocalFunctions.functions().selector); 526 testNotificationId, this.mockLocalFunctions.functions().selector);
560 }); 527 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/google_now/background.js ('k') | chrome/browser/resources/google_now/cards.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698