Search in sources :

Example 6 with JButtonFixture

use of org.fest.swing.fixture.JButtonFixture in project android by JetBrains.

the class AndroidSdkSourceAttachTest method testDownloadSdkSource.

@Ignore("failed in http://go/aj/job/studio-ui-test/417 and from IDEA")
@Test
public void testDownloadSdkSource() throws IOException {
    if (mySdkSourcePath.isDirectory()) {
        delete(mySdkSourceTmpPath);
        rename(mySdkSourcePath, mySdkSourceTmpPath);
    }
    updateSdkSourceRoot(mySdk);
    guiTest.importSimpleApplication();
    final EditorFixture editor = guiTest.ideFrame().getEditor();
    final VirtualFile classFile = findActivityClassFile();
    editor.open(classFile, EditorFixture.Tab.EDITOR);
    acceptLegalNoticeIfNeeded();
    // Download the source.
    editor.awaitNotification("Sources for '" + mySdk.getName() + "' not found.").performAction("Download");
    DialogFixture downloadDialog = findDialog(withTitle("SDK Quickfix Installation")).withTimeout(TimeUnit.MINUTES.toMillis(2)).using(guiTest.robot());
    final JButtonFixture finish = downloadDialog.button(withText("Finish"));
    // Wait until installation is finished. By then the "Finish" button will be enabled.
    Wait.seconds(1).expecting("Android source to be installed").until(finish::isEnabled);
    finish.click();
    Wait.seconds(1).expecting("source file to be opened").until(() -> !classFile.equals(editor.getCurrentFile()));
    assertIsActivityJavaFile(editor.getCurrentFile());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) JButtonFixture(org.fest.swing.fixture.JButtonFixture) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) DialogFixture(org.fest.swing.fixture.DialogFixture) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with JButtonFixture

use of org.fest.swing.fixture.JButtonFixture in project android by JetBrains.

the class ConvertToConstraintLayoutTest method testConvert.

