| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 'use strict'; | 4 'use strict'; |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * Test target. | 7 * Test target. |
| 8 * @type {DeviceHandler} | 8 * @type {DeviceHandler} |
| 9 */ | 9 */ |
| 10 var handler; | 10 var handler; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * Dummy private APIs. | 13 * Dummy private APIs. |
| 14 */ | 14 */ |
| 15 var chrome; | 15 var chrome; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Callbacks registered by setTimeout. | 18 * Callbacks registered by setTimeout. |
| 19 * @type {Array.<function>} | 19 * @type {Array.<function>} |
| 20 */ | 20 */ |
| 21 var timeoutCallbacks; | 21 var timeoutCallbacks; |
| 22 | 22 |
| 23 // Set up the test components. | 23 // Set up the test components. |
| 24 function setUp() { | 24 function setUp() { |
| 25 // Set up string assets. | 25 // Set up string assets. |
| 26 loadTimeData.data = { | 26 loadTimeData.data = { |
| 27 REMOVABLE_DEVICE_DETECTION_TITLE: 'Device detected', | 27 REMOVABLE_DEVICE_DETECTION_TITLE: 'Device detected', |
| 28 REMOVABLE_DEVICE_SCANNING_MESSAGE: 'Scanning...', | 28 REMOVABLE_DEVICE_SCANNING_MESSAGE: 'Scanning...', |
| 29 REMOVABLE_DEVICE_NAVIGATION_MESSAGE: 'DEVICE_NAVIGATION', |
| 30 REMOVABLE_DEVICE_NAVIGATION_BUTTON_LABEL: '', |
| 29 DEVICE_UNKNOWN_MESSAGE: 'DEVICE_UNKNOWN: $1', | 31 DEVICE_UNKNOWN_MESSAGE: 'DEVICE_UNKNOWN: $1', |
| 30 DEVICE_UNSUPPORTED_MESSAGE: 'DEVICE_UNSUPPORTED: $1', | 32 DEVICE_UNSUPPORTED_MESSAGE: 'DEVICE_UNSUPPORTED: $1', |
| 31 DEVICE_HARD_UNPLUGGED_TITLE: 'DEVICE_HARD_UNPLUGGED_TITLE', | 33 DEVICE_HARD_UNPLUGGED_TITLE: 'DEVICE_HARD_UNPLUGGED_TITLE', |
| 32 DEVICE_HARD_UNPLUGGED_MESSAGE: 'DEVICE_HARD_UNPLUGGED_MESSAGE', | 34 DEVICE_HARD_UNPLUGGED_MESSAGE: 'DEVICE_HARD_UNPLUGGED_MESSAGE', |
| 33 MULTIPART_DEVICE_UNSUPPORTED_MESSAGE: 'MULTIPART_DEVICE_UNSUPPORTED: $1', | 35 MULTIPART_DEVICE_UNSUPPORTED_MESSAGE: 'MULTIPART_DEVICE_UNSUPPORTED: $1', |
| 34 EXTERNAL_STORAGE_DISABLED_MESSAGE: 'EXTERNAL_STORAGE_DISABLED', | 36 EXTERNAL_STORAGE_DISABLED_MESSAGE: 'EXTERNAL_STORAGE_DISABLED', |
| 35 FORMATTING_OF_DEVICE_PENDING_TITLE: 'FORMATTING_OF_DEVICE_PENDING_TITLE', | 37 FORMATTING_OF_DEVICE_PENDING_TITLE: 'FORMATTING_OF_DEVICE_PENDING_TITLE', |
| 36 FORMATTING_OF_DEVICE_PENDING_MESSAGE: 'FORMATTING_OF_DEVICE_PENDING', | 38 FORMATTING_OF_DEVICE_PENDING_MESSAGE: 'FORMATTING_OF_DEVICE_PENDING', |
| 37 FORMATTING_OF_DEVICE_FINISHED_TITLE: 'FORMATTING_OF_DEVICE_FINISHED_TITLE', | 39 FORMATTING_OF_DEVICE_FINISHED_TITLE: 'FORMATTING_OF_DEVICE_FINISHED_TITLE', |
| 38 FORMATTING_FINISHED_SUCCESS_MESSAGE: 'FORMATTING_FINISHED_SUCCESS', | 40 FORMATTING_FINISHED_SUCCESS_MESSAGE: 'FORMATTING_FINISHED_SUCCESS', |
| (...skipping 29 matching lines...) Expand all Loading... |
| 68 } | 70 } |
| 69 }, | 71 }, |
| 70 runtime: { | 72 runtime: { |
| 71 getURL: function(path) { return path; }, | 73 getURL: function(path) { return path; }, |
| 72 onStartup: { | 74 onStartup: { |
| 73 addListener: function() {} | 75 addListener: function() {} |
| 74 } | 76 } |
| 75 } | 77 } |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 // Reset timeout callbacks. | |
| 79 timeoutCallbacks = []; | |
| 80 | |
| 81 // Make a device handler. | 80 // Make a device handler. |
| 82 handler = new DeviceHandler(); | 81 handler = new DeviceHandler(); |
| 83 } | 82 } |
| 84 | 83 |
| 85 /** | |
| 86 * Overrided setTimoeut funciton. | |
| 87 */ | |
| 88 window.setTimeout = function(func) { | |
| 89 timeoutCallbacks.push(func); | |
| 90 }; | |
| 91 | |
| 92 /** | |
| 93 * Call all pending timeout functions. | |
| 94 */ | |
| 95 function callTimeoutCallbacks() { | |
| 96 while (timeoutCallbacks.length) { | |
| 97 timeoutCallbacks.shift()(); | |
| 98 } | |
| 99 } | |
| 100 | |
| 101 function registerTypicalDevice() { | |
| 102 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | |
| 103 type: 'added', | |
| 104 devicePath: '/device/path' | |
| 105 }); | |
| 106 assertFalse('device:/device/path' in chrome.notifications.items); | |
| 107 callTimeoutCallbacks(); | |
| 108 assertEquals('Scanning...', | |
| 109 chrome.notifications.items['device:/device/path'].message); | |
| 110 } | |
| 111 | |
| 112 function testGoodDevice() { | 84 function testGoodDevice() { |
| 113 registerTypicalDevice(); | |
| 114 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 85 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 86 eventType: 'mount', |
| 115 status: 'success', | 87 status: 'success', |
| 116 volumeMetadata: { | 88 volumeMetadata: { |
| 117 isParentDevice: true, | 89 isParentDevice: true, |
| 118 deviceType: 'usb', | 90 deviceType: 'usb', |
| 119 devicePath: '/device/path', | 91 devicePath: '/device/path', |
| 120 deviceLabel: 'label' | 92 deviceLabel: 'label' |
| 121 } | 93 }, |
| 94 shouldNotify: true |
| 95 }); |
| 96 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 97 assertEquals( |
| 98 'DEVICE_NAVIGATION', |
| 99 chrome.notifications.items['deviceNavigation:/device/path'].message); |
| 100 } |
| 101 |
| 102 function testGoodDeviceNotNavigated() { |
| 103 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 104 eventType: 'mount', |
| 105 status: 'success', |
| 106 volumeMetadata: { |
| 107 isParentDevice: true, |
| 108 deviceType: 'usb', |
| 109 devicePath: '/device/path', |
| 110 deviceLabel: 'label' |
| 111 }, |
| 112 shouldNotify: false |
| 122 }); | 113 }); |
| 123 assertEquals(0, Object.keys(chrome.notifications.items).length); | 114 assertEquals(0, Object.keys(chrome.notifications.items).length); |
| 124 } | 115 } |
| 125 | 116 |
| 126 function testGoodDeviceWithBadParent() { | 117 function testGoodDeviceWithBadParent() { |
| 127 registerTypicalDevice(); | |
| 128 | |
| 129 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 118 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 119 eventType: 'mount', |
| 130 status: 'error_internal', | 120 status: 'error_internal', |
| 131 volumeMetadata: { | 121 volumeMetadata: { |
| 132 isParentDevice: true, | 122 isParentDevice: true, |
| 133 deviceType: 'usb', | 123 deviceType: 'usb', |
| 134 devicePath: '/device/path', | 124 devicePath: '/device/path', |
| 135 deviceLabel: 'label' | 125 deviceLabel: 'label' |
| 136 } | 126 }, |
| 127 shouldNotify: true |
| 137 }); | 128 }); |
| 138 assertFalse(!!chrome.notifications.items['device:/device/path']); | 129 assertFalse(!!chrome.notifications.items['device:/device/path']); |
| 139 assertEquals( | 130 assertEquals( |
| 140 'DEVICE_UNKNOWN: label', | 131 'DEVICE_UNKNOWN: label', |
| 141 chrome.notifications.items['deviceFail:/device/path'].message); | 132 chrome.notifications.items['deviceFail:/device/path'].message); |
| 142 | 133 |
| 143 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 134 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 135 eventType: 'mount', |
| 144 status: 'success', | 136 status: 'success', |
| 145 volumeMetadata: { | 137 volumeMetadata: { |
| 146 isParentDevice: false, | 138 isParentDevice: false, |
| 147 deviceType: 'usb', | 139 deviceType: 'usb', |
| 148 devicePath: '/device/path', | 140 devicePath: '/device/path', |
| 149 deviceLabel: 'label' | 141 deviceLabel: 'label' |
| 150 } | 142 }, |
| 143 shouldNotify: true |
| 151 }); | 144 }); |
| 152 assertEquals(0, Object.keys(chrome.notifications.items).length); | 145 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 146 assertEquals( |
| 147 'DEVICE_NAVIGATION', |
| 148 chrome.notifications.items['deviceNavigation:/device/path'].message); |
| 153 | 149 |
| 154 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 150 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 151 eventType: 'mount', |
| 155 status: 'success', | 152 status: 'success', |
| 156 volumeMetadata: { | 153 volumeMetadata: { |
| 157 isParentDevice: false, | 154 isParentDevice: false, |
| 158 deviceType: 'usb', | 155 deviceType: 'usb', |
| 159 devicePath: '/device/path', | 156 devicePath: '/device/path', |
| 160 deviceLabel: 'label' | 157 deviceLabel: 'label' |
| 161 } | 158 }, |
| 159 shouldNotify: true |
| 162 }); | 160 }); |
| 163 // Should do nothing this time. | 161 // Should do nothing this time. |
| 164 assertEquals(0, Object.keys(chrome.notifications.items).length); | 162 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 163 assertEquals( |
| 164 'DEVICE_NAVIGATION', |
| 165 chrome.notifications.items['deviceNavigation:/device/path'].message); |
| 165 } | 166 } |
| 166 | 167 |
| 167 function testUnsupportedDevice() { | 168 function testUnsupportedDevice() { |
| 168 registerTypicalDevice(); | |
| 169 | |
| 170 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 169 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 170 eventType: 'mount', |
| 171 status: 'error_unsupported_filesystem', | 171 status: 'error_unsupported_filesystem', |
| 172 volumeMetadata: { | 172 volumeMetadata: { |
| 173 isParentDevice: false, | 173 isParentDevice: false, |
| 174 deviceType: 'usb', | 174 deviceType: 'usb', |
| 175 devicePath: '/device/path', | 175 devicePath: '/device/path', |
| 176 deviceLabel: 'label' | 176 deviceLabel: 'label' |
| 177 } | 177 }, |
| 178 shouldNotify: true |
| 178 }); | 179 }); |
| 179 assertFalse(!!chrome.notifications.items['device:/device/path']); | 180 assertFalse(!!chrome.notifications.items['device:/device/path']); |
| 180 assertEquals( | 181 assertEquals( |
| 181 'DEVICE_UNSUPPORTED: label', | 182 'DEVICE_UNSUPPORTED: label', |
| 182 chrome.notifications.items['deviceFail:/device/path'].message); | 183 chrome.notifications.items['deviceFail:/device/path'].message); |
| 183 } | 184 } |
| 184 | 185 |
| 185 function testUnsupportedWithUnknownParent() { | 186 function testUnsupportedWithUnknownParent() { |
| 186 registerTypicalDevice(); | |
| 187 | |
| 188 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 187 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 188 eventType: 'mount', |
| 189 status: 'error_internal', | 189 status: 'error_internal', |
| 190 volumeMetadata: { | 190 volumeMetadata: { |
| 191 isParentDevice: true, | 191 isParentDevice: true, |
| 192 deviceType: 'usb', | 192 deviceType: 'usb', |
| 193 devicePath: '/device/path', | 193 devicePath: '/device/path', |
| 194 deviceLabel: 'label' | 194 deviceLabel: 'label' |
| 195 } | 195 }, |
| 196 shouldNotify: true |
| 196 }); | 197 }); |
| 197 assertEquals( | 198 assertEquals( |
| 198 'DEVICE_UNKNOWN: label', | 199 'DEVICE_UNKNOWN: label', |
| 199 chrome.notifications.items['deviceFail:/device/path'].message); | 200 chrome.notifications.items['deviceFail:/device/path'].message); |
| 200 | 201 |
| 201 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 202 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 203 eventType: 'mount', |
| 202 status: 'error_unsupported_filesystem', | 204 status: 'error_unsupported_filesystem', |
| 203 volumeMetadata: { | 205 volumeMetadata: { |
| 204 isParentDevice: false, | 206 isParentDevice: false, |
| 205 deviceType: 'usb', | 207 deviceType: 'usb', |
| 206 devicePath: '/device/path', | 208 devicePath: '/device/path', |
| 207 deviceLabel: 'label' | 209 deviceLabel: 'label' |
| 208 } | 210 }, |
| 211 shouldNotify: true |
| 209 }); | 212 }); |
| 210 assertEquals(1, Object.keys(chrome.notifications.items).length); | 213 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 211 assertEquals( | 214 assertEquals( |
| 212 'DEVICE_UNSUPPORTED: label', | 215 'DEVICE_UNSUPPORTED: label', |
| 213 chrome.notifications.items['deviceFail:/device/path'].message); | 216 chrome.notifications.items['deviceFail:/device/path'].message); |
| 214 } | 217 } |
| 215 | 218 |
| 216 function testMountPartialSuccess() { | 219 function testMountPartialSuccess() { |
| 217 registerTypicalDevice(); | |
| 218 | |
| 219 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 220 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 221 eventType: 'mount', |
| 220 status: 'success', | 222 status: 'success', |
| 221 volumeMetadata: { | 223 volumeMetadata: { |
| 222 isParentDevice: false, | 224 isParentDevice: false, |
| 223 deviceType: 'usb', | 225 deviceType: 'usb', |
| 224 devicePath: '/device/path', | 226 devicePath: '/device/path', |
| 225 deviceLabel: 'label' | 227 deviceLabel: 'label' |
| 226 } | 228 }, |
| 229 shouldNotify: true |
| 227 }); | 230 }); |
| 228 assertEquals(0, Object.keys(chrome.notifications.items).length); | 231 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 232 assertEquals( |
| 233 'DEVICE_NAVIGATION', |
| 234 chrome.notifications.items['deviceNavigation:/device/path'].message); |
| 229 | 235 |
| 230 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 236 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 237 eventType: 'mount', |
| 231 status: 'error_unsupported_filesystem', | 238 status: 'error_unsupported_filesystem', |
| 232 volumeMetadata: { | 239 volumeMetadata: { |
| 233 isParentDevice: false, | 240 isParentDevice: false, |
| 234 deviceType: 'usb', | 241 deviceType: 'usb', |
| 235 devicePath: '/device/path', | 242 devicePath: '/device/path', |
| 236 deviceLabel: 'label' | 243 deviceLabel: 'label' |
| 237 } | 244 }, |
| 245 shouldNotify: true |
| 238 }); | 246 }); |
| 239 assertEquals(1, Object.keys(chrome.notifications.items).length); | 247 assertEquals(2, Object.keys(chrome.notifications.items).length); |
| 240 assertEquals( | 248 assertEquals( |
| 241 'MULTIPART_DEVICE_UNSUPPORTED: label', | 249 'MULTIPART_DEVICE_UNSUPPORTED: label', |
| 242 chrome.notifications.items['deviceFail:/device/path'].message); | 250 chrome.notifications.items['deviceFail:/device/path'].message); |
| 243 } | 251 } |
| 244 | 252 |
| 245 function testUnknown() { | 253 function testUnknown() { |
| 246 registerTypicalDevice(); | |
| 247 | |
| 248 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 254 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 255 eventType: 'mount', |
| 249 status: 'error_unknown', | 256 status: 'error_unknown', |
| 250 volumeMetadata: { | 257 volumeMetadata: { |
| 251 isParentDevice: false, | 258 isParentDevice: false, |
| 252 deviceType: 'usb', | 259 deviceType: 'usb', |
| 253 devicePath: '/device/path', | 260 devicePath: '/device/path', |
| 254 deviceLabel: 'label' | 261 deviceLabel: 'label' |
| 255 } | 262 }, |
| 263 shouldNotify: true |
| 256 }); | 264 }); |
| 257 assertEquals(1, Object.keys(chrome.notifications.items).length); | 265 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 258 assertEquals( | 266 assertEquals( |
| 259 'DEVICE_UNKNOWN: label', | 267 'DEVICE_UNKNOWN: label', |
| 260 chrome.notifications.items['deviceFail:/device/path'].message); | 268 chrome.notifications.items['deviceFail:/device/path'].message); |
| 261 } | 269 } |
| 262 | 270 |
| 263 function testNonASCIILabel() { | 271 function testNonASCIILabel() { |
| 264 registerTypicalDevice(); | |
| 265 | |
| 266 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 272 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 273 eventType: 'mount', |
| 267 status: 'error_internal', | 274 status: 'error_internal', |
| 268 volumeMetadata: { | 275 volumeMetadata: { |
| 269 isParentDevice: false, | 276 isParentDevice: false, |
| 270 deviceType: 'usb', | 277 deviceType: 'usb', |
| 271 devicePath: '/device/path', | 278 devicePath: '/device/path', |
| 272 // "RA (U+30E9) BE (U+30D9) RU (U+30EB)" in Katakana letters. | 279 // "RA (U+30E9) BE (U+30D9) RU (U+30EB)" in Katakana letters. |
| 273 deviceLabel: '\u30E9\u30D9\u30EB' | 280 deviceLabel: '\u30E9\u30D9\u30EB' |
| 274 } | 281 }, |
| 282 shouldNotify: true |
| 275 }); | 283 }); |
| 276 assertEquals(1, Object.keys(chrome.notifications.items).length); | 284 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 277 assertEquals( | 285 assertEquals( |
| 278 'DEVICE_UNKNOWN: \u30E9\u30D9\u30EB', | 286 'DEVICE_UNKNOWN: \u30E9\u30D9\u30EB', |
| 279 chrome.notifications.items['deviceFail:/device/path'].message); | 287 chrome.notifications.items['deviceFail:/device/path'].message); |
| 280 } | 288 } |
| 281 | 289 |
| 282 function testMulitpleFail() { | 290 function testMulitpleFail() { |
| 283 registerTypicalDevice(); | |
| 284 | |
| 285 // The first parent error. | 291 // The first parent error. |
| 286 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 292 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 293 eventType: 'mount', |
| 287 status: 'error_internal', | 294 status: 'error_internal', |
| 288 volumeMetadata: { | 295 volumeMetadata: { |
| 289 isParentDevice: true, | 296 isParentDevice: true, |
| 290 deviceType: 'usb', | 297 deviceType: 'usb', |
| 291 devicePath: '/device/path', | 298 devicePath: '/device/path', |
| 292 deviceLabel: 'label' | 299 deviceLabel: 'label' |
| 293 } | 300 }, |
| 301 shouldNotify: true |
| 294 }); | 302 }); |
| 295 assertEquals(1, Object.keys(chrome.notifications.items).length); | 303 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 296 assertEquals( | 304 assertEquals( |
| 297 'DEVICE_UNKNOWN: label', | 305 'DEVICE_UNKNOWN: label', |
| 298 chrome.notifications.items['deviceFail:/device/path'].message); | 306 chrome.notifications.items['deviceFail:/device/path'].message); |
| 299 | 307 |
| 300 // The first child error that replaces the parent error. | 308 // The first child error that replaces the parent error. |
| 301 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 309 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 310 eventType: 'mount', |
| 302 status: 'error_internal', | 311 status: 'error_internal', |
| 303 volumeMetadata: { | 312 volumeMetadata: { |
| 304 isParentDevice: false, | 313 isParentDevice: false, |
| 305 deviceType: 'usb', | 314 deviceType: 'usb', |
| 306 devicePath: '/device/path', | 315 devicePath: '/device/path', |
| 307 deviceLabel: 'label' | 316 deviceLabel: 'label' |
| 308 } | 317 }, |
| 318 shouldNotify: true |
| 309 }); | 319 }); |
| 310 assertEquals(1, Object.keys(chrome.notifications.items).length); | 320 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 311 assertEquals( | 321 assertEquals( |
| 312 'DEVICE_UNKNOWN: label', | 322 'DEVICE_UNKNOWN: label', |
| 313 chrome.notifications.items['deviceFail:/device/path'].message); | 323 chrome.notifications.items['deviceFail:/device/path'].message); |
| 314 | 324 |
| 315 // The second child error that turns to a multi-partition error. | 325 // The second child error that turns to a multi-partition error. |
| 316 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 326 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 327 eventType: 'mount', |
| 317 status: 'error_internal', | 328 status: 'error_internal', |
| 318 volumeMetadata: { | 329 volumeMetadata: { |
| 319 isParentDevice: false, | 330 isParentDevice: false, |
| 320 deviceType: 'usb', | 331 deviceType: 'usb', |
| 321 devicePath: '/device/path', | 332 devicePath: '/device/path', |
| 322 deviceLabel: 'label' | 333 deviceLabel: 'label' |
| 323 } | 334 }, |
| 335 shouldNotify: true |
| 324 }); | 336 }); |
| 325 assertEquals(1, Object.keys(chrome.notifications.items).length); | 337 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 326 assertEquals( | 338 assertEquals( |
| 327 'MULTIPART_DEVICE_UNSUPPORTED: label', | 339 'MULTIPART_DEVICE_UNSUPPORTED: label', |
| 328 chrome.notifications.items['deviceFail:/device/path'].message); | 340 chrome.notifications.items['deviceFail:/device/path'].message); |
| 329 | 341 |
| 330 // The third child error that should be ignored because the error message does | 342 // The third child error that should be ignored because the error message does |
| 331 // not changed. | 343 // not changed. |
| 332 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 344 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ |
| 345 eventType: 'mount', |
| 333 status: 'error_internal', | 346 status: 'error_internal', |
| 334 volumeMetadata: { | 347 volumeMetadata: { |
| 335 isParentDevice: false, | 348 isParentDevice: false, |
| 336 deviceType: 'usb', | 349 deviceType: 'usb', |
| 337 devicePath: '/device/path', | 350 devicePath: '/device/path', |
| 338 deviceLabel: 'label' | 351 deviceLabel: 'label' |
| 339 } | 352 }, |
| 353 shouldNotify: true |
| 340 }); | 354 }); |
| 341 assertEquals(1, Object.keys(chrome.notifications.items).length); | 355 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 342 assertEquals( | 356 assertEquals( |
| 343 'MULTIPART_DEVICE_UNSUPPORTED: label', | 357 'MULTIPART_DEVICE_UNSUPPORTED: label', |
| 344 chrome.notifications.items['deviceFail:/device/path'].message); | 358 chrome.notifications.items['deviceFail:/device/path'].message); |
| 345 } | 359 } |
| 346 | 360 |
| 347 function testScanCanceled() { | 361 function testScanCanceled() { |
| 348 registerTypicalDevice(); | 362 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ |
| 363 type: 'scan_started', |
| 364 devicePath: '/device/path' |
| 365 }); |
| 366 assertTrue('device:/device/path' in chrome.notifications.items); |
| 367 assertEquals('Scanning...', |
| 368 chrome.notifications.items['device:/device/path'].message); |
| 349 | 369 |
| 350 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 370 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ |
| 351 type: 'scan_canceled', | 371 type: 'scan_cancelled', |
| 352 devicePath: '/device/path' | 372 devicePath: '/device/path' |
| 353 }); | 373 }); |
| 354 assertEquals(0, Object.keys(chrome.notifications.items).length); | 374 assertEquals(0, Object.keys(chrome.notifications.items).length); |
| 355 | 375 |
| 356 // Nothing happened. | 376 // Nothing happened. |
| 357 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 377 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ |
| 358 type: 'removed', | 378 type: 'removed', |
| 359 devicePath: '/device/path' | 379 devicePath: '/device/path' |
| 360 }); | 380 }); |
| 361 assertEquals(0, Object.keys(chrome.notifications.items).length); | 381 assertEquals(0, Object.keys(chrome.notifications.items).length); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 function testDeviceHardUnplugged() { | 437 function testDeviceHardUnplugged() { |
| 418 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 438 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ |
| 419 type: 'hard_unplugged', | 439 type: 'hard_unplugged', |
| 420 devicePath: '/device/path' | 440 devicePath: '/device/path' |
| 421 }); | 441 }); |
| 422 assertEquals(1, Object.keys(chrome.notifications.items).length); | 442 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 423 assertEquals('DEVICE_HARD_UNPLUGGED_MESSAGE', | 443 assertEquals('DEVICE_HARD_UNPLUGGED_MESSAGE', |
| 424 chrome.notifications.items[ | 444 chrome.notifications.items[ |
| 425 'hardUnplugged:/device/path'].message); | 445 'hardUnplugged:/device/path'].message); |
| 426 } | 446 } |
| OLD | NEW |