| 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...', | |
| 29 REMOVABLE_DEVICE_NAVIGATION_MESSAGE: 'DEVICE_NAVIGATION', | 28 REMOVABLE_DEVICE_NAVIGATION_MESSAGE: 'DEVICE_NAVIGATION', |
| 30 REMOVABLE_DEVICE_NAVIGATION_BUTTON_LABEL: '', | 29 REMOVABLE_DEVICE_NAVIGATION_BUTTON_LABEL: '', |
| 31 DEVICE_UNKNOWN_MESSAGE: 'DEVICE_UNKNOWN: $1', | 30 DEVICE_UNKNOWN_MESSAGE: 'DEVICE_UNKNOWN: $1', |
| 32 DEVICE_UNSUPPORTED_MESSAGE: 'DEVICE_UNSUPPORTED: $1', | 31 DEVICE_UNSUPPORTED_MESSAGE: 'DEVICE_UNSUPPORTED: $1', |
| 33 DEVICE_HARD_UNPLUGGED_TITLE: 'DEVICE_HARD_UNPLUGGED_TITLE', | 32 DEVICE_HARD_UNPLUGGED_TITLE: 'DEVICE_HARD_UNPLUGGED_TITLE', |
| 34 DEVICE_HARD_UNPLUGGED_MESSAGE: 'DEVICE_HARD_UNPLUGGED_MESSAGE', | 33 DEVICE_HARD_UNPLUGGED_MESSAGE: 'DEVICE_HARD_UNPLUGGED_MESSAGE', |
| 35 MULTIPART_DEVICE_UNSUPPORTED_MESSAGE: 'MULTIPART_DEVICE_UNSUPPORTED: $1', | 34 MULTIPART_DEVICE_UNSUPPORTED_MESSAGE: 'MULTIPART_DEVICE_UNSUPPORTED: $1', |
| 36 EXTERNAL_STORAGE_DISABLED_MESSAGE: 'EXTERNAL_STORAGE_DISABLED', | 35 EXTERNAL_STORAGE_DISABLED_MESSAGE: 'EXTERNAL_STORAGE_DISABLED', |
| 37 FORMATTING_OF_DEVICE_PENDING_TITLE: 'FORMATTING_OF_DEVICE_PENDING_TITLE', | 36 FORMATTING_OF_DEVICE_PENDING_TITLE: 'FORMATTING_OF_DEVICE_PENDING_TITLE', |
| 38 FORMATTING_OF_DEVICE_PENDING_MESSAGE: 'FORMATTING_OF_DEVICE_PENDING', | 37 FORMATTING_OF_DEVICE_PENDING_MESSAGE: 'FORMATTING_OF_DEVICE_PENDING', |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 deviceLabel: 'label' | 350 deviceLabel: 'label' |
| 352 }, | 351 }, |
| 353 shouldNotify: true | 352 shouldNotify: true |
| 354 }); | 353 }); |
| 355 assertEquals(1, Object.keys(chrome.notifications.items).length); | 354 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 356 assertEquals( | 355 assertEquals( |
| 357 'MULTIPART_DEVICE_UNSUPPORTED: label', | 356 'MULTIPART_DEVICE_UNSUPPORTED: label', |
| 358 chrome.notifications.items['deviceFail:/device/path'].message); | 357 chrome.notifications.items['deviceFail:/device/path'].message); |
| 359 } | 358 } |
| 360 | 359 |
| 361 function testScanCanceled() { | |
| 362 chrome.fileManagerPrivate.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); | |
| 369 | |
| 370 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ | |
| 371 type: 'scan_cancelled', | |
| 372 devicePath: '/device/path' | |
| 373 }); | |
| 374 assertEquals(0, Object.keys(chrome.notifications.items).length); | |
| 375 | |
| 376 // Nothing happened. | |
| 377 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ | |
| 378 type: 'removed', | |
| 379 devicePath: '/device/path' | |
| 380 }); | |
| 381 assertEquals(0, Object.keys(chrome.notifications.items).length); | |
| 382 } | |
| 383 | |
| 384 function testDisabledDevice() { | 360 function testDisabledDevice() { |
| 385 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ | 361 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
| 386 type: 'disabled', | 362 type: 'disabled', |
| 387 devicePath: '/device/path' | 363 devicePath: '/device/path' |
| 388 }); | 364 }); |
| 389 assertEquals(1, Object.keys(chrome.notifications.items).length); | 365 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 390 assertEquals('EXTERNAL_STORAGE_DISABLED', | 366 assertEquals('EXTERNAL_STORAGE_DISABLED', |
| 391 chrome.notifications.items['deviceFail:/device/path'].message); | 367 chrome.notifications.items['deviceFail:/device/path'].message); |
| 392 | 368 |
| 393 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ | 369 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 function testDeviceHardUnplugged() { | 413 function testDeviceHardUnplugged() { |
| 438 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ | 414 chrome.fileManagerPrivate.onDeviceChanged.dispatch({ |
| 439 type: 'hard_unplugged', | 415 type: 'hard_unplugged', |
| 440 devicePath: '/device/path' | 416 devicePath: '/device/path' |
| 441 }); | 417 }); |
| 442 assertEquals(1, Object.keys(chrome.notifications.items).length); | 418 assertEquals(1, Object.keys(chrome.notifications.items).length); |
| 443 assertEquals('DEVICE_HARD_UNPLUGGED_MESSAGE', | 419 assertEquals('DEVICE_HARD_UNPLUGGED_MESSAGE', |
| 444 chrome.notifications.items[ | 420 chrome.notifications.items[ |
| 445 'hardUnplugged:/device/path'].message); | 421 'hardUnplugged:/device/path'].message); |
| 446 } | 422 } |
| OLD | NEW |