Commit 6330d60e authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

FilesApp: Add closeQuickView integration test.

Wrote a test to close Quick View dialog. In order to do this, also
extended test.util.sync.{fakeMouseClick,sendEvent} functions.

BUG=739103
TEST= out/Debug/browser_tests
'--gtest_filter=QuickView/FileManagerBrowserTest.Test*'

Change-Id: Idad7568541eba65b08a116f8a29b94a6c009cf7c
Reviewed-on: https://chromium-review.googlesource.com/567910Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Reviewed-by: default avatarKeigo Oka <oka@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487389}
parent 7605788b
...@@ -179,7 +179,8 @@ WRAPPED_INSTANTIATE_TEST_CASE_P( ...@@ -179,7 +179,8 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
WRAPPED_INSTANTIATE_TEST_CASE_P( WRAPPED_INSTANTIATE_TEST_CASE_P(
QuickView, QuickView,
FileManagerBrowserTest, FileManagerBrowserTest,
::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "openQuickView"))); ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "openQuickView"),
TestParameter(NOT_IN_GUEST_MODE, "closeQuickView")));
#if defined(DISABLE_SLOW_FILESAPP_TESTS) #if defined(DISABLE_SLOW_FILESAPP_TESTS)
#define MAYBE_DirectoryTreeContextMenu DISABLED_DirectoryTreeContextMenu #define MAYBE_DirectoryTreeContextMenu DISABLED_DirectoryTreeContextMenu
......
...@@ -334,17 +334,33 @@ test.util.sync.inputText = function(contentWindow, query, text) { ...@@ -334,17 +334,33 @@ test.util.sync.inputText = function(contentWindow, query, text) {
* Sends an event to the element specified by |targetQuery| or active element. * Sends an event to the element specified by |targetQuery| or active element.
* *
* @param {Window} contentWindow Window to be tested. * @param {Window} contentWindow Window to be tested.
* @param {?string} targetQuery Query to specify the element. If this value is * @param {?string|Array<string>} targetQuery Query to specify the element.
* null, an event is dispatched to active element of the document. * If this value is null, an event is dispatched to active element of the
* document.
* If targetQuery is an array, |targetQuery[0]| specifies the first
* element(s), |targetQuery[1]| specifies elements inside the shadow DOM of
* the first element, and so on.
* @param {!Event} event Event to be sent. * @param {!Event} event Event to be sent.
* @param {string=} opt_iframeQuery Optional iframe selector. * @param {string=} opt_iframeQuery Optional iframe selector.
* @return {boolean} True if the event is sent to the target, false otherwise. * @return {boolean} True if the event is sent to the target, false otherwise.
*/ */
test.util.sync.sendEvent = function( test.util.sync.sendEvent = function(
contentWindow, targetQuery, event, opt_iframeQuery) { contentWindow, targetQuery, event, opt_iframeQuery) {
var target = targetQuery === null ? var target;
contentWindow.document.activeElement : if (targetQuery === null) {
test.util.sync.getElement_(contentWindow, targetQuery, opt_iframeQuery); target = contentWindow.document.activeElement;
} else if (typeof targetQuery === 'string') {
target =
test.util.sync.getElement_(contentWindow, targetQuery, opt_iframeQuery);
} else if (Array.isArray(targetQuery)) {
var doc = test.util.sync.getDocument_(
contentWindow, opt_iframeQuery || undefined);
if (doc) {
var elems = test.util.sync.deepQuerySelectorAll_(doc, targetQuery);
if (elems.length > 0)
target = elems[0];
}
}
if (!target) if (!target)
return false; return false;
...@@ -415,7 +431,10 @@ test.util.sync.fakeKeyDown = function( ...@@ -415,7 +431,10 @@ test.util.sync.fakeKeyDown = function(
* events in turns. * events in turns.
* *
* @param {Window} contentWindow Window to be tested. * @param {Window} contentWindow Window to be tested.
* @param {string} targetQuery Query to specify the element. * @param {string|Array<string>} targetQuery Query to specify the element.
* If targetQuery is an array, |targetQuery[0]| specifies the first
* element(s), |targetQuery[1]| specifies elements inside the shadow DOM of
* the first element, and so on.
* @param {string=} opt_iframeQuery Optional iframe selector. * @param {string=} opt_iframeQuery Optional iframe selector.
* @return {boolean} True if the all events are sent to the target, false * @return {boolean} True if the all events are sent to the target, false
* otherwise. * otherwise.
......
...@@ -4,18 +4,9 @@ ...@@ -4,18 +4,9 @@
'use strict'; 'use strict';
/** function openQuickViewSteps(appId) {
* Tests opening the Quick View. return [
*/
testcase.openQuickView = function() {
var appId;
StepsRunner.run([
function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
},
function(results) { function(results) {
appId = results.windowId;
// Select an image file. // Select an image file.
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'selectFile', appId, ['My Desktop Background.png'], this.next); 'selectFile', appId, ['My Desktop Background.png'], this.next);
...@@ -52,5 +43,66 @@ testcase.openQuickView = function() { ...@@ -52,5 +43,66 @@ testcase.openQuickView = function() {
checkIfNoErrorsOccured(this.next); checkIfNoErrorsOccured(this.next);
}, },
]); function() {
// Wait until Quick View is displayed.
repeatUntil(function() {
return remoteCall
.callRemoteTestUtil(
'deepQueryAllElements', appId,
[['#quick-view', '#dialog'], null, ['display']])
.then(function(results) {
if (results.length === 0 ||
results[0].styles.display === 'none') {
return pending('Quick View is not opened yet.');
};
return results;
});
}).then(this.next);
},
];
}
function closeQuickViewSteps(appId) {
return [
function() {
return remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, [['#quick-view', '#contentPanel']],
this.next);
},
function(result) {
chrome.test.assertEq(true, result);
// Wait until Quick View is displayed.
repeatUntil(function() {
return remoteCall
.callRemoteTestUtil(
'deepQueryAllElements', appId,
[['#quick-view', '#dialog'], null, ['display']])
.then(function(results) {
if (results.length > 0 && results[0].styles.display !== 'none') {
return pending('Quick View is not closed yet.');
};
return;
});
}).then(this.next);
}
];
}
/**
* Tests opening the Quick View.
*/
testcase.openQuickView = function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS).then(function(results) {
StepsRunner.run(openQuickViewSteps(results.windowId));
});
};
/**
* Test closing Quick View.
*/
testcase.closeQuickView = function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS).then(function(results) {
StepsRunner.run(openQuickViewSteps(results.windowId)
.concat(closeQuickViewSteps(results.windowId)));
});
}; };
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