1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * Mock class for VolumeManager.
9 function MockVolumeManager() {
10 this.volumeInfoList = new cr.ui.ArrayDataModel([]);
12 this.volumeInfoList.push(MockVolumeManager.createMockVolumeInfo(
13 VolumeManagerCommon.VolumeType.DRIVE, 'drive'));
14 this.volumeInfoList.push(MockVolumeManager.createMockVolumeInfo(
15 VolumeManagerCommon.VolumeType.DOWNLOADS, 'downloads'));
19 * Returns the corresponding VolumeInfo.
21 * @param {MockFileEntry} entry MockFileEntry pointing anywhere on a volume.
22 * @return {VolumeInfo} Corresponding VolumeInfo.
24 MockVolumeManager.prototype.getVolumeInfo = function(entry) {
25 for (var i = 0; i < this.volumeInfoList.length; i++) {
26 if (this.volumeInfoList.item(i).volumeId === entry.volumeId)
27 return this.volumeInfoList.item(i);
33 * Utility function to create a mock VolumeInfo.
34 * @param {VolumeType} type Volume type.
35 * @param {string} path Volume path.
36 * @return {VolumeInfo} Created mock VolumeInfo.
38 MockVolumeManager.createMockVolumeInfo = function(type, volumeId) {
39 var fileSystem = new MockFileSystem(volumeId, 'filesystem:' + volumeId);
40 fileSystem.entries['/'] = new MockDirectoryEntry(fileSystem, '/');
42 var volumeInfo = new VolumeInfo(
50 {isCurrentProfile: true, displayName: ''}, // profile