Search in sources :

Example 1 with IdeFrameFixture

use of com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture in project android by JetBrains.

the class LaunchAndroidApplicationTest method testDebugOnEmulator.

@Ignore("http://b/30795134")
@Test
public void testDebugOnEmulator() throws IOException, ClassNotFoundException, EvaluateException {
    guiTest.importSimpleApplication();
    createAVD();
    IdeFrameFixture ideFrameFixture = guiTest.ideFrame();
    ideFrameFixture.debugApp(APP_NAME).selectDevice(AVD_NAME).clickOk();
    // Make sure the right app is being used. This also serves as the sync point for the package to get uploaded to the device/emulator.
    ideFrameFixture.getDebugToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(LOCAL_PATH_OUTPUT), 120);
    ideFrameFixture.getDebugToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(DEBUG_OUTPUT), 120);
    ideFrameFixture.getAndroidToolWindow().selectDevicesTab().selectProcess(PROCESS_NAME).clickTerminateApplication();
}
Also used : IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) PatternTextMatcher(org.fest.swing.util.PatternTextMatcher) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with IdeFrameFixture

use of com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture in project android by JetBrains.

the class InstantRunTest method hotSwap.

/**
   * Verifies that instant run hot swap works as expected.
   * <p>
   * This is run to qualify releases. Please involve the test team in substantial changes.
   * <p>
   * TR ID: C14581583
   * <p>
   *   <pre>
   *   Test Steps:
   *   1. Import SimpleApplication.
   *   2. Update the gradle plugin version if necessary for testing purpose.
   *   3. Create an AVD with a system image API 21 or above.
   *   4. Run on the AVD
   *   5. Verify 1.
   *   6. Edit a java file.
   *   7. Run again.
   *   8. Verify 2.
   *   Verify:
   *   1. Make sure the right app is installed and started in Run tool window.
   *   2. Make sure the instant run hot swap is applied in Run tool window.
   *   </pre>
   */
@RunIn(TestGroup.QA)
@Test
public void hotSwap() throws Exception {
    IdeFrameFixture ideFrameFixture = guiTest.importSimpleApplication();
    updateGradleVersion(guiTest.getProjectPath());
    createAVD();
    ideFrameFixture.runApp(APP_NAME).selectDevice(AVD_NAME).clickOk();
    ideFrameFixture.getRunToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(RUN_OUTPUT), 120);
    ideFrameFixture.getEditor().open("app/src/main/java/google/simpleapplication/MyActivity.java").enterText(Strings.repeat("\n", 10));
    ideFrameFixture.waitForGradleProjectSyncToFinish().findRunApplicationButton().click();
    ideFrameFixture.getRunToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(HOT_SWAP_OUTPUT), 120);
}
Also used : IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) PatternTextMatcher(org.fest.swing.util.PatternTextMatcher) RunIn(com.android.tools.idea.tests.gui.framework.RunIn)

Example 3 with IdeFrameFixture

use of com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture in project android by JetBrains.

the class InstantRunTest method changeManifest.

/**
   * Verifies that instant run works as expected when AndroidManifest is changed.
   * <p>
   * This is run to qualify releases. Please involve the test team in substantial changes.
   * <p>
   * TR ID: C14581585
   * <p>
   *   <pre>
   *   Test Steps:
   *   1. Import SimpleApplication.
   *   2. Update the gradle plugin version if necessary for testing purpose.
   *   3. Create an AVD with a system image API 21 or above.
   *   4. Run on the AVD
   *   5. Verify 1.
   *   6. Edit AndroidManifest.
   *   7. Run again.
   *   8. Verify 2.
   *   Verify:
   *   1. Make sure the right app is installed and started in Run tool window.
   *   2. Make sure the instant run is applied in EventLog tool window.
   *   </pre>
   */
