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

Unified Diff: ui/file_manager/file_manager/common/js/unittest_util.js

Issue 795833002: MediaScanner improvements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pull 'n merge. Created 6 years 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: ui/file_manager/file_manager/common/js/unittest_util.js
diff --git a/ui/file_manager/file_manager/common/js/unittest_util.js b/ui/file_manager/file_manager/common/js/unittest_util.js
index 27501222c74efde364b97ec91c7cb4edd37e07e6..aacecae4a3e2c8c3e809724bfa6025c407e314ba 100644
--- a/ui/file_manager/file_manager/common/js/unittest_util.js
+++ b/ui/file_manager/file_manager/common/js/unittest_util.js
@@ -40,6 +40,47 @@ function waitUntil(testFunction) {
}
/**
+ * Asserts that two lists contain the same set of Entries. Entries are deemed
+ * to be the same if they point to the same full path.
+ *
+ * @param {!Array.<!FileEntry>} expected
+ * @param {!Array.<!FileEntry>} actual
+ */
+function assertFileEntryListEquals(expected, actual) {
+
+ var entryToPath = function(entry) {
+ assertTrue(entry.isFile);
+ return entry.fullPath;
+ };
+
+ assertFileEntryPathsEqual(expected.map(entryToPath), actual);
+}
+
+/**
+ * Asserts that a list of FileEntry instances point to the expected paths.
+ *
+ * @param {!Array.<string>} expectedPaths
+ * @param {!Array.<!FileEntry>} fileEntries
+ */
+function assertFileEntryPathsEqual(expectedPaths, fileEntries) {
+ assertEquals(expectedPaths.length, fileEntries.length);
+
+ var entryToPath = function(entry) {
+ assertTrue(entry.isFile);
+ return entry.fullPath;
+ };
+
+ var actualPaths = fileEntries.map(entryToPath);
+ actualPaths.sort();
+ expectedPaths = expectedPaths.slice();
+ expectedPaths.sort();
+
+ assertEquals(
+ JSON.stringify(expectedPaths),
+ JSON.stringify(actualPaths));
+}
+
+/**
* A class that captures calls to a funtion so that values can be validated.
* For use in tests only.
*

Powered by Google App Engine
This is Rietveld 408576698