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

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

Issue 663513003: Add an unittest for background/volume_manager.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase: Changed import_history_unittest to use MockFileSystem. Created 6 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_entry.js
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
index 9c0b5924ec5845346d19439d5de0b9a0ec268831..f5968f9678ac3192d8dd71745f21eec8a6903706 100644
--- a/chrome/test/data/file_manager/unit_tests/mocks/mock_entry.js
+++ b/chrome/test/data/file_manager/unit_tests/mocks/mock_entry.js
@@ -13,17 +13,19 @@ function joinPath(a, b) {
};
/**
- * Test file system.
+ * Mock class for DOMFileSystem.
*
- * @param {string} fileSystemId File system ID.
+ * @param {string} volumeId Volume ID.
+ * @param {string} rootURL URL string of root which is used in MockEntry.toURL.
* @constructor
*/
-function TestFileSystem(fileSystemId) {
- this.fileSystemId = fileSystemId;
+function MockFileSystem(volumeId, rootURL) {
+ this.name = volumeId;
this.entries = {};
+ this.rootURL = rootURL;
};
-TestFileSystem.prototype = {
+MockFileSystem.prototype = {
get root() { return this.entries['/']; }
};
@@ -54,7 +56,7 @@ MockEntry.prototype = {
* @return {string} Fake URL.
*/
MockEntry.prototype.toURL = function() {
- return 'filesystem:' + this.filesystem.fileSystemId + this.fullPath;
+ return this.filesystem.rootURL + this.fullPath;
};
/**
@@ -212,3 +214,23 @@ MockDirectoryEntry.prototype.getDirectory =
else
onSuccess(this.filesystem.entries[fullPath]);
};
+
+/**
+ * Creates a MockDirectoryReader for the entry.
+ */
+MockDirectoryEntry.prototype.createReader = function() {
+ return new MockDirectoryReader();
+}
+
+/**
+ * Mock class for DirectoryReader.
+ */
+function MockDirectoryReader() {}
+
+/**
+ * Reads entries.
+ * Current implementation just calls success callback.
+ */
+MockDirectoryReader.prototype.readEntries = function(success, error) {
+ success();
+}

Powered by Google App Engine
This is Rietveld 408576698