Search in sources :

Example 1 with GuiQuery

use of org.fest.swing.edt.GuiQuery in project intellij-community by JetBrains.

the class ComboBoxActionFixture method click.

private void click() {
    final JButtonFixture comboBoxButtonFixture = new JButtonFixture(myRobot, myTarget);
    Pause.pause(new Condition("Wait until comboBoxButton is enabled") {

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

                @Override
                protected Boolean executeInEDT() throws Throwable {
                    return comboBoxButtonFixture.target().isEnabled();
                }
            });
        }
    }, GuiTestUtil.SHORT_TIMEOUT);
    comboBoxButtonFixture.click();
}
Also used : Condition(org.fest.swing.timing.Condition) JButtonFixture(org.fest.swing.fixture.JButtonFixture) GuiQuery(org.fest.swing.edt.GuiQuery)

Example 2 with GuiQuery

use of org.fest.swing.edt.GuiQuery 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 3 with GuiQuery

use of org.fest.swing.edt.GuiQuery 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 4 with GuiQuery

use of org.fest.swing.edt.GuiQuery 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;
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) Condition(org.fest.swing.timing.Condition) Project(com.intellij.openapi.project.Project) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FileEditor(com.intellij.openapi.fileEditor.FileEditor) GuiQuery(org.fest.swing.edt.GuiQuery) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor)

Example 5 with GuiQuery

use of org.fest.swing.edt.GuiQuery 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;
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) Condition(org.fest.swing.timing.Condition) AbstractTreeBuilder(com.intellij.ide.util.treeView.AbstractTreeBuilder) GuiQuery(org.fest.swing.edt.GuiQuery) Tree(com.intellij.ui.treeStructure.Tree)

Aggregations

GuiQuery (org.fest.swing.edt.GuiQuery)5 Condition (org.fest.swing.timing.Condition)5 Assert.assertNotNull (junit.framework.Assert.assertNotNull)2 GuiTask (org.fest.swing.edt.GuiTask)2 NotNull (org.jetbrains.annotations.NotNull)2 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)1 AbstractTreeBuilder (com.intellij.ide.util.treeView.AbstractTreeBuilder)1 Document (com.intellij.openapi.editor.Document)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 Project (com.intellij.openapi.project.Project)1 Tree (com.intellij.ui.treeStructure.Tree)1 CommonProcessors (com.intellij.util.CommonProcessors)1 Collection (java.util.Collection)1 JButtonFixture (org.fest.swing.fixture.JButtonFixture)1