// Set up string assets.
loadTimeData.data = {
REMOVABLE_DEVICE_DETECTION_TITLE: 'Device detected',
- REMOVABLE_DEVICE_SCANNING_MESSAGE: 'Scanning...',
+ REMOVABLE_DEVICE_NAVIGATION_MESSAGE: 'DEVICE_NAVIGATION',
+ REMOVABLE_DEVICE_NAVIGATION_BUTTON_LABEL: '',
DEVICE_UNKNOWN_MESSAGE: 'DEVICE_UNKNOWN: $1',
DEVICE_UNSUPPORTED_MESSAGE: 'DEVICE_UNSUPPORTED: $1',
DEVICE_HARD_UNPLUGGED_TITLE: 'DEVICE_HARD_UNPLUGGED_TITLE',
// Make dummy APIs.
chrome = {
- fileBrowserPrivate: {
+ fileManagerPrivate: {
onDeviceChanged: {
addListener: function(listener) {
this.dispatch = listener;
},
notifications: {
create: function(id, params, callback) {
- assertFalse(!!this.items[id]);
this.items[id] = params;
callback();
},
}
};
- // Reset timeout callbacks.
- timeoutCallbacks = [];
-
// Make a device handler.
handler = new DeviceHandler();
}
-/**
- * Overrided setTimoeut funciton.
- */
-window.setTimeout = function(func) {
- timeoutCallbacks.push(func);
-};
-
-/**
- * Call all pending timeout functions.
- */
-function callTimeoutCallbacks() {
- while (timeoutCallbacks.length) {
- timeoutCallbacks.shift()();
- }
-}
-
-function registerTypicalDevice() {
- chrome.fileBrowserPrivate.onDeviceChanged.dispatch({
- type: 'added',
- devicePath: '/device/path'
+function testGoodDevice() {
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
+ status: 'success',
+ volumeMetadata: {
+ isParentDevice: true,
+ deviceType: 'usb',
+ devicePath: '/device/path',
+ deviceLabel: 'label'
+ },
+ shouldNotify: true
});
- assertFalse('device:/device/path' in chrome.notifications.items);
- callTimeoutCallbacks();
- assertEquals('Scanning...',
- chrome.notifications.items['device:/device/path'].message);
+ assertEquals(1, Object.keys(chrome.notifications.items).length);
+ assertEquals(
+ 'DEVICE_NAVIGATION',
+ chrome.notifications.items['deviceNavigation:/device/path'].message);
}
-function testGoodDevice() {
- registerTypicalDevice();
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+function testGoodDeviceNotNavigated() {
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'success',
volumeMetadata: {
isParentDevice: true,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: false
});
assertEquals(0, Object.keys(chrome.notifications.items).length);
}
function testGoodDeviceWithBadParent() {
- registerTypicalDevice();
-
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'error_internal',
volumeMetadata: {
isParentDevice: true,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
assertFalse(!!chrome.notifications.items['device:/device/path']);
assertEquals(
'DEVICE_UNKNOWN: label',
chrome.notifications.items['deviceFail:/device/path'].message);
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'success',
volumeMetadata: {
isParentDevice: false,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
- assertEquals(0, Object.keys(chrome.notifications.items).length);
+ assertEquals(1, Object.keys(chrome.notifications.items).length);
+ assertEquals(
+ 'DEVICE_NAVIGATION',
+ chrome.notifications.items['deviceNavigation:/device/path'].message);
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'success',
volumeMetadata: {
isParentDevice: false,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
// Should do nothing this time.
- assertEquals(0, Object.keys(chrome.notifications.items).length);
+ assertEquals(1, Object.keys(chrome.notifications.items).length);
+ assertEquals(
+ 'DEVICE_NAVIGATION',
+ chrome.notifications.items['deviceNavigation:/device/path'].message);
}
function testUnsupportedDevice() {
- registerTypicalDevice();
-
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'error_unsupported_filesystem',
volumeMetadata: {
isParentDevice: false,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
assertFalse(!!chrome.notifications.items['device:/device/path']);
assertEquals(
}
function testUnsupportedWithUnknownParent() {
- registerTypicalDevice();
-
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'error_internal',
volumeMetadata: {
isParentDevice: true,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
assertEquals(
'DEVICE_UNKNOWN: label',
chrome.notifications.items['deviceFail:/device/path'].message);
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'error_unsupported_filesystem',
volumeMetadata: {
isParentDevice: false,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
assertEquals(1, Object.keys(chrome.notifications.items).length);
assertEquals(
}
function testMountPartialSuccess() {
- registerTypicalDevice();
-
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'success',
volumeMetadata: {
isParentDevice: false,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
- assertEquals(0, Object.keys(chrome.notifications.items).length);
+ assertEquals(1, Object.keys(chrome.notifications.items).length);
+ assertEquals(
+ 'DEVICE_NAVIGATION',
+ chrome.notifications.items['deviceNavigation:/device/path'].message);
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'error_unsupported_filesystem',
volumeMetadata: {
isParentDevice: false,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
- assertEquals(1, Object.keys(chrome.notifications.items).length);
+ assertEquals(2, Object.keys(chrome.notifications.items).length);
assertEquals(
'MULTIPART_DEVICE_UNSUPPORTED: label',
chrome.notifications.items['deviceFail:/device/path'].message);
}
function testUnknown() {
- registerTypicalDevice();
-
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'error_unknown',
volumeMetadata: {
isParentDevice: false,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
assertEquals(1, Object.keys(chrome.notifications.items).length);
assertEquals(
}
function testNonASCIILabel() {
- registerTypicalDevice();
-
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'error_internal',
volumeMetadata: {
isParentDevice: false,
devicePath: '/device/path',
// "RA (U+30E9) BE (U+30D9) RU (U+30EB)" in Katakana letters.
deviceLabel: '\u30E9\u30D9\u30EB'
- }
+ },
+ shouldNotify: true
});
assertEquals(1, Object.keys(chrome.notifications.items).length);
assertEquals(
}
function testMulitpleFail() {
- registerTypicalDevice();
-
// The first parent error.
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'error_internal',
volumeMetadata: {
isParentDevice: true,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
assertEquals(1, Object.keys(chrome.notifications.items).length);
assertEquals(
chrome.notifications.items['deviceFail:/device/path'].message);
// The first child error that replaces the parent error.
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'error_internal',
volumeMetadata: {
isParentDevice: false,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
assertEquals(1, Object.keys(chrome.notifications.items).length);
assertEquals(
chrome.notifications.items['deviceFail:/device/path'].message);
// The second child error that turns to a multi-partition error.
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'error_internal',
volumeMetadata: {
isParentDevice: false,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
assertEquals(1, Object.keys(chrome.notifications.items).length);
assertEquals(
// The third child error that should be ignored because the error message does
// not changed.
- chrome.fileBrowserPrivate.onMountCompleted.dispatch({
+ chrome.fileManagerPrivate.onMountCompleted.dispatch({
+ eventType: 'mount',
status: 'error_internal',
volumeMetadata: {
isParentDevice: false,
deviceType: 'usb',
devicePath: '/device/path',
deviceLabel: 'label'
- }
+ },
+ shouldNotify: true
});
assertEquals(1, Object.keys(chrome.notifications.items).length);
assertEquals(
chrome.notifications.items['deviceFail:/device/path'].message);
}
-function testScanCanceled() {
- registerTypicalDevice();
-
- chrome.fileBrowserPrivate.onDeviceChanged.dispatch({
- type: 'scan_canceled',
- devicePath: '/device/path'
- });
- assertEquals(0, Object.keys(chrome.notifications.items).length);
-
- // Nothing happened.
- chrome.fileBrowserPrivate.onDeviceChanged.dispatch({
- type: 'removed',
- devicePath: '/device/path'
- });
- assertEquals(0, Object.keys(chrome.notifications.items).length);
-}
-
function testDisabledDevice() {
- chrome.fileBrowserPrivate.onDeviceChanged.dispatch({
+ chrome.fileManagerPrivate.onDeviceChanged.dispatch({
type: 'disabled',
devicePath: '/device/path'
});
assertEquals('EXTERNAL_STORAGE_DISABLED',
chrome.notifications.items['deviceFail:/device/path'].message);
- chrome.fileBrowserPrivate.onDeviceChanged.dispatch({
+ chrome.fileManagerPrivate.onDeviceChanged.dispatch({
type: 'removed',
devicePath: '/device/path'
});
}
function testFormatSucceeded() {
- chrome.fileBrowserPrivate.onDeviceChanged.dispatch({
+ chrome.fileManagerPrivate.onDeviceChanged.dispatch({
type: 'format_start',
devicePath: '/device/path'
});
assertEquals('FORMATTING_OF_DEVICE_PENDING',
chrome.notifications.items['formatStart:/device/path'].message);
- chrome.fileBrowserPrivate.onDeviceChanged.dispatch({
+ chrome.fileManagerPrivate.onDeviceChanged.dispatch({
type: 'format_success',
devicePath: '/device/path'
});
}
function testFormatFailed() {
- chrome.fileBrowserPrivate.onDeviceChanged.dispatch({
+ chrome.fileManagerPrivate.onDeviceChanged.dispatch({
type: 'format_start',
devicePath: '/device/path'
});
assertEquals('FORMATTING_OF_DEVICE_PENDING',
chrome.notifications.items['formatStart:/device/path'].message);
- chrome.fileBrowserPrivate.onDeviceChanged.dispatch({
+ chrome.fileManagerPrivate.onDeviceChanged.dispatch({
type: 'format_fail',
devicePath: '/device/path'
});
}
function testDeviceHardUnplugged() {
- chrome.fileBrowserPrivate.onDeviceChanged.dispatch({
+ chrome.fileManagerPrivate.onDeviceChanged.dispatch({
type: 'hard_unplugged',
devicePath: '/device/path'
});