use of com.android.tools.idea.tests.gui.framework.fixture.ThemeSelectionDialogFixture 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();
}
use of com.android.tools.idea.tests.gui.framework.fixture.ThemeSelectionDialogFixture 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");
}
use of com.android.tools.idea.tests.gui.framework.fixture.ThemeSelectionDialogFixture 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");
}
Aggregations