| 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 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 'cards.js' | 19 'cards.js' |
| 20 ] | 20 ] |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 var testCardId = 'TEST CARD ID'; | 23 var testCardId = 'TEST CARD ID'; |
| 24 var testNotification = {testNotificationField: 'TEST NOTIFICATION VALUE'}; | 24 var testNotification = {testNotificationField: 'TEST NOTIFICATION VALUE'}; |
| 25 var expectedShowAlarmId = 'card-show-TEST CARD ID'; | 25 var expectedShowAlarmId = 'card-show-TEST CARD ID'; |
| 26 var expectedHideAlarmId = 'card-hide-TEST CARD ID'; | 26 var expectedHideAlarmId = 'card-hide-TEST CARD ID'; |
| 27 var testActionUrls = {testField: 'TEST VALUE'}; | 27 var testActionUrls = {testField: 'TEST VALUE'}; |
| 28 var testDismissal = {testDismissalField: 'TEST DISMISSAL VALUE'}; | 28 var testDismissals = [ |
| 29 {testDismissalField: 'TEST DISMISSAL VALUE 1'}, |
| 30 {testDismissalField: 'TEST DISMISSAL VALUE 2'} |
| 31 ]; |
| 32 var testGroupRank = 271; |
| 29 | 33 |
| 30 function setUpCardManagerTest(fixture) { | 34 function setUpCardManagerTest(fixture) { |
| 31 fixture.makeAndRegisterMockApis([ | 35 fixture.makeAndRegisterMockApis([ |
| 32 'chrome.alarms.clear', | 36 'chrome.alarms.clear', |
| 33 'chrome.alarms.create', | 37 'chrome.alarms.create', |
| 34 'chrome.notifications.clear', | 38 'chrome.notifications.clear', |
| 35 'instrumented.alarms.onAlarm.addListener', | 39 'instrumented.alarms.onAlarm.addListener', |
| 36 'instrumented.notifications.create', | 40 'instrumented.notifications.create', |
| 37 'instrumented.notifications.update', | 41 'instrumented.notifications.update', |
| 38 'instrumented.storage.local.get' | 42 'instrumented.storage.local.get' |
| (...skipping 21 matching lines...) Expand all Loading... |
| 60 } | 64 } |
| 61 | 65 |
| 62 TEST_F('GoogleNowCardsUnitTest', 'BuildCardManager', function() { | 66 TEST_F('GoogleNowCardsUnitTest', 'BuildCardManager', function() { |
| 63 // Tests that buildCardSet() call completes with no problems. | 67 // Tests that buildCardSet() call completes with no problems. |
| 64 var test = setUpCardManagerTest(this); | 68 var test = setUpCardManagerTest(this); |
| 65 | 69 |
| 66 assertEquals('object', typeof test.cardSet); | 70 assertEquals('object', typeof test.cardSet); |
| 67 assertEquals('function', typeof test.alarmCallback); | 71 assertEquals('function', typeof test.alarmCallback); |
| 68 }); | 72 }); |
| 69 | 73 |
| 70 TEST_F('GoogleNowCardsUnitTest', 'CreateCard', function() { | 74 TEST_F('GoogleNowCardsUnitTest', 'CreateCardEmptyTrigger', function() { |
| 71 // Creates a new card with no trigger. | 75 // Creates a new card with empty trigger. |
| 72 | 76 |
| 73 // Setup and expectations. | 77 // Setup and expectations. |
| 74 var test = setUpCardManagerTest(this); | 78 var test = setUpCardManagerTest(this); |
| 75 this.mockApis.expects(once()). | 79 this.mockApis.expects(once()). |
| 76 chrome_alarms_clear(expectedHideAlarmId); | 80 chrome_alarms_clear(expectedHideAlarmId); |
| 77 this.mockApis.expects(once()). | 81 this.mockApis.expects(once()). |
| 78 chrome_alarms_clear(expectedShowAlarmId); | 82 chrome_alarms_clear(expectedShowAlarmId); |
| 79 var chromeNotificationsCreateSavedArgs = new SaveMockArguments(); | 83 var chromeNotificationsCreateSavedArgs = new SaveMockArguments(); |
| 80 this.mockApis.expects(once()). | 84 this.mockApis.expects(once()). |
| 81 instrumented_notifications_create( | 85 instrumented_notifications_create( |
| 82 chromeNotificationsCreateSavedArgs.match(eq(testCardId)), | 86 chromeNotificationsCreateSavedArgs.match(eq(testCardId)), |
| 83 chromeNotificationsCreateSavedArgs.match(eqJSON(testNotification)), | 87 chromeNotificationsCreateSavedArgs.match(eqJSON(testNotification)), |
| 84 chromeNotificationsCreateSavedArgs.match(ANYTHING)). | 88 chromeNotificationsCreateSavedArgs.match(ANYTHING)). |
| 85 will(invokeCallback(chromeNotificationsCreateSavedArgs, 2, testCardId)); | 89 will(invokeCallback(chromeNotificationsCreateSavedArgs, 2, testCardId)); |
| 86 | 90 |
| 87 // Call tested method. | 91 // Call tested method. |
| 88 var notificationData = test.cardSet.update({ | 92 var notificationData = test.cardSet.update(testCardId, { |
| 89 notificationId: testCardId, | |
| 90 notification: testNotification, | 93 notification: testNotification, |
| 91 actionUrls: testActionUrls, | 94 actionUrls: testActionUrls, |
| 92 dismissal: testDismissal, | 95 dismissals: testDismissals, |
| 93 version: 0}); | 96 groupRank: testGroupRank, |
| 94 | |
| 95 // Check the return value. | |
| 96 assertEquals( | |
| 97 JSON.stringify({ | |
| 98 actionUrls: testActionUrls, | |
| 99 cardCreateInfo: { | |
| 100 notification: testNotification, | |
| 101 timeHide: undefined, | |
| 102 version: 0 | |
| 103 }, | |
| 104 dismissalParameters: testDismissal | |
| 105 }), | |
| 106 JSON.stringify(notificationData)); | |
| 107 }); | |
| 108 | |
| 109 TEST_F('GoogleNowCardsUnitTest', 'CreateCardEmptyTrigger', function() { | |
| 110 // Creates a new card with empty trigger. | |
| 111 | |
| 112 // Setup and expectations. | |
| 113 var test = setUpCardManagerTest(this); | |
| 114 this.mockApis.expects(once()). | |
| 115 chrome_alarms_clear(expectedHideAlarmId); | |
| 116 this.mockApis.expects(once()). | |
| 117 chrome_alarms_clear(expectedShowAlarmId); | |
| 118 this.mockApis.expects(once()). | |
| 119 instrumented_notifications_create( | |
| 120 testCardId, eqJSON(testNotification), ANYTHING); | |
| 121 | |
| 122 // Call tested method. | |
| 123 var notificationData = test.cardSet.update({ | |
| 124 notificationId: testCardId, | |
| 125 notification: testNotification, | |
| 126 actionUrls: testActionUrls, | |
| 127 dismissal: testDismissal, | |
| 128 version: 0, | 97 version: 0, |
| 129 trigger: {}}); | 98 trigger: {}}); |
| 130 | 99 |
| 131 // Check the return value. | 100 // Check the return value. |
| 132 assertEquals( | 101 assertEquals( |
| 133 JSON.stringify({ | 102 JSON.stringify({ |
| 134 actionUrls: testActionUrls, | 103 actionUrls: testActionUrls, |
| 135 cardCreateInfo: { | 104 cardCreateInfo: { |
| 136 notification: testNotification, | 105 notification: testNotification, |
| 137 timeHide: undefined, | 106 hideTime: undefined, |
| 138 version: 0 | 107 version: 0 |
| 139 }, | 108 }, |
| 140 dismissalParameters: testDismissal | 109 dismissals: testDismissals |
| 141 }), | 110 }), |
| 142 JSON.stringify(notificationData)); | 111 JSON.stringify(notificationData)); |
| 143 }); | 112 }); |
| 144 | 113 |
| 145 TEST_F('GoogleNowCardsUnitTest', 'CreateCardHideTime', function() { | 114 TEST_F('GoogleNowCardsUnitTest', 'CreateCardHideTime', function() { |
| 146 // Creates a new card with trigger specifying hide time. | 115 // Creates a new card with trigger specifying hide time. |
| 147 | 116 |
| 148 // Setup and expectations. | 117 // Setup and expectations. |
| 149 var test = setUpCardManagerTest(this); | 118 var test = setUpCardManagerTest(this); |
| 150 this.mockApis.expects(once()). | 119 this.mockApis.expects(once()). |
| 151 chrome_alarms_clear(expectedHideAlarmId); | 120 chrome_alarms_clear(expectedHideAlarmId); |
| 152 this.mockApis.expects(once()). | 121 this.mockApis.expects(once()). |
| 153 chrome_alarms_clear(expectedShowAlarmId); | 122 chrome_alarms_clear(expectedShowAlarmId); |
| 154 var chromeNotificationsCreateSavedArgs = new SaveMockArguments(); | 123 var chromeNotificationsCreateSavedArgs = new SaveMockArguments(); |
| 155 this.mockApis.expects(once()). | 124 this.mockApis.expects(once()). |
| 156 instrumented_notifications_create( | 125 instrumented_notifications_create( |
| 157 chromeNotificationsCreateSavedArgs.match(eq(testCardId)), | 126 chromeNotificationsCreateSavedArgs.match(eq(testCardId)), |
| 158 chromeNotificationsCreateSavedArgs.match(eqJSON(testNotification)), | 127 chromeNotificationsCreateSavedArgs.match(eqJSON(testNotification)), |
| 159 chromeNotificationsCreateSavedArgs.match(ANYTHING)). | 128 chromeNotificationsCreateSavedArgs.match(ANYTHING)). |
| 160 will(invokeCallback(chromeNotificationsCreateSavedArgs, 2, testCardId)); | 129 will(invokeCallback(chromeNotificationsCreateSavedArgs, 2, testCardId)); |
| 161 this.mockApis.expects(once()). | 130 this.mockApis.expects(once()). |
| 162 chrome_alarms_create(expectedHideAlarmId, eqJSON({when: 1313000})); | 131 chrome_alarms_create(expectedHideAlarmId, eqJSON({when: 1313000})); |
| 163 | 132 |
| 164 // Call tested method. | 133 // Call tested method. |
| 165 var notificationData = test.cardSet.update({ | 134 var notificationData = test.cardSet.update(testCardId, { |
| 166 notificationId: testCardId, | |
| 167 notification: testNotification, | 135 notification: testNotification, |
| 168 actionUrls: testActionUrls, | 136 actionUrls: testActionUrls, |
| 169 dismissal: testDismissal, | 137 dismissals: testDismissals, |
| 138 groupRank: testGroupRank, |
| 170 version: 0, | 139 version: 0, |
| 171 trigger: {hideTimeSec: 1013}}); | 140 trigger: {hideTime: 1313000}}); |
| 172 | 141 |
| 173 // Check the return value. | 142 // Check the return value. |
| 174 assertEquals( | 143 assertEquals( |
| 175 JSON.stringify({ | 144 JSON.stringify({ |
| 176 actionUrls: testActionUrls, | 145 actionUrls: testActionUrls, |
| 177 cardCreateInfo: { | 146 cardCreateInfo: { |
| 178 notification: testNotification, | 147 notification: testNotification, |
| 179 timeHide: 1313000, | 148 hideTime: 1313000, |
| 180 version: 0 | 149 version: 0 |
| 181 }, | 150 }, |
| 182 dismissalParameters: testDismissal | 151 dismissals: testDismissals |
| 183 }), | 152 }), |
| 184 JSON.stringify(notificationData)); | 153 JSON.stringify(notificationData)); |
| 185 }); | 154 }); |
| 186 | 155 |
| 187 TEST_F('GoogleNowCardsUnitTest', 'UpdateCardSameVersion', function() { | 156 TEST_F('GoogleNowCardsUnitTest', 'UpdateCardSameVersion', function() { |
| 188 // Updates a card with another card with same version. | 157 // Updates a card with another card with same version. |
| 189 | 158 |
| 190 // Setup and expectations. | 159 // Setup and expectations. |
| 191 var test = setUpCardManagerTest(this); | 160 var test = setUpCardManagerTest(this); |
| 192 this.mockApis.expects(once()). | 161 this.mockApis.expects(once()). |
| 193 chrome_alarms_clear(expectedHideAlarmId); | 162 chrome_alarms_clear(expectedHideAlarmId); |
| 194 this.mockApis.expects(once()). | 163 this.mockApis.expects(once()). |
| 195 chrome_alarms_clear(expectedShowAlarmId); | 164 chrome_alarms_clear(expectedShowAlarmId); |
| 196 var chromeNotificationsCreateSavedArgs = new SaveMockArguments(); | 165 var chromeNotificationsCreateSavedArgs = new SaveMockArguments(); |
| 197 this.mockApis.expects(once()). | 166 this.mockApis.expects(once()). |
| 198 instrumented_notifications_update( | 167 instrumented_notifications_update( |
| 199 chromeNotificationsCreateSavedArgs.match(eq(testCardId)), | 168 chromeNotificationsCreateSavedArgs.match(eq(testCardId)), |
| 200 chromeNotificationsCreateSavedArgs.match(eqJSON(testNotification)), | 169 chromeNotificationsCreateSavedArgs.match(eqJSON(testNotification)), |
| 201 chromeNotificationsCreateSavedArgs.match(ANYTHING)). | 170 chromeNotificationsCreateSavedArgs.match(ANYTHING)). |
| 202 will(invokeCallback(chromeNotificationsCreateSavedArgs, 2, true)); | 171 will(invokeCallback(chromeNotificationsCreateSavedArgs, 2, true)); |
| 203 | 172 |
| 204 // Call tested method. | 173 // Call tested method. |
| 205 var notificationData = test.cardSet.update({ | 174 var notificationData = test.cardSet.update(testCardId, { |
| 206 notificationId: testCardId, | |
| 207 notification: testNotification, | 175 notification: testNotification, |
| 208 actionUrls: testActionUrls, | 176 actionUrls: testActionUrls, |
| 209 dismissal: testDismissal, | 177 dismissals: testDismissals, |
| 210 version: 0}, | 178 groupRank: testGroupRank, |
| 179 version: 0, |
| 180 trigger: {}}, |
| 211 0); | 181 0); |
| 212 | 182 |
| 213 // Check the return value. | 183 // Check the return value. |
| 214 assertEquals( | 184 assertEquals( |
| 215 JSON.stringify({ | 185 JSON.stringify({ |
| 216 actionUrls: testActionUrls, | 186 actionUrls: testActionUrls, |
| 217 cardCreateInfo: { | 187 cardCreateInfo: { |
| 218 notification: testNotification, | 188 notification: testNotification, |
| 219 version: 0, | 189 version: 0, |
| 220 previousVersion: 0 | 190 previousVersion: 0 |
| 221 }, | 191 }, |
| 222 dismissalParameters: testDismissal | 192 dismissals: testDismissals |
| 223 }), | 193 }), |
| 224 JSON.stringify(notificationData)); | 194 JSON.stringify(notificationData)); |
| 225 }); | 195 }); |
| 226 | 196 |
| 227 TEST_F('GoogleNowCardsUnitTest', 'UpdateCardSameVersionHideTime', function() { | 197 TEST_F('GoogleNowCardsUnitTest', 'UpdateCardSameVersionHideTime', function() { |
| 228 // Updates a card with another card with same version and specifying hide | 198 // Updates a card with another card with same version and specifying hide |
| 229 // time. | 199 // time. |
| 230 | 200 |
| 231 // Setup and expectations. | 201 // Setup and expectations. |
| 232 var test = setUpCardManagerTest(this); | 202 var test = setUpCardManagerTest(this); |
| 233 this.mockApis.expects(once()). | 203 this.mockApis.expects(once()). |
| 234 chrome_alarms_clear(expectedHideAlarmId); | 204 chrome_alarms_clear(expectedHideAlarmId); |
| 235 this.mockApis.expects(once()). | 205 this.mockApis.expects(once()). |
| 236 chrome_alarms_clear(expectedShowAlarmId); | 206 chrome_alarms_clear(expectedShowAlarmId); |
| 237 var chromeNotificationsCreateSavedArgs = new SaveMockArguments(); | 207 var chromeNotificationsCreateSavedArgs = new SaveMockArguments(); |
| 238 this.mockApis.expects(once()). | 208 this.mockApis.expects(once()). |
| 239 instrumented_notifications_update( | 209 instrumented_notifications_update( |
| 240 chromeNotificationsCreateSavedArgs.match(eq(testCardId)), | 210 chromeNotificationsCreateSavedArgs.match(eq(testCardId)), |
| 241 chromeNotificationsCreateSavedArgs.match(eqJSON(testNotification)), | 211 chromeNotificationsCreateSavedArgs.match(eqJSON(testNotification)), |
| 242 chromeNotificationsCreateSavedArgs.match(ANYTHING)). | 212 chromeNotificationsCreateSavedArgs.match(ANYTHING)). |
| 243 will(invokeCallback(chromeNotificationsCreateSavedArgs, 2, testCardId)); | 213 will(invokeCallback(chromeNotificationsCreateSavedArgs, 2, testCardId)); |
| 244 this.mockApis.expects(once()). | 214 this.mockApis.expects(once()). |
| 245 chrome_alarms_create(expectedHideAlarmId, eqJSON({when: 1313000})); | 215 chrome_alarms_create(expectedHideAlarmId, eqJSON({when: 1313000})); |
| 246 | 216 |
| 247 // Call tested method. | 217 // Call tested method. |
| 248 test.cardSet.update({ | 218 test.cardSet.update(testCardId, { |
| 249 notificationId: testCardId, | |
| 250 notification: testNotification, | 219 notification: testNotification, |
| 251 actionUrls: testActionUrls, | 220 actionUrls: testActionUrls, |
| 252 dismissal: testDismissal, | 221 dismissals: testDismissals, |
| 222 groupRank: testGroupRank, |
| 253 version: 0, | 223 version: 0, |
| 254 trigger: {hideTimeSec: 1013}}, | 224 trigger: {hideTime: 1313000}}, |
| 255 0); | 225 0); |
| 256 }); | 226 }); |
| 257 | 227 |
| 258 TEST_F('GoogleNowCardsUnitTest', 'UpdateCardDifferentVersion', function() { | 228 TEST_F('GoogleNowCardsUnitTest', 'UpdateCardDifferentVersion', function() { |
| 259 // Updates a card with another card with different version. | 229 // Updates a card with another card with different version. |
| 260 | 230 |
| 261 // Setup and expectations. | 231 // Setup and expectations. |
| 262 var test = setUpCardManagerTest(this); | 232 var test = setUpCardManagerTest(this); |
| 263 this.mockApis.expects(once()). | 233 this.mockApis.expects(once()). |
| 264 chrome_alarms_clear(expectedHideAlarmId); | 234 chrome_alarms_clear(expectedHideAlarmId); |
| 265 this.mockApis.expects(once()). | 235 this.mockApis.expects(once()). |
| 266 chrome_alarms_clear(expectedShowAlarmId); | 236 chrome_alarms_clear(expectedShowAlarmId); |
| 267 this.mockApis.expects(once()). | 237 this.mockApis.expects(once()). |
| 268 instrumented_notifications_create( | 238 instrumented_notifications_create( |
| 269 testCardId, eqJSON(testNotification), ANYTHING); | 239 testCardId, eqJSON(testNotification), ANYTHING); |
| 270 | 240 |
| 271 // Call tested method. | 241 // Call tested method. |
| 272 test.cardSet.update({ | 242 test.cardSet.update(testCardId, { |
| 273 notificationId: testCardId, | |
| 274 notification: testNotification, | 243 notification: testNotification, |
| 275 actionUrls: testActionUrls, | 244 actionUrls: testActionUrls, |
| 276 dismissal: testDismissal, | 245 dismissals: testDismissals, |
| 277 version: 0}, | 246 groupRank: testGroupRank, |
| 247 version: 0, |
| 248 trigger: {}}, |
| 278 1); | 249 1); |
| 279 }); | 250 }); |
| 280 | 251 |
| 281 TEST_F('GoogleNowCardsUnitTest', 'CreateCardTriggerShowNow', function() { | 252 TEST_F('GoogleNowCardsUnitTest', 'CreateCardTriggerShowNow', function() { |
| 282 // Creates a new card with trigger that requires showing the card immediately. | 253 // Creates a new card with trigger that requires showing the card immediately. |
| 283 | 254 |
| 284 // Setup and expectations. | 255 // Setup and expectations. |
| 285 var test = setUpCardManagerTest(this); | 256 var test = setUpCardManagerTest(this); |
| 286 this.mockApis.expects(once()). | 257 this.mockApis.expects(once()). |
| 287 chrome_alarms_clear(expectedHideAlarmId); | 258 chrome_alarms_clear(expectedHideAlarmId); |
| 288 this.mockApis.expects(once()). | 259 this.mockApis.expects(once()). |
| 289 chrome_alarms_clear(expectedShowAlarmId); | 260 chrome_alarms_clear(expectedShowAlarmId); |
| 290 this.mockApis.expects(once()). | 261 this.mockApis.expects(once()). |
| 291 instrumented_notifications_create( | 262 instrumented_notifications_create( |
| 292 testCardId, eqJSON(testNotification), ANYTHING); | 263 testCardId, eqJSON(testNotification), ANYTHING); |
| 293 | 264 |
| 294 // Call tested method. | 265 // Call tested method. |
| 295 test.cardSet.update({ | 266 test.cardSet.update(testCardId, { |
| 296 notificationId: testCardId, | |
| 297 notification: testNotification, | 267 notification: testNotification, |
| 298 actionUrls: testActionUrls, | 268 actionUrls: testActionUrls, |
| 299 dismissal: testDismissal, | 269 dismissals: testDismissals, |
| 270 groupRank: testGroupRank, |
| 300 version: 0, | 271 version: 0, |
| 301 trigger: {showTimeSec: 0}}); | 272 trigger: {showTime: Date.now()}}); |
| 302 }); | 273 }); |
| 303 | 274 |
| 304 TEST_F('GoogleNowCardsUnitTest', 'CreateCardTriggerShowLater', function() { | 275 TEST_F('GoogleNowCardsUnitTest', 'CreateCardTriggerShowLater', function() { |
| 305 // Creates a new card with trigger that requires showing the card later. | 276 // Creates a new card with trigger that requires showing the card later. |
| 306 // We are supposed to schedule an alarm to show the notification later. | 277 // We are supposed to schedule an alarm to show the notification later. |
| 307 | 278 |
| 308 // Setup and expectations. | 279 // Setup and expectations. |
| 309 var test = setUpCardManagerTest(this); | 280 var test = setUpCardManagerTest(this); |
| 310 this.mockApis.expects(once()). | 281 this.mockApis.expects(once()). |
| 311 chrome_alarms_clear(expectedHideAlarmId); | 282 chrome_alarms_clear(expectedHideAlarmId); |
| 312 this.mockApis.expects(once()). | 283 this.mockApis.expects(once()). |
| 313 chrome_alarms_create(expectedShowAlarmId, eqJSON({when: 539000})); | 284 chrome_alarms_create(expectedShowAlarmId, eqJSON({when: 539000})); |
| 314 | 285 |
| 315 // Call tested method. | 286 // Call tested method. |
| 316 test.cardSet.update({ | 287 test.cardSet.update(testCardId, { |
| 317 notificationId: testCardId, | |
| 318 notification: testNotification, | 288 notification: testNotification, |
| 319 actionUrls: testActionUrls, | 289 actionUrls: testActionUrls, |
| 320 dismissal: testDismissal, | 290 dismissals: testDismissals, |
| 291 groupRank: testGroupRank, |
| 321 version: 0, | 292 version: 0, |
| 322 trigger: {showTimeSec: 239}}); | 293 trigger: {showTime: 539000}}); |
| 323 }); | 294 }); |
| 324 | 295 |
| 325 TEST_F('GoogleNowCardsUnitTest', 'ClearCard', function() { | 296 TEST_F('GoogleNowCardsUnitTest', 'ClearCard', function() { |
| 326 // Clears a card. | 297 // Clears a card. |
| 327 | 298 |
| 328 // Setup and expectations. | 299 // Setup and expectations. |
| 329 var test = setUpCardManagerTest(this); | 300 var test = setUpCardManagerTest(this); |
| 330 this.mockApis.expects(once()). | 301 this.mockApis.expects(once()). |
| 331 chrome_notifications_clear(testCardId, ANYTHING); | 302 chrome_notifications_clear(testCardId, ANYTHING); |
| 332 this.mockApis.expects(once()). | 303 this.mockApis.expects(once()). |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 storageGetSavedArgs.match(ANYTHING)). | 342 storageGetSavedArgs.match(ANYTHING)). |
| 372 will(invokeCallback( | 343 will(invokeCallback( |
| 373 storageGetSavedArgs, | 344 storageGetSavedArgs, |
| 374 1, | 345 1, |
| 375 { | 346 { |
| 376 notificationsData: { | 347 notificationsData: { |
| 377 'TEST CARD ID': { | 348 'TEST CARD ID': { |
| 378 actionUrls: testActionUrls, | 349 actionUrls: testActionUrls, |
| 379 cardCreateInfo: { | 350 cardCreateInfo: { |
| 380 notification: testNotification, | 351 notification: testNotification, |
| 381 timeHide: 1313000, | 352 hideTime: 1313000, |
| 382 version: 0}}}})); | 353 version: 0}}}})); |
| 383 var chromeNotificationsCreateSavedArgs = new SaveMockArguments(); | 354 var chromeNotificationsCreateSavedArgs = new SaveMockArguments(); |
| 384 this.mockApis.expects(once()). | 355 this.mockApis.expects(once()). |
| 385 instrumented_notifications_create( | 356 instrumented_notifications_create( |
| 386 chromeNotificationsCreateSavedArgs.match(eq(testCardId)), | 357 chromeNotificationsCreateSavedArgs.match(eq(testCardId)), |
| 387 chromeNotificationsCreateSavedArgs.match(eqJSON(testNotification)), | 358 chromeNotificationsCreateSavedArgs.match(eqJSON(testNotification)), |
| 388 chromeNotificationsCreateSavedArgs.match(ANYTHING)). | 359 chromeNotificationsCreateSavedArgs.match(ANYTHING)). |
| 389 will(invokeCallback(chromeNotificationsCreateSavedArgs, 2, testCardId)); | 360 will(invokeCallback(chromeNotificationsCreateSavedArgs, 2, testCardId)); |
| 390 this.mockApis.expects(once()). | 361 this.mockApis.expects(once()). |
| 391 chrome_alarms_create(expectedHideAlarmId, eqJSON({when: 1313000})); | 362 chrome_alarms_create(expectedHideAlarmId, eqJSON({when: 1313000})); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 405 storageGetSavedArgs.match(ANYTHING)). | 376 storageGetSavedArgs.match(ANYTHING)). |
| 406 will(invokeCallback( | 377 will(invokeCallback( |
| 407 storageGetSavedArgs, | 378 storageGetSavedArgs, |
| 408 1, | 379 1, |
| 409 { | 380 { |
| 410 notificationsData: { | 381 notificationsData: { |
| 411 'TEST CARD ID': { | 382 'TEST CARD ID': { |
| 412 actionUrls: testActionUrls, | 383 actionUrls: testActionUrls, |
| 413 cardCreateInfo: { | 384 cardCreateInfo: { |
| 414 notification: testNotification, | 385 notification: testNotification, |
| 415 timeHide: 1313000, | 386 hideTime: 1313000, |
| 416 version: 0, | 387 version: 0, |
| 417 previousVersion:0}}}})); | 388 previousVersion:0}}}})); |
| 418 var chromeNotificationsCreateSavedArgs = new SaveMockArguments(); | 389 var chromeNotificationsCreateSavedArgs = new SaveMockArguments(); |
| 419 this.mockApis.expects(once()). | 390 this.mockApis.expects(once()). |
| 420 instrumented_notifications_update( | 391 instrumented_notifications_update( |
| 421 testCardId, eqJSON(testNotification), ANYTHING); | 392 testCardId, eqJSON(testNotification), ANYTHING); |
| 422 | 393 |
| 423 // Call tested method. | 394 // Call tested method. |
| 424 test.alarmCallback({name: expectedShowAlarmId}); | 395 test.alarmCallback({name: expectedShowAlarmId}); |
| 425 }); | 396 }); |
| 426 | 397 |
| 427 TEST_F('GoogleNowCardsUnitTest', 'onAlarmHide', function() { | 398 TEST_F('GoogleNowCardsUnitTest', 'onAlarmHide', function() { |
| 428 // Tests onAlarm for the 'hide' alarm. | 399 // Tests onAlarm for the 'hide' alarm. |
| 429 var test = setUpCardManagerTest(this); | 400 var test = setUpCardManagerTest(this); |
| 430 this.mockApis.expects(once()). | 401 this.mockApis.expects(once()). |
| 431 chrome_notifications_clear(testCardId, ANYTHING); | 402 chrome_notifications_clear(testCardId, ANYTHING); |
| 403 this.mockApis.expects(once()). |
| 404 chrome_alarms_clear(expectedShowAlarmId); |
| 405 this.mockApis.expects(once()). |
| 406 chrome_alarms_clear(expectedHideAlarmId); |
| 407 |
| 432 | 408 |
| 433 // Call tested method. | 409 // Call tested method. |
| 434 test.alarmCallback({name: expectedHideAlarmId}); | 410 test.alarmCallback({name: expectedHideAlarmId}); |
| 435 }); | 411 }); |
| OLD | NEW |