OLD | NEW |
---|---|
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 // TODO(robliao,vadimt): Determine the granularity of testing to perform. | 5 // TODO(robliao,vadimt): Determine the granularity of testing to perform. |
6 | 6 |
7 /** | 7 /** |
8 * Test fixture for background.js. | 8 * Test fixture for background.js. |
9 * @constructor | 9 * @constructor |
10 * @extends {testing.Test} | 10 * @extends {testing.Test} |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 'ParseAndShowNotificationCardsAdd1Remove1', | 374 'ParseAndShowNotificationCardsAdd1Remove1', |
375 function() { | 375 function() { |
376 // Tests parseAndShowNotificationCards function for the case when the | 376 // Tests parseAndShowNotificationCards function for the case when the |
377 // extension has 2 groups, and the server sends update with 2 groups, one | 377 // extension has 2 groups, and the server sends update with 2 groups, one |
378 // of which is new, and another one matches a stored group. The client | 378 // of which is new, and another one matches a stored group. The client |
379 // has to delete the group that didn't receive an update, keep the | 379 // has to delete the group that didn't receive an update, keep the |
380 // existing group that received an update, and add a new stored group for | 380 // existing group that received an update, and add a new stored group for |
381 // the new group from the server. | 381 // the new group from the server. |
382 | 382 |
383 // Setup and expectations. | 383 // Setup and expectations. |
384 Date.now = function() { return 500; }; | |
385 | |
386 var serverResponse = { | 384 var serverResponse = { |
387 groups: { | 385 groups: { |
388 GROUP1: {}, | 386 GROUP1: {}, |
389 GROUP2: {} | 387 GROUP2: {} |
390 } | 388 } |
391 }; | 389 }; |
392 | 390 |
393 var storedGroups = { | 391 var storedGroups = { |
394 GROUP2: { | 392 GROUP2: { |
395 cards: ['c2'], | 393 cards: ['c2'], |
396 cardsTimestamp: 239, | 394 cardsTimestamp: 239, |
397 nextPollTime: 10000, | 395 nextPollTime: 10000, |
398 rank: 1 | 396 rank: 1 |
399 }, | 397 }, |
400 GROUP3: { | 398 GROUP3: { |
401 cards: ['c3'], | 399 cards: ['c3'], |
402 cardsTimestamp: 240, | 400 cardsTimestamp: 240, |
403 nextPollTime: 10001, | 401 nextPollTime: 10001, |
404 rank: 2 | 402 rank: 2 |
405 } | 403 } |
406 }; | 404 }; |
407 | 405 |
408 var expectedUpdatedGroups = { | 406 var expectedUpdatedGroups = { |
409 GROUP1: { | 407 GROUP1: { |
410 cards: [], | 408 cards: [] |
411 nextPollTime: Date.now() | |
robliao
2013/10/23 17:15:29
Is this not critical to the test? Seems like nextP
vadimt
2013/10/23 17:19:28
I started developing tests for parseAndShowNotific
| |
412 }, | 409 }, |
413 GROUP2: { | 410 GROUP2: { |
414 cards: ['c2'], | 411 cards: ['c2'], |
415 cardsTimestamp: 239, | 412 cardsTimestamp: 239, |
416 nextPollTime: 10000, | 413 nextPollTime: 10000, |
417 rank: 1 | 414 rank: 1 |
418 } | 415 } |
419 }; | 416 }; |
420 | 417 |
421 this.makeAndRegisterMockGlobals( | 418 this.makeAndRegisterMockGlobals( |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
828 chromeTabsCreateSavedArgs.match(eqJSON({url: testActionUrl})), | 825 chromeTabsCreateSavedArgs.match(eqJSON({url: testActionUrl})), |
829 chromeTabsCreateSavedArgs.match(ANYTHING)). | 826 chromeTabsCreateSavedArgs.match(ANYTHING)). |
830 will(invokeCallback(chromeTabsCreateSavedArgs, 1, testCreatedTab)); | 827 will(invokeCallback(chromeTabsCreateSavedArgs, 1, testCreatedTab)); |
831 this.mockApis.expects(once()).chrome_windows_create( | 828 this.mockApis.expects(once()).chrome_windows_create( |
832 eqJSON({url: testActionUrl, focused: true})); | 829 eqJSON({url: testActionUrl, focused: true})); |
833 | 830 |
834 // Invoking the tested function. | 831 // Invoking the tested function. |
835 onNotificationClicked( | 832 onNotificationClicked( |
836 testNotificationId, this.mockLocalFunctions.functions().selector); | 833 testNotificationId, this.mockLocalFunctions.functions().selector); |
837 }); | 834 }); |
OLD | NEW |