Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: ui/file_manager/file_manager/common/js/importer_common_unittest.js

Issue 886483004: Include a machine id in log files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to review comments. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 4
5 /** @type {!MockVolumeManager} */ 5 /** @type {!MockVolumeManager} */
6 var volumeManager; 6 var volumeManager;
7 7
8 /** @type {!VolumeInfo} */ 8 /** @type {!VolumeInfo} */
9 var cameraVolume; 9 var cameraVolume;
10 10
11 /** @type {!VolumeInfo} */ 11 /** @type {!VolumeInfo} */
12 var sdVolume; 12 var sdVolume;
13 13
14 /** @type {!VolumeInfo} */ 14 /** @type {!VolumeInfo} */
15 var driveVolume; 15 var driveVolume;
16 16
17 /** @type {!MockFileEntry} */ 17 /** @type {!MockFileEntry} */
18 var cameraFileEntry; 18 var cameraFileEntry;
19 19
20 /** @type {!MockFileEntry} */ 20 /** @type {!MockFileEntry} */
21 var sdFileEntry; 21 var sdFileEntry;
22 22
23 /** @type {!MockFileEntry} */ 23 /** @type {!MockFileEntry} */
24 var driveFileEntry; 24 var driveFileEntry;
25 25
26 // Sadly, boilerplate setup necessary to include test support classes.
27 loadTimeData.data = {
28 DRIVE_DIRECTORY_LABEL: 'My Drive',
29 DOWNLOADS_DIRECTORY_LABEL: 'Downloads'
30 };
31
26 // Set up the test components. 32 // Set up the test components.
27 function setUp() { 33 function setUp() {
28 // Sadly, boilerplate setup necessary to include test support classes.
29 loadTimeData.data = {
30 DRIVE_DIRECTORY_LABEL: 'My Drive',
31 DOWNLOADS_DIRECTORY_LABEL: 'Downloads'
32 };
33 var cameraFileSystem = new MockFileSystem( 34 var cameraFileSystem = new MockFileSystem(
34 'camera-fs', 'filesystem:camera-123'); 35 'camera-fs', 'filesystem:camera-123');
35 var sdFileSystem = new MockFileSystem( 36 var sdFileSystem = new MockFileSystem(
36 'sd-fs', 'filesystem:sd-123'); 37 'sd-fs', 'filesystem:sd-123');
37 cameraVolume = MockVolumeManager.createMockVolumeInfo( 38 cameraVolume = MockVolumeManager.createMockVolumeInfo(
38 VolumeManagerCommon.VolumeType.MTP, 39 VolumeManagerCommon.VolumeType.MTP,
39 'camera-fs', 40 'camera-fs',
40 'Some Camera'); 41 'Some Camera');
41 sdVolume = MockVolumeManager.createMockVolumeInfo( 42 sdVolume = MockVolumeManager.createMockVolumeInfo(
42 VolumeManagerCommon.VolumeType.REMOVABLE, 43 VolumeManagerCommon.VolumeType.REMOVABLE,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 resolver.promise 97 resolver.promise
97 .then(callback.bind(null, true)) 98 .then(callback.bind(null, true))
98 .catch( 99 .catch(
99 function(error) { 100 function(error) {
100 assertTrue(resolver.settled); 101 assertTrue(resolver.settled);
101 assertEquals('ouch', error); 102 assertEquals('ouch', error);
102 callback(false); 103 callback(false);
103 }); 104 });
104 } 105 }
105 106
107 function testGetMachineId(callback) {
108 var storage = new MockChromeStorageAPI();
109
110 var promise = importer.getMachineId().then(
111 function(firstMachineId) {
112 assertTrue(100000 <= firstMachineId <= 9999999);
113 importer.getMachineId().then(
114 function(secondMachineId) {
115 assertEquals(firstMachineId, secondMachineId);
116 });
117 });
118 reportPromise(promise, callback);
119 }
120
121 function testHistoryFilename(callback) {
122 var storage = new MockChromeStorageAPI();
123
124 var promise = importer.getHistoryFilename().then(
125 function(firstName) {
126 assertTrue(!!firstName && firstName.length > 10);
127 importer.getHistoryFilename().then(
128 function(secondName) {
129 assertEquals(firstName, secondName);
130 });
131 });
132
133 reportPromise(promise, callback);
134 }
135
106 /** @param {string} path */ 136 /** @param {string} path */
107 function assertIsMediaDir(path) { 137 function assertIsMediaDir(path) {
108 var dir = createDirectoryEntry(sdVolume, path); 138 var dir = createDirectoryEntry(sdVolume, path);
109 assertTrue(importer.isMediaDirectory(dir, volumeManager)); 139 assertTrue(importer.isMediaDirectory(dir, volumeManager));
110 } 140 }
111 141
112 /** @param {string} path */ 142 /** @param {string} path */
113 function assertIsNotMediaDir(path) { 143 function assertIsNotMediaDir(path) {
114 var dir = createDirectoryEntry(sdVolume, path); 144 var dir = createDirectoryEntry(sdVolume, path);
115 assertFalse(importer.isMediaDirectory(dir, volumeManager)); 145 assertFalse(importer.isMediaDirectory(dir, volumeManager));
(...skipping 12 matching lines...) Expand all
128 return entry; 158 return entry;
129 } 159 }
130 160
131 function createDirectoryEntry(volume, path) { 161 function createDirectoryEntry(volume, path) {
132 var entry = new MockDirectoryEntry(volume.fileSystem, path); 162 var entry = new MockDirectoryEntry(volume.fileSystem, path);
133 // Ensure the file entry has a volumeID...necessary for lookups 163 // Ensure the file entry has a volumeID...necessary for lookups
134 // via the VolumeManager. 164 // via the VolumeManager.
135 entry.volumeId = volume.volumeId; 165 entry.volumeId = volume.volumeId;
136 return entry; 166 return entry;
137 } 167 }
OLDNEW
« no previous file with comments | « ui/file_manager/file_manager/common/js/importer_common.js ('k') | ui/file_manager/file_manager/common/js/unittest_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698