*/
public void test6a() throws Exception
{
for (int j = 0; j < 50; j++)
{
final OOoBean bean = new OOoBean();
final java.awt.Frame frame = new Frame("Openoffice.org");
bean.setOOoCallTimeOut(10000);
try {
frame.add(bean, BorderLayout.CENTER);
frame.pack();
frame.setSize(600,400);
frame.show();
bean.loadFromURL("private:factory/swriter", null);
frame.validate();
// #1
Thread.sleep(1000);
StringBuffer buf = new StringBuffer(1000);
int i = 0;
for (; i < 1; i++)
{
EventQueue q = Toolkit.getDefaultToolkit().getSystemEventQueue();
q.invokeAndWait( new Runnable() {
public void run() {
try {
bean.releaseSystemWindow();
frame.remove(bean);
frame.validate();
} catch (Exception e) {
e.printStackTrace();
}
}
});
// #2
Thread.sleep(1000);
q.invokeAndWait( new Runnable() {
public void run() {
try {
frame.add(bean, BorderLayout.CENTER);
bean.aquireSystemWindow();
frame.validate();
} catch (Exception e) {
e.printStackTrace();
}
}
});
// #3
Thread.sleep(1000);
}
if (isWindows() == false)
Thread.sleep(5000);
Robot roby = new Robot();
roby.mouseMove(300, 200);
roby.waitForIdle();
roby.mousePress(InputEvent.BUTTON1_MASK);
roby.waitForIdle();
roby.mouseRelease(InputEvent.BUTTON1_MASK);
roby.waitForIdle();
roby.keyPress(KeyEvent.VK_H);
roby.waitForIdle();
roby.keyRelease(KeyEvent.VK_H);
roby.waitForIdle();
buf.append("h");
Thread.sleep(1000);
String s = getText(bean);
System.out.println(" getText: " + s);
if ( ! s.equals(buf.toString()))
{
roby.mousePress(InputEvent.BUTTON1_MASK);
roby.waitForIdle();
roby.mouseRelease(InputEvent.BUTTON1_MASK);
roby.waitForIdle();
roby.keyPress(KeyEvent.VK_H);
roby.waitForIdle();
roby.keyRelease(KeyEvent.VK_H);
roby.waitForIdle();
String sH = "h";
Thread.sleep(1000);
String s2 = getText(bean);
if ( ! sH.equals(s2))
{
failed("Focus error: After removing and adding the bean, the" +
"office window does not receive keyboard input.\n" +
"Try typing in the window, you've got 30s!!! This " +
"test may not work with Linux/Solaris", true);
System.out.println("j: " + j + " i: " + i);
Thread.sleep(30000);
break;
}
}
else
{
// Thread.sleep(2000);
}
} finally {
bean.stopOOoConnection();
frame.dispose();
}
}
}