Search in sources :

Example 1 with ThemeEditorFixture

use of com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture 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)

Example 2 with ThemeEditorFixture

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

the class MultiModuleThemeEditorTest method testModuleWithoutThemes.

@Test
public void testModuleWithoutThemes() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("MultiAndroidModule");
    final ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    final JComboBoxFixture modulesComboBox = themeEditor.getModulesComboBox();
    modulesComboBox.selectItem("app");
    themeEditor.getThemesComboBox().selectItem("AppTheme");
    themeEditor.waitForThemeSelection("AppTheme");
    modulesComboBox.selectItem("nothemeslibrary");
    guiTest.robot().waitForIdle();
    final LogModel logModel = EventLog.getLogModel(guiTest.ideFrame().getProject());
    for (Notification notification : logModel.getNotifications()) {
        assertThat(notification.getType()).isNotEqualTo(NotificationType.ERROR);
    }
}
Also used : JComboBoxFixture(org.fest.swing.fixture.JComboBoxFixture) LogModel(com.intellij.notification.LogModel) ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) Notification(com.intellij.notification.Notification) Test(org.junit.Test)

Example 3 with ThemeEditorFixture

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

the class ThemeConfigurationTest method testThemesWithConfiguration.

/**
   * Tests that the theme editor deals well with themes defined only in certain configurations
   */
@Test
public void testThemesWithConfiguration() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    JComboBoxFixture themesComboBox = themeEditor.getThemesComboBox();
    themesComboBox.selectItem("Create New Theme");
    NewStyleDialogFixture newStyleDialog = NewStyleDialogFixture.find(guiTest.robot());
    JComboBoxFixture parentComboBox = newStyleDialog.getParentComboBox();
    parentComboBox.selectItem("Show all themes");
    ThemeSelectionDialogFixture themeSelectionDialog = ThemeSelectionDialogFixture.find(guiTest.robot());
    final JTreeFixture categoriesTree = themeSelectionDialog.getCategoriesTree();
    JListFixture themeList = themeSelectionDialog.getThemeList();
    categoriesTree.clickPath("Material Dark");
    guiTest.robot().waitForIdle();
    themeList.clickItem("android:Theme.Material");
    themeSelectionDialog.clickOk();
    parentComboBox.requireSelection("android:Theme.Material");
    JTextComponentFixture newNameTextField = newStyleDialog.getNewNameTextField();
    newNameTextField.click();
    newNameTextField.deleteText();
    newNameTextField.enterText("MyMaterialTheme");
    newStyleDialog.clickOk();
    themeEditor.waitForThemeSelection("MyMaterialTheme");
    AndroidThemePreviewPanelFixture themePreviewPanel = themeEditor.getPreviewComponent().getThemePreviewPanel();
    themePreviewPanel.requirePreviewPanel();
    JButton apiButton = themeEditor.findToolbarButton("API Version in Editor");
    guiTest.robot().click(apiButton);
    clickPopupMenuItem("API 19", "19", apiButton, guiTest.robot());
    themePreviewPanel.requireErrorPanel();
    themesComboBox.selectItem("AppTheme");
    themePreviewPanel.requirePreviewPanel();
    themesComboBox.selectItem("MyMaterialTheme");
    themePreviewPanel.requireErrorPanel();
}
Also used : JTreeFixture(org.fest.swing.fixture.JTreeFixture) JComboBoxFixture(org.fest.swing.fixture.JComboBoxFixture) ThemeSelectionDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.ThemeSelectionDialogFixture) NewStyleDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.NewStyleDialogFixture) JListFixture(org.fest.swing.fixture.JListFixture) ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) AndroidThemePreviewPanelFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.AndroidThemePreviewPanelFixture) Test(org.junit.Test)

Example 4 with ThemeEditorFixture

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

the class ThemeEditorTest method testOpenProject.

@Test
public void testOpenProject() throws IOException {
    // Test that we can open the simple application and the theme editor opens correctly
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    // Search is empty
    themeEditor.getSearchTextField().requireText("");
    // Check the theme combo is populated correctly
    List<String> themeList = themeEditor.getThemesList();
    // The expected elements are:
    // 0. AppTheme
    // 1. -- Separator
    // 2. AppCompat Light
    // 3. AppCompat
    // 4. Show all themes
    // 5. -- Separator
    // 6. Create New Theme
    // 7. Rename AppTheme
    assertThat(themeList).hasSize(9);
    assertThat(themeList.get(0)).isEqualTo("AppTheme");
    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");
    assertThat(themeList.get(8)).isEqualTo("Rename AppTheme");
    assertThat(themeList.get(2)).startsWith("javax.swing.JSeparator");
    assertThat(themeList.get(6)).startsWith("javax.swing.JSeparator");
    // Check the attributes table is populated
    assertThat(themeEditor.getPropertiesTable().rowCount()).isGreaterThan(0);
    guiTest.ideFrame().getEditor().close();
    checkNoErrors();
}
Also used : ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) Test(org.junit.Test)

Example 5 with ThemeEditorFixture

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

the class ThemeSelectorTest method testRemoveAppCompat.

/**
   * Tests that we can remove AppCompat and the themes update correctly.
   * Test that we can open the simple application and the theme editor opens correctly.
   */
@Test
public void testRemoveAppCompat() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    List<String> themeList = themeEditor.getThemesList();
    assertThat(themeList).contains("Theme.AppCompat.Light.NoActionBar");
    guiTest.ideFrame().getEditor().close().open("app/build.gradle").moveBetween("compile 'com.android.support:app", "").invokeAction(EditorFixture.EditorAction.DELETE_LINE).invokeAction(EditorFixture.EditorAction.SAVE).awaitNotification("Gradle files have changed since last project sync. A project sync may be necessary for the IDE to work properly.").performAction("Sync Now").waitForGradleProjectSyncToFinish();
    // Check AppCompat themes are gone
    themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    themeList = themeEditor.getThemesList();
    assertThat(themeList).doesNotContain("Theme.AppCompat.Light.NoActionBar");
    assertThat(themeList).contains("android:Theme.Material.NoActionBar");
    assertThat(themeList).contains("android:Theme.Material.Light.NoActionBar");
}
Also used : ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) Test(org.junit.Test)

Aggregations

ThemeEditorFixture (com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture)11 Test (org.junit.Test)10 JComboBoxFixture (org.fest.swing.fixture.JComboBoxFixture)4 ThemeSelectionDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.ThemeSelectionDialogFixture)3 NewStyleDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.theme.NewStyleDialogFixture)3 EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)2 Ignore (org.junit.Ignore)2 IdeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture)1 RenameRefactoringDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture)1 AndroidThemePreviewPanelFixture (com.android.tools.idea.tests.gui.framework.fixture.theme.AndroidThemePreviewPanelFixture)1 ThemeEditorTableFixture (com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorTableFixture)1 LogModel (com.intellij.notification.LogModel)1 Notification (com.intellij.notification.Notification)1 TableCell (org.fest.swing.data.TableCell)1 JListFixture (org.fest.swing.fixture.JListFixture)1 JTextComponentFixture (org.fest.swing.fixture.JTextComponentFixture)1 JTreeFixture (org.fest.swing.fixture.JTreeFixture)1 NotNull (org.jetbrains.annotations.NotNull)1