OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 /** | |
6 * Mock class for FileEntry. | |
7 * | |
8 * @param {string} volumeId Id of the volume containing the entry. | |
9 * @param {string} fullPath Full path for the entry. | |
10 * @constructor | |
11 */ | |
12 function MockFileEntry(volumeId, fullPath) { | |
13 this.volumeId = volumeId; | |
14 this.fullPath = fullPath; | |
15 } | |
16 | |
17 /** | |
18 * Returns fake URL. | |
19 * | |
20 * @return {string} Fake URL. | |
21 */ | |
22 MockFileEntry.prototype.toURL = function() { | |
23 return 'filesystem:' + this.volumeId + this.fullPath; | |
24 }; | |
25 | |
26 /** | |
27 * Mock class for DirectoryEntry. | |
28 * | |
29 * @param {string} volumeId Id of the volume containing the entry. | |
30 * @param {string} fullPath Full path for the entry. | |
yoshiki
2014/08/04 16:35:52
jsdoc for 'contents'
hirono
2014/08/05 01:44:38
Done.
| |
31 * @constructor | |
32 */ | |
33 function MockDirectoryEntry(volumeId, fullPath, contents) { | |
34 this.contents_ = contents; | |
35 } | |
36 | |
37 /** | |
38 * Returns a file under the directory. | |
39 * | |
40 * @param {string} path Path. | |
41 * @param {Object} option Option. | |
42 * @param {callback(MockFileEntry)} successCallback Success callback. | |
43 * @param {callback(Object}} failureCallback Failure callback; | |
44 */ | |
45 MockDirectoryEntry.prototype.getFile = function( | |
46 path, option, successCallback, failureCallback) { | |
47 if (!this.contents_[path]) | |
48 failureCallback({name: util.FileError.NOT_FOUND_ERR}); | |
49 else if (!(this.contents_[path] instanceof MockFileEntry)) | |
50 failureCallback({name: util.FileError.TYPE_MISMATCH_ERR}); | |
51 else | |
52 successCallback(this.contents_[path]); | |
53 }; | |
54 | |
55 /** | |
56 * Returns a directory under the directory. | |
57 * | |
58 * @param {string} path Path. | |
59 * @param {Object} option Option. | |
60 * @param {callback(MockDirectoryEntry)} successCallback Success callback. | |
61 * @param {callback(Object}} failureCallback Failure callback; | |
62 */ | |
63 MockDirectoryEntry.prototype.getDirectory = | |
64 function(path, option, successCallback, failureCallback) { | |
65 if (!this.contents_[path]) | |
66 failureCallback({name: util.FileError.NOT_FOUND_ERR}); | |
67 else if (!(this.contents_[path] instanceof MockDirectoryEntry)) | |
68 failureCallback({name: util.FileError.TYPE_MISMATCH_ERR}); | |
69 else | |
70 successCallback(this.contents_[path]); | |
71 }; | |
OLD | NEW |