Search in sources :

Example 16 with PointQuery

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

the class DragRobotImplTest method drag_with_pointQuery_and_primary_button.

@Test
public void drag_with_pointQuery_and_primary_button() {
    // given:
    PointQuery pointQuery = mock(PointQuery.class);
    // when:
    dragRobot.drag(pointQuery, MouseButton.PRIMARY);
    // then:
    verify(mouseRobot, times(1)).press(eq(MouseButton.PRIMARY));
    verify(moveRobot, times(1)).moveTo(eq(pointQuery));
    verifyNoMoreInteractions(mouseRobot);
}
Also used : PointQuery(org.testfx.service.query.PointQuery) Test(org.junit.Test)

Example 17 with PointQuery

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

the class DragRobotImplTest method dropTo_pointQuery_with_dragged_with_primary_button.

@Test
public void dropTo_pointQuery_with_dragged_with_primary_button() {
    // given:
    PointQuery pointQuery = mock(PointQuery.class);
    // and:
    dragRobot.drag(MouseButton.PRIMARY);
    reset(mouseRobot, moveRobot);
    // when:
    dragRobot.dropTo(pointQuery);
    // then:
    verify(moveRobot, times(1)).moveTo(eq(pointQuery));
    verify(mouseRobot, times(1)).release();
    verifyNoMoreInteractions(moveRobot, mouseRobot);
}
Also used : PointQuery(org.testfx.service.query.PointQuery) Test(org.junit.Test)

Example 18 with PointQuery

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

the class MoveRobotImplTest method moveTo_a_point_within_1000_pixels.

@Test
public void moveTo_a_point_within_1000_pixels() {
    // given:
    Point2D sourcePoint = new Point2D(0, 0);
    given(baseRobot.retrieveMouse()).willReturn(sourcePoint);
    // and:
    Point2D targetPoint = new Point2D(1000, 0);
    PointQuery pointQuery = mock(PointQuery.class);
    given(pointQuery.query()).willReturn(targetPoint);
    // when:
    moveRobot.moveTo(pointQuery);
    // then:
    verify(mouseRobot, times(199)).moveNoWait(not(eq(targetPoint)));
    verify(mouseRobot, times(2)).move(targetPoint);
}
Also used : Point2D(javafx.geometry.Point2D) PointQuery(org.testfx.service.query.PointQuery) Test(org.junit.Test)

Example 19 with PointQuery

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

the class MoveRobotImplTest method moveTo_should_move_to_moved_target_point.

@Test
public void moveTo_should_move_to_moved_target_point() {
    // given:
    Point2D sourcePoint = new Point2D(0, 0);
    given(baseRobot.retrieveMouse()).willReturn(sourcePoint);
    // and:
    Point2D targetPoint = new Point2D(10, 0);
    Point2D movedTargetPoint = new Point2D(20, 0);
    PointQuery pointQuery = mock(PointQuery.class);
    given(pointQuery.query()).willReturn(targetPoint, movedTargetPoint);
    // when:
    moveRobot.moveTo(pointQuery);
    // then:
    verify(mouseRobot, times(1)).move(targetPoint);
    verify(mouseRobot, times(1)).move(movedTargetPoint);
}
Also used : Point2D(javafx.geometry.Point2D) PointQuery(org.testfx.service.query.PointQuery) Test(org.junit.Test)

Example 20 with PointQuery

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

the class MoveRobotImplTest method moveTo_a_point_with_motion_VERTICAL_FIRST.

@Test
public void moveTo_a_point_with_motion_VERTICAL_FIRST() {
    // 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.VERTICAL_FIRST);
    // then:
    verify(mouseRobot, times(199)).moveNoWait(argThat(argument -> sourcePoint.getX() == argument.getX() || targetPoint.getY() == argument.getY()));
    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)

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