本文整理汇总了Java中test.java.awt.regtesthelpers.Util.waitForCondition方法的典型用法代码示例。如果您正苦于以下问题:Java Util.waitForCondition方法的具体用法?Java Util.waitForCondition怎么用?Java Util.waitForCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test.java.awt.regtesthelpers.Util
的用法示例。
在下文中一共展示了Util.waitForCondition方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: trackEvent
import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) {
EventListener listener = null;
switch (eventID) {
case WindowEvent.WINDOW_GAINED_FOCUS:
listener = wgfListener;
break;
case FocusEvent.FOCUS_GAINED:
listener = fgListener;
break;
case ActionEvent.ACTION_PERFORMED:
listener = apListener;
break;
}
listener.listen(comp, printEvent);
action.run();
return Util.waitForCondition(listener.getNotifier(), time);
}
示例2: main
import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
Robot robot = Util.createRobot();
createAndShowGUI();
Util.waitForIdle(robot);
Util.waitForCondition(testCompleted);
if (!testResult) {
throw new RuntimeException("Test FAILED!");
}
} finally {
if (controlDialog != null) {
controlDialog.dispose();
}
if (testFrame != null) {
testFrame.dispose();
}
}
}
示例3: test1
import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
void test1() {
Util.clickOnComp(b, robot);
Util.waitForIdle(robot);
if (!tf2.hasFocus()) {
throw new TestFailedException("target component didn't get focus!");
}
robot.keyPress(KeyEvent.VK_9);
robot.delay(50);
robot.keyRelease(KeyEvent.VK_9);
synchronized (typed) {
if (!Util.waitForCondition(typed, 2000)) {
throw new TestFailedException("key char couldn't be typed!");
}
}
Util.clickOnComp(tf3, robot);
Util.waitForIdle(robot);
if (!tf3.hasFocus()) {
throw new Error("a text field couldn't be focused.");
}
typed.set(false);
robot.keyPress(KeyEvent.VK_8);
robot.delay(50);
robot.keyRelease(KeyEvent.VK_8);
synchronized (typed) {
if (!Util.waitForCondition(typed, 2000)) {
throw new TestFailedException("key char couldn't be typed!");
}
}
}
示例4: start
import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void start() {
menu.setMnemonic('f');
menu.add(item);
bar.add(menu);
frame.setJMenuBar(bar);
frame.pack();
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
dialog.add(text);
dialog.pack();
dialog.setVisible(true);
}
});
text.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
if (e.getKeyChar() == ' ') {
Sysout.println(e.toString());
synchronized (gotEvent) {
gotEvent.set(true);
gotEvent.notifyAll();
}
}
}
});
frame.setVisible(true);
Util.waitForIdle(robot);
robot.keyPress(KeyEvent.VK_ALT);
robot.delay(20);
robot.keyPress(KeyEvent.VK_F);
robot.delay(20);
robot.keyRelease(KeyEvent.VK_F);
robot.delay(20);
robot.keyRelease(KeyEvent.VK_ALT);
Util.waitForIdle(robot);
item.setSelected(true);
Util.waitForIdle(robot);
robot.keyPress(KeyEvent.VK_SPACE);
robot.delay(20);
robot.keyRelease(KeyEvent.VK_SPACE);
if (Util.waitForCondition(gotEvent, 2000)) {
throw new TestFailedException("a space went into the dialog's text field!");
}
Sysout.println("Test passed.");
}
示例5: start
import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void start() {
menu.setMnemonic('f');
submenu.setMnemonic('m');
menu.add(submenu);
submenu.add(item);
bar.add(menu);
frame.setJMenuBar(bar);
frame.pack();
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Sysout.println(e.toString());
synchronized (activated) {
activated.set(true);
activated.notifyAll();
}
}
});
frame.setVisible(true);
Util.waitForIdle(robot);
boolean isMacOSX = (OSInfo.getOSType() == OSInfo.OSType.MACOSX);
if (isMacOSX) {
robot.keyPress(KeyEvent.VK_CONTROL);
robot.delay(20);
}
robot.keyPress(KeyEvent.VK_ALT);
robot.delay(20);
robot.keyPress(KeyEvent.VK_F);
robot.delay(20);
robot.keyRelease(KeyEvent.VK_F);
robot.delay(20);
robot.keyRelease(KeyEvent.VK_ALT);
if (isMacOSX) {
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.delay(20);
}
Util.waitForIdle(robot);
robot.keyPress(KeyEvent.VK_M);
robot.delay(20);
robot.keyRelease(KeyEvent.VK_M);
Util.waitForIdle(robot);
robot.keyPress(KeyEvent.VK_SPACE);
robot.delay(20);
robot.keyRelease(KeyEvent.VK_SPACE);
Util.waitForIdle(robot);
if (!Util.waitForCondition(activated, 2000)) {
throw new TestFailedException("a submenu wasn't activated by mnemonic key press");
}
Sysout.println("Test passed.");
}
示例6: start
import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void start() {
frame.setBounds(800, 0, 200, 100);
window.setBounds(800, 200, 200, 100);
window.setLayout(new FlowLayout());
window.add(button);
window.addWindowFocusListener(new WindowAdapter() {
public void windowGainedFocus(WindowEvent e) {
Sysout.println(e.toString());
synchronized (focused) {
focused.set(true);
focused.notifyAll();
}
}});
frame.setVisible(true);
toolkit.realSync();
// Test 1. Show the window, check that it become focused.
window.setVisible(true);
toolkit.realSync();
if (!Util.waitForCondition(focused, 2000L)) {
throw new TestFailedException("the window didn't get focused on its showing!");
}
// Test 2. Show unfocusable window, check that it doesn't become focused.
window.setVisible(false);
toolkit.realSync();
window.setFocusableWindowState(false);
focused.set(false);
window.setVisible(true);
toolkit.realSync();
if (Util.waitForCondition(focused, 2000L)) {
throw new TestFailedException("the unfocusable window got focused on its showing!");
} else {
Sysout.println("Test passed");
}
}
示例7: start
import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void start() {
if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
Sysout.println("The test is not for MToolkit.");
return;
}
dialog.setBounds(800, 0, 200, 100);
frame.setBounds(800, 150, 200, 100);
dialog.addWindowFocusListener(new WindowAdapter() {
public void windowLostFocus(WindowEvent e) {
Sysout.println(e.toString());
synchronized (lostFocus) {
lostFocus.set(true);
lostFocus.notifyAll();
}
}
});
new Thread(new Runnable() {
public void run() {
dialog.setVisible(true);
}
}).start();
Util.waitTillShown(dialog);
toolkit.realSync();
// Test 1. Show a modal blocked frame, check that it doesn't steal focus.
frame.setVisible(true);
if (Util.waitForCondition(lostFocus, 2000L)) {
throw new TestFailedException("the modal blocked frame stole focus on its showing!");
}
// Test 2. Brought a modal blocked frame to front, check that it doesn't steal focus.
frame.toFront();
if (Util.waitForCondition(lostFocus, 2000L)) {
throw new TestFailedException("the modal blocked frame stole focus on its bringing to front!");
} else {
Sysout.println("Test passed");
}
}
示例8: main
import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public static void main(String[] args) {
Robot robot = Util.createRobot();
Frame testFrame = new Frame("Test Frame");
testFrame.setSize(200, 200);
testFrame.addWindowStateListener(new WindowStateListener() {
@Override
public void windowStateChanged(WindowEvent e) {
listenerNotified.set(true);
synchronized (listenerNotified) {
listenerNotified.notifyAll();
}
}
});
testFrame.setVisible(true);
Frame mainFrame = new Frame("Main Frame");
mainFrame.setSize(200, 200);
mainFrame.setLocationRelativeTo(null);
mainFrame.setVisible(true);
Util.waitForIdle(robot);
try {
Util.clickOnComp(mainFrame, robot);
Util.waitForIdle(robot);
// NORMAL -> ICONIFIED
listenerNotified.set(false);
testFrame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(robot);
Util.waitForCondition(listenerNotified, 2000);
if (!listenerNotified.get()) {
throw new RuntimeException("Test FAILED! Window state listener was not notified during NORMAL to" +
"ICONIFIED transition");
}
if (testFrame.getExtendedState() != Frame.ICONIFIED) {
throw new RuntimeException("Test FAILED! Frame is not in ICONIFIED state");
}
// ICONIFIED -> NORMAL
listenerNotified.set(false);
testFrame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(robot);
Util.waitForCondition(listenerNotified, 2000);
if (!listenerNotified.get()) {
throw new RuntimeException("Test FAILED! Window state listener was not notified during ICONIFIED to" +
"NORMAL transition");
}
if (testFrame.getExtendedState() != Frame.NORMAL) {
throw new RuntimeException("Test FAILED! Frame is not in NORMAL state");
}
} finally {
testFrame.dispose();
mainFrame.dispose();
}
}
示例9: start
import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void start() {
menu.setMnemonic('f');
submenu.setMnemonic('m');
menu.add(submenu);
submenu.add(item);
bar.add(menu);
frame.setJMenuBar(bar);
frame.pack();
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Sysout.println(e.toString());
synchronized (activated) {
activated.set(true);
activated.notifyAll();
}
}
});
frame.setVisible(true);
boolean isMacOSX = (OSInfo.getOSType() == OSInfo.OSType.MACOSX);
if (isMacOSX) {
robot.keyPress(KeyEvent.VK_CONTROL);
}
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_F);
robot.keyRelease(KeyEvent.VK_F);
robot.keyRelease(KeyEvent.VK_ALT);
if (isMacOSX) {
robot.keyRelease(KeyEvent.VK_CONTROL);
}
robot.keyPress(KeyEvent.VK_M);
robot.keyRelease(KeyEvent.VK_M);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
if (!Util.waitForCondition(activated, 2000)) {
throw new TestFailedException("a submenu wasn't activated by mnemonic key press");
}
Sysout.println("Test passed.");
}
示例10: start
import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void start() {
frame.setBounds(800, 0, 200, 100);
window.setBounds(800, 200, 200, 100);
window.setLayout(new FlowLayout());
window.add(button);
window.addWindowFocusListener(new WindowAdapter() {
public void windowGainedFocus(WindowEvent e) {
Sysout.println(e.toString());
synchronized (focused) {
focused.set(true);
focused.notifyAll();
}
}});
frame.setVisible(true);
try {
robot = new Robot();
}catch(Exception ex) {
ex.printStackTrace();
throw new RuntimeException("Unexpected failure");
}
robot.waitForIdle();
// Test 1. Show the window, check that it become focused.
window.setVisible(true);
robot.waitForIdle();
if (!Util.waitForCondition(focused, 2000L)) {
throw new TestFailedException("the window didn't get focused on its showing!");
}
// Test 2. Show unfocusable window, check that it doesn't become focused.
window.setVisible(false);
robot.waitForIdle();
window.setFocusableWindowState(false);
focused.set(false);
window.setVisible(true);
robot.waitForIdle();
if (Util.waitForCondition(focused, 2000L)) {
throw new TestFailedException("the unfocusable window got focused on its showing!");
} else {
Sysout.println("Test passed");
}
}
示例11: start
import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void start() {
if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
Sysout.println("The test is not for MToolkit.");
return;
}
dialog.setBounds(800, 0, 200, 100);
frame.setBounds(800, 150, 200, 100);
dialog.addWindowFocusListener(new WindowAdapter() {
public void windowLostFocus(WindowEvent e) {
Sysout.println(e.toString());
synchronized (lostFocus) {
lostFocus.set(true);
lostFocus.notifyAll();
}
}
});
new Thread(new Runnable() {
public void run() {
dialog.setVisible(true);
}
}).start();
Util.waitTillShown(dialog);
try {
Robot robot = new Robot();
robot.waitForIdle();
}catch(Exception ex) {
ex.printStackTrace();
throw new RuntimeException("Unexpected failure");
}
// Test 1. Show a modal blocked frame, check that it doesn't steal focus.
frame.setVisible(true);
if (Util.waitForCondition(lostFocus, 2000L)) {
throw new TestFailedException("the modal blocked frame stole focus on its showing!");
}
// Test 2. Brought a modal blocked frame to front, check that it doesn't steal focus.
frame.toFront();
if (Util.waitForCondition(lostFocus, 2000L)) {
throw new TestFailedException("the modal blocked frame stole focus on its bringing to front!");
} else {
Sysout.println("Test passed");
}
}