Search in sources :

Example 11 with NodeQuery

use of org.testfx.service.query.NodeQuery in project TestFX by TestFX.

the class NodeAndPointQueryTest method node_queryAll_returns_set_with_nodes.

@Test
public void node_queryAll_returns_set_with_nodes() {
    // when:
    NodeQuery query = fx.lookup(".button");
    // then:
    assertThat(query.queryAll(), hasItems(button0, button1));
}
Also used : NodeQuery(org.testfx.service.query.NodeQuery) Test(org.junit.Test)

Example 12 with NodeQuery

use of org.testfx.service.query.NodeQuery in project TestFX by TestFX.

the class NodeMatchersTest method hasText_filters_nodes.

@Test
public void hasText_filters_nodes() throws Exception {
    // given:
    List<Node> nodes = FxToolkit.setupFixture(() -> {
        List<Node> temp = new ArrayList<>(3);
        temp.add(new Region());
        temp.add(new Button("foo"));
        temp.add(new TextField("bar"));
        return temp;
    });
    // then:
    NodeQuery query1 = from(nodes).match(LabeledMatchers.hasText("foo"));
    assertThat(query1.queryAll(), hasItems(nodes.get(1)));
    NodeQuery query2 = from(nodes).match(TextInputControlMatchers.hasText("bar"));
    assertThat(query2.queryAll(), hasItems(nodes.get(2)));
}
Also used : Button(javafx.scene.control.Button) Node(javafx.scene.Node) NodeQuery(org.testfx.service.query.NodeQuery) ArrayList(java.util.ArrayList) Region(javafx.scene.layout.Region) TextField(javafx.scene.control.TextField) Test(org.junit.Test)

Example 13 with NodeQuery

use of org.testfx.service.query.NodeQuery in project TestFX by TestFX.

the class NodeAssertTest method hasText_filters_nodes.

@Test
public void hasText_filters_nodes() throws Exception {
    // given:
    List<Node> nodes = FxToolkit.setupFixture(() -> {
        List<Node> temp = new ArrayList<>(3);
        temp.add(new Region());
        temp.add(new Button("foo"));
        temp.add(new TextField("bar"));
        return temp;
    });
    // then:
    NodeQuery query1 = from(nodes).match(LabeledMatchers.hasText("foo"));
    assertThat(query1.queryAll()).containsExactly(nodes.get(1));
    NodeQuery query2 = from(nodes).match(TextInputControlMatchers.hasText("bar"));
    assertThat(query2.queryAll()).containsExactly(nodes.get(2));
}
Also used : Button(javafx.scene.control.Button) Node(javafx.scene.Node) NodeQuery(org.testfx.service.query.NodeQuery) ArrayList(java.util.ArrayList) Region(javafx.scene.layout.Region) TextField(javafx.scene.control.TextField) Test(org.junit.Test)

Example 14 with NodeQuery

use of org.testfx.service.query.NodeQuery in project TestFX by TestFX.

the class FxRobot method point.

@Override
public <T extends Node> PointQuery point(Predicate<T> predicate) {
    NodeQuery nodeQuery = lookup(predicate);
    Node node = queryNode(nodeQuery, "the predicate");
    return point(node).atPosition(context.getPointPosition());
}
Also used : NodeQuery(org.testfx.service.query.NodeQuery) Node(javafx.scene.Node)

Example 15 with NodeQuery

use of org.testfx.service.query.NodeQuery in project TestFX by TestFX.

the class FxRobot method pointOfVisibleNode.

private PointQuery pointOfVisibleNode(String query) {
    NodeQuery nodeQuery = lookup(query);
    Node node = queryVisibleNode(nodeQuery, "the query \"" + query + "\"");
    return point(node);
}
Also used : NodeQuery(org.testfx.service.query.NodeQuery) Node(javafx.scene.Node)

Aggregations

NodeQuery (org.testfx.service.query.NodeQuery)16 Node (javafx.scene.Node)8 Test (org.junit.Test)6 NodeFinder (org.testfx.service.finder.NodeFinder)4 ArrayList (java.util.ArrayList)2 Button (javafx.scene.control.Button)2 Cell (javafx.scene.control.Cell)2 TextField (javafx.scene.control.TextField)2 Region (javafx.scene.layout.Region)2 Unstable (org.testfx.api.annotation.Unstable)1