Skip to content

Commit

Permalink
HelpWindowTest: fix failing test in non-headless mode
Browse files Browse the repository at this point in the history
HelpWindowTest#focus_helpWindowNotFocused_focused() asserts that the
HelpWindow is not in focus when it is first shown, and then asserts
that the HelpWindow comes into focus after calling HelpWindow#focus().

When tests are run in non-headless mode, the HelpWindow will be in
focus when it is first shown, thus rendering our first assumption false
and causing the test to fail.

Let's update the test to focus on another TestFx Stage, which will
remove focus from the HelpWindow when it is first shown, ensuring that
the initial assumption is true.
  • Loading branch information
yamidark committed Apr 22, 2018
1 parent e968a29 commit 1c6071f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/test/java/seedu/address/ui/HelpWindowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ public void isShowing_helpWindowIsHiding_returnsFalse() {
}

@Test
public void focus_helpWindowNotFocused_focused() {
public void focus_helpWindowNotFocused_focused() throws Exception {
guiRobot.interact(helpWindow::show);

// Focus on another stage to remove focus from the helpWindow
FxToolkit.setupStage(Stage::requestFocus);
assertFalse(helpWindow.getRoot().isFocused());

guiRobot.interact(helpWindow::focus);
Expand Down

0 comments on commit 1c6071f

Please sign in to comment.