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; |
(...skipping 26 matching lines...) Expand all Loading... |
37 FORMATTING_OF_DEVICE_PENDING_TITLE: 'FORMATTING_OF_DEVICE_PENDING_TITLE', | 37 FORMATTING_OF_DEVICE_PENDING_TITLE: 'FORMATTING_OF_DEVICE_PENDING_TITLE', |
38 FORMATTING_OF_DEVICE_PENDING_MESSAGE: 'FORMATTING_OF_DEVICE_PENDING', | 38 FORMATTING_OF_DEVICE_PENDING_MESSAGE: 'FORMATTING_OF_DEVICE_PENDING', |
39 FORMATTING_OF_DEVICE_FINISHED_TITLE: 'FORMATTING_OF_DEVICE_FINISHED_TITLE', | 39 FORMATTING_OF_DEVICE_FINISHED_TITLE: 'FORMATTING_OF_DEVICE_FINISHED_TITLE', |
40 FORMATTING_FINISHED_SUCCESS_MESSAGE: 'FORMATTING_FINISHED_SUCCESS', | 40 FORMATTING_FINISHED_SUCCESS_MESSAGE: 'FORMATTING_FINISHED_SUCCESS', |
41 FORMATTING_OF_DEVICE_FAILED_TITLE: 'FORMATTING_OF_DEVICE_FAILED_TITLE', | 41 FORMATTING_OF_DEVICE_FAILED_TITLE: 'FORMATTING_OF_DEVICE_FAILED_TITLE', |
42 FORMATTING_FINISHED_FAILURE_MESSAGE: 'FORMATTING_FINISHED_FAILURE' | 42 FORMATTING_FINISHED_FAILURE_MESSAGE: 'FORMATTING_FINISHED_FAILURE' |
43 }; | 43 }; |
44 | 44 |
45 // Make dummy APIs. | 45 // Make dummy APIs. |
46 chrome = { | 46 chrome = { |
47 fileBrowserPrivate: { | 47 fileManagerPrivate: { |
48 onDeviceChanged: { | 48 onDeviceChanged: { |
49 addListener: function(listener) { | 49 addListener: function(listener) { |
50 this.dispatch = listener; | 50 this.dispatch = listener; |
51 } | 51 } |
52 }, | 52 }, |
53 onMountCompleted: { | 53 onMountCompleted: { |
54 addListener: function(listener) { | 54 addListener: function(listener) { |
55 this.dispatch = listener; | 55 this.dispatch = listener; |
56 } | 56 } |
57 } | 57 } |
(...skipping 17 matching lines...) Expand all Loading... |
75 addListener: function() {} | 75 addListener: function() {} |
76 } | 76 } |
77 } | 77 } |
78 }; | 78 }; |
79 | 79 |
80 // Make a device handler. | 80 // Make a device handler. |
81 handler = new DeviceHandler(); | 81 handler = new DeviceHandler(); |
82 } | 82 } |
83 | 83 |
84 function testGoodDevice() { | 84 function testGoodDevice() { |
85 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 85 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
86 eventType: 'mount', | 86 eventType: 'mount', |
87 status: 'success', | 87 status: 'success', |
88 volumeMetadata: { | 88 volumeMetadata: { |
89 isParentDevice: true, | 89 isParentDevice: true, |
90 deviceType: 'usb', | 90 deviceType: 'usb', |
91 devicePath: '/device/path', | 91 devicePath: '/device/path', |
92 deviceLabel: 'label' | 92 deviceLabel: 'label' |
93 }, | 93 }, |
94 shouldNotify: true | 94 shouldNotify: true |
95 }); | 95 }); |
96 assertEquals(1, Object.keys(chrome.notifications.items).length); | 96 assertEquals(1, Object.keys(chrome.notifications.items).length); |
97 assertEquals( | 97 assertEquals( |
98 'DEVICE_NAVIGATION', | 98 'DEVICE_NAVIGATION', |
99 chrome.notifications.items['deviceNavigation:/device/path'].message); | 99 chrome.notifications.items['deviceNavigation:/device/path'].message); |
100 } | 100 } |
101 | 101 |
102 function testGoodDeviceNotNavigated() { | 102 function testGoodDeviceNotNavigated() { |
103 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 103 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
104 eventType: 'mount', | 104 eventType: 'mount', |
105 status: 'success', | 105 status: 'success', |
106 volumeMetadata: { | 106 volumeMetadata: { |
107 isParentDevice: true, | 107 isParentDevice: true, |
108 deviceType: 'usb', | 108 deviceType: 'usb', |
109 devicePath: '/device/path', | 109 devicePath: '/device/path', |
110 deviceLabel: 'label' | 110 deviceLabel: 'label' |
111 }, | 111 }, |
112 shouldNotify: false | 112 shouldNotify: false |
113 }); | 113 }); |
114 assertEquals(0, Object.keys(chrome.notifications.items).length); | 114 assertEquals(0, Object.keys(chrome.notifications.items).length); |
115 } | 115 } |
116 | 116 |
117 function testGoodDeviceWithBadParent() { | 117 function testGoodDeviceWithBadParent() { |
118 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 118 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
119 eventType: 'mount', | 119 eventType: 'mount', |
120 status: 'error_internal', | 120 status: 'error_internal', |
121 volumeMetadata: { | 121 volumeMetadata: { |
122 isParentDevice: true, | 122 isParentDevice: true, |
123 deviceType: 'usb', | 123 deviceType: 'usb', |
124 devicePath: '/device/path', | 124 devicePath: '/device/path', |
125 deviceLabel: 'label' | 125 deviceLabel: 'label' |
126 }, | 126 }, |
127 shouldNotify: true | 127 shouldNotify: true |
128 }); | 128 }); |
129 assertFalse(!!chrome.notifications.items['device:/device/path']); | 129 assertFalse(!!chrome.notifications.items['device:/device/path']); |
130 assertEquals( | 130 assertEquals( |
131 'DEVICE_UNKNOWN: label', | 131 'DEVICE_UNKNOWN: label', |
132 chrome.notifications.items['deviceFail:/device/path'].message); | 132 chrome.notifications.items['deviceFail:/device/path'].message); |
133 | 133 |
134 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 134 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
135 eventType: 'mount', | 135 eventType: 'mount', |
136 status: 'success', | 136 status: 'success', |
137 volumeMetadata: { | 137 volumeMetadata: { |
138 isParentDevice: false, | 138 isParentDevice: false, |
139 deviceType: 'usb', | 139 deviceType: 'usb', |
140 devicePath: '/device/path', | 140 devicePath: '/device/path', |
141 deviceLabel: 'label' | 141 deviceLabel: 'label' |
142 }, | 142 }, |
143 shouldNotify: true | 143 shouldNotify: true |
144 }); | 144 }); |
145 assertEquals(1, Object.keys(chrome.notifications.items).length); | 145 assertEquals(1, Object.keys(chrome.notifications.items).length); |
146 assertEquals( | 146 assertEquals( |
147 'DEVICE_NAVIGATION', | 147 'DEVICE_NAVIGATION', |
148 chrome.notifications.items['deviceNavigation:/device/path'].message); | 148 chrome.notifications.items['deviceNavigation:/device/path'].message); |
149 | 149 |
150 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 150 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
151 eventType: 'mount', | 151 eventType: 'mount', |
152 status: 'success', | 152 status: 'success', |
153 volumeMetadata: { | 153 volumeMetadata: { |
154 isParentDevice: false, | 154 isParentDevice: false, |
155 deviceType: 'usb', | 155 deviceType: 'usb', |
156 devicePath: '/device/path', | 156 devicePath: '/device/path', |
157 deviceLabel: 'label' | 157 deviceLabel: 'label' |
158 }, | 158 }, |
159 shouldNotify: true | 159 shouldNotify: true |
160 }); | 160 }); |
161 // Should do nothing this time. | 161 // Should do nothing this time. |
162 assertEquals(1, Object.keys(chrome.notifications.items).length); | 162 assertEquals(1, Object.keys(chrome.notifications.items).length); |
163 assertEquals( | 163 assertEquals( |
164 'DEVICE_NAVIGATION', | 164 'DEVICE_NAVIGATION', |
165 chrome.notifications.items['deviceNavigation:/device/path'].message); | 165 chrome.notifications.items['deviceNavigation:/device/path'].message); |
166 } | 166 } |
167 | 167 |
168 function testUnsupportedDevice() { | 168 function testUnsupportedDevice() { |
169 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 169 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
170 eventType: 'mount', | 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 shouldNotify: true |
179 }); | 179 }); |
180 assertFalse(!!chrome.notifications.items['device:/device/path']); | 180 assertFalse(!!chrome.notifications.items['device:/device/path']); |
181 assertEquals( | 181 assertEquals( |
182 'DEVICE_UNSUPPORTED: label', | 182 'DEVICE_UNSUPPORTED: label', |
183 chrome.notifications.items['deviceFail:/device/path'].message); | 183 chrome.notifications.items['deviceFail:/device/path'].message); |
184 } | 184 } |
185 | 185 |
186 function testUnsupportedWithUnknownParent() { | 186 function testUnsupportedWithUnknownParent() { |
187 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 187 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
188 eventType: 'mount', | 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 shouldNotify: true |
197 }); | 197 }); |
198 assertEquals( | 198 assertEquals( |
199 'DEVICE_UNKNOWN: label', | 199 'DEVICE_UNKNOWN: label', |
200 chrome.notifications.items['deviceFail:/device/path'].message); | 200 chrome.notifications.items['deviceFail:/device/path'].message); |
201 | 201 |
202 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 202 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
203 eventType: 'mount', | 203 eventType: 'mount', |
204 status: 'error_unsupported_filesystem', | 204 status: 'error_unsupported_filesystem', |
205 volumeMetadata: { | 205 volumeMetadata: { |
206 isParentDevice: false, | 206 isParentDevice: false, |
207 deviceType: 'usb', | 207 deviceType: 'usb', |
208 devicePath: '/device/path', | 208 devicePath: '/device/path', |
209 deviceLabel: 'label' | 209 deviceLabel: 'label' |
210 }, | 210 }, |
211 shouldNotify: true | 211 shouldNotify: true |
212 }); | 212 }); |
213 assertEquals(1, Object.keys(chrome.notifications.items).length); | 213 assertEquals(1, Object.keys(chrome.notifications.items).length); |
214 assertEquals( | 214 assertEquals( |
215 'DEVICE_UNSUPPORTED: label', | 215 'DEVICE_UNSUPPORTED: label', |
216 chrome.notifications.items['deviceFail:/device/path'].message); | 216 chrome.notifications.items['deviceFail:/device/path'].message); |
217 } | 217 } |
218 | 218 |
219 function testMountPartialSuccess() { | 219 function testMountPartialSuccess() { |
220 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 220 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
221 eventType: 'mount', | 221 eventType: 'mount', |
222 status: 'success', | 222 status: 'success', |
223 volumeMetadata: { | 223 volumeMetadata: { |
224 isParentDevice: false, | 224 isParentDevice: false, |
225 deviceType: 'usb', | 225 deviceType: 'usb', |
226 devicePath: '/device/path', | 226 devicePath: '/device/path', |
227 deviceLabel: 'label' | 227 deviceLabel: 'label' |
228 }, | 228 }, |
229 shouldNotify: true | 229 shouldNotify: true |
230 }); | 230 }); |
231 assertEquals(1, Object.keys(chrome.notifications.items).length); | 231 assertEquals(1, Object.keys(chrome.notifications.items).length); |
232 assertEquals( | 232 assertEquals( |
233 'DEVICE_NAVIGATION', | 233 'DEVICE_NAVIGATION', |
234 chrome.notifications.items['deviceNavigation:/device/path'].message); | 234 chrome.notifications.items['deviceNavigation:/device/path'].message); |
235 | 235 |
236 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 236 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
237 eventType: 'mount', | 237 eventType: 'mount', |
238 status: 'error_unsupported_filesystem', | 238 status: 'error_unsupported_filesystem', |
239 volumeMetadata: { | 239 volumeMetadata: { |
240 isParentDevice: false, | 240 isParentDevice: false, |
241 deviceType: 'usb', | 241 deviceType: 'usb', |
242 devicePath: '/device/path', | 242 devicePath: '/device/path', |
243 deviceLabel: 'label' | 243 deviceLabel: 'label' |
244 }, | 244 }, |
245 shouldNotify: true | 245 shouldNotify: true |
246 }); | 246 }); |
247 assertEquals(2, Object.keys(chrome.notifications.items).length); | 247 assertEquals(2, Object.keys(chrome.notifications.items).length); |
248 assertEquals( | 248 assertEquals( |
249 'MULTIPART_DEVICE_UNSUPPORTED: label', | 249 'MULTIPART_DEVICE_UNSUPPORTED: label', |
250 chrome.notifications.items['deviceFail:/device/path'].message); | 250 chrome.notifications.items['deviceFail:/device/path'].message); |
251 } | 251 } |
252 | 252 |
253 function testUnknown() { | 253 function testUnknown() { |
254 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 254 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
255 eventType: 'mount', | 255 eventType: 'mount', |
256 status: 'error_unknown', | 256 status: 'error_unknown', |
257 volumeMetadata: { | 257 volumeMetadata: { |
258 isParentDevice: false, | 258 isParentDevice: false, |
259 deviceType: 'usb', | 259 deviceType: 'usb', |
260 devicePath: '/device/path', | 260 devicePath: '/device/path', |
261 deviceLabel: 'label' | 261 deviceLabel: 'label' |
262 }, | 262 }, |
263 shouldNotify: true | 263 shouldNotify: true |
264 }); | 264 }); |
265 assertEquals(1, Object.keys(chrome.notifications.items).length); | 265 assertEquals(1, Object.keys(chrome.notifications.items).length); |
266 assertEquals( | 266 assertEquals( |
267 'DEVICE_UNKNOWN: label', | 267 'DEVICE_UNKNOWN: label', |
268 chrome.notifications.items['deviceFail:/device/path'].message); | 268 chrome.notifications.items['deviceFail:/device/path'].message); |
269 } | 269 } |
270 | 270 |
271 function testNonASCIILabel() { | 271 function testNonASCIILabel() { |
272 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 272 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
273 eventType: 'mount', | 273 eventType: 'mount', |
274 status: 'error_internal', | 274 status: 'error_internal', |
275 volumeMetadata: { | 275 volumeMetadata: { |
276 isParentDevice: false, | 276 isParentDevice: false, |
277 deviceType: 'usb', | 277 deviceType: 'usb', |
278 devicePath: '/device/path', | 278 devicePath: '/device/path', |
279 // "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. |
280 deviceLabel: '\u30E9\u30D9\u30EB' | 280 deviceLabel: '\u30E9\u30D9\u30EB' |
281 }, | 281 }, |
282 shouldNotify: true | 282 shouldNotify: true |
283 }); | 283 }); |
284 assertEquals(1, Object.keys(chrome.notifications.items).length); | 284 assertEquals(1, Object.keys(chrome.notifications.items).length); |
285 assertEquals( | 285 assertEquals( |
286 'DEVICE_UNKNOWN: \u30E9\u30D9\u30EB', | 286 'DEVICE_UNKNOWN: \u30E9\u30D9\u30EB', |
287 chrome.notifications.items['deviceFail:/device/path'].message); | 287 chrome.notifications.items['deviceFail:/device/path'].message); |
288 } | 288 } |
289 | 289 |
290 function testMulitpleFail() { | 290 function testMulitpleFail() { |
291 // The first parent error. | 291 // The first parent error. |
292 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 292 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
293 eventType: 'mount', | 293 eventType: 'mount', |
294 status: 'error_internal', | 294 status: 'error_internal', |
295 volumeMetadata: { | 295 volumeMetadata: { |
296 isParentDevice: true, | 296 isParentDevice: true, |
297 deviceType: 'usb', | 297 deviceType: 'usb', |
298 devicePath: '/device/path', | 298 devicePath: '/device/path', |
299 deviceLabel: 'label' | 299 deviceLabel: 'label' |
300 }, | 300 }, |
301 shouldNotify: true | 301 shouldNotify: true |
302 }); | 302 }); |
303 assertEquals(1, Object.keys(chrome.notifications.items).length); | 303 assertEquals(1, Object.keys(chrome.notifications.items).length); |
304 assertEquals( | 304 assertEquals( |
305 'DEVICE_UNKNOWN: label', | 305 'DEVICE_UNKNOWN: label', |
306 chrome.notifications.items['deviceFail:/device/path'].message); | 306 chrome.notifications.items['deviceFail:/device/path'].message); |
307 | 307 |
308 // The first child error that replaces the parent error. | 308 // The first child error that replaces the parent error. |
309 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 309 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
310 eventType: 'mount', | 310 eventType: 'mount', |
311 status: 'error_internal', | 311 status: 'error_internal', |
312 volumeMetadata: { | 312 volumeMetadata: { |
313 isParentDevice: false, | 313 isParentDevice: false, |
314 deviceType: 'usb', | 314 deviceType: 'usb', |
315 devicePath: '/device/path', | 315 devicePath: '/device/path', |
316 deviceLabel: 'label' | 316 deviceLabel: 'label' |
317 }, | 317 }, |
318 shouldNotify: true | 318 shouldNotify: true |
319 }); | 319 }); |
320 assertEquals(1, Object.keys(chrome.notifications.items).length); | 320 assertEquals(1, Object.keys(chrome.notifications.items).length); |
321 assertEquals( | 321 assertEquals( |
322 'DEVICE_UNKNOWN: label', | 322 'DEVICE_UNKNOWN: label', |
323 chrome.notifications.items['deviceFail:/device/path'].message); | 323 chrome.notifications.items['deviceFail:/device/path'].message); |
324 | 324 |
325 // The second child error that turns to a multi-partition error. | 325 // The second child error that turns to a multi-partition error. |
326 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 326 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
327 eventType: 'mount', | 327 eventType: 'mount', |
328 status: 'error_internal', | 328 status: 'error_internal', |
329 volumeMetadata: { | 329 volumeMetadata: { |
330 isParentDevice: false, | 330 isParentDevice: false, |
331 deviceType: 'usb', | 331 deviceType: 'usb', |
332 devicePath: '/device/path', | 332 devicePath: '/device/path', |
333 deviceLabel: 'label' | 333 deviceLabel: 'label' |
334 }, | 334 }, |
335 shouldNotify: true | 335 shouldNotify: true |
336 }); | 336 }); |
337 assertEquals(1, Object.keys(chrome.notifications.items).length); | 337 assertEquals(1, Object.keys(chrome.notifications.items).length); |
338 assertEquals( | 338 assertEquals( |
339 'MULTIPART_DEVICE_UNSUPPORTED: label', | 339 'MULTIPART_DEVICE_UNSUPPORTED: label', |
340 chrome.notifications.items['deviceFail:/device/path'].message); | 340 chrome.notifications.items['deviceFail:/device/path'].message); |
341 | 341 |
342 // 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 |
343 // not changed. | 343 // not changed. |
344 chrome.fileBrowserPrivate.onMountCompleted.dispatch({ | 344 chrome.fileManagerPrivate.onMountCompleted.dispatch({ |
345 eventType: 'mount', | 345 eventType: 'mount', |
346 status: 'error_internal', | 346 status: 'error_internal', |
347 volumeMetadata: { | 347 volumeMetadata: { |
348 isParentDevice: false, | 348 isParentDevice: false, |
349 deviceType: 'usb', | 349 deviceType: 'usb', |
350 devicePath: '/device/path', | 350 devicePath: '/device/path', |
351 deviceLabel: 'label' | 351 deviceLabel: 'label' |
352 }, | 352 }, |
353 shouldNotify: true | 353 shouldNotify: true |
354 }); | 354 }); |
355 assertEquals(1, Object.keys(chrome.notifications.items).length); | 355 assertEquals(1, Object.keys(chrome.notifications.items).length); |
356 assertEquals( | 356 assertEquals( |
357 'MULTIPART_DEVICE_UNSUPPORTED: label', | 357 'MULTIPART_DEVICE_UNSUPPORTED: label', |
358 chrome.notifications.items['deviceFail:/device/path'].message); | 358 chrome.notifications.items['deviceFail:/device/path'].message); |
359 } | 359 } |
360 | 360 |
361 function testScanCanceled() { | 361 function testScanCanceled() { |
362 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 362 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
363 type: 'scan_started', | 363 type: 'scan_started', |
364 devicePath: '/device/path' | 364 devicePath: '/device/path' |
365 }); | 365 }); |
366 assertTrue('device:/device/path' in chrome.notifications.items); | 366 assertTrue('device:/device/path' in chrome.notifications.items); |
367 assertEquals('Scanning...', | 367 assertEquals('Scanning...', |
368 chrome.notifications.items['device:/device/path'].message); | 368 chrome.notifications.items['device:/device/path'].message); |
369 | 369 |
370 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 370 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
371 type: 'scan_cancelled', | 371 type: 'scan_cancelled', |
372 devicePath: '/device/path' | 372 devicePath: '/device/path' |
373 }); | 373 }); |
374 assertEquals(0, Object.keys(chrome.notifications.items).length); | 374 assertEquals(0, Object.keys(chrome.notifications.items).length); |
375 | 375 |
376 // Nothing happened. | 376 // Nothing happened. |
377 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 377 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
378 type: 'removed', | 378 type: 'removed', |
379 devicePath: '/device/path' | 379 devicePath: '/device/path' |
380 }); | 380 }); |
381 assertEquals(0, Object.keys(chrome.notifications.items).length); | 381 assertEquals(0, Object.keys(chrome.notifications.items).length); |
382 } | 382 } |
383 | 383 |
384 function testDisabledDevice() { | 384 function testDisabledDevice() { |
385 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 385 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
386 type: 'disabled', | 386 type: 'disabled', |
387 devicePath: '/device/path' | 387 devicePath: '/device/path' |
388 }); | 388 }); |
389 assertEquals(1, Object.keys(chrome.notifications.items).length); | 389 assertEquals(1, Object.keys(chrome.notifications.items).length); |
390 assertEquals('EXTERNAL_STORAGE_DISABLED', | 390 assertEquals('EXTERNAL_STORAGE_DISABLED', |
391 chrome.notifications.items['deviceFail:/device/path'].message); | 391 chrome.notifications.items['deviceFail:/device/path'].message); |
392 | 392 |
393 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 393 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
394 type: 'removed', | 394 type: 'removed', |
395 devicePath: '/device/path' | 395 devicePath: '/device/path' |
396 }); | 396 }); |
397 assertEquals(0, Object.keys(chrome.notifications.items).length); | 397 assertEquals(0, Object.keys(chrome.notifications.items).length); |
398 } | 398 } |
399 | 399 |
400 function testFormatSucceeded() { | 400 function testFormatSucceeded() { |
401 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 401 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
402 type: 'format_start', | 402 type: 'format_start', |
403 devicePath: '/device/path' | 403 devicePath: '/device/path' |
404 }); | 404 }); |
405 assertEquals(1, Object.keys(chrome.notifications.items).length); | 405 assertEquals(1, Object.keys(chrome.notifications.items).length); |
406 assertEquals('FORMATTING_OF_DEVICE_PENDING', | 406 assertEquals('FORMATTING_OF_DEVICE_PENDING', |
407 chrome.notifications.items['formatStart:/device/path'].message); | 407 chrome.notifications.items['formatStart:/device/path'].message); |
408 | 408 |
409 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 409 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
410 type: 'format_success', | 410 type: 'format_success', |
411 devicePath: '/device/path' | 411 devicePath: '/device/path' |
412 }); | 412 }); |
413 assertEquals(1, Object.keys(chrome.notifications.items).length); | 413 assertEquals(1, Object.keys(chrome.notifications.items).length); |
414 assertEquals('FORMATTING_FINISHED_SUCCESS', | 414 assertEquals('FORMATTING_FINISHED_SUCCESS', |
415 chrome.notifications.items[ | 415 chrome.notifications.items[ |
416 'formatSuccess:/device/path'].message); | 416 'formatSuccess:/device/path'].message); |
417 } | 417 } |
418 | 418 |
419 function testFormatFailed() { | 419 function testFormatFailed() { |
420 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 420 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
421 type: 'format_start', | 421 type: 'format_start', |
422 devicePath: '/device/path' | 422 devicePath: '/device/path' |
423 }); | 423 }); |
424 assertEquals(1, Object.keys(chrome.notifications.items).length); | 424 assertEquals(1, Object.keys(chrome.notifications.items).length); |
425 assertEquals('FORMATTING_OF_DEVICE_PENDING', | 425 assertEquals('FORMATTING_OF_DEVICE_PENDING', |
426 chrome.notifications.items['formatStart:/device/path'].message); | 426 chrome.notifications.items['formatStart:/device/path'].message); |
427 | 427 |
428 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 428 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
429 type: 'format_fail', | 429 type: 'format_fail', |
430 devicePath: '/device/path' | 430 devicePath: '/device/path' |
431 }); | 431 }); |
432 assertEquals(1, Object.keys(chrome.notifications.items).length); | 432 assertEquals(1, Object.keys(chrome.notifications.items).length); |
433 assertEquals('FORMATTING_FINISHED_FAILURE', | 433 assertEquals('FORMATTING_FINISHED_FAILURE', |
434 chrome.notifications.items['formatFail:/device/path'].message); | 434 chrome.notifications.items['formatFail:/device/path'].message); |
435 } | 435 } |
436 | 436 |
437 function testDeviceHardUnplugged() { | 437 function testDeviceHardUnplugged() { |
438 chrome.fileBrowserPrivate.onDeviceChanged.dispatch({ | 438 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
439 type: 'hard_unplugged', | 439 type: 'hard_unplugged', |
440 devicePath: '/device/path' | 440 devicePath: '/device/path' |
441 }); | 441 }); |
442 assertEquals(1, Object.keys(chrome.notifications.items).length); | 442 assertEquals(1, Object.keys(chrome.notifications.items).length); |
443 assertEquals('DEVICE_HARD_UNPLUGGED_MESSAGE', | 443 assertEquals('DEVICE_HARD_UNPLUGGED_MESSAGE', |
444 chrome.notifications.items[ | 444 chrome.notifications.items[ |
445 'hardUnplugged:/device/path'].message); | 445 'hardUnplugged:/device/path'].message); |
446 } | 446 } |
OLD | NEW |