Search in sources :

Example 1 with ThemePreviewFixture

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

the class EditorFixture method getThemePreview.

/**
   * Returns a fixture around the theme preview window, <b>if</b> the currently edited file
   * is a styles file and if the XML editor tab of the layout is currently showing.
   *
   * @param switchToTabIfNecessary if true, switch to the editor tab if it is not already showing
   * @return the theme preview fixture
   */
@Nullable
public ThemePreviewFixture getThemePreview(boolean switchToTabIfNecessary) {
    VirtualFile currentFile = getCurrentFile();
    if (ResourceHelper.getFolderType(currentFile) != ResourceFolderType.VALUES) {
        return null;
    }
    if (switchToTabIfNecessary) {
        selectEditorTab(Tab.EDITOR);
    }
    boolean visible = GuiQuery.getNonNull(() -> ToolWindowManager.getInstance(myFrame.getProject()).getToolWindow("Theme Preview").isActive());
    if (!visible) {
        myFrame.invokeMenuPath("View", "Tool Windows", "Theme Preview");
    }
    Wait.seconds(1).expecting("Theme Preview window to be visible").until(() -> GuiQuery.getNonNull(() -> {
        ToolWindow window = ToolWindowManager.getInstance(myFrame.getProject()).getToolWindow("Theme Preview");
        return window != null && window.isVisible();
    }));
    // Wait for it to be fully opened
    robot.waitForIdle();
    return new ThemePreviewFixture(robot, myFrame.getProject());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ToolWindow(com.intellij.openapi.wm.ToolWindow) ThemePreviewFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemePreviewFixture) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ThemePreviewFixture (com.android.tools.idea.tests.gui.framework.fixture.theme.ThemePreviewFixture)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 Nullable (org.jetbrains.annotations.Nullable)1