diff options
author | hirono@chromium.org <hirono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-05 08:20:41 +0000 |
---|---|---|
committer | hirono@chromium.org <hirono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-05 08:20:41 +0000 |
commit | 4d94a6680a999ed995203a46c8cb905f14bd716a (patch) | |
tree | 77fe8e85748a255ce15f759a8edabb9b246cd732 /chrome/test | |
parent | cbca73279f9719247a79877f2a4a278d66e5715d (diff) | |
download | chromium_src-4d94a6680a999ed995203a46c8cb905f14bd716a.zip chromium_src-4d94a6680a999ed995203a46c8cb905f14bd716a.tar.gz chromium_src-4d94a6680a999ed995203a46c8cb905f14bd716a.tar.bz2 |
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
Diffstat (limited to 'chrome/test')
4 files changed, 76 insertions, 27 deletions
diff --git a/chrome/test/data/file_manager/unit_tests/metadata_cache_unittest.html b/chrome/test/data/file_manager/unit_tests/metadata_cache_unittest.html index 0732456..97f8fea 100644 --- a/chrome/test/data/file_manager/unit_tests/metadata_cache_unittest.html +++ b/chrome/test/data/file_manager/unit_tests/metadata_cache_unittest.html @@ -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> diff --git a/chrome/test/data/file_manager/unit_tests/mocks/mock_entry.js b/chrome/test/data/file_manager/unit_tests/mocks/mock_entry.js new file mode 100644 index 0000000..5110334 --- /dev/null +++ b/chrome/test/data/file_manager/unit_tests/mocks/mock_entry.js @@ -0,0 +1,73 @@ +// 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]); +}; diff --git a/chrome/test/data/file_manager/unit_tests/mocks/mock_file_entry.js b/chrome/test/data/file_manager/unit_tests/mocks/mock_file_entry.js deleted file mode 100644 index c16a63d..0000000 --- a/chrome/test/data/file_manager/unit_tests/mocks/mock_file_entry.js +++ /dev/null @@ -1,24 +0,0 @@ -// 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; -}; diff --git a/chrome/test/data/file_manager/unit_tests/navigation_list_model_unittest.html b/chrome/test/data/file_manager/unit_tests/navigation_list_model_unittest.html index 5b980a8..2cedd98 100644 --- a/chrome/test/data/file_manager/unit_tests/navigation_list_model_unittest.html +++ b/chrome/test/data/file_manager/unit_tests/navigation_list_model_unittest.html @@ -1,5 +1,5 @@ <!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> |