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. |
* |