Search in sources :

Example 6 with Condition

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;
}
Also used : Condition(org.fest.swing.timing.Condition) GuiQuery(org.fest.swing.edt.GuiQuery) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) Collection(java.util.Collection) Document(com.intellij.openapi.editor.Document) CommonProcessors(com.intellij.util.CommonProcessors) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with Condition

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;
}
Also used : Condition(org.fest.swing.timing.Condition) ProgressManager(com.intellij.openapi.progress.ProgressManager) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with Condition

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;
}
Also used : Condition(org.fest.swing.timing.Condition) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with Condition

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);
}
Also used : Condition(org.fest.swing.timing.Condition)

Example 10 with Condition

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();
}
Also used : Condition(org.fest.swing.timing.Condition) Ref(com.intellij.openapi.util.Ref) Content(com.intellij.ui.content.Content) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Condition (org.fest.swing.timing.Condition)36 NotNull (org.jetbrains.annotations.NotNull)17 Ref (com.intellij.openapi.util.Ref)9 GuiTask (org.fest.swing.edt.GuiTask)8 Collection (java.util.Collection)7 Assert.assertNotNull (junit.framework.Assert.assertNotNull)6 GenericTypeMatcher (org.fest.swing.core.GenericTypeMatcher)5 GuiQuery (org.fest.swing.edt.GuiQuery)5 Assert.assertNotNull (org.junit.Assert.assertNotNull)5 ComponentLookupException (org.fest.swing.exception.ComponentLookupException)4 Nullable (org.jetbrains.annotations.Nullable)4 Project (com.intellij.openapi.project.Project)3 Content (com.intellij.ui.content.Content)3 ProjectView (com.intellij.ide.projectView.ProjectView)2 AnAction (com.intellij.openapi.actionSystem.AnAction)2 FileEditor (com.intellij.openapi.fileEditor.FileEditor)2 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)2 ProgressManager (com.intellij.openapi.progress.ProgressManager)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 IdeFrameImpl (com.intellij.openapi.wm.impl.IdeFrameImpl)2