Search in sources :

Example 21 with Condition

use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.

the class JBPopupFixture method findContextMenu.

public static JBPopupFixture findContextMenu(Robot robot) {
    pause(new Condition("Find context menu") {

        @Override
        public boolean test() {
            final JBPopupMenu contextMenu = robot.finder().findByType(JBPopupMenu.class);
            return contextMenu != null;
        }
    }, SHORT_TIMEOUT);
    final JBPopupMenu contextMenu = robot.finder().findByType(JBPopupMenu.class);
    assertNotNull(contextMenu);
    return new JBPopupFixture(contextMenu, robot);
}
Also used : Condition(org.fest.swing.timing.Condition) JBPopupMenu(com.intellij.openapi.ui.JBPopupMenu)

Example 22 with Condition

use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.

the class JDialogFixture method find.

@NotNull
public static JDialogFixture find(@NotNull Robot robot, String title, Timeout timeout) {
    GenericTypeMatcher<JDialog> matcher = new GenericTypeMatcher<JDialog>(JDialog.class) {

        @Override
        protected boolean isMatching(@NotNull JDialog dialog) {
            return title.equals(dialog.getTitle()) && dialog.isShowing();
        }
    };
    Pause.pause(new Condition("Finding for JDialogFixture with title \"" + title + "\"") {

        @Override
        public boolean test() {
            Collection<JDialog> dialogs = robot.finder().findAll(matcher);
            return !dialogs.isEmpty();
        }
    }, timeout);
    JDialog dialog = robot.finder().find(matcher);
    return new JDialogFixture(robot, dialog);
}
Also used : Condition(org.fest.swing.timing.Condition) Collection(java.util.Collection) GenericTypeMatcher(org.fest.swing.core.GenericTypeMatcher) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 23 with Condition

use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.

the class MenuFixture method findShowingPopupMenus.

@NotNull
private List<JPopupMenu> findShowingPopupMenus(final int expectedCount) {
    final Ref<List<JPopupMenu>> ref = new Ref<List<JPopupMenu>>();
    Pause.pause(new Condition("waiting for " + expectedCount + " JPopupMenus to show up") {

        @Override
        public boolean test() {
            List<JPopupMenu> popupMenus = newArrayList(myRobot.finder().findAll(new GenericTypeMatcher<JPopupMenu>(JPopupMenu.class) {

                @Override
                protected boolean isMatching(@NotNull JPopupMenu popupMenu) {
                    return popupMenu.isShowing();
                }
            }));
            boolean allFound = popupMenus.size() == expectedCount;
            if (allFound) {
                ref.set(popupMenus);
            }
            return allFound;
        }
    });
    List<JPopupMenu> popupMenus = ref.get();
    assertThat(popupMenus).isNotNull().hasSize(expectedCount);
    return popupMenus;
}
Also used : Condition(org.fest.swing.timing.Condition) Ref(com.intellij.openapi.util.Ref) ArrayList(java.util.ArrayList) List(java.util.List) Lists.newArrayList(org.fest.util.Lists.newArrayList) Assert.assertNotNull(org.junit.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 24 with Condition

use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.

the class FileFixture method requireOpenAndSelected.

@NotNull
public FileFixture requireOpenAndSelected() {
    requireVirtualFile();
    pause(new Condition("File " + quote(myPath.getPath()) + " to be opened") {

        @Override
        public boolean test() {
            //noinspection ConstantConditions
            return execute(new GuiQuery<Boolean>() {

                @Override
                protected Boolean executeInEDT() throws Throwable {
                    return isOpenAndSelected();
                }
            });
        }
    }, SHORT_TIMEOUT);
    return this;
}
Also used : Condition(org.fest.swing.timing.Condition) GuiQuery(org.fest.swing.edt.GuiQuery) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 25 with Condition

use of org.fest.swing.timing.Condition in project intellij-community by JetBrains.

the class IdeFrameFixture method verifyVariablesAtBreakpoint.

public boolean verifyVariablesAtBreakpoint(String[] expectedVariablePatterns, String debugConfigName, long tryUntilMillis) {
    DebugToolWindowFixture debugToolWindowFixture = new DebugToolWindowFixture(this);
    final ExecutionToolWindowFixture.ContentFixture contentFixture = debugToolWindowFixture.findContent(debugConfigName);
    contentFixture.clickDebuggerTreeRoot();
    // Wait for the debugger tree to appear.
    pause(new Condition("Looking for debugger tree.") {

        @Override
        public boolean test() {
            return contentFixture.getDebuggerTreeRoot() != null;
        }
    }, Timeout.timeout(tryUntilMillis));
    // Get the debugger tree and print it.
    XDebuggerTreeNode debuggerTreeRoot = contentFixture.getDebuggerTreeRoot();
    if (debuggerTreeRoot == null) {
        return false;
    }
    List<String> unmatchedPatterns = getUnmatchedTerminalVariableValues(expectedVariablePatterns, debuggerTreeRoot);
    return unmatchedPatterns.isEmpty();
}
Also used : Condition(org.fest.swing.timing.Condition) XDebuggerTreeNode(com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode)

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