Commit ea8536ef authored by Rachel Sugrono's avatar Rachel Sugrono Committed by Commit Bot

[QuickView] Add tab-index focus test for audio files

Add a test that tab-index key focus works correctly (the tab-indexable
elements are cycled through in order) when Quick View is displaying a
audio file in its content panel.

Tab past the content panel to skip over checking the focus on the content
webview/audio: these can have multiple internal elements that can
take the focus and our test should be independent of that.

Bug: 907380
Change-Id: Ifd8b298865c05cbfcc318e63b0d701fb6ca8f7d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2004171Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Commit-Queue: Rachel Sugrono <rsugrono@google.com>
Cr-Commit-Position: refs/heads/master@{#732260}
parent 9e2856b7
......@@ -466,6 +466,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("openQuickViewMtp"),
TestCase("openQuickViewTabIndexImage"),
TestCase("openQuickViewTabIndexText"),
TestCase("openQuickViewTabIndexAudio"),
TestCase("pressEnterOnInfoBoxToOpenClose"),
TestCase("closeQuickView"),
TestCase("openQuickViewFromDirectoryTree")));
......
......@@ -1342,4 +1342,59 @@
await remoteCall.waitForElement(appId, query.query);
}
};
/**
* Tests the tab-index focus order when sending tab keys when an audio file is
* shown in Quick View.
*/
testcase.openQuickViewTabIndexAudio = async () => {
// Open Files app on Downloads containing ENTRIES.beautiful song.
const appId = await setupAndWaitUntilReady(
RootPath.DOWNLOADS, [ENTRIES.beautiful], []);
// Open the file in Quick View.
await openQuickView(appId, ENTRIES.beautiful.nameText);
// Prepare a list of tab-index focus queries.
const tabQueries = [
{'query': ['#quick-view', '[aria-label="Back"]:focus']},
{'query': ['#quick-view', '[aria-label="Open"]:focus']},
{'query': ['#quick-view', '[aria-label="File info"]:focus']},
];
for (const query of tabQueries) {
// Make the browser dispatch a tab key event to FilesApp.
const result = await sendTestMessage(
{name: 'dispatchTabKey', shift: query.shift || false});
chrome.test.assertEq(
result, 'tabKeyDispatched', 'Tab key dispatch failure');
// Note: Allow 500ms between key events to filter out the focus
// traversal problems noted in crbug.com/907380#c10.
await wait(500);
// Check: the queried element should gain the focus.
await remoteCall.waitForElement(appId, query.query);
}
// Send tab keys until Back gains the focus again.
while (true) {
// Make the browser dispatch a tab key event to FilesApp.
const result =
await sendTestMessage({name: 'dispatchTabKey', shift: false});
chrome.test.assertEq(
result, 'tabKeyDispatched', 'Tab key dispatch failure');
// Note: Allow 500ms between key events to filter out the focus
// traversal problems noted in crbug.com/907380#c10.
await wait(500);
// Check: back should eventually get the focus again.
const activeElement = await remoteCall.callRemoteTestUtil(
'deepGetActiveElement', appId, []);
if (activeElement.attributes['aria-label'] === 'Back') {
break;
}
}
};
})();
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