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

Unified Diff: chrome/test/data/file_manager/unit_tests/mocks/mock_volume_manager.js

Issue 48623002: [Files.app] Add an unittest of NavigationListModel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/file_manager/unit_tests/mocks/mock_volume_manager.js
diff --git a/chrome/test/data/file_manager/unit_tests/mocks/mock_volume_manager.js b/chrome/test/data/file_manager/unit_tests/mocks/mock_volume_manager.js
new file mode 100644
index 0000000000000000000000000000000000000000..ade2fed6927a7189f15ce81684215f07ecde5ed7
--- /dev/null
+++ b/chrome/test/data/file_manager/unit_tests/mocks/mock_volume_manager.js
@@ -0,0 +1,62 @@
+// 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 VolumeManager.
mtomasz 2013/10/29 07:28:17 @constructor missing
yoshiki 2013/10/31 09:07:23 Done.
+ */
+function MockVolumeManager() {
+ this.volumeInfoList = new cr.ui.ArrayDataModel([]);
+
+ this.volumeInfoList.push(MockVolumeManager.createMockVolumeInfo(
+ util.VolumeType.DRIVE, '/drive'));
+ this.volumeInfoList.push(MockVolumeManager.createMockVolumeInfo(
+ util.VolumeType.DOWNLOADS, '/Downloads'));
+};
mtomasz 2013/10/29 07:28:17 nit: ; redundant
yoshiki 2013/10/31 09:07:23 Done.
+
+/**
+ * Returns the corresponding VolumeInfo.
+ * @param {string} mountPath Path to be looking for with.
+ * @return {VolumeInfo} Corresponding VolumeInfo.
+ */
+MockVolumeManager.prototype.getVolumeInfo = function(mountPath) {
+ for (var i = 0; i < this.volumeInfoList.length; i++) {
+ if (this.volumeInfoList.item(i).mountPath === mountPath)
+ return this.volumeInfoList.item(i);
+ }
+ return null;
+}
mtomasz 2013/10/29 07:28:17 nit: ; missing
yoshiki 2013/10/31 09:07:23 Done.
+
+/**
+ * Resolve FileEntry.
+ * @param {string} path
+ * @param {function(FileEntry)} successCallback Callback on success.
+ * @param {function()} errorCallback Callback on error.
+ */
+MockVolumeManager.prototype.resolvePath = function(
+ path, successCallback, errorCallback) {
+ var mockFileEntry = new MockFileEntry();
+ mockFileEntry.fullPath = path;
+ successCallback(mockFileEntry);
+}
mtomasz 2013/10/29 07:28:17 ditto
yoshiki 2013/10/31 09:07:23 Done.
+
+/**
+ * Utility function to create a mock VolumeInfo.
+ * @param {VolumeType} type Volume type.
+ * @param {string} path Volume path.
+ * @return {VolumeInfo} Created mock VolumeInfo.
+ */
+MockVolumeManager.createMockVolumeInfo = function(type, path) {
+ var entry = new MockFileEntry();
+ entry.fullPath = path;
+
+ var volumeInfo = new VolumeInfo(
+ type,
+ path,
+ entry, // Directory entry.
+ '', // error
+ '', // deviceType
+ false); // readonly
+
+ return volumeInfo;
+}
mtomasz 2013/10/29 07:28:17 ditto
yoshiki 2013/10/31 09:07:23 Done.

Powered by Google App Engine
This is Rietveld 408576698