use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class FileFixture method waitForCodeAnalysisHighlightCount.
@NotNull
public FileFixture waitForCodeAnalysisHighlightCount(@NotNull final HighlightSeverity severity, final int expected) {
final Document document = getNotNullDocument();
pause(new Condition("Waiting for code analysis " + severity + " count to reach " + expected) {
@Override
public boolean test() {
Collection<HighlightInfo> highlightInfos = execute(new GuiQuery<Collection<HighlightInfo>>() {
@Override
protected Collection<HighlightInfo> executeInEDT() throws Throwable {
CommonProcessors.CollectProcessor<HighlightInfo> processor = new CommonProcessors.CollectProcessor<HighlightInfo>();
DaemonCodeAnalyzerEx.processHighlights(document, myProject, severity, 0, document.getTextLength(), processor);
return processor.getResults();
}
});
assertNotNull(highlightInfos);
return highlightInfos.size() == expected;
}
}, SHORT_TIMEOUT);
return this;
}
use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class IdeFrameFixture method waitForBackgroundTasksToFinish.
//@NotNull
//public IdeFrameFixture waitForGradleProjectSyncToFail() {
// try {
// waitForGradleProjectSyncToFinish(true);
// fail("Expecting project sync to fail");
// }
// catch (RuntimeException expected) {
// // expected failure.
// }
// return waitForBackgroundTasksToFinish();
//}
//@NotNull
//public IdeFrameFixture waitForGradleProjectSyncToStart() {
// Project project = getProject();
// final GradleSyncState syncState = GradleSyncState.getInstance(project);
// if (!syncState.isSyncInProgress()) {
// pause(new Condition("Syncing project " + quote(project.getName()) + " to finish") {
// @Override
// public boolean test() {
// return myGradleProjectEventListener.isSyncStarted();
// }
// }, SHORT_TIMEOUT);
// }
// return this;
//}
//@NotNull
//public IdeFrameFixture waitForGradleProjectSyncToFinish() {
// waitForGradleProjectSyncToFinish(false);
// return this;
//}
//private void waitForGradleProjectSyncToFinish(final boolean expectSyncFailure) {
// final Project project = getProject();
//
// // ensure GradleInvoker (in-process build) is always enabled.
// AndroidGradleBuildConfiguration buildConfiguration = AndroidGradleBuildConfiguration.getInstance(project);
// buildConfiguration.USE_EXPERIMENTAL_FASTER_BUILD = true;
//
// pause(new Condition("Syncing project " + quote(project.getName()) + " to finish") {
// @Override
// public boolean test() {
// GradleSyncState syncState = GradleSyncState.getInstance(project);
// boolean syncFinished =
// (myGradleProjectEventListener.isSyncFinished() || syncState.isSyncNeeded() != ThreeState.YES) && !syncState.isSyncInProgress();
// if (expectSyncFailure) {
// syncFinished = syncFinished && myGradleProjectEventListener.hasSyncError();
// }
// return syncFinished;
// }
// }, LONG_TIMEOUT);
//
// findGradleSyncAction().waitUntilEnabledAndShowing();
//
// if (myGradleProjectEventListener.hasSyncError()) {
// RuntimeException syncError = myGradleProjectEventListener.getSyncError();
// myGradleProjectEventListener.reset();
// throw syncError;
// }
//
// if (!myGradleProjectEventListener.isSyncSkipped()) {
// waitForBuildToFinish(SOURCE_GEN);
// }
//
// waitForBackgroundTasksToFinish();
//}
@NotNull
public IdeFrameFixture waitForBackgroundTasksToFinish() {
Pause.pause(new Condition("Background tasks to finish") {
@Override
public boolean test() {
ProgressManager progressManager = ProgressManager.getInstance();
return !progressManager.hasModalProgressIndicator() && !progressManager.hasProgressIndicator() && !progressManager.hasUnsafeProgressIndicator();
}
}, GuiTestUtil.LONG_TIMEOUT);
robot().waitForIdle();
return this;
}
use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class IdeFrameFixture method requestProjectSync.
@NotNull
public IdeFrameFixture requestProjectSync() {
//myGradleProjectEventListener.reset();
// We wait until all "Run Configurations" are populated in the toolbar combo-box. Until then the "Project Sync" button is not in its
// final position, and FEST will click the wrong button.
Pause.pause(new Condition("Waiting for 'Run Configurations' to be populated") {
@Override
public boolean test() {
RunConfigurationComboBoxFixture runConfigurationComboBox = RunConfigurationComboBoxFixture.find(IdeFrameFixture.this);
return isNotEmpty(runConfigurationComboBox.getText());
}
}, GuiTestUtil.SHORT_TIMEOUT);
waitForBackgroundTasksToFinish();
findGradleSyncAction().waitUntilEnabledAndShowing();
return this;
}
use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class SelectSdkDialogFixture method clickOk.
public void clickOk() {
pause(new Condition("Waiting when ok button at SDK select dialog will be ready for a click") {
@Override
public boolean test() {
JButton button = GuiTestUtil.findButton(SelectSdkDialogFixture.this, "OK", myRobot);
return button.isEnabled();
}
}, GuiTestUtil.SHORT_TIMEOUT);
GuiTestUtil.findAndClickOkButton(this);
}
use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.
the class ToolWindowFixture method getContent.
@Nullable
protected Content getContent(@NotNull final String displayName) {
activateAndWaitUntilIsVisible();
final Ref<Content> contentRef = new Ref<>();
pause(new Condition("finding content '" + displayName + "'") {
@Override
public boolean test() {
Content[] contents = getContents();
for (Content content : contents) {
if (displayName.equals(content.getDisplayName())) {
contentRef.set(content);
return true;
}
}
return false;
}
}, GuiTestUtil.SHORT_TIMEOUT);
return contentRef.get();
}
Aggregations