@Ignore("http://b.android.com/211200")
@Test
public void testConvert() throws Exception {
    guiTest.importSimpleApplication();
    EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.open("app/src/main/res/layout/absolute.xml", EditorFixture.Tab.DESIGN);
    NlEditorFixture layout = editor.getLayoutEditor(false);
    layout.waitForRenderToFinish();
    // Find and click the first button
    NlComponentFixture button = layout.findView("Button", 0);
    button.invokeContextMenuAction("Convert AbsoluteLayout to ConstraintLayout");
    // Confirm dialog
    DialogFixture quickFixDialog = WindowFinder.findDialog(Matchers.byTitle(Dialog.class, "Convert to ConstraintLayout")).withTimeout(TimeUnit.MINUTES.toMillis(2)).using(guiTest.robot());
    // Press OK
    JButtonFixture finish = quickFixDialog.button(withText("OK"));
    finish.click();
    // Check that we've converted to what we expected
    layout.waitForRenderToFinish();
    editor.selectEditorTab(EditorFixture.Tab.EDITOR);
    waitForScout();
    editor.invokeAction(EditorFixture.EditorAction.FORMAT);
    @Language("XML") String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<android.support.constraint.ConstraintLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + "    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n" + "    xmlns:tools=\"http://schemas.android.com/tools\"\n" + "    android:id=\"@+id/constraintLayout\"\n" + "    android:layout_width=\"match_parent\"\n" + "    android:layout_height=\"match_parent\"\n" + "    tools:layout_editor_absoluteX=\"<test>\"\n" + "    tools:layout_editor_absoluteY=\"<test>\">\n" + "\n" + "    <Button\n" + "        android:id=\"@+id/button\"\n" + "        android:layout_width=\"wrap_content\"\n" + "        android:layout_height=\"wrap_content\"\n" + "        android:layout_marginStart=\"<test>\"\n" + "        android:layout_marginTop=\"<test>\"\n" + "        android:text=\"Button\"\n" + "        app:layout_constraintLeft_toLeftOf=\"@+id/constraintLayout\"\n" + "        app:layout_constraintTop_toTopOf=\"@+id/constraintLayout\"\n" + "        tools:layout_constraintLeft_creator=\"1\"\n" + "        tools:layout_constraintTop_creator=\"1\"\n" + "        tools:layout_editor_absoluteX=\"<test>\"\n" + "        tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + "    <Button\n" + "        android:id=\"@+id/button2\"\n" + "        android:layout_width=\"wrap_content\"\n" + "        android:layout_height=\"wrap_content\"\n" + "        android:layout_marginStart=\"<test>\"\n" + "        android:text=\"Button\"\n" + "        app:layout_constraintLeft_toLeftOf=\"@+id/button\"\n" + "        app:layout_constraintTop_toBottomOf=\"@+id/button\"\n" + "        tools:layout_constraintLeft_creator=\"1\"\n" + "        tools:layout_constraintTop_creator=\"1\"\n" + "        tools:layout_editor_absoluteX=\"<test>\"\n" + "        tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + "    <EditText\n" + "        android:id=\"@+id/editText\"\n" + "        android:layout_width=\"wrap_content\"\n" + "        android:layout_height=\"wrap_content\"\n" + "        android:layout_marginBottom=\"<test>\"\n" + "        android:layout_marginEnd=\"<test>\"\n" + "        android:layout_marginTop=\"<test>\"\n" + "        android:ems=\"10\"\n" + "        android:inputType=\"textPersonName\"\n" + "        android:text=\"Name\"\n" + "        app:layout_constraintBottom_toBottomOf=\"@+id/button6\"\n" + "        app:layout_constraintRight_toRightOf=\"@+id/constraintLayout\"\n" + "        app:layout_constraintTop_toTopOf=\"@+id/constraintLayout\"\n" + "        tools:layout_constraintBottom_creator=\"1\"\n" + "        tools:layout_constraintRight_creator=\"1\"\n" + "        tools:layout_constraintTop_creator=\"1\"\n" + "        tools:layout_editor_absoluteX=\"<test>\"\n" + "        tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + "\n" + "    <Button\n" + "        android:id=\"@+id/button3\"\n" + "        android:layout_width=\"wrap_content\"\n" + "        android:layout_height=\"wrap_content\"\n" + "        android:layout_marginStart=\"<test>\"\n" + "        android:text=\"Button\"\n" + "        app:layout_constraintBottom_toBottomOf=\"@+id/button5\"\n" + "        app:layout_constraintLeft_toLeftOf=\"@+id/constraintLayout\"\n" + "        app:layout_constraintTop_toTopOf=\"@+id/button5\"\n" + "        tools:layout_constraintBottom_creator=\"1\"\n" + "        tools:layout_constraintLeft_creator=\"1\"\n" + "        tools:layout_constraintTop_creator=\"1\"\n" + "        tools:layout_editor_absoluteX=\"<test>\"\n" + "        tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + "    <Button\n" + "        android:id=\"@+id/button5\"\n" + "        android:layout_width=\"wrap_content\"\n" + "        android:layout_height=\"wrap_content\"\n" + "        android:layout_marginBottom=\"<test>\"\n" + "        android:text=\"Button\"\n" + "        app:layout_constraintBottom_toBottomOf=\"@+id/constraintLayout\"\n" + "        app:layout_constraintLeft_toLeftOf=\"@+id/constraintLayout\"\n" + "        app:layout_constraintRight_toRightOf=\"@+id/constraintLayout\"\n" + "        tools:layout_constraintBottom_creator=\"1\"\n" + "        tools:layout_constraintLeft_creator=\"1\"\n" + "        tools:layout_constraintRight_creator=\"1\"\n" + "        tools:layout_editor_absoluteX=\"<test>\"\n" + "        tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + "    <Button\n" + "        android:id=\"@+id/button6\"\n" + "        android:layout_width=\"wrap_content\"\n" + "        android:layout_height=\"wrap_content\"\n" + "        android:layout_marginEnd=\"<test>\"\n" + "        android:text=\"Button\"\n" + "        app:layout_constraintBottom_toBottomOf=\"@+id/button5\"\n" + "        app:layout_constraintRight_toRightOf=\"@+id/constraintLayout\"\n" + "        app:layout_constraintTop_toTopOf=\"@+id/button5\"\n" + "        tools:layout_constraintBottom_creator=\"1\"\n" + "        tools:layout_constraintRight_creator=\"1\"\n" + "        tools:layout_constraintTop_creator=\"1\"\n" + "        tools:layout_editor_absoluteX=\"<test>\"\n" + "        tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + "</android.support.constraint.ConstraintLayout>\n" + "\n";
    assertThat(wipeDimensions(editor.getCurrentFileContents())).isEqualTo(wipeDimensions(xml));
}
Also used : JButtonFixture(org.fest.swing.fixture.JButtonFixture) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) NlEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture) NlEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture) DialogFixture(org.fest.swing.fixture.DialogFixture) Language(org.intellij.lang.annotations.Language) NlComponentFixture(com.android.tools.idea.tests.gui.framework.fixture.layout.NlComponentFixture) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with JButtonFixture

