diff --git a/pom.xml b/pom.xml index 35ecc5837..642bd916e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.loadui testFx - 3.1.2-SNAPSHOT + 3.1.2 TestFX TestFX https://github.com/SmartBear/TestFX diff --git a/src/main/java/org/loadui/testfx/controls/Commons.java b/src/main/java/org/loadui/testfx/controls/Commons.java index 76708ac38..0162c23f9 100644 --- a/src/main/java/org/loadui/testfx/controls/Commons.java +++ b/src/main/java/org/loadui/testfx/controls/Commons.java @@ -60,7 +60,7 @@ public static Matcher hasText( Matcher stringMatcher ) return new HasLabelMatcher( stringMatcher ); } - public static T nodeLabeledBy(String labelQuery) + public static Node nodeLabeledBy(String labelQuery) { Node foundNode = GuiTest.find(labelQuery); @@ -68,13 +68,13 @@ public static T nodeLabeledBy(String labelQuery) Label label = ( Label )foundNode; Node labelFor = label.getLabelFor(); checkNotNull(labelFor); - return (T) labelFor; + return labelFor; } - public static T nodeLabeledBy(Label label) + public static Node nodeLabeledBy(Label label) { Node labelFor = label.getLabelFor(); checkNotNull(labelFor); - return (T) labelFor; + return labelFor; } } diff --git a/src/main/java/org/loadui/testfx/controls/impl/HasLabelStringMatcher.java b/src/main/java/org/loadui/testfx/controls/impl/HasLabelStringMatcher.java index 3f9d318ef..56d60a0a7 100644 --- a/src/main/java/org/loadui/testfx/controls/impl/HasLabelStringMatcher.java +++ b/src/main/java/org/loadui/testfx/controls/impl/HasLabelStringMatcher.java @@ -4,7 +4,7 @@ import javafx.scene.control.Labeled; import javafx.scene.control.TextInputControl; import org.hamcrest.Description; -import org.junit.internal.matchers.TypeSafeMatcher; +import org.hamcrest.TypeSafeMatcher; import static com.google.common.base.Preconditions.checkArgument; import static org.loadui.testfx.GuiTest.find; @@ -12,17 +12,27 @@ public class HasLabelStringMatcher extends TypeSafeMatcher { private final String label; + private String actualText; - public HasLabelStringMatcher( String label ) + public HasLabelStringMatcher( String label ) { this.label = label; } public void describeTo( Description desc ) { - desc.appendText( "Node should have label " + label ); + desc.appendText( "Node should have label "); + desc.appendValue( label ); } + @Override + public void describeMismatchSafely( Object query, Description desc ) + { + desc.appendText("Label was "); + desc.appendValue( actualText ); + } + + @Override public boolean matchesSafely( Object target ) { @@ -41,13 +51,16 @@ private boolean nodeHasLabel( Node node ) { checkArgument( node instanceof Labeled || node instanceof TextInputControl, "Target node must be Labeled or TextInputControl." ); - if( node instanceof Labeled ) + if( node instanceof Labeled ) { Labeled labeled = ( Labeled )node; - return label.equals( labeled.getText() ); + actualText = labeled.getText(); } - - TextInputControl textInput = ( TextInputControl )node; - return label.equals( textInput.getText() ); + else + { + TextInputControl textInput = ( TextInputControl )node; + actualText = textInput.getText(); + } + return label.equals(actualText); } } \ No newline at end of file diff --git a/src/main/java/org/loadui/testfx/utils/FXTestUtils.java b/src/main/java/org/loadui/testfx/utils/FXTestUtils.java index 16c72bba5..fb48fa710 100644 --- a/src/main/java/org/loadui/testfx/utils/FXTestUtils.java +++ b/src/main/java/org/loadui/testfx/utils/FXTestUtils.java @@ -284,11 +284,9 @@ public static void releaseButtons() try { Robot robot = new Robot(); robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK); - robot.keyRelease(KeyEvent.SHIFT_DOWN_MASK); - robot.keyRelease(KeyEvent.CTRL_DOWN_MASK); - robot.keyRelease(KeyEvent.ALT_DOWN_MASK); - robot.keyRelease(KeyEvent.VK_META); + robot.mouseRelease(InputEvent.BUTTON2_DOWN_MASK); + robot.keyRelease(KeyEvent.VK_SHIFT); + robot.keyRelease(KeyEvent.VK_CONTROL); } catch (AWTException e) { System.out.println("[TestFX] Failed releasing keys."); e.printStackTrace(); diff --git a/src/test/java/org/loadui/testfx/TimeoutTest.java b/src/test/java/org/loadui/testfx/TimeoutTest.java deleted file mode 100644 index 6ccb2d87c..000000000 --- a/src/test/java/org/loadui/testfx/TimeoutTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.loadui.testfx; - -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.scene.Parent; -import javafx.scene.control.Button; -import javafx.scene.control.TextField; -import javafx.scene.layout.VBoxBuilder; -import org.junit.Test; - -import static javafx.scene.input.KeyCode.TAB; -import static org.loadui.testfx.Assertions.verifyThat; -import static org.loadui.testfx.controls.Commons.hasText; -import static org.loadui.testfx.controls.TextInputControls.clearTextIn; - -public class TimeoutTest extends GuiTest -{ - - public static final String TEXT_FIELD = ".text-field"; - - @Override - protected Parent getRootNode() - { - final Button b = new Button("Exit"); - b.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - b.getScene().getWindow().hide(); - } - }); - return VBoxBuilder - .create() - .children(b).build(); - } - - @Test(timeout = 15_000) - public void shouldNotFreezeOnFxTerminate() - { - click("Exit"); - } -}