本文整理汇总了Java中org.fest.swing.core.Robot类的典型用法代码示例。如果您正苦于以下问题:Java Robot类的具体用法?Java Robot怎么用?Java Robot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Robot类属于org.fest.swing.core包,在下文中一共展示了Robot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: find
import org.fest.swing.core.Robot; //导入依赖的package包/类
public static <T extends Component> T find(
Robot robot,
Container root,
GenericTypeMatcher<T> m ) {
ComponentHierarchy hierarchy = robot.hierarchy();
List<Component> found = null;
if (root == null) {
found = find(hierarchy, m);
} else {
found = find(new SingleComponentHierarchy(root, hierarchy), m);
}
if (found.isEmpty()) {
throw componentNotFound(robot, hierarchy, m);
}
if (found.size() > 1) {
throw multipleComponentsFound(found, m);
}
Component component = found.iterator().next();
return m.supportedType().cast(component);
}
示例2: getComponentHierarchy
import org.fest.swing.core.Robot; //导入依赖的package包/类
/**
*
* @param driver Swing driver
* @return the component hierarchy as {@link String}
*/
public static String getComponentHierarchy(
SwingDriverInternal driver ) {
ContainerFixture<?> containerFixture = driver.getActiveContainerFixture();
Robot robot = null;
if (containerFixture != null) {
// use the current robot instance
robot = containerFixture.robot;
} else {
robot = BasicRobot.robotWithCurrentAwtHierarchy();
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
robot.printer().printComponents(new PrintStream(outputStream), ( (containerFixture != null)
? containerFixture.component()
: null));
return outputStream.toString();
}
示例3: find
import org.fest.swing.core.Robot; //导入依赖的package包/类
@NotNull
public static ChooseGradleHomeDialogFixture find(@NotNull final Robot robot) {
DialogFixture found = findDialog(new GenericTypeMatcher<Dialog>(Dialog.class) {
@Override
protected boolean isMatching(@NotNull Dialog dialog) {
if (!dialog.isVisible() || !dialog.isShowing()) {
return false;
}
ComponentFinder finder = robot.finder();
finder.find(dialog, new ComponentMatcher() {
@Override
public boolean matches(Component c) {
if (c instanceof JBLabel) {
return "Gradle home:".equals(((JBLabel)c).getText());
}
return false;
}
});
finder.findByType(dialog, TextFieldWithBrowseButton.class);
return true;
}
}).withTimeout(LONG_TIMEOUT.duration()).using(robot);
return new ChooseGradleHomeDialogFixture(robot, found.target());
}
示例4: find
import org.fest.swing.core.Robot; //导入依赖的package包/类
@NotNull
public static IdeFrameFixture find(@NotNull final Robot robot, @NotNull final File projectPath, @Nullable final String projectName) {
final GenericTypeMatcher<IdeFrameImpl> matcher = new GenericTypeMatcher<IdeFrameImpl>(IdeFrameImpl.class) {
@Override
protected boolean isMatching(@NotNull IdeFrameImpl frame) {
Project project = frame.getProject();
if (project != null && projectPath.getPath().equals(project.getBasePath())) {
return projectName == null || projectName.equals(project.getName());
}
return false;
}
};
pause(new Condition("IdeFrame " + quote(projectPath.getPath()) + " to show up") {
@Override
public boolean test() {
Collection<IdeFrameImpl> frames = robot.finder().findAll(matcher);
return !frames.isEmpty();
}
}, LONG_TIMEOUT);
IdeFrameImpl ideFrame = robot.finder().find(matcher);
return new IdeFrameFixture(robot, ideFrame, projectPath);
}
示例5: AndroidToolWindowFixture
import org.fest.swing.core.Robot; //导入依赖的package包/类
public AndroidToolWindowFixture(@NotNull Project project, final @NotNull Robot robot) {
super(AndroidToolWindowFactory.TOOL_WINDOW_ID, project, robot);
show();
final JPanel contentPanel = getContentPanel();
pause(new Condition("Wait for window to finish initializing.") {
@Override
public boolean test() {
try {
myRobot.finder().find(contentPanel, JLabelMatcher.withText("Initializing..."));
}
catch (ComponentLookupException e) {
// Didn't find it. Great, we're done!
return true;
}
return false;
}
}, SHORT_TIMEOUT);
myProcessListFixture = new ProcessListFixture(robot, robot.finder().findByType(getContentPanel(), JList.class, false));
}
示例6: waitUntilFound
import org.fest.swing.core.Robot; //导入依赖的package包/类
/** Waits for a first component which passes the given matcher under the given root to become visible. */
@NotNull
public static <T extends Component> T waitUntilFound(@NotNull final Robot robot,
@Nullable final Container root,
@NotNull final GenericTypeMatcher<T> matcher) {
final AtomicReference<T> reference = new AtomicReference<T>();
pause(new Condition("Find component using " + matcher.toString()) {
@Override
public boolean test() {
ComponentFinder finder = robot.finder();
Collection<T> allFound = root != null ? finder.findAll(root, matcher) : finder.findAll(matcher);
boolean found = allFound.size() == 1;
if (found) {
reference.set(getFirstItem(allFound));
}
else if (allFound.size() > 1) {
// Only allow a single component to be found, otherwise you can get some really confusing
// test failures; the matcher should pick a specific enough instance
fail("Found more than one " + matcher.supportedType().getSimpleName() + " which matches the criteria: " + allFound);
}
return found;
}
}, SHORT_TIMEOUT);
return reference.get();
}
示例7: menuItemWithPath
import org.fest.swing.core.Robot; //导入依赖的package包/类
public static JMenuItemFixture menuItemWithPath(
Robot robot,
Container root,
String... path ) {
ComponentMatcher m = new JMenuItemMatcher(path);
Component item = robot.finder().find(root, m);
assertThat(item).as(format(item)).isInstanceOf(JMenuItem.class);
return new JMenuItemFixture(robot, (JMenuItem) item);
}
示例8: componentNotFound
import org.fest.swing.core.Robot; //导入依赖的package包/类
private static ComponentLookupException componentNotFound(
Robot robot,
ComponentHierarchy h,
ComponentMatcher m ) {
String message = concat("Unable to find component using matcher ", m, ".");
message = concat(message,
LINE_SEPARATOR,
LINE_SEPARATOR,
"Component hierarchy:",
LINE_SEPARATOR,
formattedHierarchy(robot.printer(), root(h)));
throw new ComponentLookupException(message);
}
示例9: IdeFrameFixture
import org.fest.swing.core.Robot; //导入依赖的package包/类
public IdeFrameFixture(@NotNull Robot robot, @NotNull IdeFrameImpl target, @NotNull File projectPath) {
super(IdeFrameFixture.class, robot, target);
myProjectPath = projectPath;
final Project project = getProject();
Disposable disposable = new NoOpDisposable();
Disposer.register(project, disposable);
myGradleProjectEventListener = new GradleProjectEventListener();
MessageBusConnection connection = project.getMessageBus().connect(disposable);
connection.subscribe(GRADLE_SYNC_TOPIC, myGradleProjectEventListener);
connection.subscribe(GRADLE_BUILD_TOPIC, myGradleProjectEventListener);
}
示例10: findOpenProjectDialog
import org.fest.swing.core.Robot; //导入依赖的package包/类
@NotNull
public static FileChooserDialogFixture findOpenProjectDialog(@NotNull Robot robot) {
return findDialog(robot, new GenericTypeMatcher<JDialog>(JDialog.class) {
@Override
protected boolean isMatching(@NotNull JDialog dialog) {
return dialog.isShowing() && "Open File or Project".equals(dialog.getTitle());
}
});
}
示例11: findImportProjectDialog
import org.fest.swing.core.Robot; //导入依赖的package包/类
@NotNull
public static FileChooserDialogFixture findImportProjectDialog(@NotNull Robot robot) {
return findDialog(robot, new GenericTypeMatcher<JDialog>(JDialog.class) {
@Override
protected boolean isMatching(@NotNull JDialog dialog) {
String title = dialog.getTitle();
return dialog.isShowing() && title != null && title.startsWith("Select") && title.endsWith("Project to Import");
}
});
}
示例12: find
import org.fest.swing.core.Robot; //导入依赖的package包/类
@NotNull
public static AvdManagerDialogFixture find(@NotNull Robot robot) {
JFrame frame = waitUntilFound(robot, new GenericTypeMatcher<JFrame>(JFrame.class) {
@Override
protected boolean isMatching(@NotNull JFrame dialog) {
return "Android Virtual Device Manager".equals(dialog.getTitle()) && dialog.isShowing();
}
});
return new AvdManagerDialogFixture(robot, frame);
}
示例13: LibraryPropertiesDialogFixture
import org.fest.swing.core.Robot; //导入依赖的package包/类
protected LibraryPropertiesDialogFixture(@NotNull Robot robot,
@NotNull JDialog target,
@NotNull LibraryPropertiesDialog wrapper,
@NotNull Library library,
@NotNull Project project) {
super(robot, target, wrapper);
myLibraryName = nullToEmpty(library.getName());
myProject = project;
}
示例14: ToolWindowFixture
import org.fest.swing.core.Robot; //导入依赖的package包/类
protected ToolWindowFixture(@NotNull final String toolWindowId, @NotNull final Project project, @NotNull Robot robot) {
myToolWindowId = toolWindowId;
myProject = project;
final Ref<ToolWindow> toolWindowRef = new Ref<ToolWindow>();
pause(new Condition("Find tool window with ID '" + toolWindowId + "'") {
@Override
public boolean test() {
ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(toolWindowId);
toolWindowRef.set(toolWindow);
return toolWindow != null;
}
}, SHORT_TIMEOUT);
myRobot = robot;
myToolWindow = toolWindowRef.get();
}
示例15: find
import org.fest.swing.core.Robot; //导入依赖的package包/类
@NotNull
public static WelcomeFrameFixture find(@NotNull Robot robot) {
for (Frame frame : Frame.getFrames()) {
if (frame instanceof WelcomeFrame && frame.isShowing()) {
return new WelcomeFrameFixture(robot, (WelcomeFrame)frame);
}
}
throw new ComponentLookupException("Unable to find 'Welcome' window");
}