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());
}
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());
}
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;
}
}
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);
}
}
Aggregations