Commit aeac5434 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Files app: Change waitForWindow() test helper to support regex

Change waitForWindow() test helper to support regex as `windowId`
prefix. This is a preparation to allow apps to run with slightly
different name in the HTML file to allow switching the HTML file to use
JS module.

Change the tests `OpenAudioFiles/FilesAppBrowserTest*` to use regex so
it can run with `audio_player.html` and `audi_player_modules.html`.
Preparing to convert Audio Player foreground page to run with JS
modules.

Bug: 1133186
Change-Id: I8f93000408f824c119e151e67c562fb4c9a25652
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2546303
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarJeremie Boulic <jboulic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828614}
parent f35be459
......@@ -104,7 +104,8 @@
'openFile', appId, ['Beautiful Song.ogg']));
// Wait for the Audio Player window.
const audioAppId = await audioPlayerApp.waitForWindow('audio_player.html');
const audioAppId = await audioPlayerApp.waitForWindow(
'(audio_player|audio_player_module)\.html');
// Check: Audio Player should automatically play the file.
const playFile = audioPlayingQuery('Beautiful Song.ogg');
......@@ -137,7 +138,8 @@
'openFile', appId, ['Beautiful Song.ogg']));
// Wait for the Audio Player window.
const audioAppId = await audioPlayerApp.waitForWindow('audio_player.html');
const audioAppId = await audioPlayerApp.waitForWindow(
'(audio_player|audio_player_module)\.html');
// Check: Audio Player should automatically play the file.
const playFile = audioPlayingQuery('Beautiful Song.ogg');
......@@ -173,7 +175,8 @@
'openFile', appId, ['Beautiful Song.ogg']));
// Wait for the Audio Player window.
const audioAppId = await audioPlayerApp.waitForWindow('audio_player.html');
const audioAppId = await audioPlayerApp.waitForWindow(
'(audio_player|audio_player_module)\.html');
// Check: Audio Player should automatically play the file.
const playFile = audioPlayingQuery('Beautiful Song.ogg');
......@@ -235,7 +238,8 @@
'openFile', appId, ['Beautiful Song.ogg']));
// Wait for the Audio Player window.
const audioAppId = await audioPlayerApp.waitForWindow('audio_player.html');
const audioAppId = await audioPlayerApp.waitForWindow(
'(audio_player|audio_player_module)\.html');
// Check: Audio Player should automatically play the file.
const playFile = audioPlayingQuery('Beautiful Song.ogg');
......@@ -274,7 +278,8 @@
'openFile', appId, ['Beautiful Song.ogg']));
// Wait for the Audio Player window.
const audioAppId = await audioPlayerApp.waitForWindow('audio_player.html');
const audioAppId = await audioPlayerApp.waitForWindow(
'(audio_player|audio_player_module)\.html');
// Check: Audio Player should automatically play the file.
const playFile = audioPlayingQuery('Beautiful Song.ogg');
......@@ -321,7 +326,8 @@
'openFile', appId, ['Beautiful Song.ogg']));
// Wait for the Audio Player window.
const audioAppId = await audioPlayerApp.waitForWindow('audio_player.html');
const audioAppId = await audioPlayerApp.waitForWindow(
'(audio_player|audio_player_module)\.html');
// Check: Audio Player should automatically play the file.
const playFile = audioPlayingQuery('Beautiful Song.ogg');
......@@ -361,7 +367,8 @@
'openFile', appId, ['Beautiful Song.ogg']));
// Wait for the Audio Player window.
const audioAppId = await audioPlayerApp.waitForWindow('audio_player.html');
const audioAppId = await audioPlayerApp.waitForWindow(
'(audio_player|audio_player_module)\.html');
// Check: Audio Player should automatically play the file.
const playFile = audioPlayingQuery('Beautiful Song.ogg');
......@@ -415,7 +422,8 @@
'openFile', appId, ['newly added file.ogg']));
// Wait for the Audio Player window.
const audioAppId = await audioPlayerApp.waitForWindow('audio_player.html');
const audioAppId = await audioPlayerApp.waitForWindow(
'(audio_player|audio_player_module)\.html');
// Check: Audio Player should automatically play the file.
const playFile = audioPlayingQuery('newly added file.ogg');
......@@ -468,7 +476,8 @@
'openFile', appId, ['newly added file.ogg']));
// Wait for the Audio Player window.
const audioAppId = await audioPlayerApp.waitForWindow('audio_player.html');
const audioAppId = await audioPlayerApp.waitForWindow(
'(audio_player|audio_player_module)\.html');
// Check: Audio Player should automatically play the file.
const playFile = audioPlayingQuery('newly added file.ogg');
......@@ -508,7 +517,8 @@
'openFile', appId, ['newly added file.ogg']));
// Wait for the Audio Player window.
const audioAppId = await audioPlayerApp.waitForWindow('audio_player.html');
const audioAppId = await audioPlayerApp.waitForWindow(
'(audio_player|audio_player_module)\.html');
// Check: Audio Player should automatically play the file.
const playFile = audioPlayingQuery('newly added file.ogg');
......
......@@ -115,10 +115,11 @@ class RemoteCall {
*/
waitForWindow(windowIdPrefix) {
const caller = getCaller();
const windowIdRegex = new RegExp(windowIdPrefix);
return repeatUntil(async () => {
const windows = await this.callRemoteTestUtil('getWindows', null, []);
for (const id in windows) {
if (id.indexOf(windowIdPrefix) === 0) {
if (id.indexOf(windowIdPrefix) === 0 || windowIdRegex.test(id)) {
return id;
}
}
......
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