Search in sources :

Example 1 with ProjectStructureDialogFixture

use of com.android.tools.idea.tests.gui.framework.fixture.projectstructure.ProjectStructureDialogFixture 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 2 with ProjectStructureDialogFixture

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

the class DeveloperServicesTest method toggleDevServicesDependencies.

/**
   * Verifies that Developer Services dependencies can be added and removed in app build gradle file.
   * <p>
   * This is run to qualify releases. Please involve the test team in substantial changes.
   * <p>
   * TR ID: C14581655
   * <p>
   *   <pre>
   *   Test Steps:
   *   1. Import a project.
   *   2. Open File > Project Structure
   *   3. Developer Services option is listed and contains the following options: Ads, Authentication, Notifications.
   *   4. Enable all services.
   *   5. Click OK button.
   *   6. Open app/build.gradle
   *   7. Dependencies are added for each of the enabled services.
   *   8. Open File > Structure
   *   9. Disable services for Ads, Authentication, Notification.
   *   10. Click OK button.
   *   11. Open app/build.gradle
   *   12. Dependencies are removed for the services.
   *   Verify:
   *   Toggling Developer Services dependencies reflects in app build gradle file.
   *   </pre>
   * <p>
   *   The test checks both the presence of the string and that the build.gradle file is written correctly by parsing it.
   */
@RunIn(TestGroup.QA)
@Test
public void toggleDevServicesDependencies() throws Exception {
    IdeFrameFixture ideFrameFixture = guiTest.importSimpleApplication();
    ideFrameFixture.openFromMenu(ProjectStructureDialogFixture::find, "File", "Project Structure...").setServiceEnabled("Ads", true).setServiceEnabled("Authentication", true).setServiceEnabled("Notifications", true).clickOk();
    String gradleFileContents = getBuildGradleFileContents();
    assertThat(gradleFileContents).contains("compile 'com.google.android.gms:play-services-ads:");
    assertThat(gradleFileContents).contains("compile 'com.google.android.gms:play-services-auth:");
    assertThat(gradleFileContents).contains("compile 'com.google.android.gms:play-services-gcm:");
    // Parsing of the Gradle file needs to be done in a ReadAction.
    ApplicationManager.getApplication().runReadAction(new Runnable() {

        @Override
        public void run() {
            GradleBuildModel buildModel = GradleBuildModel.parseBuildFile(getBuildGradleFile(), ideFrameFixture.getProject());
            assertThat(dependencyIsPresent(buildModel, "play-services-ads")).isTrue();
            assertThat(dependencyIsPresent(buildModel, "play-services-auth")).isTrue();
            assertThat(dependencyIsPresent(buildModel, "play-services-gcm")).isTrue();
        }
    });
    // Disable the services.
    ideFrameFixture.openFromMenu(ProjectStructureDialogFixture::find, "File", "Project Structure...").setServiceEnabled("Ads", false).setServiceEnabled("Authentication", false).setServiceEnabled("Notifications", false).clickOk();
    gradleFileContents = getBuildGradleFileContents();
    assertThat(gradleFileContents).doesNotContain("compile 'com.google.android.gms:play-services-ads:");
    assertThat(gradleFileContents).doesNotContain("compile 'com.google.android.gms:play-services-auth:");
    assertThat(gradleFileContents).doesNotContain("compile 'com.google.android.gms:play-services-gcm:");
    ApplicationManager.getApplication().runReadAction(new Runnable() {

        @Override
        public void run() {
            GradleBuildModel buildModel = GradleBuildModel.parseBuildFile(getBuildGradleFile(), ideFrameFixture.getProject());
            assertThat(dependencyIsPresent(buildModel, "play-services-ads")).isFalse();
            assertThat(dependencyIsPresent(buildModel, "play-services-auth")).isFalse();
            assertThat(dependencyIsPresent(buildModel, "play-services-gcm")).isFalse();
        }
    });
}
Also used : ProjectStructureDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.projectstructure.ProjectStructureDialogFixture) GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) Test(org.junit.Test) RunIn(com.android.tools.idea.tests.gui.framework.RunIn)

Aggregations

RunIn (com.android.tools.idea.tests.gui.framework.RunIn)2 IdeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture)2 ProjectStructureDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.projectstructure.ProjectStructureDialogFixture)2 Test (org.junit.Test)2 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)1 EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)1 BuildTypesTabFixture (com.android.tools.idea.tests.gui.framework.fixture.projectstructure.BuildTypesTabFixture)1