OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 /** | |
6 * Mock class for VolumeManager. | |
mtomasz
2013/10/29 07:28:17
@constructor missing
yoshiki
2013/10/31 09:07:23
Done.
| |
7 */ | |
8 function MockVolumeManager() { | |
9 this.volumeInfoList = new cr.ui.ArrayDataModel([]); | |
10 | |
11 this.volumeInfoList.push(MockVolumeManager.createMockVolumeInfo( | |
12 util.VolumeType.DRIVE, '/drive')); | |
13 this.volumeInfoList.push(MockVolumeManager.createMockVolumeInfo( | |
14 util.VolumeType.DOWNLOADS, '/Downloads')); | |
15 }; | |
mtomasz
2013/10/29 07:28:17
nit: ; redundant
yoshiki
2013/10/31 09:07:23
Done.
| |
16 | |
17 /** | |
18 * Returns the corresponding VolumeInfo. | |
19 * @param {string} mountPath Path to be looking for with. | |
20 * @return {VolumeInfo} Corresponding VolumeInfo. | |
21 */ | |
22 MockVolumeManager.prototype.getVolumeInfo = function(mountPath) { | |
23 for (var i = 0; i < this.volumeInfoList.length; i++) { | |
24 if (this.volumeInfoList.item(i).mountPath === mountPath) | |
25 return this.volumeInfoList.item(i); | |
26 } | |
27 return null; | |
28 } | |
mtomasz
2013/10/29 07:28:17
nit: ; missing
yoshiki
2013/10/31 09:07:23
Done.
| |
29 | |
30 /** | |
31 * Resolve FileEntry. | |
32 * @param {string} path | |
33 * @param {function(FileEntry)} successCallback Callback on success. | |
34 * @param {function()} errorCallback Callback on error. | |
35 */ | |
36 MockVolumeManager.prototype.resolvePath = function( | |
37 path, successCallback, errorCallback) { | |
38 var mockFileEntry = new MockFileEntry(); | |
39 mockFileEntry.fullPath = path; | |
40 successCallback(mockFileEntry); | |
41 } | |
mtomasz
2013/10/29 07:28:17
ditto
yoshiki
2013/10/31 09:07:23
Done.
| |
42 | |
43 /** | |
44 * Utility function to create a mock VolumeInfo. | |
45 * @param {VolumeType} type Volume type. | |
46 * @param {string} path Volume path. | |
47 * @return {VolumeInfo} Created mock VolumeInfo. | |
48 */ | |
49 MockVolumeManager.createMockVolumeInfo = function(type, path) { | |
50 var entry = new MockFileEntry(); | |
51 entry.fullPath = path; | |
52 | |
53 var volumeInfo = new VolumeInfo( | |
54 type, | |
55 path, | |
56 entry, // Directory entry. | |
57 '', // error | |
58 '', // deviceType | |
59 false); // readonly | |
60 | |
61 return volumeInfo; | |
62 } | |
mtomasz
2013/10/29 07:28:17
ditto
yoshiki
2013/10/31 09:07:23
Done.
| |
OLD | NEW |