Search in sources :

Example 6 with ThemeEditorFixture

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

the class ThemeEditorGuiTestUtils method openThemeEditor.

@NotNull
public static ThemeEditorFixture openThemeEditor(@NotNull IdeFrameFixture projectFrame) {
    ThemeEditorFixture themeEditor = projectFrame.getEditor().open("app/src/main/res/values/styles.xml", EditorFixture.Tab.EDITOR).awaitNotification("Edit all themes in the project in the theme editor.").performAction("Open editor").getEditor().getThemeEditor();
    themeEditor.getPreviewComponent().getThemePreviewPanel().getPreviewPanel().waitForRender();
    return themeEditor;
}
Also used : ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with ThemeEditorFixture

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

the class ThemeEditorTest method testConfigurationToolbar.

@Ignore("go/studio-builder/builders/ubuntu-studio-master-dev-uitests/builds/71")
@Test
public void testConfigurationToolbar() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    JButton apiButton = themeEditor.findToolbarButton("Android version to use when rendering layouts in the IDE");
    guiTest.robot().click(apiButton);
    clickPopupMenuItem("API 21", "21", apiButton, guiTest.robot());
    JButton deviceButton = themeEditor.findToolbarButton("The virtual device to render the layout with");
    guiTest.robot().click(deviceButton);
    clickPopupMenuItem("Nexus 6P", "Nexus 6P", deviceButton, guiTest.robot());
    themeEditor.getPreviewComponent().requireApi(21).requireDevice("Nexus 6P");
}
Also used : ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with ThemeEditorFixture

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

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

the class ThemeSelectorTest method testShowAllThemes.

/**
   * Tests the Show all themes dialog from the theme selector
   */
@Test
public void testShowAllThemes() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    JComboBoxFixture themesComboBox = themeEditor.getThemesComboBox();
    String selectedTheme = themesComboBox.selectedItem();
    themesComboBox.selectItem("Show all themes");
    ThemeSelectionDialogFixture themeSelectionDialog = ThemeSelectionDialogFixture.find(guiTest.robot());
    themeSelectionDialog.clickCancel();
    themesComboBox.requireSelection(selectedTheme);
    themesComboBox.selectItem("Show all themes");
    themeSelectionDialog = ThemeSelectionDialogFixture.find(guiTest.robot());
    JTreeFixture categoriesTree = themeSelectionDialog.getCategoriesTree();
    JListFixture themeList = themeSelectionDialog.getThemeList();
    categoriesTree.clickRow(1);
    assertEquals("Manifest Themes", categoriesTree.node(1).value());
    assertThat(themeList.contents()).asList().containsExactly("AppTheme");
    categoriesTree.clickRow(2);
    assertEquals("Project Themes", categoriesTree.node(2).value());
    assertThat(themeList.contents()).hasLength(2);
    assertThat(themeList.contents()[0]).isEqualTo("AppTheme");
    categoriesTree.clickRow(10);
    assertEquals("All", categoriesTree.node(10).value());
    assertThat(themeList.contents()[0]).isEqualTo("android:Theme");
    themeList.selectItem("Theme.AppCompat.NoActionBar");
    themeSelectionDialog.clickOk();
    themeEditor.waitForThemeSelection("Theme.AppCompat.NoActionBar");
}
Also used : ThemeSelectionDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.ThemeSelectionDialogFixture) ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) Test(org.junit.Test)

Example 10 with ThemeEditorFixture

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

the class MultiModuleThemeEditorTest method testMultipleModules.

@Test
public void testMultipleModules() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("MultiAndroidModule");
    final ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    assertThat(themeEditor.getModulesList()).containsExactly("app", "library", "library2", "library3", "nothemeslibrary");
    final JComboBoxFixture modulesComboBox = themeEditor.getModulesComboBox();
    modulesComboBox.selectItem("app");
    final List<String> appThemes = themeEditor.getThemesList();
    assertThat(appThemes).containsAllOf("AppTheme", "Library1DependentTheme", "Library1Theme", "Library2Theme");
    assertThat(appThemes).doesNotContain("Library3Theme");
    modulesComboBox.selectItem("library");
    final List<String> library1Themes = themeEditor.getThemesList();
    assertThat(library1Themes).containsAllOf("Library1Theme", "Library2Theme");
    assertThat(library1Themes).containsNoneOf("AppTheme", "Library1DependentTheme", "Library3Theme");
    modulesComboBox.selectItem("library2");
    final List<String> library2Themes = themeEditor.getThemesList();
    assertThat(library2Themes).contains("Library2Theme");
    assertThat(library2Themes).containsNoneOf("AppTheme", "Library1DependentTheme", "Library1Theme", "Library3Theme");
    modulesComboBox.selectItem("library3");
    final List<String> library3Themes = themeEditor.getThemesList();
    assertThat(library3Themes).contains("Library3Theme");
    assertThat(library3Themes).containsNoneOf("AppTheme", "Library1DependentTheme", "Library1Theme", "Library2Theme");
}
Also used : JComboBoxFixture(org.fest.swing.fixture.JComboBoxFixture) 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