Search in sources :

Example 6 with IdeFrameFixture

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

the class ConvertToWebpActionTest method testConvertLossyWithPreviews.

@Test
public void testConvertLossyWithPreviews() throws IOException {
    if (!WebpNativeLibHelper.loadNativeLibraryIfNeeded()) {
        System.out.println("Skipping " + ConvertToWebpActionTest.class.getSimpleName() + " because the webp decoder is not available");
        return;
    }
    guiTest.importProjectAndWaitForProjectSyncToFinish("ImportWebpProject");
    IdeFrameFixture projectFrame = guiTest.ideFrame();
    Project project = projectFrame.getProject();
    VirtualFile res = project.getBaseDir().findFileByRelativePath("app/src/main/res");
    VirtualFile pngIcon = project.getBaseDir().findFileByRelativePath("app/src/main/res/mipmap-xhdpi/ic_test.png");
    assertThat(pngIcon.exists()).isTrue();
    invokeConvertToWebpAction(project, res);
    // Settings dialog
    WebpConversionDialogFixture settingsDialog = WebpConversionDialogFixture.findDialog(guiTest.robot());
    settingsDialog.selectLossy();
    settingsDialog.clickOk();
    WebpPreviewDialogFixture previewDialog = WebpPreviewDialogFixture.findDialog(guiTest.robot());
    previewDialog.clickFinish();
    VirtualFile webpIcon = project.getBaseDir().findFileByRelativePath("app/src/main/res/mipmap-xhdpi/ic_test.webp");
    assertThat(webpIcon).isNotNull();
    pngIcon = project.getBaseDir().findFileByRelativePath("app/src/main/res/mipmap-xhdpi/ic_test.png");
    assertThat(pngIcon).isNull();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) Test(org.junit.Test)

Example 7 with IdeFrameFixture

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

the class ConvertToWebpActionTest method testConvertLossless.

@Test
public void testConvertLossless() throws IOException {
    if (!WebpNativeLibHelper.loadNativeLibraryIfNeeded()) {
        System.out.println("Skipping " + ConvertToWebpActionTest.class.getSimpleName() + " because the webp decoder is not available");
        return;
    }
    guiTest.importProjectAndWaitForProjectSyncToFinish("ImportWebpProject");
    IdeFrameFixture projectFrame = guiTest.ideFrame();
    Project project = projectFrame.getProject();
    VirtualFile res = project.getBaseDir().findFileByRelativePath("app/src/main/res");
    VirtualFile webpIcon = project.getBaseDir().findFileByRelativePath("app/src/main/res/mipmap-xhdpi/ic_test.webp");
    assertThat(webpIcon).isNull();
    VirtualFile pngIcon = project.getBaseDir().findFileByRelativePath("app/src/main/res/mipmap-xhdpi/ic_test.png");
    assertThat(pngIcon.exists()).isTrue();
    invokeConvertToWebpAction(project, res);
    WebpConversionDialogFixture dialog = WebpConversionDialogFixture.findDialog(guiTest.robot());
    dialog.selectLossless();
    dialog.clickOk();
    // Check that the webp icon now exists
    webpIcon = project.getBaseDir().findFileByRelativePath("app/src/main/res/mipmap-xhdpi/ic_test.webp");
    assertThat(webpIcon).isNotNull();
    assertThat(pngIcon.exists()).isFalse();
    // ..and that the .png icon doesn't
    pngIcon = project.getBaseDir().findFileByRelativePath("app/src/main/res/mipmap-xhdpi/ic_test.png");
    assertThat(pngIcon).isNull();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) Test(org.junit.Test)

Example 8 with IdeFrameFixture

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

the class ManifestEditorTest method testNonPrimaryManifest.

@Test
public void testNonPrimaryManifest() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("Flavoredapp");
    IdeFrameFixture projectFrame = guiTest.ideFrame();
    EditorFixture editor = projectFrame.getEditor();
    editor.open("src/main/AndroidManifest.xml");
    editor.selectEditorTab(EditorFixture.Tab.MERGED_MANIFEST);
    MergedManifestFixture mergedManifestFixture = editor.getMergedManifestEditor();
    Color defaultBackgroundColor = mergedManifestFixture.getDefaultBackgroundColor();
    mergedManifestFixture.getTree().clickRow(1);
    assertThat(mergedManifestFixture.getSelectedNodeColor()).isNotEqualTo(defaultBackgroundColor);
    mergedManifestFixture.getTree().clickRow(3);
    assertThat(mergedManifestFixture.getSelectedNodeColor()).isEqualTo(defaultBackgroundColor);
    mergedManifestFixture.getTree().clickRow(2);
    mergedManifestFixture.requireText("Manifest Sources \n" + "\n" + "Flavoredapp main manifest (this file)\n" + "\n" + "myaarlibrary manifest\n" + "\n" + "build.gradle injection\n" + " Other Manifest Files (Included in merge, but did not contribute any elements)\n" + "locallib manifest, Flavoredapp debug manifest, Flavoredapp flavor1 manifest,\n" + "support-compat:25.0.0 manifest, support-core-ui:25.0.0 manifest,\n" + "support-core-utils:25.0.0 manifest, support-fragment:25.0.0 manifest,\n" + "support-media-compat:25.0.0 manifest, support-v4:25.0.0 manifest  Merging Log\n" + "Value provided by Gradle Added from the Flavoredapp main manifest (this file),\n" + "line 1 Value provided by Gradle\n", true);
    editor.open("src/debug/AndroidManifest.xml");
    editor.selectEditorTab(EditorFixture.Tab.MERGED_MANIFEST);
    mergedManifestFixture = editor.getMergedManifestEditor();
    mergedManifestFixture.getTree().clickRow(3);
    assertNotEquals(defaultBackgroundColor, mergedManifestFixture.getSelectedNodeColor());
    editor.open("src/flavor1/AndroidManifest.xml");
    editor.selectEditorTab(EditorFixture.Tab.MERGED_MANIFEST);
    mergedManifestFixture = editor.getMergedManifestEditor();
    mergedManifestFixture.getTree().clickRow(3);
    assertNotEquals(defaultBackgroundColor, mergedManifestFixture.getSelectedNodeColor());
}
Also used : MergedManifestFixture(com.android.tools.idea.tests.gui.framework.fixture.MergedManifestFixture) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) Test(org.junit.Test)

