本文整理汇总了Java中org.eclipse.swtbot.swt.finder.SWTBot.sleep方法的典型用法代码示例。如果您正苦于以下问题:Java SWTBot.sleep方法的具体用法?Java SWTBot.sleep怎么用?Java SWTBot.sleep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swtbot.swt.finder.SWTBot
的用法示例。
在下文中一共展示了SWTBot.sleep方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitUntilTreeItemHasItem
import org.eclipse.swtbot.swt.finder.SWTBot; //导入方法依赖的package包/类
/**
* Blocks the caller until the tree item has the given item text.
*
* @param tree the tree item to search
* @param nodeText the item text to look for
* @throws org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException if the item could not
* be found within the timeout period
*/
private static void waitUntilTreeItemHasItem(SWTBot bot, final SWTBotTreeItem tree,
final String nodeText) {
// Attempt #1
if (!waitUntilTreeHasItemImpl(bot, tree.widget, nodeText)) {
// Attempt #2: Something went wrong, try to cautiously reopen it.
bot.sleep(1000);
// There isn't a method to collapse, so double-click instead
tree.doubleClick();
bot.waitUntil(new TreeCollapsedCondition(tree.widget));
bot.sleep(1000);
tree.expand();
bot.waitUntil(new TreeExpandedCondition(tree.widget));
if (!waitUntilTreeHasItemImpl(bot, tree.widget, nodeText)) {
printTree(tree.widget);
throw new TimeoutException(
String.format("Timed out waiting for %s, giving up...", nodeText));
}
}
}
示例2: waitUntilTreeItemHasItem
import org.eclipse.swtbot.swt.finder.SWTBot; //导入方法依赖的package包/类
/**
* Blocks the caller until the tree item has the given item text.
*
* @param tree the tree item to search
* @param nodeText the item text to look for
* @throws org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException if the item could not
* be found within the timeout period
*/
private static void waitUntilTreeItemHasItem(SWTBot bot, final SWTBotTreeItem tree,
final String nodeText) {
// Attempt #1
if (!waitUntilTreeHasItemImpl(bot, tree.widget, nodeText)) {
// Attempt #2: Something went wrong, try to cautiously reopen it.
bot.sleep(1000);
// There isn't a method to collapse, so double-click instead
tree.doubleClick();
bot.waitUntil(new TreeCollapsedCondition(tree.widget));
bot.sleep(1000);
tree.expand();
bot.waitUntil(new TreeExpandedCondition(tree.widget));
if (!waitUntilTreeHasItemImpl(bot, tree.widget, nodeText)) {
printTree(tree.widget);
throw new TimeoutException(
String.format("Timed out waiting for %s, giving up...", nodeText));
}
}
}
示例3: waitUntilTreeHasText
import org.eclipse.swtbot.swt.finder.SWTBot; //导入方法依赖的package包/类
/**
* Blocks the caller until all of the direct children of the tree have text. The assumption is
* that the tree does not have any "empty" children.
*
* TODO: Refactor some of this logic; it follows the same general pattern as
* {@link #waitUntilTreeItemHasItem(SWTBot, SWTBotTreeItem, String)}.
*
* @param tree the tree to search
* @throws TimeoutException if all of the direct children of the tree do not have text within the
* timeout period
*/
public static void waitUntilTreeHasText(SWTBot bot, final SWTBotTreeItem tree)
throws TimeoutException {
// Attempt #1
if (!waitUntilTreeHasTextImpl(bot, tree.widget)) {
// Attempt #2: Something went wrong, try to cautiously reopen it.
bot.sleep(1000);
// There isn't a method to collapse, so double-click instead
tree.doubleClick();
bot.waitUntil(new TreeCollapsedCondition(tree.widget));
bot.sleep(1000);
tree.expand();
bot.waitUntil(new TreeExpandedCondition(tree.widget));
if (!waitUntilTreeHasTextImpl(bot, tree.widget)) {
printTree(tree.widget);
throw new TimeoutException(
"Timed out waiting for text of the tree's children, giving up...");
}
}
}
示例4: waitForProjects
import org.eclipse.swtbot.swt.finder.SWTBot; //导入方法依赖的package包/类
/**
* Wait until all background tasks are complete.
*/
public static void waitForProjects(final SWTBot bot, IProject... projects) {
Runnable delayTactic = new Runnable() {
@Override
public void run() {
bot.sleep(300);
}
};
ProjectUtils.waitForProjects(delayTactic, projects);
}
示例5: openPreferencesDialogViaEvents
import org.eclipse.swtbot.swt.finder.SWTBot; //导入方法依赖的package包/类
private static void openPreferencesDialogViaEvents(SWTBot bot) {
Display display = bot.getDisplay();
Event event = new Event();
// Move to the "Apple" menu item (it catches 0, 0)
event.type = SWT.MouseMove;
event.x = 0;
event.y = 0;
display.post(event);
bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
// Click
event.type = SWT.MouseDown;
event.button = 1;
display.post(event);
bot.sleep(SwtBotTestingUtilities.EVENT_DOWN_UP_DELAY_MS);
event.type = SWT.MouseUp;
display.post(event);
bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
// Right to the "Eclipse" menu item
SwtBotTestingUtilities.sendKeyDownAndUp(bot, SWT.ARROW_RIGHT, '\0');
bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
// Down two to the "Preferences..." menu item
SwtBotTestingUtilities.sendKeyDownAndUp(bot, SWT.ARROW_DOWN, '\0');
bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
SwtBotTestingUtilities.sendKeyDownAndUp(bot, SWT.ARROW_DOWN, '\0');
bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
// Press enter
SwtBotTestingUtilities.sendKeyDownAndUp(bot, 0, '\r');
bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
}
示例6: waitUntilTreeHasText
import org.eclipse.swtbot.swt.finder.SWTBot; //导入方法依赖的package包/类
/**
* Blocks the caller until all of the direct children of the tree have text. The assumption is
* that the tree does not have any "empty" children.
*
* @param tree the tree to search
* @throws TimeoutException if any of the direct children of the tree do not have text within the
* timeout period
*/
public static void waitUntilTreeHasText(SWTBot bot, final SWTBotTreeItem tree)
throws TimeoutException {
// TODO: Refactor some of this logic; it follows the same general pattern as
// {@link #waitUntilTreeItemHasItem(SWTBot, SWTBotTreeItem, String)}.
// Attempt #1
if (!waitUntilTreeHasTextImpl(bot, tree.widget)) {
// Attempt #2: Something went wrong, try to cautiously reopen it.
bot.sleep(1000);
// There isn't a method to collapse, so double-click instead
tree.doubleClick();
bot.waitUntil(new TreeCollapsedCondition(tree.widget));
bot.sleep(1000);
tree.expand();
bot.waitUntil(new TreeExpandedCondition(tree.widget));
if (!waitUntilTreeHasTextImpl(bot, tree.widget)) {
printTree(tree.widget);
throw new TimeoutException(
"Timed out waiting for text of the tree's children, giving up...");
}
}
}
示例7: sendKeyDownAndUp
import org.eclipse.swtbot.swt.finder.SWTBot; //导入方法依赖的package包/类
/**
* Injects a key or character via down and up events. Only one of {@code keyCode} or
* {@code character} must be provided. Use
*
* @param keyCode the keycode of the key (use {@code 0} if unspecified)
* @param character the character to press (use {@code '\0'} if unspecified)
*/
public static void sendKeyDownAndUp(SWTBot bot, int keyCode, char character) {
Event ev = new Event();
ev.keyCode = keyCode;
ev.character = character;
ev.type = SWT.KeyDown;
bot.getDisplay().post(ev);
bot.sleep(EVENT_DOWN_UP_DELAY_MS);
ev.type = SWT.KeyUp;
bot.getDisplay().post(ev);
}
示例8: waitForIdle
import org.eclipse.swtbot.swt.finder.SWTBot; //导入方法依赖的package包/类
/**
* Wait until all background tasks are complete.
*/
public static void waitForIdle(SWTBot bot) {
SwtBotUtils.print("\t\tWaiting for idle");
while (!Job.getJobManager().isIdle()) {
bot.sleep(500);
}
SwtBotUtils.print("\t\tNow idle");
}
示例9: openPreferencesDialogViaEvents
import org.eclipse.swtbot.swt.finder.SWTBot; //导入方法依赖的package包/类
private static void openPreferencesDialogViaEvents(SWTBot bot) {
Display display = bot.getDisplay();
Event ev = new Event();
// Move to the "Apple" menu item (it catches 0, 0)
ev.type = SWT.MouseMove;
ev.x = 0;
ev.y = 0;
display.post(ev);
bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
// Click
ev.type = SWT.MouseDown;
ev.button = 1;
display.post(ev);
bot.sleep(SwtBotUtils.EVENT_DOWN_UP_DELAY_MS);
ev.type = SWT.MouseUp;
display.post(ev);
bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
// Right to the "Eclipse" menu item
SwtBotUtils.sendKeyDownAndUp(bot, SWT.ARROW_RIGHT, '\0');
bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
// Down two to the "Preferences..." menu item
SwtBotUtils.sendKeyDownAndUp(bot, SWT.ARROW_DOWN, '\0');
bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
SwtBotUtils.sendKeyDownAndUp(bot, SWT.ARROW_DOWN, '\0');
bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
// Press enter
SwtBotUtils.sendKeyDownAndUp(bot, 0, '\r');
bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
}
示例10: sendKeyDownAndUp
import org.eclipse.swtbot.swt.finder.SWTBot; //导入方法依赖的package包/类
/**
* Injects a key or character via down and up events.
*
* @param keyCode the keycode of the key (only this or character have to be provided.)
* @param character the character to press (only this or keyCode have to be provided.)
*/
public static void sendKeyDownAndUp(SWTBot bot, int keyCode, char character) {
Event ev = new Event();
ev.keyCode = keyCode;
ev.character = character;
ev.type = SWT.KeyDown;
bot.getDisplay().post(ev);
bot.sleep(EVENT_DOWN_UP_DELAY_MS);
ev.type = SWT.KeyUp;
bot.getDisplay().post(ev);
}