Search in sources :

Example 1 with MouseEventBuilder

use of com.android.tools.idea.uibuilder.fixtures.MouseEventBuilder in project android by JetBrains.

the class LayoutTestUtilities method pressMouse.

public static void pressMouse(InteractionManager manager, int button, int x, int y, int modifiers) {
    Object listener = manager.getListener();
    assertTrue(listener instanceof MouseListener);
    MouseListener mouseListener = (MouseListener) listener;
    JComponent layeredPane = manager.getSurface().getLayeredPane();
    mouseListener.mousePressed(new MouseEventBuilder(x, y).withSource(layeredPane).withMask(modifiers).build());
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEventBuilder(com.android.tools.idea.uibuilder.fixtures.MouseEventBuilder)

Example 2 with MouseEventBuilder

use of com.android.tools.idea.uibuilder.fixtures.MouseEventBuilder in project android by JetBrains.

the class LayoutTestUtilities method releaseMouse.

public static void releaseMouse(InteractionManager manager, int button, int x, int y, int modifiers) {
    Object listener = manager.getListener();
    assertTrue(listener instanceof MouseListener);
    MouseListener mouseListener = (MouseListener) listener;
    JComponent layeredPane = manager.getSurface().getLayeredPane();
    mouseListener.mousePressed(new MouseEventBuilder(x, y).withSource(layeredPane).withMask(modifiers).build());
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEventBuilder(com.android.tools.idea.uibuilder.fixtures.MouseEventBuilder)

Example 3 with MouseEventBuilder

use of com.android.tools.idea.uibuilder.fixtures.MouseEventBuilder in project android by JetBrains.

the class LayoutTestUtilities method moveMouse.

public static void moveMouse(InteractionManager manager, int x1, int y1, int x2, int y2, int modifiers) {
    Object listener = manager.getListener();
    assertTrue(listener instanceof MouseMotionListener);
    MouseMotionListener mouseListener = (MouseMotionListener) listener;
    int frames = 5;
    double x = x1;
    double y = y1;
    double xSlope = (x2 - x) / frames;
    double ySlope = (y2 - y) / frames;
    JComponent layeredPane = manager.getSurface().getLayeredPane();
    for (int i = 0; i < frames + 1; i++) {
        MouseEvent event = new MouseEventBuilder((int) x, (int) y).withSource(layeredPane).withMask(modifiers).build();
        mouseListener.mouseMoved(event);
        x += xSlope;
        y += ySlope;
    }
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseEventBuilder(com.android.tools.idea.uibuilder.fixtures.MouseEventBuilder) MouseMotionListener(java.awt.event.MouseMotionListener)

Example 4 with MouseEventBuilder

use of com.android.tools.idea.uibuilder.fixtures.MouseEventBuilder in project android by JetBrains.

the class LayoutTestUtilities method clickMouse.

public static void clickMouse(InteractionManager manager, int button, int count, int x, int y, int modifiers) {
    JComponent layeredPane = manager.getSurface().getLayeredPane();
    for (int i = 0; i < count; i++) {
        pressMouse(manager, button, x, y, modifiers);
        releaseMouse(manager, button, x, y, modifiers);
        Object listener = manager.getListener();
        assertTrue(listener instanceof MouseListener);
        MouseListener mouseListener = (MouseListener) listener;
        MouseEvent event = new MouseEventBuilder(x, y).withSource(layeredPane).withButton(button).withMask(modifiers).withClickCount(i).build();
        mouseListener.mouseClicked(event);
    }
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) MouseEventBuilder(com.android.tools.idea.uibuilder.fixtures.MouseEventBuilder)

Aggregations

MouseEventBuilder (com.android.tools.idea.uibuilder.fixtures.MouseEventBuilder)4 MouseListener (java.awt.event.MouseListener)3 MouseEvent (java.awt.event.MouseEvent)2 MouseMotionListener (java.awt.event.MouseMotionListener)1