web: Remove `RufflePlayer.playButtonClicked`

Replace its few usages with `play` which is part of the public API.
Also made little cleanups to the selfhosted test utils along the way.
This commit is contained in:
relrelb 2021-07-09 10:53:48 +03:00 committed by relrelb
parent 76849c485e
commit 803da71e9c
2 changed files with 9 additions and 30 deletions

View File

@ -196,10 +196,7 @@ export class RufflePlayer extends HTMLElement {
this.container = this.shadow.getElementById("container")!; this.container = this.shadow.getElementById("container")!;
this.playButton = this.shadow.getElementById("play_button")!; this.playButton = this.shadow.getElementById("play_button")!;
if (this.playButton) { if (this.playButton) {
this.playButton.addEventListener( this.playButton.addEventListener("click", () => this.play());
"click",
this.playButtonClicked.bind(this)
);
} }
this.unmuteOverlay = this.shadow.getElementById("unmute_overlay")!; this.unmuteOverlay = this.shadow.getElementById("unmute_overlay")!;
@ -590,10 +587,6 @@ export class RufflePlayer extends HTMLElement {
} }
} }
private playButtonClicked(): void {
this.play();
}
/** /**
* Plays or resumes the movie. * Plays or resumes the movie.
*/ */

View File

@ -55,17 +55,9 @@ function play_and_monitor(browser, player, expected_output) {
// TODO: better way to test for this in the API // TODO: better way to test for this in the API
browser.waitUntil( browser.waitUntil(
() => { () =>
return ( has_error(browser) ||
has_error(browser) || browser.execute((player) => player.instance, player),
browser.execute((player) => {
return (
player.playButtonClicked !== undefined &&
player.instance
);
}, player)
);
},
{ {
timeoutMsg: "Expected player to have initialized", timeoutMsg: "Expected player to have initialized",
} }
@ -76,9 +68,7 @@ function play_and_monitor(browser, player, expected_output) {
player.traceObserver = (msg) => { player.traceObserver = (msg) => {
player.__ruffle_log__ += msg + "\n"; player.__ruffle_log__ += msg + "\n";
}; };
player.play();
// TODO: make this an actual intended api...
player.playButtonClicked();
}, player); }, player);
if (expected_output === undefined) { if (expected_output === undefined) {
@ -86,13 +76,9 @@ function play_and_monitor(browser, player, expected_output) {
} }
browser.waitUntil( browser.waitUntil(
() => { () =>
return ( browser.execute((player) => player.__ruffle_log__, player) ===
browser.execute((player) => { expected_output,
return player.__ruffle_log__;
}, player) === expected_output
);
},
{ {
timeoutMsg: "Expected Ruffle to trace a message", timeoutMsg: "Expected Ruffle to trace a message",
} }
@ -115,6 +101,7 @@ function open_test(browser, absolute_dir, file_name) {
/** Test set-up for JS API testing. */ /** Test set-up for JS API testing. */
function js_api_before(swf) { function js_api_before(swf) {
let player = null; let player = null;
before("Loads the test", () => { before("Loads the test", () => {
browser.url("http://localhost:4567/test_assets/js_api.html"); browser.url("http://localhost:4567/test_assets/js_api.html");
@ -135,7 +122,6 @@ function js_api_before(swf) {
play_and_monitor(browser, player); play_and_monitor(browser, player);
} }
}); });
return player;
} }
module.exports = { module.exports = {