Search in sources :

Example 1 with PointLocatorImpl

use of org.testfx.service.locator.impl.PointLocatorImpl in project TestFX by TestFX.

the class AwtRobotAdapterTest method setup.

@Before
public void setup() throws Exception {
    robotAdapter = new AwtRobotAdapter();
    targetStage = FxToolkit.setupStage(stage -> {
        region = new Region();
        region.setStyle("-fx-background-color: magenta;");
        VBox box = new VBox(region);
        box.setPadding(new Insets(10));
        box.setSpacing(10);
        VBox.setVgrow(region, Priority.ALWAYS);
        sceneRoot = new StackPane(box);
        Scene scene = new Scene(sceneRoot, 300, 100);
        stage.setScene(scene);
        stage.show();
    });
    PointLocator pointLocator = new PointLocatorImpl(new BoundsLocatorImpl());
    regionPoint = pointLocator.point(region).atPosition(Pos.CENTER).query();
}
Also used : EventHandler(javafx.event.EventHandler) CoreMatchers.is(org.hamcrest.CoreMatchers.is) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Pos(javafx.geometry.Pos) Scene(javafx.scene.Scene) MouseButton(javafx.scene.input.MouseButton) WaitForAsyncUtils.asyncFx(org.testfx.util.WaitForAsyncUtils.asyncFx) Assume.assumeThat(org.junit.Assume.assumeThat) BeforeClass(org.junit.BeforeClass) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) MouseEvent(javafx.scene.input.MouseEvent) Assume.assumeFalse(org.junit.Assume.assumeFalse) PointLocator(org.testfx.service.locator.PointLocator) CoreMatchers.not(org.hamcrest.CoreMatchers.not) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) StackPane(javafx.scene.layout.StackPane) FxToolkit(org.testfx.api.FxToolkit) VBox(javafx.scene.layout.VBox) TestFXRule(org.testfx.framework.junit.TestFXRule) GraphicsEnvironment(java.awt.GraphicsEnvironment) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) PointLocatorImpl(org.testfx.service.locator.impl.PointLocatorImpl) Parent(javafx.scene.Parent) WaitForAsyncUtils.sleep(org.testfx.util.WaitForAsyncUtils.sleep) Insets(javafx.geometry.Insets) After(org.junit.After) Point2D(javafx.geometry.Point2D) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) Before(org.junit.Before) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Rectangle2D(javafx.geometry.Rectangle2D) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) KeyEvent(javafx.scene.input.KeyEvent) WaitForAsyncUtils(org.testfx.util.WaitForAsyncUtils) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) Priority(javafx.scene.layout.Priority) BoundsLocatorImpl(org.testfx.service.locator.impl.BoundsLocatorImpl) Region(javafx.scene.layout.Region) Rule(org.junit.Rule) Stage(javafx.stage.Stage) Image(javafx.scene.image.Image) Mockito.mock(org.mockito.Mockito.mock) PointLocatorImpl(org.testfx.service.locator.impl.PointLocatorImpl) Insets(javafx.geometry.Insets) PointLocator(org.testfx.service.locator.PointLocator) BoundsLocatorImpl(org.testfx.service.locator.impl.BoundsLocatorImpl) Region(javafx.scene.layout.Region) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane) Before(org.junit.Before)

Example 2 with PointLocatorImpl

use of org.testfx.service.locator.impl.PointLocatorImpl in project TestFX by TestFX.

the class GlassRobotAdapterTest method setup.

@Before
public void setup() throws Exception {
    robotAdapter = new GlassRobotAdapter();
    targetStage = FxToolkit.setupStage(stage -> {
        region = new Region();
        region.setStyle("-fx-background-color: magenta;");
        VBox box = new VBox(region);
        box.setPadding(new Insets(10));
        box.setSpacing(10);
        VBox.setVgrow(region, Priority.ALWAYS);
        sceneRoot = new StackPane(box);
        Scene scene = new Scene(sceneRoot, 300, 100);
        stage.setScene(scene);
        stage.show();
    });
    PointLocator pointLocator = new PointLocatorImpl(new BoundsLocatorImpl());
    regionCenter = pointLocator.point(region).atPosition(Pos.CENTER).query();
}
Also used : EventHandler(javafx.event.EventHandler) CoreMatchers.is(org.hamcrest.CoreMatchers.is) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Pos(javafx.geometry.Pos) Scene(javafx.scene.Scene) MouseButton(javafx.scene.input.MouseButton) WaitForAsyncUtils.asyncFx(org.testfx.util.WaitForAsyncUtils.asyncFx) Assume.assumeThat(org.junit.Assume.assumeThat) BeforeClass(org.junit.BeforeClass) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) MouseEvent(javafx.scene.input.MouseEvent) PointLocator(org.testfx.service.locator.PointLocator) CoreMatchers.not(org.hamcrest.CoreMatchers.not) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) StackPane(javafx.scene.layout.StackPane) FxToolkit(org.testfx.api.FxToolkit) VBox(javafx.scene.layout.VBox) TestFXRule(org.testfx.framework.junit.TestFXRule) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) PointLocatorImpl(org.testfx.service.locator.impl.PointLocatorImpl) Parent(javafx.scene.Parent) WaitForAsyncUtils.sleep(org.testfx.util.WaitForAsyncUtils.sleep) Insets(javafx.geometry.Insets) BoundsQueryUtils(org.testfx.util.BoundsQueryUtils) After(org.junit.After) Point2D(javafx.geometry.Point2D) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) Before(org.junit.Before) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Rectangle2D(javafx.geometry.Rectangle2D) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) KeyEvent(javafx.scene.input.KeyEvent) WaitForAsyncUtils(org.testfx.util.WaitForAsyncUtils) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) Priority(javafx.scene.layout.Priority) BoundsLocatorImpl(org.testfx.service.locator.impl.BoundsLocatorImpl) Region(javafx.scene.layout.Region) Rule(org.junit.Rule) Stage(javafx.stage.Stage) Image(javafx.scene.image.Image) Bounds(javafx.geometry.Bounds) Mockito.mock(org.mockito.Mockito.mock) PointLocatorImpl(org.testfx.service.locator.impl.PointLocatorImpl) Insets(javafx.geometry.Insets) PointLocator(org.testfx.service.locator.PointLocator) BoundsLocatorImpl(org.testfx.service.locator.impl.BoundsLocatorImpl) Region(javafx.scene.layout.Region) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane) Before(org.junit.Before)

Aggregations

TimeUnit (java.util.concurrent.TimeUnit)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 EventHandler (javafx.event.EventHandler)2 Insets (javafx.geometry.Insets)2 Point2D (javafx.geometry.Point2D)2 Pos (javafx.geometry.Pos)2 Rectangle2D (javafx.geometry.Rectangle2D)2 Parent (javafx.scene.Parent)2 Scene (javafx.scene.Scene)2 Image (javafx.scene.image.Image)2 KeyCode (javafx.scene.input.KeyCode)2 KeyEvent (javafx.scene.input.KeyEvent)2 MouseButton (javafx.scene.input.MouseButton)2 MouseEvent (javafx.scene.input.MouseEvent)2 Priority (javafx.scene.layout.Priority)2 Region (javafx.scene.layout.Region)2 StackPane (javafx.scene.layout.StackPane)2 VBox (javafx.scene.layout.VBox)2 Color (javafx.scene.paint.Color)2 Stage (javafx.stage.Stage)2