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 /** | 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 */ | 54 */ |
55 function mockInitializeDependencies(fixture) { | 55 function mockInitializeDependencies(fixture) { |
56 fixture.makeAndRegisterMockGlobals([ | 56 fixture.makeAndRegisterMockGlobals([ |
57 'recordEvent', | 57 'recordEvent', |
58 'showWelcomeToast', | 58 'showWelcomeToast', |
59 'startPollingCards' | 59 'startPollingCards' |
60 ]); | 60 ]); |
61 fixture.makeAndRegisterMockApis([ | 61 fixture.makeAndRegisterMockApis([ |
62 'authenticationManager.isSignedIn', | 62 'authenticationManager.isSignedIn', |
63 'chrome.location.clearWatch', | 63 'chrome.location.clearWatch', |
64 'chrome.notifications.getAll', | 64 'chrome.storage.local.set', |
65 'chrome.preferencesPrivate.googleGeolocationAccessEnabled.get', | 65 'instrumented.notifications.getAll', |
66 'storage.get', | 66 'instrumented.preferencesPrivate.googleGeolocationAccessEnabled.get', |
67 'storage.set', | 67 'instrumented.storage.local.get', |
68 'tasks.add', | 68 'tasks.add', |
69 'updateCardsAttempts.isRunning', | 69 'updateCardsAttempts.isRunning', |
70 'updateCardsAttempts.stop' | 70 'updateCardsAttempts.stop' |
71 ]); | 71 ]); |
72 } | 72 } |
73 | 73 |
74 /** | 74 /** |
75 * Sets up the test to expect the state machine calls and send | 75 * Sets up the test to expect the state machine calls and send |
76 * the specified state machine state. Currently used to test initialize(). | 76 * the specified state machine state. Currently used to test initialize(). |
77 * Note that this CAN NOT be used if any of the methods below are called | 77 * Note that this CAN NOT be used if any of the methods below are called |
(...skipping 14 matching lines...) Expand all Loading... |
92 mockApisObj.expects(once()). | 92 mockApisObj.expects(once()). |
93 authenticationManager_isSignedIn( | 93 authenticationManager_isSignedIn( |
94 authenticationManagerIsSignedInSavedArgs.match(ANYTHING)). | 94 authenticationManagerIsSignedInSavedArgs.match(ANYTHING)). |
95 will(invokeCallback( | 95 will(invokeCallback( |
96 authenticationManagerIsSignedInSavedArgs, | 96 authenticationManagerIsSignedInSavedArgs, |
97 0, | 97 0, |
98 testIdentityToken)); | 98 testIdentityToken)); |
99 | 99 |
100 var googleGeolocationPrefGetSavedArgs = new SaveMockArguments(); | 100 var googleGeolocationPrefGetSavedArgs = new SaveMockArguments(); |
101 mockApisObj.expects(once()). | 101 mockApisObj.expects(once()). |
102 chrome_preferencesPrivate_googleGeolocationAccessEnabled_get( | 102 instrumented_preferencesPrivate_googleGeolocationAccessEnabled_get( |
103 googleGeolocationPrefGetSavedArgs.match(eqJSON({})), | 103 googleGeolocationPrefGetSavedArgs.match(eqJSON({})), |
104 googleGeolocationPrefGetSavedArgs.match(ANYTHING)). | 104 googleGeolocationPrefGetSavedArgs.match(ANYTHING)). |
105 will(invokeCallback( | 105 will(invokeCallback( |
106 googleGeolocationPrefGetSavedArgs, 1, {value: testGeolocationPref})); | 106 googleGeolocationPrefGetSavedArgs, 1, {value: testGeolocationPref})); |
107 | 107 |
108 var storageGetSavedArgs = new SaveMockArguments(); | 108 var storageGetSavedArgs = new SaveMockArguments(); |
109 mockApisObj.expects(once()). | 109 mockApisObj.expects(once()). |
110 storage_get( | 110 instrumented_storage_local_get( |
111 storageGetSavedArgs.match(eq('userRespondedToToast')), | 111 storageGetSavedArgs.match(eq('userRespondedToToast')), |
112 storageGetSavedArgs.match(ANYTHING)). | 112 storageGetSavedArgs.match(ANYTHING)). |
113 will(invokeCallback(storageGetSavedArgs, 1, testUserRespondedToToast)); | 113 will(invokeCallback(storageGetSavedArgs, 1, testUserRespondedToToast)); |
114 } | 114 } |
115 | 115 |
116 /** | 116 /** |
117 * Sets up the test to expect the initialization calls that | 117 * Sets up the test to expect the initialization calls that |
118 * initialize() invokes. | 118 * initialize() invokes. |
119 * Note that this CAN NOT be used if any of the methods below are called | 119 * Note that this CAN NOT be used if any of the methods below are called |
120 * outside of this context with the same argument matchers. | 120 * outside of this context with the same argument matchers. |
121 * expects() calls cannot be chained with the same argument matchers. | 121 * expects() calls cannot be chained with the same argument matchers. |
122 */ | 122 */ |
123 function expectInitialization(mockApisObj) { | 123 function expectInitialization(mockApisObj) { |
124 mockApisObj.expects(once()). | 124 mockApisObj.expects(once()). |
125 chrome_location_clearWatch(ANYTHING); | 125 chrome_location_clearWatch(ANYTHING); |
126 mockApisObj.expects(once()). | 126 mockApisObj.expects(once()). |
127 updateCardsAttempts_stop(); | 127 updateCardsAttempts_stop(); |
128 mockApisObj.expects(once()). | 128 mockApisObj.expects(once()). |
129 storage_set(eqJSON({notificationsData: {}})); | 129 chrome_storage_local_set(eqJSON({notificationsData: {}})); |
130 var tasksAddSavedArgs = new SaveMockArguments(); | 130 var tasksAddSavedArgs = new SaveMockArguments(); |
131 mockApisObj.expects(once()). | 131 mockApisObj.expects(once()). |
132 tasks_add( | 132 tasks_add( |
133 tasksAddSavedArgs.match(ANYTHING), | 133 tasksAddSavedArgs.match(ANYTHING), |
134 tasksAddSavedArgs.match(ANYTHING)). | 134 tasksAddSavedArgs.match(ANYTHING)). |
135 will(invokeCallback(tasksAddSavedArgs, 1, function() {})); | 135 will(invokeCallback(tasksAddSavedArgs, 1, function() {})); |
136 var updateCardsAttemptsIsRunningSavedArgs = new SaveMockArguments(); | 136 var updateCardsAttemptsIsRunningSavedArgs = new SaveMockArguments(); |
137 mockApisObj.expects(once()). | 137 mockApisObj.expects(once()). |
138 updateCardsAttempts_isRunning( | 138 updateCardsAttempts_isRunning( |
139 updateCardsAttemptsIsRunningSavedArgs.match(ANYTHING)). | 139 updateCardsAttemptsIsRunningSavedArgs.match(ANYTHING)). |
(...skipping 27 matching lines...) Expand all Loading... |
167 expectInitialization(this.mockApis); | 167 expectInitialization(this.mockApis); |
168 | 168 |
169 expectStateMachineCalls( | 169 expectStateMachineCalls( |
170 this.mockApis, | 170 this.mockApis, |
171 testIdentityToken, | 171 testIdentityToken, |
172 testGeolocationPref, | 172 testGeolocationPref, |
173 testUserRespondedToToast); | 173 testUserRespondedToToast); |
174 | 174 |
175 var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); | 175 var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); |
176 this.mockApis.expects(exactly(2)). | 176 this.mockApis.expects(exactly(2)). |
177 chrome_notifications_getAll( | 177 instrumented_notifications_getAll( |
178 chromeNotificationGetAllSavedArgs.match(ANYTHING)). | 178 chromeNotificationGetAllSavedArgs.match(ANYTHING)). |
179 will( | 179 will( |
180 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {}), | 180 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {}), |
181 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {})); | 181 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {})); |
182 | 182 |
183 // TODO(robliao,vadimt): Determine the granularity of testing to perform. | 183 // TODO(robliao,vadimt): Determine the granularity of testing to perform. |
184 | 184 |
185 // Invoking the tested function. | 185 // Invoking the tested function. |
186 initialize(); | 186 initialize(); |
187 }); | 187 }); |
(...skipping 23 matching lines...) Expand all Loading... |
211 expectInitialization(this.mockApis); | 211 expectInitialization(this.mockApis); |
212 | 212 |
213 expectStateMachineCalls( | 213 expectStateMachineCalls( |
214 this.mockApis, | 214 this.mockApis, |
215 testIdentityToken, | 215 testIdentityToken, |
216 testGeolocationPref, | 216 testGeolocationPref, |
217 testUserRespondedToToast); | 217 testUserRespondedToToast); |
218 | 218 |
219 var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); | 219 var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); |
220 this.mockApis.expects(exactly(2)). | 220 this.mockApis.expects(exactly(2)). |
221 chrome_notifications_getAll( | 221 instrumented_notifications_getAll( |
222 chromeNotificationGetAllSavedArgs.match(ANYTHING)). | 222 chromeNotificationGetAllSavedArgs.match(ANYTHING)). |
223 will( | 223 will( |
224 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {}), | 224 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {}), |
225 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {})); | 225 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {})); |
226 | 226 |
227 // Invoking the tested function. | 227 // Invoking the tested function. |
228 initialize(); | 228 initialize(); |
229 }); | 229 }); |
230 | 230 |
231 TEST_F( | 231 TEST_F( |
(...skipping 18 matching lines...) Expand all Loading... |
250 expectInitialization(this.mockApis); | 250 expectInitialization(this.mockApis); |
251 | 251 |
252 expectStateMachineCalls( | 252 expectStateMachineCalls( |
253 this.mockApis, | 253 this.mockApis, |
254 testIdentityToken, | 254 testIdentityToken, |
255 testGeolocationPref, | 255 testGeolocationPref, |
256 testUserRespondedToToast); | 256 testUserRespondedToToast); |
257 | 257 |
258 var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); | 258 var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); |
259 this.mockApis.expects(exactly(2)). | 259 this.mockApis.expects(exactly(2)). |
260 chrome_notifications_getAll( | 260 instrumented_notifications_getAll( |
261 chromeNotificationGetAllSavedArgs.match(ANYTHING)). | 261 chromeNotificationGetAllSavedArgs.match(ANYTHING)). |
262 will( | 262 will( |
263 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {}), | 263 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {}), |
264 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {})); | 264 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {})); |
265 | 265 |
266 this.mockGlobals.expects(once()).showWelcomeToast(); | 266 this.mockGlobals.expects(once()).showWelcomeToast(); |
267 | 267 |
268 // Invoking the tested function. | 268 // Invoking the tested function. |
269 initialize(); | 269 initialize(); |
270 }); | 270 }); |
(...skipping 16 matching lines...) Expand all Loading... |
287 expectInitialization(this.mockApis); | 287 expectInitialization(this.mockApis); |
288 | 288 |
289 expectStateMachineCalls( | 289 expectStateMachineCalls( |
290 this.mockApis, | 290 this.mockApis, |
291 testIdentityToken, | 291 testIdentityToken, |
292 testGeolocationPref, | 292 testGeolocationPref, |
293 testUserRespondedToToast); | 293 testUserRespondedToToast); |
294 | 294 |
295 var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); | 295 var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); |
296 this.mockApis.expects(exactly(2)). | 296 this.mockApis.expects(exactly(2)). |
297 chrome_notifications_getAll( | 297 instrumented_notifications_getAll( |
298 chromeNotificationGetAllSavedArgs.match(ANYTHING)). | 298 chromeNotificationGetAllSavedArgs.match(ANYTHING)). |
299 will( | 299 will( |
300 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {}), | 300 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {}), |
301 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {})); | 301 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {})); |
302 | 302 |
303 this.mockGlobals.expects(once()).startPollingCards(); | 303 this.mockGlobals.expects(once()).startPollingCards(); |
304 | 304 |
305 // Invoking the tested function. | 305 // Invoking the tested function. |
306 initialize(); | 306 initialize(); |
307 }); | 307 }); |
(...skipping 19 matching lines...) Expand all Loading... |
327 expectInitialization(this.mockApis); | 327 expectInitialization(this.mockApis); |
328 | 328 |
329 expectStateMachineCalls( | 329 expectStateMachineCalls( |
330 this.mockApis, | 330 this.mockApis, |
331 testIdentityToken, | 331 testIdentityToken, |
332 testGeolocationPref, | 332 testGeolocationPref, |
333 testUserRespondedToToast); | 333 testUserRespondedToToast); |
334 | 334 |
335 var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); | 335 var chromeNotificationGetAllSavedArgs = new SaveMockArguments(); |
336 this.mockApis.expects(exactly(2)). | 336 this.mockApis.expects(exactly(2)). |
337 chrome_notifications_getAll( | 337 instrumented_notifications_getAll( |
338 chromeNotificationGetAllSavedArgs.match(ANYTHING)). | 338 chromeNotificationGetAllSavedArgs.match(ANYTHING)). |
339 will( | 339 will( |
340 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {}), | 340 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {}), |
341 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {})); | 341 invokeCallback(chromeNotificationGetAllSavedArgs, 0, {})); |
342 | 342 |
343 // Invoking the tested function. | 343 // Invoking the tested function. |
344 initialize(); | 344 initialize(); |
345 }); | 345 }); |
346 | 346 |
347 /** | 347 /** |
348 * Mocks global functions and APIs that onNotificationClicked() depends upon. | 348 * Mocks global functions and APIs that onNotificationClicked() depends upon. |
349 * @param {Test} fixture Test fixture. | 349 * @param {Test} fixture Test fixture. |
350 */ | 350 */ |
351 function mockOnNotificationClickedDependencies(fixture) { | 351 function mockOnNotificationClickedDependencies(fixture) { |
352 fixture.makeAndRegisterMockApis([ | 352 fixture.makeAndRegisterMockApis([ |
353 'storage.get', | 353 'chrome.windows.create', |
354 'chrome.tabs.create', | 354 'instrumented.storage.local.get', |
355 'chrome.windows.create']); | 355 'instrumented.tabs.create']); |
356 } | 356 } |
357 | 357 |
358 TEST_F( | 358 TEST_F( |
359 'GoogleNowBackgroundUnitTest', | 359 'GoogleNowBackgroundUnitTest', |
360 'OnNotificationClicked_NoData', | 360 'OnNotificationClicked_NoData', |
361 function() { | 361 function() { |
362 // Tests the case when there is no data associated with notification id. | 362 // Tests the case when there is no data associated with notification id. |
363 // In this case, the function should do nothing. | 363 // In this case, the function should do nothing. |
364 | 364 |
365 // Setup and expectations. | 365 // Setup and expectations. |
366 var testNotificationId = 'TEST_ID'; | 366 var testNotificationId = 'TEST_ID'; |
367 var testNotificationData = {}; | 367 var testNotificationData = {}; |
368 | 368 |
369 mockOnNotificationClickedDependencies(this); | 369 mockOnNotificationClickedDependencies(this); |
370 this.makeMockLocalFunctions(['selector']); | 370 this.makeMockLocalFunctions(['selector']); |
371 | 371 |
372 var storageGetSavedArgs = new SaveMockArguments(); | 372 var storageGetSavedArgs = new SaveMockArguments(); |
373 this.mockApis.expects(once()). | 373 this.mockApis.expects(once()). |
374 storage_get( | 374 instrumented_storage_local_get( |
375 storageGetSavedArgs.match(eq('notificationsData')), | 375 storageGetSavedArgs.match(eq('notificationsData')), |
376 storageGetSavedArgs.match(ANYTHING)). | 376 storageGetSavedArgs.match(ANYTHING)). |
377 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData)); | 377 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData)); |
378 | 378 |
379 // Invoking the tested function. | 379 // Invoking the tested function. |
380 onNotificationClicked( | 380 onNotificationClicked( |
381 testNotificationId, this.mockLocalFunctions.functions().selector); | 381 testNotificationId, this.mockLocalFunctions.functions().selector); |
382 }); | 382 }); |
383 | 383 |
384 TEST_F( | 384 TEST_F( |
385 'GoogleNowBackgroundUnitTest', | 385 'GoogleNowBackgroundUnitTest', |
386 'OnNotificationClicked_ActionUrlsNotObject', | 386 'OnNotificationClicked_ActionUrlsNotObject', |
387 function() { | 387 function() { |
388 // Tests the case when the data associated with notification id is not an | 388 // Tests the case when the data associated with notification id is not an |
389 // object, probably because of a malformed server response. | 389 // object, probably because of a malformed server response. |
390 // In this case, the function should do nothing. | 390 // In this case, the function should do nothing. |
391 | 391 |
392 // Setup and expectations. | 392 // Setup and expectations. |
393 var testActionUrls = 'string, not object'; | 393 var testActionUrls = 'string, not object'; |
394 var testNotificationId = 'TEST_ID'; | 394 var testNotificationId = 'TEST_ID'; |
395 var testNotificationData = { | 395 var testNotificationData = { |
396 notificationsData: {'TEST_ID': {actionUrls: testActionUrls}} | 396 notificationsData: {'TEST_ID': {actionUrls: testActionUrls}} |
397 }; | 397 }; |
398 | 398 |
399 mockOnNotificationClickedDependencies(this); | 399 mockOnNotificationClickedDependencies(this); |
400 this.makeMockLocalFunctions(['selector']); | 400 this.makeMockLocalFunctions(['selector']); |
401 | 401 |
402 var storageGetSavedArgs = new SaveMockArguments(); | 402 var storageGetSavedArgs = new SaveMockArguments(); |
403 this.mockApis.expects(once()). | 403 this.mockApis.expects(once()). |
404 storage_get( | 404 instrumented_storage_local_get( |
405 storageGetSavedArgs.match(eq('notificationsData')), | 405 storageGetSavedArgs.match(eq('notificationsData')), |
406 storageGetSavedArgs.match(ANYTHING)). | 406 storageGetSavedArgs.match(ANYTHING)). |
407 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData)); | 407 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData)); |
408 | 408 |
409 // Invoking the tested function. | 409 // Invoking the tested function. |
410 onNotificationClicked( | 410 onNotificationClicked( |
411 testNotificationId, this.mockLocalFunctions.functions().selector); | 411 testNotificationId, this.mockLocalFunctions.functions().selector); |
412 }); | 412 }); |
413 | 413 |
414 TEST_F( | 414 TEST_F( |
(...skipping 10 matching lines...) Expand all Loading... |
425 var testNotificationData = { | 425 var testNotificationData = { |
426 notificationsData: {'TEST_ID': {actionUrls: testActionUrls}} | 426 notificationsData: {'TEST_ID': {actionUrls: testActionUrls}} |
427 }; | 427 }; |
428 var testActionUrl = {}; | 428 var testActionUrl = {}; |
429 | 429 |
430 mockOnNotificationClickedDependencies(this); | 430 mockOnNotificationClickedDependencies(this); |
431 this.makeMockLocalFunctions(['selector']); | 431 this.makeMockLocalFunctions(['selector']); |
432 | 432 |
433 var storageGetSavedArgs = new SaveMockArguments(); | 433 var storageGetSavedArgs = new SaveMockArguments(); |
434 this.mockApis.expects(once()). | 434 this.mockApis.expects(once()). |
435 storage_get( | 435 instrumented_storage_local_get( |
436 storageGetSavedArgs.match(eq('notificationsData')), | 436 storageGetSavedArgs.match(eq('notificationsData')), |
437 storageGetSavedArgs.match(ANYTHING)). | 437 storageGetSavedArgs.match(ANYTHING)). |
438 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData)); | 438 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData)); |
439 this.mockLocalFunctions.expects(once()).selector(testActionUrls).will( | 439 this.mockLocalFunctions.expects(once()).selector(testActionUrls).will( |
440 returnValue(testActionUrl)); | 440 returnValue(testActionUrl)); |
441 | 441 |
442 // Invoking the tested function. | 442 // Invoking the tested function. |
443 onNotificationClicked( | 443 onNotificationClicked( |
444 testNotificationId, this.mockLocalFunctions.functions().selector); | 444 testNotificationId, this.mockLocalFunctions.functions().selector); |
445 }); | 445 }); |
(...skipping 11 matching lines...) Expand all Loading... |
457 notificationsData: {'TEST_ID': {actionUrls: testActionUrls}} | 457 notificationsData: {'TEST_ID': {actionUrls: testActionUrls}} |
458 }; | 458 }; |
459 var testActionUrl = 'http://testurl.com'; | 459 var testActionUrl = 'http://testurl.com'; |
460 var testCreatedTab = {}; | 460 var testCreatedTab = {}; |
461 | 461 |
462 mockOnNotificationClickedDependencies(this); | 462 mockOnNotificationClickedDependencies(this); |
463 this.makeMockLocalFunctions(['selector']); | 463 this.makeMockLocalFunctions(['selector']); |
464 | 464 |
465 var storageGetSavedArgs = new SaveMockArguments(); | 465 var storageGetSavedArgs = new SaveMockArguments(); |
466 this.mockApis.expects(once()). | 466 this.mockApis.expects(once()). |
467 storage_get( | 467 instrumented_storage_local_get( |
468 storageGetSavedArgs.match(eq('notificationsData')), | 468 storageGetSavedArgs.match(eq('notificationsData')), |
469 storageGetSavedArgs.match(ANYTHING)). | 469 storageGetSavedArgs.match(ANYTHING)). |
470 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData)); | 470 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData)); |
471 this.mockLocalFunctions.expects(once()).selector(testActionUrls).will( | 471 this.mockLocalFunctions.expects(once()).selector(testActionUrls).will( |
472 returnValue(testActionUrl)); | 472 returnValue(testActionUrl)); |
473 var chromeTabsCreateSavedArgs = new SaveMockArguments(); | 473 var chromeTabsCreateSavedArgs = new SaveMockArguments(); |
474 this.mockApis.expects(once()). | 474 this.mockApis.expects(once()). |
475 chrome_tabs_create( | 475 instrumented_tabs_create( |
476 chromeTabsCreateSavedArgs.match(eqJSON({url: testActionUrl})), | 476 chromeTabsCreateSavedArgs.match(eqJSON({url: testActionUrl})), |
477 chromeTabsCreateSavedArgs.match(ANYTHING)). | 477 chromeTabsCreateSavedArgs.match(ANYTHING)). |
478 will(invokeCallback(chromeTabsCreateSavedArgs, 1, testCreatedTab)); | 478 will(invokeCallback(chromeTabsCreateSavedArgs, 1, testCreatedTab)); |
479 | 479 |
480 // Invoking the tested function. | 480 // Invoking the tested function. |
481 onNotificationClicked( | 481 onNotificationClicked( |
482 testNotificationId, this.mockLocalFunctions.functions().selector); | 482 testNotificationId, this.mockLocalFunctions.functions().selector); |
483 }); | 483 }); |
484 | 484 |
485 TEST_F( | 485 TEST_F( |
(...skipping 11 matching lines...) Expand all Loading... |
497 notificationsData: {'TEST_ID': {actionUrls: testActionUrls}} | 497 notificationsData: {'TEST_ID': {actionUrls: testActionUrls}} |
498 }; | 498 }; |
499 var testActionUrl = 'http://testurl.com'; | 499 var testActionUrl = 'http://testurl.com'; |
500 var testCreatedTab = undefined; // chrome.tabs.create fails | 500 var testCreatedTab = undefined; // chrome.tabs.create fails |
501 | 501 |
502 mockOnNotificationClickedDependencies(this); | 502 mockOnNotificationClickedDependencies(this); |
503 this.makeMockLocalFunctions(['selector']); | 503 this.makeMockLocalFunctions(['selector']); |
504 | 504 |
505 var storageGetSavedArgs = new SaveMockArguments(); | 505 var storageGetSavedArgs = new SaveMockArguments(); |
506 this.mockApis.expects(once()). | 506 this.mockApis.expects(once()). |
507 storage_get( | 507 instrumented_storage_local_get( |
508 storageGetSavedArgs.match(eq('notificationsData')), | 508 storageGetSavedArgs.match(eq('notificationsData')), |
509 storageGetSavedArgs.match(ANYTHING)). | 509 storageGetSavedArgs.match(ANYTHING)). |
510 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData)); | 510 will(invokeCallback(storageGetSavedArgs, 1, testNotificationData)); |
511 this.mockLocalFunctions.expects(once()).selector(testActionUrls).will( | 511 this.mockLocalFunctions.expects(once()).selector(testActionUrls).will( |
512 returnValue(testActionUrl)); | 512 returnValue(testActionUrl)); |
513 var chromeTabsCreateSavedArgs = new SaveMockArguments(); | 513 var chromeTabsCreateSavedArgs = new SaveMockArguments(); |
514 this.mockApis.expects(once()). | 514 this.mockApis.expects(once()). |
515 chrome_tabs_create( | 515 instrumented_tabs_create( |
516 chromeTabsCreateSavedArgs.match(eqJSON({url: testActionUrl})), | 516 chromeTabsCreateSavedArgs.match(eqJSON({url: testActionUrl})), |
517 chromeTabsCreateSavedArgs.match(ANYTHING)). | 517 chromeTabsCreateSavedArgs.match(ANYTHING)). |
518 will(invokeCallback(chromeTabsCreateSavedArgs, 1, testCreatedTab)); | 518 will(invokeCallback(chromeTabsCreateSavedArgs, 1, testCreatedTab)); |
519 this.mockApis.expects(once()).chrome_windows_create( | 519 this.mockApis.expects(once()).chrome_windows_create( |
520 eqJSON({url: testActionUrl})); | 520 eqJSON({url: testActionUrl})); |
521 | 521 |
522 // Invoking the tested function. | 522 // Invoking the tested function. |
523 onNotificationClicked( | 523 onNotificationClicked( |
524 testNotificationId, this.mockLocalFunctions.functions().selector); | 524 testNotificationId, this.mockLocalFunctions.functions().selector); |
525 }); | 525 }); |
OLD | NEW |