@RunIn(TestGroup.QA)
@Test
public void changeManifest() throws Exception {
    IdeFrameFixture ideFrameFixture = guiTest.importSimpleApplication();
    updateGradleVersion(guiTest.getProjectPath());
    createAVD();
    ideFrameFixture.runApp(APP_NAME).selectDevice(AVD_NAME).clickOk();
    ideFrameFixture.getRunToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(RUN_OUTPUT), 120);
    ideFrameFixture.getEditor().open("app/src/main/AndroidManifest.xml", EditorFixture.Tab.EDITOR).moveBetween("", "<application").enterText("<uses-permission android:name=\"android.permission.INTERNET\" /\n");
    ideFrameFixture.waitForGradleProjectSyncToFinish().findRunApplicationButton().click();
    ideFrameFixture.getRunToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(RUN_OUTPUT), 120);
    Wait.seconds(1).expecting("The notification is showing").until(() -> {
        try {
            Notification notification = Iterables.getLast(EventLog.getLogModel(ideFrameFixture.getProject()).getNotifications());
            assertThat(notification.getContent()).matches(INSTANT_RUN_NOTIFICATION_REGEX);
            return true;
        } catch (Exception e) {
            System.out.println(e.getClass().toString());
            return false;
        }
    });
}
Also used : IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) PatternTextMatcher(org.fest.swing.util.PatternTextMatcher) Notification(com.intellij.notification.Notification) IOException(java.io.IOException) RunIn(com.android.tools.idea.tests.gui.framework.RunIn)

Example 4 with IdeFrameFixture

use of com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture in project android by JetBrains.

the class InstantRunTest method coldSwap.

/**
   * Verifies that instant run cold swap works as expected.
   * <p>
   * This is run to qualify releases. Please involve the test team in substantial changes.
   * <p>
   * TR ID: C14581584
   * <p>
   *   <pre>
   *   Test Steps:
   *   1. Import SimpleApplication.
   *   2. Update the gradle plugin version if necessary for testing purpose.
   *   3. Create an AVD with a system image API 21 or above.
   *   4. Run on the AVD
   *   5. Verify 1.
   *   6. Edit a resource xml file.
   *   7. Run again.
   *   8. Verify 2.
   *   Verify:
   *   1. Make sure the right app is installed and started in Run tool window.
   *   2. Make sure the instant run cold swap is applied in Run tool window.
   *   </pre>
   */
@RunIn(TestGroup.QA)
@Test
public void coldSwap() throws Exception {
    IdeFrameFixture ideFrameFixture = guiTest.importSimpleApplication();
    updateGradleVersion(guiTest.getProjectPath());
    createAVD();
    ideFrameFixture.runApp(APP_NAME).selectDevice(AVD_NAME).clickOk();
    ideFrameFixture.getRunToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(RUN_OUTPUT), 120);
    ideFrameFixture.getEditor().open("app/src/main/res/layout/activity_my.xml", EditorFixture.Tab.DESIGN).getLayoutEditor(false).dragComponentToSurface("Widgets", "TextView").waitForRenderToFinish();
    ideFrameFixture.waitForGradleProjectSyncToFinish().findRunApplicationButton().click();
    ideFrameFixture.getRunToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(COLD_SWAP_OUTPUT), 120);
}
Also used : IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) PatternTextMatcher(org.fest.swing.util.PatternTextMatcher) RunIn(com.android.tools.idea.tests.gui.framework.RunIn)

Example 5 with IdeFrameFixture

use of com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture in project android by JetBrains.

the class ThemeSelectorTest method testRenameTheme.

/**
   * Tests the theme renaming functionality of the theme selector
   * and that IntelliJ's Undo works can revert this action
   */
