Search in sources :

Example 21 with EditorFixture

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

the class ThemePreviewTest method testPreviewAvailability.

@Test
public void testPreviewAvailability() throws Exception {
    guiTest.importSimpleApplication();
    Project project = guiTest.ideFrame().getProject();
    EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.open("app/src/main/res/values/styles.xml", EditorFixture.Tab.EDITOR);
    // No style or theme selected
    assertFalse(ToolWindowManager.getInstance(project).getToolWindow("Theme Preview").isAvailable());
    editor.moveBetween("PreviewTheme", "");
    guiTest.robot().waitForIdle();
    assertTrue(ToolWindowManager.getInstance(project).getToolWindow("Theme Preview").isAvailable());
    // A style is selected but it's not a theme so the preview shouldn't be available
    editor.moveBetween("NotATheme", "");
    guiTest.robot().waitForIdle();
    assertFalse(ToolWindowManager.getInstance(project).getToolWindow("Theme Preview").isAvailable());
}
Also used : Project(com.intellij.openapi.project.Project) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) Test(org.junit.Test)

Example 22 with EditorFixture

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

the class ThemeSelectorTest method testCreateNewTheme.

/**
   * Tests the theme creation functionality of the theme selector
   * and that IntelliJ's Undo can revert this action
   */
@Test
public void testCreateNewTheme() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    JComboBoxFixture themesComboBox = themeEditor.getThemesComboBox();
    String selectedTheme = themesComboBox.selectedItem();
    themesComboBox.selectItem("Create New Theme");
    NewStyleDialogFixture newStyleDialog = NewStyleDialogFixture.find(guiTest.robot());
    newStyleDialog.clickCancel();
    themeEditor.waitForThemeSelection(selectedTheme);
    themesComboBox.selectItem("Create New Theme");
    newStyleDialog = NewStyleDialogFixture.find(guiTest.robot());
    JTextComponentFixture newNameTextField = newStyleDialog.getNewNameTextField();
    JComboBoxFixture parentComboBox = newStyleDialog.getParentComboBox();
    parentComboBox.requireSelection("AppTheme");
    String[] parentsArray = parentComboBox.contents();
    // The expected elements are:
    // 0. AppTheme
    // 1. -- Separator
    // 2. AppCompat Light
    // 3. AppCompat
    // 4. -- Separator
    // 5. Show all themes
    assertThat(parentsArray).hasLength(6);
    assertThat(parentsArray[0]).isEqualTo("AppTheme");
    assertThat(parentsArray[2]).isEqualTo("Theme.AppCompat.Light.NoActionBar");
    assertThat(parentsArray[3]).isEqualTo("Theme.AppCompat.NoActionBar");
    assertThat(parentsArray[5]).isEqualTo("Show all themes");
    assertThat(parentsArray[1]).startsWith("javax.swing.JSeparator");
    assertThat(parentsArray[4]).startsWith("javax.swing.JSeparator");
    parentComboBox.selectItem("Theme.AppCompat.NoActionBar");
    newNameTextField.requireText("Theme.AppTheme.NoActionBar");
    parentComboBox.selectItem("Show all themes");
    ThemeSelectionDialogFixture themeSelectionDialog = ThemeSelectionDialogFixture.find(guiTest.robot());
    JTreeFixture categoriesTree = themeSelectionDialog.getCategoriesTree();
    JListFixture themeList = themeSelectionDialog.getThemeList();
    categoriesTree.clickRow(5);
    themeList.clickItem(0);
    themeList.requireSelection("android:Theme.Holo");
    themeSelectionDialog.clickOk();
    parentComboBox.requireSelection("android:Theme.Holo");
    newNameTextField.requireText("Theme.AppTheme");
    newNameTextField.deleteText().enterText("NewTheme");
    newStyleDialog.clickOk();
    themeEditor.waitForThemeSelection("NewTheme");
    ThemeEditorTableFixture themeEditorTable = themeEditor.getPropertiesTable();
    TableCell parentCell = row(0).column(0);
    assertEquals("android:Theme.Holo", themeEditorTable.getComboBoxSelectionAt(parentCell));
    // required to ensure that the Select Previous Tab action is available
    themeEditor.focus();
    EditorFixture editor = guiTest.ideFrame().invokeMenuPath("Window", "Editor Tabs", "Select Previous Tab").getEditor();
    assertThat(editor.getCurrentFileContents()).contains("name=\"AppTheme");
    editor.moveBetween("", "name=\"NewTheme");
    assertThat(editor.getCurrentLine().trim()).isEqualTo("<style name=\"NewTheme\" parent=\"android:Theme.Holo\" />");
    // Tests Undo
    guiTest.ideFrame().invokeMenuPath("Window", "Editor Tabs", "Select Next Tab").invokeMenuPath("Edit", "Undo Create new style NewTheme");
    themeEditor.waitForThemeSelection("AppTheme");
    guiTest.ideFrame().invokeMenuPath("Window", "Editor Tabs", "Select Previous Tab");
    assertThat(editor.getCurrentFileContents()).doesNotContain("name=\"NewTheme");
}
Also used : ThemeSelectionDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.ThemeSelectionDialogFixture) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) TableCell(org.fest.swing.data.TableCell) NewStyleDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.NewStyleDialogFixture) ThemeEditorTableFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorTableFixture) ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) Test(org.junit.Test)

