Skip to content

Commit

Permalink
Wait for state change after clicking on media control buttons for Med…
Browse files Browse the repository at this point in the history
…ia Player Test 8
  • Loading branch information
indritbeqiri committed Nov 5, 2024
1 parent 1f8b6c6 commit 3333589
Showing 1 changed file with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,6 @@ private void start(Stage stage) {
stage.toFront();
}

@AfterEach
void tearDown() {
if (mediaPlayer != null) {
mediaPlayer.stop();
mediaPlayer = null;
}
}

@Test
@Order(1)
void media_player_controls(FxRobot robot) throws TimeoutException {
Expand Down Expand Up @@ -460,7 +452,7 @@ public void playback_rate_behaviour(FxRobot robot) throws TimeoutException, Inte
assertThat(mediaPlayer.getCurrentRate()).isEqualTo(0.0);
log.debug("Checks passed");

robot.clickOn(playButton);
clickPlayButton(robot);

log.debug("Waiting for media player to play for additional 5 seconds...");
final Duration currentTime1 = mediaPlayer.getCurrentTime();
Expand All @@ -473,7 +465,7 @@ public void playback_rate_behaviour(FxRobot robot) throws TimeoutException, Inte
assertThat(mediaPlayer.getCurrentRate()).isEqualTo(1.0);
log.debug("Checks passed");

robot.clickOn(pauseButton);
clickPauseButton(robot);

log.debug("Check initial playback rate and current rate in paused state...");
assertThat(mediaPlayer.getRate()).isEqualTo(1.0);
Expand All @@ -483,7 +475,7 @@ public void playback_rate_behaviour(FxRobot robot) throws TimeoutException, Inte
log.debug("Set playback rate to 4.0");
mediaPlayer.setRate(4.0);

robot.clickOn(playButton);
clickPlayButton(robot);

log.debug("Waiting for media player to play for additional 20 seconds...");
final Duration currentTime2 = mediaPlayer.getCurrentTime();
Expand Down Expand Up @@ -519,11 +511,11 @@ public void playback_rate_behaviour(FxRobot robot) throws TimeoutException, Inte
assertThat(mediaPlayer.getCurrentRate()).isEqualTo(4.0);
log.debug("Checks passed");

robot.clickOn(pauseButton);
clickPauseButton(robot);
TimeUnit.SECONDS.sleep(1);
log.debug("Set playback rate to 10.0");
mediaPlayer.setRate(10.0); // more than 8.0, is clamp to 8.0
robot.clickOn(playButton);
clickPlayButton(robot);

log.debug("Waiting for media player to play for additional 30 seconds...");
final Duration currentTime5 = mediaPlayer.getCurrentTime();
Expand All @@ -537,7 +529,7 @@ public void playback_rate_behaviour(FxRobot robot) throws TimeoutException, Inte
assertThat(mediaPlayer.getCurrentRate()).isEqualTo(10.0);
log.debug("Checks passed");

robot.clickOn(stopButton);
clickStopButton(robot);

log.debug("Check playback rate and current rate in stopped state...");
assertThat(mediaPlayer.getRate()).isEqualTo(10.0);
Expand Down Expand Up @@ -569,6 +561,18 @@ private void clickPlayButton(FxRobot robot) throws TimeoutException {
log.debug("Checks passed");
}

private void clickPauseButton(FxRobot robot) throws TimeoutException {
log.debug("Click on pause button");
robot.clickOn(pauseButton);
waitForStatus(Status.PAUSED);
log.debug("Run additional checks...");
WaitForAsyncUtils.waitForFxEvents();
assertThat(playButton.isDisable()).isFalse();
assertThat(pauseButton.isDisable()).isTrue();
assertThat(stopButton.isDisable()).isFalse();
log.debug("Checks passed");
}

private void clickStopButton(FxRobot robot) throws TimeoutException {
log.debug("Click on stop button");
robot.clickOn(stopButton);
Expand Down

0 comments on commit 3333589

Please sign in to comment.