Commit 8b73ec30 authored by dhaddock's avatar dhaddock Committed by Commit bot

browser_tests for searching within Downloads in Files

This adds tests for a search in Downloads. It first performs a basic search,
it then checks that the search is case-insensitive and performs a search that
should match no files and checks the correct error string is displayed.

TEST=browser_tests --gtest_filter="*FileDisplay/FileManagerBrowserTest/{4,5,6}*"
BUG=None

Review URL: https://codereview.chromium.org/1067983002

Cr-Commit-Position: refs/heads/master@{#324384}
parent 5f4e78e2
......@@ -830,7 +830,10 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "fileDisplayDownloads"),
TestParameter(IN_GUEST_MODE, "fileDisplayDownloads"),
TestParameter(NOT_IN_GUEST_MODE, "fileDisplayDrive"),
TestParameter(NOT_IN_GUEST_MODE, "fileDisplayMtp")));
TestParameter(NOT_IN_GUEST_MODE, "fileDisplayMtp"),
TestParameter(NOT_IN_GUEST_MODE, "searchNormal"),
TestParameter(NOT_IN_GUEST_MODE, "searchCaseInsensitive"),
TestParameter(NOT_IN_GUEST_MODE, "searchNotFound")));
// Slow tests are disabled on debug build. http://crbug.com/327719
// Fails on official build. http://crbug.com/429294
......
......@@ -88,3 +88,111 @@ testcase.fileDisplayMtp = function() {
}
]);
};
/**
* Searches for a string in Downloads and checks the correct results are
* being displayed.
*
* @param {string} searchTerm The string to search for.
* @param {Array<Object>} expectedResults The results set.
*
*/
function searchDownloads(searchTerm, expectedResults) {
var appId;
StepsRunner.run([
function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
},
// Focus the search box.
function(inAppId, list) {
appId = inAppId;
remoteCall.callRemoteTestUtil('fakeEvent',
appId,
['#search-box input', 'focus'],
this.next);
},
// Input a text.
function(result) {
chrome.test.assertTrue(result);
remoteCall.callRemoteTestUtil('inputText',
appId,
['#search-box input', searchTerm],
this.next);
},
// Notify the element of the input.
function() {
remoteCall.callRemoteTestUtil('fakeEvent',
appId,
['#search-box input', 'input'],
this.next);
},
function(result) {
remoteCall.waitForFileListChange(appId, BASIC_LOCAL_ENTRY_SET.length).
then(this.next);
},
function(actualFilesAfter) {
chrome.test.assertEq(
TestEntryInfo.getExpectedRows(expectedResults).sort(),
actualFilesAfter);
checkIfNoErrorsOccured(this.next);
}
]);
}
testcase.searchNormal = function() {
searchDownloads('hello', [ENTRIES.hello]);
};
testcase.searchCaseInsensitive = function() {
searchDownloads('HELLO', [ENTRIES.hello]);
};
/**
* Searches for a string that doesn't match anything in Downloads
* and checks that the no items match string is displayed.
*
*/
testcase.searchNotFound = function() {
var appId;
var searchTerm = 'blahblah';
StepsRunner.run([
function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
},
// Focus the search box.
function(inAppId, list) {
appId = inAppId;
console.log(list);
remoteCall.callRemoteTestUtil('fakeEvent',
appId,
['#search-box input', 'focus'],
this.next);
},
// Input a text.
function(result) {
chrome.test.assertTrue(result);
remoteCall.callRemoteTestUtil('inputText',
appId,
['#search-box input', searchTerm],
this.next);
},
// Notify the element of the input.
function() {
remoteCall.callRemoteTestUtil('fakeEvent',
appId,
['#search-box input', 'input'],
this.next);
},
function(result) {
remoteCall.waitForElement(appId, ['#no-search-results b']).
then(this.next);
},
function(element) {
chrome.test.assertEq(element.text, '\"' + searchTerm + '\"');
checkIfNoErrorsOccured(this.next);
}
]);
};
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