Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#47: getVisibleNodes() returns normal static Set #48

Merged
merged 1 commit into from
Jan 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/java/org/loadui/testfx/GuiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.SceneBuilder;
import javafx.scene.control.Label;
import javafx.scene.input.KeyCode;
import javafx.scene.input.MouseButton;
import javafx.stage.PopupWindow;
Expand Down Expand Up @@ -236,7 +235,7 @@ private static <T extends Node> Set<T> getVisibleNodes(Set<T> foundNodes) {
Set<T> visibleNodes = filter(foundNodes, isVisible);
if( visibleNodes.isEmpty() )
throw new NoNodesVisibleException("Matching nodes were found, but none of them were visible. Screenshot saved as " +captureScreenshot().getAbsolutePath() + ".");
return visibleNodes;
return new LinkedHashSet<>(visibleNodes);
}

private static void assertNodesFound(Object query, Collection<? extends Node> foundNodes) {
Expand Down
1 change: 0 additions & 1 deletion src/test/java/org/loadui/testfx/TextInputControlsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import javafx.scene.Parent;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.VBoxBuilder;
import org.junit.Test;

Expand Down
13 changes: 12 additions & 1 deletion src/test/java/org/loadui/testfx/VisibilityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import static org.loadui.testfx.Assertions.verifyThat;
import static org.loadui.testfx.controls.Commons.hasText;
import static org.hamcrest.Matchers.is;

/**
* TestFX should not find/click invisible nodes.
Expand Down Expand Up @@ -57,6 +58,13 @@ public void shouldClickNodeThatIsMostlyOutsideTheScene()
click(target);
verifyThat(target, hasText("Clicked"));
}

@Test
public void shouldFindVisibleTwinOnly()
{
verifyThat(findAll("Twin").size(), is(1));
verifyThat(find("#twin").isVisible(), is(true));
}

@Override
protected Parent getRootNode() {
Expand All @@ -71,6 +79,9 @@ public void handle(ActionEvent _) {
nodeMostlyOutside.setText("Clicked");
}
});
return VBoxBuilder.create().children(nodeNotInScene, invisibleNode, nodeMostlyOutside, invisibleContainer).build();
Button visibleTwin = ButtonBuilder.create().text("Twin").id("twin").build();
Button invisibleTwin = ButtonBuilder.create().text("Twin").id("twin").visible(false).build();
return VBoxBuilder.create().children(invisibleTwin, visibleTwin, nodeNotInScene, invisibleNode, nodeMostlyOutside, invisibleContainer).build();
}
}