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

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

Issue 439753002: Files.app: Add the MockDirectoryEntry class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
(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 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698