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

Side by Side Diff: chrome/test/data/file_manager/unit_tests/volume_manager_unittest.js

Issue 762593006: Prototype implementation of MediaImportHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move MediaImportHandler into the importer namespace; make the import destination pluggable. Created 6 years 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 var chrome; 5 var chrome;
6 6
7 loadTimeData.data = { 7 loadTimeData.data = {
8 DRIVE_DIRECTORY_LABEL: 'My Drive', 8 DRIVE_DIRECTORY_LABEL: 'My Drive',
9 DOWNLOADS_DIRECTORY_LABEL: 'Downloads' 9 DOWNLOADS_DIRECTORY_LABEL: 'Downloads'
10 }; 10 };
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 }, 83 },
84 { 84 {
85 volumeId: 'drive:drive-foobar%40chromium.org-hash', 85 volumeId: 'drive:drive-foobar%40chromium.org-hash',
86 volumeLabel: '', 86 volumeLabel: '',
87 volumeType: VolumeManagerCommon.VolumeType.DRIVE, 87 volumeType: VolumeManagerCommon.VolumeType.DRIVE,
88 isReadOnly: false, 88 isReadOnly: false,
89 profile: getMockProfile() 89 profile: getMockProfile()
90 } 90 }
91 ]; 91 ];
92 chrome.fileManagerPrivate.fileSystemMap_ = { 92 chrome.fileManagerPrivate.fileSystemMap_ = {
93 'download:Downloads': createMockFileSystem('download:Downloads'), 93 'download:Downloads': new MockFileSystem('download:Downloads'),
94 'drive:drive-foobar%40chromium.org-hash': 94 'drive:drive-foobar%40chromium.org-hash':
95 createMockFileSystem('drive:drive-foobar%40chromium.org-hash') 95 new MockFileSystem('drive:drive-foobar%40chromium.org-hash')
96 }; 96 };
97 } 97 }
98 98
99 function tearDown() { 99 function tearDown() {
100 VolumeManager.revokeInstanceForTesting(); 100 VolumeManager.revokeInstanceForTesting();
101 chrome = null; 101 chrome = null;
102 } 102 }
103 103
104 /** 104 /**
105 * Returns a mock profile. 105 * Returns a mock profile.
106 * 106 *
107 * @return {{displayName:string, isCurrentProfile:boolean, profileId:string}} 107 * @return {{displayName:string, isCurrentProfile:boolean, profileId:string}}
108 * Mock profile 108 * Mock profile
109 */ 109 */
110 function getMockProfile() { 110 function getMockProfile() {
111 return { 111 return {
112 displayName: 'foobar@chromium.org', 112 displayName: 'foobar@chromium.org',
113 isCurrentProfile: true, 113 isCurrentProfile: true,
114 profileId: '' 114 profileId: ''
115 }; 115 };
116 } 116 }
117 117
118 /**
119 * Creates a mock file system.
120 *
121 * @return {MockFileSystem} A mock file system.
122 */
123 function createMockFileSystem(volumeId) {
124 var fileSystem = new MockFileSystem(volumeId, 'filesystem:' + volumeId);
125 fileSystem.entries['/'] = new MockDirectoryEntry(fileSystem, '/');
126 return fileSystem;
127 }
128
129 function testGetVolumeInfo(callback) { 118 function testGetVolumeInfo(callback) {
130 reportPromise(VolumeManager.getInstance().then(function(volumeManager) { 119 reportPromise(VolumeManager.getInstance().then(function(volumeManager) {
131 var entry = new MockFileEntry(createMockFileSystem('download:Downloads'), 120 var entry = new MockFileEntry(new MockFileSystem('download:Downloads'),
132 '/foo/bar/bla.zip'); 121 '/foo/bar/bla.zip');
133 122
134 var volumeInfo = volumeManager.getVolumeInfo(entry); 123 var volumeInfo = volumeManager.getVolumeInfo(entry);
135 assertEquals('download:Downloads', volumeInfo.volumeId); 124 assertEquals('download:Downloads', volumeInfo.volumeId);
136 assertEquals(VolumeManagerCommon.VolumeType.DOWNLOADS, 125 assertEquals(VolumeManagerCommon.VolumeType.DOWNLOADS,
137 volumeInfo.volumeType); 126 volumeInfo.volumeType);
138 }), callback); 127 }), callback);
139 } 128 }
140 129
141 function testGetDriveConnectionState(callback) { 130 function testGetDriveConnectionState(callback) {
(...skipping 14 matching lines...) Expand all
156 assertEquals(VolumeManagerCommon.DriveConnectionType.ONLINE, 145 assertEquals(VolumeManagerCommon.DriveConnectionType.ONLINE,
157 volumeManager.getDriveConnectionState()); 146 volumeManager.getDriveConnectionState());
158 }), callback); 147 }), callback);
159 } 148 }
160 149
161 function testMountArchiveAndUnmount(callback) { 150 function testMountArchiveAndUnmount(callback) {
162 // Set states of mock fileManagerPrivate APIs. 151 // Set states of mock fileManagerPrivate APIs.
163 const mountSourcePath = '/usr/local/home/test/Downloads/foobar.zip'; 152 const mountSourcePath = '/usr/local/home/test/Downloads/foobar.zip';
164 chrome.fileManagerPrivate.mountSourcePath_ = mountSourcePath; 153 chrome.fileManagerPrivate.mountSourcePath_ = mountSourcePath;
165 chrome.fileManagerPrivate.fileSystemMap_['archive:foobar.zip'] = 154 chrome.fileManagerPrivate.fileSystemMap_['archive:foobar.zip'] =
166 createMockFileSystem('archive:foobar.zip'); 155 new MockFileSystem('archive:foobar.zip');
167 156
168 reportPromise(VolumeManager.getInstance().then(function(volumeManager) { 157 reportPromise(VolumeManager.getInstance().then(function(volumeManager) {
169 var numberOfVolumes = volumeManager.volumeInfoList.length; 158 var numberOfVolumes = volumeManager.volumeInfoList.length;
170 159
171 return new Promise(function(resolve, reject) { 160 return new Promise(function(resolve, reject) {
172 // Mount an archieve 161 // Mount an archieve
173 volumeManager.mountArchive( 162 volumeManager.mountArchive(
174 'filesystem:chrome-extension://extensionid/external/Downloads-test/' + 163 'filesystem:chrome-extension://extensionid/external/Downloads-test/' +
175 'foobar.zip', 164 'foobar.zip',
176 resolve, reject); 165 resolve, reject);
(...skipping 13 matching lines...) Expand all
190 }).then(function(result) { 179 }).then(function(result) {
191 assertEquals(numberOfVolumes + 1, volumeManager.volumeInfoList.length); 180 assertEquals(numberOfVolumes + 1, volumeManager.volumeInfoList.length);
192 181
193 return new Promise(function(resolve, reject) { 182 return new Promise(function(resolve, reject) {
194 // Unmount the mounted archievea 183 // Unmount the mounted archievea
195 volumeManager.volumeInfoList.addEventListener('splice', function(e) { 184 volumeManager.volumeInfoList.addEventListener('splice', function(e) {
196 assertEquals(numberOfVolumes, volumeManager.volumeInfoList.length); 185 assertEquals(numberOfVolumes, volumeManager.volumeInfoList.length);
197 resolve(true); 186 resolve(true);
198 }); 187 });
199 var entry = new MockFileEntry( 188 var entry = new MockFileEntry(
200 createMockFileSystem('archive:foobar.zip'), 189 new MockFileSystem('archive:foobar.zip'),
201 '/foo.txt'); 190 '/foo.txt');
202 var volumeInfo = volumeManager.getVolumeInfo(entry); 191 var volumeInfo = volumeManager.getVolumeInfo(entry);
203 volumeManager.unmount(volumeInfo); 192 volumeManager.unmount(volumeInfo);
204 }); 193 });
205 }); 194 });
206 }), callback); 195 }), callback);
207 } 196 }
208 197
209 function testGetCurrentProfileVolumeInfo(callback) { 198 function testGetCurrentProfileVolumeInfo(callback) {
210 reportPromise(VolumeManager.getInstance().then(function(volumeManager) { 199 reportPromise(VolumeManager.getInstance().then(function(volumeManager) {
211 var volumeInfo = volumeManager.getCurrentProfileVolumeInfo( 200 var volumeInfo = volumeManager.getCurrentProfileVolumeInfo(
212 VolumeManagerCommon.VolumeType.DRIVE); 201 VolumeManagerCommon.VolumeType.DRIVE);
213 202
214 assertEquals('drive:drive-foobar%40chromium.org-hash', 203 assertEquals('drive:drive-foobar%40chromium.org-hash',
215 volumeInfo.volumeId); 204 volumeInfo.volumeId);
216 assertEquals(VolumeManagerCommon.VolumeType.DRIVE, volumeInfo.volumeType); 205 assertEquals(VolumeManagerCommon.VolumeType.DRIVE, volumeInfo.volumeType);
217 }), callback); 206 }), callback);
218 } 207 }
219 208
220 function testGetLocationInfo(callback) { 209 function testGetLocationInfo(callback) {
221 reportPromise(VolumeManager.getInstance().then(function(volumeManager) { 210 reportPromise(VolumeManager.getInstance().then(function(volumeManager) {
222 var downloadEntry = new MockFileEntry( 211 var downloadEntry = new MockFileEntry(
223 createMockFileSystem('download:Downloads'), 212 new MockFileSystem('download:Downloads'),
224 '/foo/bar/bla.zip'); 213 '/foo/bar/bla.zip');
225 var downloadLocationInfo = volumeManager.getLocationInfo(downloadEntry); 214 var downloadLocationInfo = volumeManager.getLocationInfo(downloadEntry);
226 assertEquals(VolumeManagerCommon.VolumeType.DOWNLOADS, 215 assertEquals(VolumeManagerCommon.VolumeType.DOWNLOADS,
227 downloadLocationInfo.rootType) 216 downloadLocationInfo.rootType)
228 assertFalse(downloadLocationInfo.isReadOnly); 217 assertFalse(downloadLocationInfo.isReadOnly);
229 assertFalse(downloadLocationInfo.isRootEntry); 218 assertFalse(downloadLocationInfo.isRootEntry);
230 219
231 var driveEntry = new MockFileEntry( 220 var driveEntry = new MockFileEntry(
232 createMockFileSystem('drive:drive-foobar%40chromium.org-hash'), 221 new MockFileSystem('drive:drive-foobar%40chromium.org-hash'),
233 '/root'); 222 '/root');
234 var driveLocationInfo = volumeManager.getLocationInfo(driveEntry); 223 var driveLocationInfo = volumeManager.getLocationInfo(driveEntry);
235 assertEquals(VolumeManagerCommon.VolumeType.DRIVE, 224 assertEquals(VolumeManagerCommon.VolumeType.DRIVE,
236 driveLocationInfo.rootType) 225 driveLocationInfo.rootType)
237 assertFalse(driveLocationInfo.isReadOnly); 226 assertFalse(driveLocationInfo.isReadOnly);
238 assertTrue(driveLocationInfo.isRootEntry); 227 assertTrue(driveLocationInfo.isRootEntry);
239 }), callback); 228 }), callback);
240 } 229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698