Example 23 with EditorFixture

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

the class AttributeResolveTest method testResolveNewlyAddedTag.

@Test
public void testResolveNewlyAddedTag() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("LayoutTest");
    EditorFixture editor = guiTest.ideFrame().getEditor();
    // TODO add dependency using new parser API
    File appBuildFile = new File(guiTest.ideFrame().getProjectPath(), join("app", FN_BUILD_GRADLE));
    assertAbout(file()).that(appBuildFile).isFile();
    appendToFile(appBuildFile, "\ndependencies { compile 'com.android.support:design:+' }\n");
    guiTest.ideFrame().requestProjectSync();
    guiTest.ideFrame().waitForGradleProjectSyncToFinish();
    editor.open("app/src/main/res/layout/layout2.xml", EditorFixture.Tab.EDITOR);
    editor.moveBetween("", "<TextView");
    editor.enterText("<android.support.design.widget.FloatingActionButton android:onClick=\"onCreate\" /\n");
    editor.moveBetween("on", "Create");
    guiTest.waitForBackgroundTasks();
    editor.invokeAction(EditorFixture.EditorAction.GOTO_DECLARATION);
    assertEquals("MyActivity.java", editor.getCurrentFileName());
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) File(java.io.File) FileUtil.appendToFile(com.intellij.openapi.util.io.FileUtil.appendToFile) Test(org.junit.Test)

Example 24 with EditorFixture

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

the class AttributeValueTest method testAttributeValueInput.

@Test
public void testAttributeValueInput() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("SimpleApplication");
    final EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.open("app/src/main/res/layout/activity_my.xml", EditorFixture.Tab.EDITOR);
    editor.moveBetween("<TextView", "");
    editor.enterText("\nandroid:fontFamily=\"monospace\"");
    // No double quotes have been added because of automatic first quote insertion
    assertThat(editor.getCurrentLine().trim()).isEqualTo("android:fontFamily=\"monospace\"");
    editor.enterText("\nandroid:inputT");
    editor.invokeAction(EditorFixture.EditorAction.COMPLETE_CURRENT_STATEMENT);
    // Invoking completion adds quotes
    assertThat(editor.getCurrentLine().trim()).isEqualTo("android:inputType=\"\"");
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) Test(org.junit.Test)

Example 25 with EditorFixture

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

the class GradleIncreaseLanguageLevelTest method testIncreaseLanguageLevelForJava.

@Ignore("http://wpie20.hot.corp.google.com:8200/builders/ubuntu-studio-master-dev-uitests/builds/28/")
@Test
public void testIncreaseLanguageLevelForJava() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("MultiModule");
    EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.open("library2/src/main/java/com/example/MyClass.java");
    editor.moveBetween("MyClass {", "");
    useJava7FeatureAndIncreaseLanguageLevel(editor);
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)41 Test (org.junit.Test)37 IdeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture)9 Ignore (org.junit.Ignore)7 GradleBuildModelFixture (com.android.tools.idea.tests.gui.framework.fixture.gradle.GradleBuildModelFixture)6 NlComponentFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlComponentFixture)6 NlEditorFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture)6 ArtifactDependencySpec (com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencySpec)4 MergedManifestFixture (com.android.tools.idea.tests.gui.framework.fixture.MergedManifestFixture)4 RunIn (com.android.tools.idea.tests.gui.framework.RunIn)3 RenameRefactoringDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 DialogFixture (org.fest.swing.fixture.DialogFixture)3 JButtonFixture (org.fest.swing.fixture.JButtonFixture)3 JTreeFixture (org.fest.swing.fixture.JTreeFixture)3 ExpectedModuleDependency (com.android.tools.idea.gradle.dsl.model.dependencies.ExpectedModuleDependency)2 ChooseResourceDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.ChooseResourceDialogFixture)2 ConflictsDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture.ConflictsDialogFixture)2 ThemeEditorFixture (com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture)2 Project (com.intellij.openapi.project.Project)2