Search in sources :

Example 86 with Region

use of javafx.scene.layout.Region in project TestFX by TestFX.

the class JavafxRobotAdapterTest method setup.

@Before
public void setup() throws Exception {
    targetStage = FxToolkit.setupStage(stage -> {
        region = new Region();
        region.setStyle("-fx-background-color: magenta;");
        textField = new TextField();
        textArea = new TextArea();
        textArea.setPrefRowCount(6);
        VBox box = new VBox(region, textField, textArea);
        box.setPadding(new Insets(10));
        box.setSpacing(10);
        VBox.setVgrow(region, Priority.ALWAYS);
        sceneRoot = new StackPane(box);
        Scene scene = new Scene(sceneRoot, 300, 300);
        stage.setScene(scene);
        stage.show();
    });
    robotAdapter = new JavafxRobotAdapter();
    robotAdapter.robotCreate(targetStage.getScene());
    // Points are set to bounds in scene
    regionPoint = pointInCenterFor(region.localToScene(region.getBoundsInLocal()));
    textFieldPoint = pointInCenterFor(textField.localToScene(textField.getBoundsInLocal()));
    textAreaPoint = pointInCenterFor(textArea.localToScene(textArea.getBoundsInLocal()));
}
Also used : IntStream(java.util.stream.IntStream) CoreMatchers.is(org.hamcrest.CoreMatchers.is) Scene(javafx.scene.Scene) MouseButton(javafx.scene.input.MouseButton) Assume.assumeThat(org.junit.Assume.assumeThat) TextArea(javafx.scene.control.TextArea) BeforeClass(org.junit.BeforeClass) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) TextInputControlMatchers(org.testfx.matcher.control.TextInputControlMatchers) CoreMatchers.not(org.hamcrest.CoreMatchers.not) CompletableFuture(java.util.concurrent.CompletableFuture) StackPane(javafx.scene.layout.StackPane) FxToolkit(org.testfx.api.FxToolkit) VBox(javafx.scene.layout.VBox) TestFXRule(org.testfx.framework.junit.TestFXRule) Parent(javafx.scene.Parent) Insets(javafx.geometry.Insets) After(org.junit.After) Point2D(javafx.geometry.Point2D) Assert.fail(org.junit.Assert.fail) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Before(org.junit.Before) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Rectangle2D(javafx.geometry.Rectangle2D) TextField(javafx.scene.control.TextField) FxAssert.verifyThat(org.testfx.api.FxAssert.verifyThat) Test(org.junit.Test) Collectors(java.util.stream.Collectors) WaitForAsyncUtils(org.testfx.util.WaitForAsyncUtils) TimeUnit(java.util.concurrent.TimeUnit) Platform(javafx.application.Platform) CountDownLatch(java.util.concurrent.CountDownLatch) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) Rule(org.junit.Rule) Stage(javafx.stage.Stage) Image(javafx.scene.image.Image) Bounds(javafx.geometry.Bounds) Insets(javafx.geometry.Insets) TextArea(javafx.scene.control.TextArea) Region(javafx.scene.layout.Region) TextField(javafx.scene.control.TextField) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane) Before(org.junit.Before)

Example 87 with Region

use of javafx.scene.layout.Region in project TestFX by TestFX.

the class WindowFinderImplTest method setupStages.

public void setupStages() {
    window = new Stage();
    window.setTitle("window");
    windowInWindow = new Stage();
    windowInWindow.setTitle("windowInWindow");
    windowInWindow.initOwner(window);
    windowInWindowInWindow = new Stage();
    windowInWindowInWindow.setTitle("windowInWindowInWindow");
    windowInWindowInWindow.initOwner(windowInWindow);
    otherWindow = new Stage();
    otherWindow.setTitle("otherWindow");
    scene = new Scene(new Region(), 600, 400);
    otherWindow.setScene(scene);
    window.show();
    windowInWindow.show();
    windowInWindowInWindow.show();
    otherWindow.show();
}
Also used : Stage(javafx.stage.Stage) Region(javafx.scene.layout.Region) Scene(javafx.scene.Scene)

Example 88 with Region

use of javafx.scene.layout.Region in project TestFX by TestFX.

the class WindowFinderImplTest method setup.

@Before
public void setup() throws TimeoutException {
    FxToolkit.registerPrimaryStage();
    FxToolkit.showStage();
    FxToolkit.setupScene(() -> new Scene(new Region(), 600, 400));
    FxToolkit.setupFixture(this::setupStages);
    windowFinder = new WindowFinderImpl();
}
Also used : Region(javafx.scene.layout.Region) Scene(javafx.scene.Scene) Before(org.junit.Before)

Example 89 with Region

use of javafx.scene.layout.Region in project TestFX by TestFX.

the class BoundsLocatorImplTest method setup.

@Before
public void setup() throws TimeoutException {
    FxToolkit.registerPrimaryStage();
    FxToolkit.setupScene(() -> new Scene(new Region(), 600, 400));
    FxToolkit.setupFixture(this::setupStages);
    boundsLocator = new BoundsLocatorImpl();
    windowInsets = calculateWindowInsets(primaryWindow, primaryScene);
}
Also used : Region(javafx.scene.layout.Region) Scene(javafx.scene.Scene) Before(org.junit.Before)

Example 90 with Region

use of javafx.scene.layout.Region in project TestFX by TestFX.

the class NodeMatchersTest method anything.

@Test
public void anything() throws Exception {
    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;
    });
    assertThat(from(nodes).match(NodeMatchers.anything()).queryAll(), hasItem(nodes.get(1)));
}
Also used : Button(javafx.scene.control.Button) Node(javafx.scene.Node) ArrayList(java.util.ArrayList) Region(javafx.scene.layout.Region) TextField(javafx.scene.control.TextField) Test(org.junit.Test)

Aggregations

Region (javafx.scene.layout.Region)106 Text (javafx.scene.text.Text)25 VBox (javafx.scene.layout.VBox)22 Label (javafx.scene.control.Label)21 Pane (javafx.scene.layout.Pane)21 Button (javafx.scene.control.Button)18 InnerShadow (javafx.scene.effect.InnerShadow)17 Scene (javafx.scene.Scene)16 Node (javafx.scene.Node)15 Insets (javafx.geometry.Insets)14 HBox (javafx.scene.layout.HBox)14 DropShadow (javafx.scene.effect.DropShadow)13 ArrayList (java.util.ArrayList)12 StackPane (javafx.scene.layout.StackPane)12 Canvas (javafx.scene.canvas.Canvas)11 Color (javafx.scene.paint.Color)11 GridPane (javafx.scene.layout.GridPane)10 Group (javafx.scene.Group)9 Background (javafx.scene.layout.Background)8 BackgroundFill (javafx.scene.layout.BackgroundFill)8