Commit 4d94a668 authored by hirono@chromium.org's avatar hirono@chromium.org

Files.app: Add the MockDirectoryEntry class.

BUG=315439
TEST=run the js tests.

Review URL: https://codereview.chromium.org/439753002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287496 0039d316-1c4b-4281-b951-d872f2087c98
parent cbca7327
......@@ -8,7 +8,7 @@
<body>
<script src="../../../../../ui/file_manager/file_manager/foreground/js/metadata/metadata_cache.js"></script>
<script src="mocks/mock_file_entry.js"></script>
<script src="mocks/mock_entry.js"></script>
<script src="metadata_cache_unittest.js"></script>
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* Mock class for FileEntry.
*
* @param {string} volumeId Id of the volume containing the entry.
* @param {string} fullPath Full path for the entry.
* @constructor
*/
function MockFileEntry(volumeId, fullPath) {
this.volumeId = volumeId;
this.fullPath = fullPath;
}
/**
* Returns fake URL.
*
* @return {string} Fake URL.
*/
MockFileEntry.prototype.toURL = function() {
return 'filesystem:' + this.volumeId + this.fullPath;
};
/**
* Mock class for DirectoryEntry.
*
* @param {string} volumeId Id of the volume containing the entry.
* @param {string} fullPath Full path for the entry.
* @param {Object.<String, MockFileEntry|MockDirectoryEntry>} contents Map of
* path and MockEntry contained in the directory.
* @constructor
*/
function MockDirectoryEntry(volumeId, fullPath, contents) {
this.contents_ = contents;
}
/**
* Returns a file under the directory.
*
* @param {string} path Path.
* @param {Object} option Option.
* @param {callback(MockFileEntry)} successCallback Success callback.
* @param {callback(Object)} failureCallback Failure callback;
*/
MockDirectoryEntry.prototype.getFile = function(
path, option, successCallback, failureCallback) {
if (!this.contents_[path])
failureCallback({name: util.FileError.NOT_FOUND_ERR});
else if (!(this.contents_[path] instanceof MockFileEntry))
failureCallback({name: util.FileError.TYPE_MISMATCH_ERR});
else
successCallback(this.contents_[path]);
};
/**
* Returns a directory under the directory.
*
* @param {string} path Path.
* @param {Object} option Option.
* @param {callback(MockDirectoryEntry)} successCallback Success callback.
* @param {callback(Object)} failureCallback Failure callback;
*/
MockDirectoryEntry.prototype.getDirectory =
function(path, option, successCallback, failureCallback) {
if (!this.contents_[path])
failureCallback({name: util.FileError.NOT_FOUND_ERR});
else if (!(this.contents_[path] instanceof MockDirectoryEntry))
failureCallback({name: util.FileError.TYPE_MISMATCH_ERR});
else
successCallback(this.contents_[path]);
};
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* Mock class for FileEntry.
*
* @param {string} volumeId Id of the volume containing the entry.
* @param {string} fullPath Full path for the entry.
* @constructor
*/
function MockFileEntry(volumeId, fullPath) {
this.volumeId = volumeId;
this.fullPath = fullPath;
}
/**
* Returns fake URL.
*
* @return {string} Fake URL.
*/
MockFileEntry.prototype.toURL = function() {
return 'filesystem:' + this.volumeId + this.fullPath;
};
<!DOCTYPE html>
<!-- Copyright 2013 The Chromium Authors. All rights reserved.
<!-- Copyright 2014 The Chromium Authors. All rights reserved.
-- Use of this source code is governed by a BSD-style license that can be
-- found in the LICENSE file.
-->
......@@ -20,7 +20,7 @@
<script src="../../../../../ui/file_manager/file_manager/background/js/volume_manager.js"></script>
<script src="../../../../../ui/file_manager/file_manager/foreground/js/navigation_list_model.js"></script>
<script src="mocks/mock_file_entry.js"></script>
<script src="mocks/mock_entry.js"></script>
<script src="mocks/mock_file_system.js"></script>
<script src="mocks/mock_volume_manager.js"></script>
<script src="mocks/mock_folder_shortcut_data_model.js"></script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment