use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class ProjectViewFixture method selectAndroidPane.
@NotNull
public PaneFixture selectAndroidPane() {
activate();
final ProjectView projectView = ProjectView.getInstance(myProject);
pause(new Condition("Project view is initialized") {
@Override
public boolean test() {
//noinspection ConstantConditions
return field("isInitialized").ofType(boolean.class).in(projectView).get();
}
}, SHORT_TIMEOUT);
final String id = "AndroidView";
GuiActionRunner.execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
projectView.changeView(id);
}
});
return new PaneFixture(projectView.getProjectViewPaneById(id));
}
use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class ProjectViewFixture method selectProjectPane.
@NotNull
public PaneFixture selectProjectPane() {
activate();
final ProjectView projectView = ProjectView.getInstance(myProject);
pause(new Condition("Project view is initialized") {
@Override
public boolean test() {
//noinspection ConstantConditions
return field("isInitialized").ofType(boolean.class).in(projectView).get();
}
}, SHORT_TIMEOUT);
final String id = "ProjectPane";
GuiActionRunner.execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
projectView.changeView(id);
}
});
return new PaneFixture(projectView.getProjectViewPaneById(id));
}
use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class EditorFixture method getFocusedEditor.
/**
* Requests focus in the editor, waits and returns editor component
*/
@Nullable
private JComponent getFocusedEditor() {
Editor editor = execute(new GuiQuery<Editor>() {
@Override
@Nullable
protected Editor executeInEDT() throws Throwable {
FileEditorManager manager = FileEditorManager.getInstance(myFrame.getProject());
// Must be called from the EDT
return manager.getSelectedTextEditor();
}
});
//wait when TextEditor ContentComponent will showing
pause(new Condition("Waiting for showing focused textEditor") {
@Override
public boolean test() {
return editor.getContentComponent().isShowing();
}
}, SHORT_TIMEOUT);
if (editor != null) {
JComponent contentComponent = editor.getContentComponent();
new ComponentDriver(robot).focusAndWaitForFocusGain(contentComponent);
assertSame(contentComponent, FocusManager.getCurrentManager().getFocusOwner());
return contentComponent;
} else {
fail("Expected to find editor to focus, but there is no current editor");
return null;
}
}
use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class EditorFixture method open.
/**
* Opens up a different file. This will run through the "Open File..." dialog to
* find and select the given file.
*
* @param file the file to open
* @param tab which tab to open initially, if there are multiple editors
*/
public EditorFixture open(@NotNull final VirtualFile file, @NotNull final Tab tab) {
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
// TODO: Use UI to navigate to the file instead
Project project = myFrame.getProject();
FileEditorManager manager = FileEditorManager.getInstance(project);
if (tab == Tab.EDITOR) {
manager.openTextEditor(new OpenFileDescriptor(project, file), true);
} else {
manager.openFile(file, true);
}
}
});
pause(new Condition("File " + quote(file.getPath()) + " to be opened") {
@Override
public boolean test() {
//noinspection ConstantConditions
return execute(new GuiQuery<Boolean>() {
@Override
protected Boolean executeInEDT() throws Throwable {
FileEditor[] editors = FileEditorManager.getInstance(myFrame.getProject()).getEditors(file);
if (editors.length == 0)
return false;
return editors[0].getComponent().isShowing();
}
});
}
}, SHORT_TIMEOUT);
// TODO: Maybe find a better way to keep Documents in sync with their VirtualFiles.
invokeActionViaKeystroke("Synchronize");
return this;
}
use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class SelectSdkDialogFixture method selectPathToSdk.
public SelectSdkDialogFixture selectPathToSdk(@NotNull File pathToSdk) {
final JTextField textField = myRobot.finder().findByType(JTextField.class);
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
textField.setText(pathToSdk.getPath());
}
});
final Tree tree = myRobot.finder().findByType(myDialog, Tree.class);
final AbstractTreeBuilder builder = AbstractTreeBuilder.getBuilderFor(tree);
pause(new Condition("Wait until path is updated") {
@Override
public boolean test() {
//noinspection ConstantConditions
return execute(new GuiQuery<Boolean>() {
@Override
protected Boolean executeInEDT() throws Throwable {
return (textField.getText().equals(pathToSdk.getPath()) && !builder.getUi().getUpdater().hasNodesToUpdate());
}
});
}
}, SHORT_TIMEOUT);
return this;
}
Aggregations