Commit afc0bf31 authored by satorux@chromium.org's avatar satorux@chromium.org

drive: Make FileManagerBrowserTest more robust

Previously, getFileList() was called directly from testFileDisplay().
This was bad, as it's not guaranteed that the file list is already rendered
by the time testFileDisplay() is called, hence the test was flaky.
We should use waitForFileListChange() instead.

Likewise, doKeyboardTest() and doKeyboardTestWithConfirmation() are fixed
in the same way.

BUG=224534

Review URL: https://chromiumcodereview.appspot.com/13450004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192550 0039d316-1c4b-4281-b951-d872f2087c98
parent e951d159
...@@ -84,44 +84,61 @@ function waitAndAcceptDialog(callback) { ...@@ -84,44 +84,61 @@ function waitAndAcceptDialog(callback) {
// Checks that the files initially added by the C++ side are displayed, and // Checks that the files initially added by the C++ side are displayed, and
// that a subsequently added file shows up. // that a subsequently added file shows up.
function testFileDisplay() { function testFileDisplay() {
getFileList(function(actualFilesBefore) { waitForFileListChange(
chrome.test.assertEq(EXPECTED_FILES_BEFORE, actualFilesBefore); 0,
chrome.test.sendMessage('initial check done', function(reply) { function(actualFilesBefore) {
chrome.test.assertEq('file added', reply); chrome.test.assertEq(EXPECTED_FILES_BEFORE, actualFilesBefore);
waitForFileListChange( chrome.test.sendMessage('initial check done', function(reply) {
chrome.test.assertEq('file added', reply);
waitForFileListChange(
EXPECTED_FILES_BEFORE.length, EXPECTED_FILES_BEFORE.length,
chrome.test.callbackPass(function(actualFilesAfter) { chrome.test.callbackPass(function(actualFilesAfter) {
chrome.test.assertEq(EXPECTED_FILES_AFTER, actualFilesAfter); chrome.test.assertEq(EXPECTED_FILES_AFTER, actualFilesAfter);
})); }));
});
}); });
});
} }
// Injects the keyboard test code into the file manager tab and runs the // Injects the keyboard test code into the file manager tab and runs the
// keyboard delete test. // keyboard delete test.
function doKeyboardTestWithConfirmation(code) { function doKeyboardTestWithConfirmation(code) {
chrome.tabs.executeScript(null, {file: 'fake_keypress.js'}, function(result) { // Wait until the file list is rendered.
chrome.tabs.executeScript(null, {code: code}, function(result) { waitForFileListChange(
chrome.test.assertFalse(!result[0]); 0,
waitAndAcceptDialog(function() { function(unused) {
// Succeed here if anything happens; the C++ code checks what happened. // Once the file list is rendered, start the keyboard test.
waitForFileListChange(EXPECTED_FILES_BEFORE.length, chrome.tabs.executeScript(
chrome.test.succeed); null, {file: 'fake_keypress.js'}, function(result) {
chrome.tabs.executeScript(null, {code: code}, function(result) {
chrome.test.assertFalse(!result[0]);
waitAndAcceptDialog(function() {
// Succeed here if anything happens; the C++ code checks what
// happened.
waitForFileListChange(EXPECTED_FILES_BEFORE.length,
chrome.test.succeed);
});
});
}); });
}); });
});
} }
// Injects the keyboard test code into the file manager tab and runs the // Injects the keyboard test code into the file manager tab and runs the
// keyboard copy test. // keyboard copy test.
function doKeyboardTest(code) { function doKeyboardTest(code) {
chrome.tabs.executeScript(null, {file: 'fake_keypress.js'}, function(result) { waitForFileListChange(
chrome.tabs.executeScript(null, {code: code}, function(result) { 0,
chrome.test.assertFalse(!result[0]); function(unused) {
// Succeed here if anything happens; the C++ code checks what happened. chrome.tabs.executeScript(
waitForFileListChange(EXPECTED_FILES_BEFORE.length, chrome.test.succeed); null, {file: 'fake_keypress.js'}, function(result) {
chrome.tabs.executeScript(null, {code: code}, function(result) {
chrome.test.assertFalse(!result[0]);
// Succeed here if anything happens; the C++ code checks what
// happened.
waitForFileListChange(EXPECTED_FILES_BEFORE.length,
chrome.test.succeed);
});
});
}); });
});
} }
chrome.test.runTests([ chrome.test.runTests([
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment