Got my robot code working,
public void startSimulation(String finalName) throws Exception {
Robot robot = new Robot();
FileReader fr = new FileReader(finalName);
BufferedReader br = new BufferedReader(fr);
System.out.println("START SIMULATION");
while (br.ready()) {
Thread.sleep(delay);
String action = br.readLine();
if (action.equals("click")) {
System.out.println("CLICK:" + action);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
} else if (action.indexOf(',') != -1) {
System.out.println("MOVE:" + action);
StringTokenizer st = new StringTokenizer(action, ",");
int titleBarSize = 20;
int frameBorderSize = 3;
int x = new Integer(st.nextToken()) + frameBorderSize;
int y = new Integer(st.nextToken()) + titleBarSize;
robot.mouseMove(x, y);
} else {
System.out.println("PRESS:" + action);
int keycode = new Integer(action);
robot.keyPress(keycode);
robot.keyRelease(keycode);
}
}
}
private PrintWriter pw;
private int delay = 0;
public void startRecord(String fileName) throws Exception{
pw = new PrintWriter(fileName);
System.out.println("START RECORDING");
window.getComponentMouseListeners().add(new
ComponentMouseListener.Adapter() {
@Override
public boolean mouseMove(Component component, int x, int y) {
System.out.println("x: " + x + " y: " + y);
pw.println(x + "," + y);
return false;
}
});
window.getComponentMouseButtonListeners().add(new
ComponentMouseButtonListener.Adapter() {
@Override
public boolean mouseClick(Component component, Button button,
int x, int y, int count) {
System.out.println("click");
pw.println("click");
return false;
}
});
window.getComponentKeyListeners().add(new
ComponentKeyListener.Adapter() {
@Override
public boolean keyPressed(Component component, int keyCode,
KeyLocation keyLocation) {
System.out.println(keyCode + "");
pw.println(keyCode + "");
return false;
}
});
}
Works only if x and y or the host frame is both 0. The tile bar
height border width of the HostFrame is also estimated.
How about making this a utility in pivot?
On Wed, Oct 14, 2009 at 11:13 AM, Vicente de Rivera III <
[email protected]> wrote:
> On third thought, I'll just have to do manual testing. The animation
> effects make it complicated to test my pivot app ( I need to test CRUD
> functionally w/ a tableViewRowEditor ).
> I think I'll just code for a Java Robot that can replicate an actual usage
> case of my app. Any open source library that already does this?
>
> On Wed, Oct 14, 2009 at 9:05 AM, Vicente de Rivera III <
> [email protected]> wrote:
>
>> On second thought, i really need to run my pivot app many times for each
>> test
>
>
>