Example 9 with IdeFrameFixture

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

the class BuildTypesTest method addNewBuildType.

/**
   * Verifies addition of new build types
   * <p>This is run to qualify releases. Please involve the test team in substantial changes.
   * <p>TR ID: C14581580
   * <pre>
   *   Test Steps:
   *   1. Open the project structure dialog
   *   2. Select a module
   *   3. Click the Build Types tab
   *   4. Create new Build Type and name it newBuildType
   *   5. Set properties debuggable and version Name Suffix to valid values
   *   Verification:
   *   1. Open the build.gradle file for that module and verify
   *   entries for build types to contain new build type added.
   *   2. Verify the properties in the file match the values
   *   set in the project structure flavor dialog
   * </pre>
   */
@RunIn(TestGroup.QA)
@Test
public void addNewBuildType() throws Exception {
    IdeFrameFixture ideFrame = guiTest.importSimpleApplication();
    ProjectStructureDialogFixture projectStructureDialog = ideFrame.openFromMenu(ProjectStructureDialogFixture::find, "File", "Project Structure...");
    BuildTypesTabFixture buildTypesTab = projectStructureDialog.selectConfigurable("app").selectBuildTypesTab();
    buildTypesTab.setName("newBuildType").setDebuggable("true").setVersionNameSuffix("suffix");
    projectStructureDialog.clickOk();
    ideFrame.waitForGradleProjectSyncToFinish();
    EditorFixture editor = ideFrame.getEditor().open("/app/build.gradle");
    String gradleFileContents = editor.getCurrentFileContents();
    assertThat(gradleFileContents).containsMatch("newBuildType \\{\\n[\\s]*debuggable true\\n[\\s]*versionNameSuffix 'suffix'\\n[\\s]*\\}");
}
Also used : ProjectStructureDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.projectstructure.ProjectStructureDialogFixture) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) BuildTypesTabFixture(com.android.tools.idea.tests.gui.framework.fixture.projectstructure.BuildTypesTabFixture) Test(org.junit.Test) RunIn(com.android.tools.idea.tests.gui.framework.RunIn)

Example 10 with IdeFrameFixture

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

the class NlEditorTest method testCopyAndPaste.

@Test
public void testCopyAndPaste() throws Exception {
    guiTest.importSimpleApplication();
    IdeFrameFixture ideFrame = guiTest.ideFrame();
    EditorFixture editor = ideFrame.getEditor().open("app/src/main/res/layout/activity_my.xml", EditorFixture.Tab.DESIGN);
    NlEditorFixture layout = editor.getLayoutEditor(true).dragComponentToSurface("Widgets", "Button").dragComponentToSurface("Widgets", "CheckBox").waitForRenderToFinish();
    // Find and click the first text view
    NlComponentFixture textView = layout.findView("CheckBox", 0);
    textView.click();
    // It should be selected now
    layout.requireSelection(Collections.singletonList(textView));
    // 4 = root layout + 3 widgets
    assertEquals(4, layout.getAllComponents().size());
    ideFrame.invokeMenuPath("Edit", "Cut");
    layout.requireSelection(Collections.emptyList());
    assertEquals(3, layout.getAllComponents().size());
    layout.findView("Button", 0).click();
    ideFrame.invokeMenuPath("Edit", "Paste");
    layout.findView("CheckBox", 0).click();
    ideFrame.invokeMenuPath("Edit", "Copy");
    ideFrame.invokeMenuPath("Edit", "Paste");
    assertEquals(5, layout.getAllComponents().size());
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) NlEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture) NlEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture) IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) NlComponentFixture(com.android.tools.idea.tests.gui.framework.fixture.layout.NlComponentFixture) Test(org.junit.Test)

Aggregations

IdeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture)19 Test (org.junit.Test)15 EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)9 RunIn (com.android.tools.idea.tests.gui.framework.RunIn)7 PatternTextMatcher (org.fest.swing.util.PatternTextMatcher)6 MergedManifestFixture (com.android.tools.idea.tests.gui.framework.fixture.MergedManifestFixture)4 Ignore (org.junit.Ignore)4 JTreeFixture (org.fest.swing.fixture.JTreeFixture)3 ProjectStructureDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.projectstructure.ProjectStructureDialogFixture)2 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)1 DebugToolWindowFixture (com.android.tools.idea.tests.gui.framework.fixture.DebugToolWindowFixture)1 RenameRefactoringDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture)1 WelcomeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.WelcomeFrameFixture)1 NlComponentFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlComponentFixture)1 NlEditorFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture)1 BrowseSamplesWizardFixture (com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.BrowseSamplesWizardFixture)1 ConfigureAndroidProjectStepFixture (com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.ConfigureAndroidProjectStepFixture)1 BuildTypesTabFixture (com.android.tools.idea.tests.gui.framework.fixture.projectstructure.BuildTypesTabFixture)1