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

Unified Diff: chrome/test/data/extensions/api_test/file_browser/drive_search_test/test.js

Issue 137533009: drive: Stop depending on order of search results from tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
« no previous file with comments | « chrome/browser/chromeos/drive/file_system/search_operation_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/file_browser/drive_search_test/test.js
diff --git a/chrome/test/data/extensions/api_test/file_browser/drive_search_test/test.js b/chrome/test/data/extensions/api_test/file_browser/drive_search_test/test.js
index 96bd87f00c8216db04e3318a38b6a427c1834901..9450f750f21f3e722e7cc913908de47d0ecb5d94 100644
--- a/chrome/test/data/extensions/api_test/file_browser/drive_search_test/test.js
+++ b/chrome/test/data/extensions/api_test/file_browser/drive_search_test/test.js
@@ -90,53 +90,44 @@ chrome.test.runTests([
// Tests chrome.fileBrowserPrivate.searchDrive method.
function driveSearch() {
- var testCases = [
- {
- nextFeed: '',
- expectedPath: '/drive/root/test_dir/empty_test_dir',
- expectedType: 'dir',
- expectedNextFeed:
- 'http://localhost/?start-offset=1&max-results=1&q=empty',
- },
- {
- // The same as the previous test case's expected next feed.
- nextFeed: 'http://localhost/?start-offset=1&max-results=1&q=empty',
- expectedPath: '/drive/root/test_dir/empty_test_file.foo',
- expectedType: 'file',
- expectedNextFeed: '',
- }
+ var query = 'empty';
+ var expectedEntries = [
+ {path: '/drive/root/test_dir/empty_test_dir', type: 'dir'},
+ {path: '/drive/root/test_dir/empty_test_file.foo', type: 'file'},
];
- function runNextQuery() {
- // If there is no more queries the test ended successfully.
- if (testCases.length == 0) {
- chrome.test.succeed();
- return;
- }
-
- var testCase = testCases.shift();
+ function runNextQuery(entries, nextFeed) {
+ chrome.test.assertFalse(!entries);
// Each search query should return exactly one result (this should be
// ensured by Chrome part of the test).
- chrome.fileBrowserPrivate.searchDrive(
- {query: 'empty', nextFeed: testCase.nextFeed},
- function(entries, nextFeed) {
- chrome.test.assertFalse(!entries);
- chrome.test.assertEq(1, entries.length);
- chrome.test.assertEq(testCase.expectedPath,
- entries[0].fullPath);
- chrome.test.assertEq(testCase.expectedNextFeed, nextFeed);
-
- var verifyEntry = getEntryVerifier(testCase.expectedType);
- chrome.test.assertFalse(!verifyEntry);
+ chrome.test.assertEq(1, entries.length);
- // The callback will be called only it the entry is successfully
- // verified, otherwise the test function will fail.
- verifyEntry(entries[0], runNextQuery);
+ var index = -1;
+ for (var i = 0; i < expectedEntries.length; ++i) {
+ if (expectedEntries[i].path === entries[0].fullPath)
+ index = i;
+ }
+ chrome.test.assertFalse(index === -1);
+
+ var verifyEntry = getEntryVerifier(expectedEntries[index].type);
+ chrome.test.assertFalse(!verifyEntry);
+ verifyEntry(entries[0], function() {
+ expectedEntries.splice(index, 1);
+
+ if (nextFeed === '') {
+ chrome.test.assertEq(0, expectedEntries.length);
+ chrome.test.succeed();
+ return;
+ }
+
+ chrome.fileBrowserPrivate.searchDrive(
+ {query: query, nextFeed: nextFeed}, runNextQuery);
});
}
- runNextQuery();
+ chrome.fileBrowserPrivate.searchDrive(
+ {query: query, nextFeed: ''}, runNextQuery);
},
// Tests chrome.fileBrowserPrivate.searchDriveMetadata method.
« no previous file with comments | « chrome/browser/chromeos/drive/file_system/search_operation_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698