use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class GuiTestUtil method waitForIdeToStart.
// Called by IdeTestApplication via reflection.
@SuppressWarnings("UnusedDeclaration")
public static void waitForIdeToStart() {
GuiActionRunner.executeInEDT(false);
Robot robot = null;
try {
robot = BasicRobot.robotWithCurrentAwtHierarchy();
final MyProjectManagerListener listener = new MyProjectManagerListener();
//[ACCEPT IntelliJ IDEA Privacy Policy Agreement]
acceptAgreementIfNeeded(robot);
findFrame(new GenericTypeMatcher<Frame>(Frame.class) {
@Override
protected boolean isMatching(@NotNull Frame frame) {
if (frame instanceof IdeFrame) {
if (frame instanceof IdeFrameImpl) {
listener.myActive = true;
ProjectManager.getInstance().addProjectManagerListener(listener);
}
return true;
}
return false;
}
}).withTimeout(LONG_TIMEOUT.duration()).using(robot);
if (listener.myActive) {
Pause.pause(new Condition("Project to be opened") {
@Override
public boolean test() {
boolean notified = listener.myNotified;
if (notified) {
ProgressManager progressManager = ProgressManager.getInstance();
boolean isIdle = !progressManager.hasModalProgressIndicator() && !progressManager.hasProgressIndicator() && !progressManager.hasUnsafeProgressIndicator();
if (isIdle) {
ProjectManager.getInstance().removeProjectManagerListener(listener);
}
return isIdle;
}
return false;
}
}, LONG_TIMEOUT);
}
} finally {
GuiActionRunner.executeInEDT(true);
if (robot != null) {
robot.cleanUpWithoutDisposingWindows();
}
}
}
use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class NewProjectWizardFixture method selectSdkPath.
public NewProjectWizardFixture selectSdkPath(@NotNull File sdkPath, String sdkType) {
final SelectSdkDialogFixture sdkDialogFixture = SelectSdkDialogFixture.find(robot(), sdkType);
sdkDialogFixture.selectPathToSdk(sdkPath).clickOk();
pause(new Condition("Waiting for the returning of focus to dialog: " + target().getTitle()) {
@Override
public boolean test() {
return target().isFocused();
}
}, GuiTestUtil.SHORT_TIMEOUT);
return this;
}
use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class GuiTestBase method closeAllProjects.
@SuppressWarnings("UnusedDeclaration")
protected // Called by GuiTestRunner via reflection.
void closeAllProjects() {
pause(new Condition("Close all projects") {
@Override
public boolean test() {
final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
TransactionGuard.submitTransaction(ApplicationManager.getApplication(), () -> {
for (Project project : openProjects) {
assertTrue("Failed to close project " + quote(project.getName()), closeAndDispose(project));
}
});
}
});
return ProjectManager.getInstance().getOpenProjects().length == 0;
}
}, SHORT_TIMEOUT);
//noinspection ConstantConditions
boolean welcomeFrameShown = execute(new GuiQuery<Boolean>() {
@Override
protected Boolean executeInEDT() throws Throwable {
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
if (openProjects.length == 0) {
WelcomeFrame.showNow();
WindowManagerImpl windowManager = (WindowManagerImpl) WindowManager.getInstance();
windowManager.disposeRootFrame();
return true;
}
return false;
}
});
if (welcomeFrameShown) {
pause(new Condition("'Welcome' frame to show up") {
@Override
public boolean test() {
for (Frame frame : Frame.getFrames()) {
if (frame == WelcomeFrame.getInstance() && frame.isShowing()) {
return true;
}
}
return false;
}
}, SHORT_TIMEOUT);
}
}
use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class NewProjectWizardFixture method setProjectName.
@NotNull
public NewProjectWizardFixture setProjectName(@NotNull String projectName) {
String labelText = GuiTestUtil.adduction(IdeBundle.message("label.project.name"));
pause(new Condition("Waiting for the sliding to project name settings") {
@Override
public boolean test() {
final Component label;
try {
label = robot().finder().findByLabel(labelText);
} catch (ComponentLookupException componentLookupException) {
return false;
}
return true;
}
}, GuiTestUtil.SHORT_TIMEOUT);
final JTextComponentFixture textField = findTextField(labelText);
robot().click(textField.target());
textField.setText(projectName);
return this;
}
use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class JBListPopupFixture method findListPopup.
public static JBListPopupFixture findListPopup(Robot robot) {
pause(new Condition("Find JBList popup") {
@Override
public boolean test() {
final JBList jblist = getList(robot);
return jblist != null;
}
}, SHORT_TIMEOUT);
final JBList jblist = getList(robot);
Assert.assertNotNull(jblist);
return new JBListPopupFixture(jblist, robot);
}
Aggregations