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

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

Issue 145353010: Gate console.log output in Google Now (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 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 () {
11 testing.Test.call(this); 11 testing.Test.call(this);
12 } 12 }
13 13
14 GoogleNowCardsUnitTest.prototype = { 14 GoogleNowCardsUnitTest.prototype = {
15 __proto__: testing.Test.prototype, 15 __proto__: testing.Test.prototype,
16 16
17 /** @override */ 17 /** @override */
18 extraLibraries: [ 18 extraLibraries: [
19 'common_test_util.js',
19 'cards.js' 20 'cards.js'
20 ] 21 ]
21 }; 22 };
22 23
23 // Test implementation of a function provided by utility.js. 24 // Test implementation of a function provided by utility.js.
24 function verify(condition, message) { 25 function verify(condition, message) {
25 assertTrue(condition, message); 26 assertTrue(condition, message);
26 } 27 }
27 28
28 var testCardId = 'TEST CARD ID'; 29 var testCardId = 'TEST CARD ID';
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 this.mockApis.expects(once()). 112 this.mockApis.expects(once()).
112 chrome_alarms_clear(expectedAlarmId); 113 chrome_alarms_clear(expectedAlarmId);
113 var chromeNotificationsUpdateSavedArgs = new SaveMockArguments(); 114 var chromeNotificationsUpdateSavedArgs = new SaveMockArguments();
114 this.mockApis.expects(once()). 115 this.mockApis.expects(once()).
115 instrumented_notifications_update( 116 instrumented_notifications_update(
116 chromeNotificationsUpdateSavedArgs.match(eq(testCardId)), 117 chromeNotificationsUpdateSavedArgs.match(eq(testCardId)),
117 chromeNotificationsUpdateSavedArgs.match(eqJSON(testNotificationA)), 118 chromeNotificationsUpdateSavedArgs.match(eqJSON(testNotificationA)),
118 chromeNotificationsUpdateSavedArgs.match(ANYTHING)). 119 chromeNotificationsUpdateSavedArgs.match(ANYTHING)).
119 will(invokeCallback( 120 will(invokeCallback(
120 chromeNotificationsUpdateSavedArgs, 2, notificationUpdateSuccessful)); 121 chromeNotificationsUpdateSavedArgs, 2, notificationUpdateSuccessful));
121 this.mockApis.expects(once()).» 122 this.mockApis.expects(once()).
122 chrome_alarms_create(expectedAlarmId, eqJSON({when: 300001})); 123 chrome_alarms_create(expectedAlarmId, eqJSON({when: 300001}));
123 124
124 // Call tested method. 125 // Call tested method.
125 var notificationData = test.cardSet.update( 126 var notificationData = test.cardSet.update(
126 testCardId, [testUncombinedNotification], {}); 127 testCardId, [testUncombinedNotification], {});
127 128
128 // Check the return value. 129 // Check the return value.
129 assertEquals( 130 assertEquals(
130 JSON.stringify({ 131 JSON.stringify({
131 actionUrls: testActionUrlsA, 132 actionUrls: testActionUrlsA,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 this.mockApis.expects(once()). 172 this.mockApis.expects(once()).
172 instrumented_notifications_create( 173 instrumented_notifications_create(
173 chromeNotificationsCreateSavedArgs.match(eq(testCardId)), 174 chromeNotificationsCreateSavedArgs.match(eq(testCardId)),
174 chromeNotificationsCreateSavedArgs.match(eqJSON(testNotificationA)), 175 chromeNotificationsCreateSavedArgs.match(eqJSON(testNotificationA)),
175 chromeNotificationsCreateSavedArgs.match(ANYTHING)). 176 chromeNotificationsCreateSavedArgs.match(ANYTHING)).
176 will(invokeCallback(chromeNotificationsCreateSavedArgs, 2, testCardId)); 177 will(invokeCallback(chromeNotificationsCreateSavedArgs, 2, testCardId));
177 178
178 this.mockLocalFunctions.expects(once()). 179 this.mockLocalFunctions.expects(once()).
179 onCardShown(eqJSON(testUncombinedNotification.receivedNotification)); 180 onCardShown(eqJSON(testUncombinedNotification.receivedNotification));
180 181
181 this.mockApis.expects(once()).» 182 this.mockApis.expects(once()).
182 chrome_alarms_create(expectedAlarmId, eqJSON({when: 300001})); 183 chrome_alarms_create(expectedAlarmId, eqJSON({when: 300001}));
183 184
184 // Call tested method. 185 // Call tested method.
185 var notificationData = test.cardSet.update( 186 var notificationData = test.cardSet.update(
186 testCardId, 187 testCardId,
187 [testUncombinedNotification], 188 [testUncombinedNotification],
188 {}, 189 {},
189 this.mockLocalFunctions.functions().onCardShown); 190 this.mockLocalFunctions.functions().onCardShown);
190 191
191 // Check the return value. 192 // Check the return value.
(...skipping 21 matching lines...) Expand all
213 }, 214 },
214 showTime: 300001, 215 showTime: 300001,
215 hideTime: 300002 216 hideTime: 300002
216 }; 217 };
217 218
218 // Setup and expectations. 219 // Setup and expectations.
219 var test = setUpCardManagerTest(this); 220 var test = setUpCardManagerTest(this);
220 221
221 this.mockApis.expects(once()). 222 this.mockApis.expects(once()).
222 chrome_alarms_clear(expectedAlarmId); 223 chrome_alarms_clear(expectedAlarmId);
223 this.mockApis.expects(once()).» 224 this.mockApis.expects(once()).
224 instrumented_notifications_clear(testCardId, ANYTHING); 225 instrumented_notifications_clear(testCardId, ANYTHING);
225 this.mockApis.expects(once()).» 226 this.mockApis.expects(once()).
226 chrome_alarms_create(expectedAlarmId, eqJSON({when: 300001})); 227 chrome_alarms_create(expectedAlarmId, eqJSON({when: 300001}));
227 228
228 // Call tested method. 229 // Call tested method.
229 var notificationData = test.cardSet.update( 230 var notificationData = test.cardSet.update(
230 testCardId, [testUncombinedNotification], {}); 231 testCardId, [testUncombinedNotification], {});
231 232
232 // Check the return value. 233 // Check the return value.
233 assertEquals( 234 assertEquals(
234 JSON.stringify({ 235 JSON.stringify({
235 timestamp: 300000, 236 timestamp: 300000,
(...skipping 15 matching lines...) Expand all
251 dismissal: testDismissalA, 252 dismissal: testDismissalA,
252 groupName: groupNameA 253 groupName: groupNameA
253 }, 254 },
254 hideTime: 300000 255 hideTime: 300000
255 }; 256 };
256 257
257 // Setup and expectations. 258 // Setup and expectations.
258 var test = setUpCardManagerTest(this); 259 var test = setUpCardManagerTest(this);
259 this.mockApis.expects(once()). 260 this.mockApis.expects(once()).
260 chrome_alarms_clear(expectedAlarmId); 261 chrome_alarms_clear(expectedAlarmId);
261 this.mockApis.expects(once()).» 262 this.mockApis.expects(once()).
262 instrumented_notifications_clear(testCardId, ANYTHING); 263 instrumented_notifications_clear(testCardId, ANYTHING);
263 264
264 var groups = { 265 var groups = {
265 A: { 266 A: {
266 cards: [{chromeNotificationId: 'ID1'}, {chromeNotificationId: testCardId}] 267 cards: [{chromeNotificationId: 'ID1'}, {chromeNotificationId: testCardId}]
267 }, 268 },
268 B: { 269 B: {
269 cards: [{chromeNotificationId: testCardId}, {chromeNotificationId: 'ID2'}] 270 cards: [{chromeNotificationId: testCardId}, {chromeNotificationId: 'ID2'}]
270 } 271 }
271 }; 272 };
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 this.mockApis.expects(once()). 324 this.mockApis.expects(once()).
324 chrome_alarms_clear(expectedAlarmId); 325 chrome_alarms_clear(expectedAlarmId);
325 var chromeNotificationsUpdateSavedArgs = new SaveMockArguments(); 326 var chromeNotificationsUpdateSavedArgs = new SaveMockArguments();
326 this.mockApis.expects(once()). 327 this.mockApis.expects(once()).
327 instrumented_notifications_update( 328 instrumented_notifications_update(
328 chromeNotificationsUpdateSavedArgs.match(eq(testCardId)), 329 chromeNotificationsUpdateSavedArgs.match(eq(testCardId)),
329 chromeNotificationsUpdateSavedArgs.match(eqJSON(testNotificationB)), 330 chromeNotificationsUpdateSavedArgs.match(eqJSON(testNotificationB)),
330 chromeNotificationsUpdateSavedArgs.match(ANYTHING)). 331 chromeNotificationsUpdateSavedArgs.match(ANYTHING)).
331 will(invokeCallback( 332 will(invokeCallback(
332 chromeNotificationsUpdateSavedArgs, 2, notificationUpdateSuccessful)); 333 chromeNotificationsUpdateSavedArgs, 2, notificationUpdateSuccessful));
333 this.mockApis.expects(once()).» 334 this.mockApis.expects(once()).
334 chrome_alarms_create(expectedAlarmId, eqJSON({when: 300001})); 335 chrome_alarms_create(expectedAlarmId, eqJSON({when: 300001}));
335 336
336 // Call tested method. 337 // Call tested method.
337 var notificationData = test.cardSet.update( 338 var notificationData = test.cardSet.update(
338 testCardId, 339 testCardId,
339 [testUncombinedNotificationA, testUncombinedNotificationB], 340 [testUncombinedNotificationA, testUncombinedNotificationB],
340 {}); 341 {});
341 342
342 // Check the return value. 343 // Check the return value.
343 assertEquals( 344 assertEquals(
(...skipping 19 matching lines...) Expand all
363 groupName: groupNameA 364 groupName: groupNameA
364 }, 365 },
365 showTime: 299995, 366 showTime: 299995,
366 hideTime: 300005 367 hideTime: 300005
367 }; 368 };
368 369
369 // Setup and expectations. 370 // Setup and expectations.
370 var test = setUpCardManagerTest(this); 371 var test = setUpCardManagerTest(this);
371 this.mockApis.expects(once()). 372 this.mockApis.expects(once()).
372 chrome_alarms_clear(expectedAlarmId); 373 chrome_alarms_clear(expectedAlarmId);
373 this.mockApis.expects(once()).» 374 this.mockApis.expects(once()).
374 instrumented_notifications_clear(testCardId, ANYTHING); 375 instrumented_notifications_clear(testCardId, ANYTHING);
375 376
376 var groups = { 377 var groups = {
377 A: { 378 A: {
378 cards: [{chromeNotificationId: 'ID1'}, {chromeNotificationId: testCardId}] 379 cards: [{chromeNotificationId: 'ID1'}, {chromeNotificationId: testCardId}]
379 }, 380 },
380 B: { 381 B: {
381 cards: [{chromeNotificationId: testCardId}, {chromeNotificationId: 'ID2'}] 382 cards: [{chromeNotificationId: testCardId}, {chromeNotificationId: 'ID2'}]
382 } 383 }
383 }; 384 };
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 groupName: groupNameB 444 groupName: groupNameB
444 }, 445 },
445 showTime: 299995, 446 showTime: 299995,
446 hideTime: 300005 447 hideTime: 300005
447 }; 448 };
448 449
449 // Setup and expectations. 450 // Setup and expectations.
450 var test = setUpCardManagerTest(this); 451 var test = setUpCardManagerTest(this);
451 this.mockApis.expects(once()). 452 this.mockApis.expects(once()).
452 chrome_alarms_clear(expectedAlarmId); 453 chrome_alarms_clear(expectedAlarmId);
453 this.mockApis.expects(once()).» 454 this.mockApis.expects(once()).
454 instrumented_notifications_clear(testCardId, ANYTHING); 455 instrumented_notifications_clear(testCardId, ANYTHING);
455 this.mockApis.expects(once()).» 456 this.mockApis.expects(once()).
456 chrome_alarms_create(expectedAlarmId, eqJSON({when: 300010})); 457 chrome_alarms_create(expectedAlarmId, eqJSON({when: 300010}));
457 458
458 // Call tested method. 459 // Call tested method.
459 var dismissalResult = test.cardSet.onDismissal( 460 var dismissalResult = test.cardSet.onDismissal(
460 testCardId, 461 testCardId,
461 { 462 {
462 actionUrls: testActionUrlsB, 463 actionUrls: testActionUrlsB,
463 timestamp: 299999, 464 timestamp: 299999,
464 combinedCard: [testUncombinedNotificationA, testUncombinedNotificationB] 465 combinedCard: [testUncombinedNotificationA, testUncombinedNotificationB]
465 }, 466 },
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 this.mockApis.expects(once()). 604 this.mockApis.expects(once()).
604 chrome_alarms_clear(expectedAlarmId); 605 chrome_alarms_clear(expectedAlarmId);
605 var chromeNotificationsUpdateSavedArgs = new SaveMockArguments(); 606 var chromeNotificationsUpdateSavedArgs = new SaveMockArguments();
606 this.mockApis.expects(once()). 607 this.mockApis.expects(once()).
607 instrumented_notifications_update( 608 instrumented_notifications_update(
608 chromeNotificationsUpdateSavedArgs.match(eq(testCardId)), 609 chromeNotificationsUpdateSavedArgs.match(eq(testCardId)),
609 chromeNotificationsUpdateSavedArgs.match(eqJSON(testNotificationA)), 610 chromeNotificationsUpdateSavedArgs.match(eqJSON(testNotificationA)),
610 chromeNotificationsUpdateSavedArgs.match(ANYTHING)). 611 chromeNotificationsUpdateSavedArgs.match(ANYTHING)).
611 will(invokeCallback( 612 will(invokeCallback(
612 chromeNotificationsUpdateSavedArgs, 2, notificationUpdateSuccessful)); 613 chromeNotificationsUpdateSavedArgs, 2, notificationUpdateSuccessful));
613 this.mockApis.expects(once()).» 614 this.mockApis.expects(once()).
614 chrome_alarms_create(expectedAlarmId, eqJSON({when: 300001})); 615 chrome_alarms_create(expectedAlarmId, eqJSON({when: 300001}));
615 this.mockApis.expects(once()). 616 this.mockApis.expects(once()).
616 chrome_storage_local_set(eqJSON({ 617 chrome_storage_local_set(eqJSON({
617 notificationsData: { 618 notificationsData: {
618 'TEST CARD ID': { 619 'TEST CARD ID': {
619 actionUrls: testActionUrlsA, 620 actionUrls: testActionUrlsA,
620 timestamp: 300000, 621 timestamp: 300000,
621 combinedCard: [testUncombinedNotification] 622 combinedCard: [testUncombinedNotification]
622 } 623 }
623 }, 624 },
624 notificationGroups: { 625 notificationGroups: {
625 }})); 626 }}));
626 627
627 // Call tested method. 628 // Call tested method.
628 test.alarmCallback({name: expectedAlarmId}); 629 test.alarmCallback({name: expectedAlarmId});
629 }); 630 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/google_now/background.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