Search in sources :

Example 21 with PointQuery

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

the class MoveRobotImplTest method moveTo_a_point_with_motion_DIRECT.

@Test
public void moveTo_a_point_with_motion_DIRECT() {
    // given:
    Point2D sourcePoint = new Point2D(0, 0);
    given(baseRobot.retrieveMouse()).willReturn(sourcePoint);
    // and:
    Point2D targetPoint = new Point2D(300, 100);
    PointQuery pointQuery = mock(PointQuery.class);
    given(pointQuery.query()).willReturn(targetPoint);
    // when:
    moveRobot.moveTo(pointQuery, Motion.DIRECT);
    // then:
    verify(mouseRobot, times(199)).moveNoWait(argThat(argument -> sourcePoint.getY() != argument.getY() || targetPoint.getX() != argument.getX()));
    verify(mouseRobot, times(2)).move(targetPoint);
}
Also used : ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Motion(org.testfx.robot.Motion) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) TestFXRule(org.testfx.framework.junit.TestFXRule) MouseRobot(org.testfx.robot.MouseRobot) Mockito.verify(org.mockito.Mockito.verify) Rule(org.junit.Rule) MoveRobot(org.testfx.robot.MoveRobot) BDDMockito.given(org.mockito.BDDMockito.given) BaseRobot(org.testfx.robot.BaseRobot) Point2D(javafx.geometry.Point2D) SleepRobot(org.testfx.robot.SleepRobot) PointQuery(org.testfx.service.query.PointQuery) AdditionalMatchers.not(org.mockito.AdditionalMatchers.not) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) Point2D(javafx.geometry.Point2D) PointQuery(org.testfx.service.query.PointQuery) Test(org.junit.Test)

Example 22 with PointQuery

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

the class NodeAndPointQueryTest method point_query_returns_point.

@Test
public void point_query_returns_point() {
    // when:
    PointQuery pointQuery = fx.point(".button");
    // then:
    assertThat(pointQuery.query(), instanceOf(Point2D.class));
}
Also used : Point2D(javafx.geometry.Point2D) PointQuery(org.testfx.service.query.PointQuery) Test(org.junit.Test)

Aggregations

PointQuery (org.testfx.service.query.PointQuery)22 Test (org.junit.Test)19 Point2D (javafx.geometry.Point2D)16 Before (org.junit.Before)3 Rule (org.junit.Rule)3 AdditionalMatchers.not (org.mockito.AdditionalMatchers.not)3 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)3 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)3 BDDMockito.given (org.mockito.BDDMockito.given)3 Mockito.mock (org.mockito.Mockito.mock)3 Mockito.times (org.mockito.Mockito.times)3 Mockito.verify (org.mockito.Mockito.verify)3 TestFXRule (org.testfx.framework.junit.TestFXRule)3 BaseRobot (org.testfx.robot.BaseRobot)3 Motion (org.testfx.robot.Motion)3 MouseRobot (org.testfx.robot.MouseRobot)3 MoveRobot (org.testfx.robot.MoveRobot)3 SleepRobot (org.testfx.robot.SleepRobot)3 BoundingBox (javafx.geometry.BoundingBox)2 Bounds (javafx.geometry.Bounds)2