Skip to content

Commit

Permalink
Merge pull request #61 from SmartBear/user-movement-detection
Browse files Browse the repository at this point in the history
Misc fixes + bumped version.
  • Loading branch information
Henrik Olsson committed Jan 31, 2014
2 parents 5c2d33f + 69a60b2 commit 1140c79
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 59 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.loadui</groupId>
<artifactId>testFx</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.1.2</version>
<name>TestFX</name>
<description>TestFX</description>
<url>https://github.com/SmartBear/TestFX</url>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/loadui/testfx/controls/Commons.java
Expand Up @@ -60,21 +60,21 @@ public static Matcher<Object> hasText( Matcher<String> stringMatcher )
return new HasLabelMatcher( stringMatcher );
}

public static <T extends Node> T nodeLabeledBy(String labelQuery)
public static Node nodeLabeledBy(String labelQuery)
{
Node foundNode = GuiTest.find(labelQuery);

checkArgument(foundNode instanceof Label);
Label label = ( Label )foundNode;
Node labelFor = label.getLabelFor();
checkNotNull(labelFor);
return (T) labelFor;
return labelFor;
}

public static <T extends Node> T nodeLabeledBy(Label label)
public static Node nodeLabeledBy(Label label)
{
Node labelFor = label.getLabelFor();
checkNotNull(labelFor);
return (T) labelFor;
return labelFor;
}
}
Expand Up @@ -4,25 +4,35 @@
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;

public class HasLabelStringMatcher extends TypeSafeMatcher<Object>
{
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 )
{
Expand All @@ -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);
}
}
8 changes: 3 additions & 5 deletions src/main/java/org/loadui/testfx/utils/FXTestUtils.java
Expand Up @@ -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();
Expand Down
41 changes: 0 additions & 41 deletions src/test/java/org/loadui/testfx/TimeoutTest.java

This file was deleted.

0 comments on commit 1140c79

Please sign in to comment.