@Ignore("go/studio-builder/builders/ubuntu-studio-master-dev-uitests/builds/257")
@Test
public void testRenameTheme() throws IOException {
    guiTest.importSimpleApplication();
    IdeFrameFixture ideFrame = guiTest.ideFrame();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(ideFrame);
    final JComboBoxFixture themesComboBox = themeEditor.getThemesComboBox();
    themesComboBox.selectItem("Rename AppTheme");
    RenameRefactoringDialogFixture renameRefactoringDialog = RenameRefactoringDialogFixture.find(guiTest.robot());
    renameRefactoringDialog.setNewName("NewAppTheme").clickRefactor();
    themeEditor.waitForThemeSelection("NewAppTheme");
    themesComboBox.requireSelection("NewAppTheme");
    List<String> themeList = themeEditor.getThemesList();
    assertThat(themeList).hasSize(9);
    assertThat(themeList.get(0)).isEqualTo("NewAppTheme");
    assertThat(themeList.get(8)).isEqualTo("Rename NewAppTheme");
    guiTest.robot().waitForIdle();
    // AppCompat is read-only, being a library theme
    themesComboBox.selectItem("Theme.AppCompat.NoActionBar");
    themeList = themeEditor.getThemesList();
    assertThat(themeList).hasSize(8);
    assertThat(themeList.get(0)).isEqualTo("NewAppTheme");
    assertThat(themeList.get(3)).isEqualTo("Theme.AppCompat.Light.NoActionBar");
    assertThat(themeList.get(4)).isEqualTo("Theme.AppCompat.NoActionBar");
    assertThat(themeList.get(5)).isEqualTo("Show all themes");
    assertThat(themeList.get(7)).isEqualTo("Create New Theme");
    EditorFixture editor = ideFrame.invokeMenuPath("Window", "Editor Tabs", "Select Previous Tab").getEditor();
    assertThat(editor.getCurrentFileContents()).doesNotContain("name=\"AppTheme");
    editor.moveBetween("", "name=\"NewAppTheme");
    assertThat(editor.getCurrentLine().trim()).isEqualTo("<style name=\"NewAppTheme\" parent=\"android:Theme.Holo.Light.DarkActionBar\">");
    // Testing Undo
    ideFrame.invokeMenuPath("Window", "Editor Tabs", "Select Next Tab");
    themesComboBox.selectItem("NewAppTheme");
    ideFrame.invokeMenuPath("Edit", "Undo Renaming attribute value AppTh...").findMessageDialog("Undo").clickOk();
    themeEditor.waitForThemeSelection("AppTheme");
    // required to ensure that the Select Previous Tab action is available
    themeEditor.focus();
    ideFrame.invokeMenuPath("Window", "Editor Tabs", "Select Previous Tab");
    assertThat(editor.getCurrentFileContents()).doesNotContain("name=\"NewAppTheme");
    editor.moveBetween("", "name=\"AppTheme");
    assertThat(editor.getCurrentLine().trim()).isEqualTo("<style name=\"AppTheme\" parent=\"android:Theme.Holo.Light.DarkActionBar\">");
}
Also used : RenameRefactoringDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

IdeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture)19 Test (org.junit.Test)15 EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)9 RunIn (com.android.tools.idea.tests.gui.framework.RunIn)7 PatternTextMatcher (org.fest.swing.util.PatternTextMatcher)6 MergedManifestFixture (com.android.tools.idea.tests.gui.framework.fixture.MergedManifestFixture)4 Ignore (org.junit.Ignore)4 JTreeFixture (org.fest.swing.fixture.JTreeFixture)3 ProjectStructureDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.projectstructure.ProjectStructureDialogFixture)2 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)1 DebugToolWindowFixture (com.android.tools.idea.tests.gui.framework.fixture.DebugToolWindowFixture)1 RenameRefactoringDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture)1 WelcomeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.WelcomeFrameFixture)1 NlComponentFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlComponentFixture)1 NlEditorFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture)1 BrowseSamplesWizardFixture (com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.BrowseSamplesWizardFixture)1 ConfigureAndroidProjectStepFixture (com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.ConfigureAndroidProjectStepFixture)1 BuildTypesTabFixture (com.android.tools.idea.tests.gui.framework.fixture.projectstructure.BuildTypesTabFixture)1