use of org.fest.swing.fixture.JButtonFixture in project android by JetBrains.

the class ComboBoxActionFixture method click.

private void click() {
    final JButtonFixture comboBoxButtonFixture = new JButtonFixture(myRobot, myTarget);
    Wait.seconds(1).expecting("comboBoxButton to be enabled").until(() -> GuiQuery.getNonNull(() -> comboBoxButtonFixture.target().isEnabled()));
    comboBoxButtonFixture.click();
}
Also used : JButtonFixture(org.fest.swing.fixture.JButtonFixture)

Example 9 with JButtonFixture

use of org.fest.swing.fixture.JButtonFixture in project android by JetBrains.

the class GuiTests method findAndClickButton.

public static void findAndClickButton(@NotNull ContainerFixture<? extends Container> container, @NotNull String text) {
    Robot robot = container.robot();
    new JButtonFixture(robot, GuiTests.waitUntilShowing(robot, container.target(), Matchers.byText(JButton.class, text))).click();
}
Also used : JButtonFixture(org.fest.swing.fixture.JButtonFixture) Robot(org.fest.swing.core.Robot) BasicRobot(org.fest.swing.core.BasicRobot)

Example 10 with JButtonFixture

use of org.fest.swing.fixture.JButtonFixture in project android by JetBrains.

the class GuiTests method findAndClickButtonWhenEnabled.

public static void findAndClickButtonWhenEnabled(@NotNull ContainerFixture<? extends Container> container, @NotNull String text) {
    Robot robot = container.robot();
    new JButtonFixture(robot, GuiTests.waitUntilShowingAndEnabled(robot, container.target(), Matchers.byText(JButton.class, text))).click();
}
Also used : JButtonFixture(org.fest.swing.fixture.JButtonFixture) Robot(org.fest.swing.core.Robot) BasicRobot(org.fest.swing.core.BasicRobot)

Aggregations

JButtonFixture (org.fest.swing.fixture.JButtonFixture)12 Test (org.junit.Test)4 EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)3 DialogFixture (org.fest.swing.fixture.DialogFixture)3 Ignore (org.junit.Ignore)3 NlComponentFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlComponentFixture)2 NlEditorFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture)2 BasicRobot (org.fest.swing.core.BasicRobot)2 Robot (org.fest.swing.core.Robot)2 JLabelFixture (org.fest.swing.fixture.JLabelFixture)2 NewXmlValueWizardFixture (com.android.tools.idea.tests.gui.framework.fixture.npw.NewXmlValueWizardFixture)1 PublicAtsApi (com.axway.ats.common.PublicAtsApi)1 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)1 SwingDriverInternal (com.axway.ats.uiengine.internal.driver.SwingDriverInternal)1 SwingElementState (com.axway.ats.uiengine.utilities.swing.SwingElementState)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Component (java.awt.Component)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1