use of com.android.tools.idea.tests.gui.framework.fixture.BuildVariantsToolWindowFixture in project android by JetBrains.
the class BuildVariantsTest method testSwitchVariantWithFlavor.
@Ignore("failed in http://go/aj/job/studio-ui-test/389 and from IDEA")
@Test
public void testSwitchVariantWithFlavor() throws IOException {
guiTest.importProjectAndWaitForProjectSyncToFinish("Flavoredlib");
BuildVariantsToolWindowFixture buildVariants = guiTest.ideFrame().getBuildVariantsWindow();
buildVariants.selectVariantForModule(MODULE_NAME, "flavor1Release");
String generatedSourceDirPath = MODULE_NAME + "/build/generated/source/";
Collection<String> sourceFolders = guiTest.ideFrame().getSourceFolderRelativePaths(MODULE_NAME, SOURCE);
assertThat(sourceFolders).containsAllOf(generatedSourceDirPath + "r/flavor1/release", generatedSourceDirPath + "aidl/flavor1/release", generatedSourceDirPath + "buildConfig/flavor1/release", generatedSourceDirPath + "rs/flavor1/release", MODULE_NAME + "/src/flavor1Release/aidl", MODULE_NAME + "/src/flavor1Release/java", MODULE_NAME + "/src/flavor1Release/jni", MODULE_NAME + "/src/flavor1Release/rs");
Module appModule = guiTest.ideFrame().getModule(MODULE_NAME);
JpsAndroidModuleProperties androidFacetProperties = AndroidFacet.getInstance(appModule).getProperties();
assertEquals("assembleFlavor1Release", androidFacetProperties.ASSEMBLE_TASK_NAME);
// 'release' variant does not have the _android_test_ artifact.
assertThat(androidFacetProperties.ASSEMBLE_TEST_TASK_NAME).isEmpty();
buildVariants.selectVariantForModule(MODULE_NAME, "flavor1Debug");
sourceFolders = guiTest.ideFrame().getSourceFolderRelativePaths(MODULE_NAME, SOURCE);
assertThat(sourceFolders).containsAllOf(generatedSourceDirPath + "r/flavor1/debug", generatedSourceDirPath + "aidl/flavor1/debug", generatedSourceDirPath + "buildConfig/flavor1/debug", generatedSourceDirPath + "rs/flavor1/debug", MODULE_NAME + "/src/flavor1Debug/aidl", MODULE_NAME + "/src/flavor1Debug/java", MODULE_NAME + "/src/flavor1Debug/jni", MODULE_NAME + "/src/flavor1Debug/rs");
assertEquals("assembleFlavor1Debug", androidFacetProperties.ASSEMBLE_TASK_NAME);
// Verifies that https://code.google.com/p/android/issues/detail?id=83077 is not a bug.
assertEquals("assembleFlavor1DebugAndroidTest", androidFacetProperties.ASSEMBLE_TEST_TASK_NAME);
}
use of com.android.tools.idea.tests.gui.framework.fixture.BuildVariantsToolWindowFixture in project android by JetBrains.
the class BuildVariantsTest method doTestGeneratedFolders.
private void doTestGeneratedFolders(@NotNull String pluginVersion, @NotNull String gradleVersion) throws IOException {
guiTest.importMultiModule();
guiTest.ideFrame().updateAndroidGradlePluginVersion(pluginVersion);
guiTest.ideFrame().updateGradleWrapperVersion(gradleVersion);
// Add generated folders to all kinds of variants.
File appBuildFile = new File(guiTest.ideFrame().getProjectPath(), join("app", SdkConstants.FN_BUILD_GRADLE));
assertAbout(file()).that(appBuildFile).isFile();
String gradleSnippet = "project.afterEvaluate {\n" + " android.applicationVariants.all { variant ->\n" + " if (variant.name != 'debug') return" + "\n" + "" + " File sourceFolder = file(\"${buildDir}/generated/customCode/${variant.dirName}\")\n" + " variant.addJavaSourceFoldersToModel(sourceFolder)\n" + "\n" + " def androidTestVariant = variant.testVariant\n" + " File androidTestSourceFolder = file(\"${buildDir}/generated/customCode/${androidTestVariant.dirName}\")\n" + " androidTestVariant.addJavaSourceFoldersToModel(androidTestSourceFolder)\n";
if (pluginVersion.startsWith("1.3")) {
gradleSnippet += "\n" + " def unitTestVariant = variant.unitTestVariant\n" + " File unitTestSourceFolder = file(\"${buildDir}/generated/customCode/${unitTestVariant.dirName}\")\n" + " unitTestVariant.addJavaSourceFoldersToModel(unitTestSourceFolder)\n";
}
gradleSnippet += "}\n}";
appendToFile(appBuildFile, gradleSnippet);
guiTest.ideFrame().requestProjectSync().waitForGradleProjectSyncToFinish();
BuildVariantsToolWindowFixture buildVariants = guiTest.ideFrame().getBuildVariantsWindow();
assertEquals("Android Instrumentation Tests", buildVariants.getSelectedTestArtifact());
String generatedSourceDirPath = MODULE_NAME + "/build/generated/customCode/";
String mainSrc = generatedSourceDirPath + "debug";
String androidTestSrc = generatedSourceDirPath + "androidTest/debug";
String unitTestSrc = generatedSourceDirPath + "test/debug";
if (compareVersions(pluginVersion, "1.1") < 0) {
// In 1.0, we used "test/debug" for android tests and there was no concept of unit testing.
androidTestSrc = unitTestSrc;
unitTestSrc = null;
}
Collection<String> sourceFolders = guiTest.ideFrame().getSourceFolderRelativePaths(MODULE_NAME, SOURCE);
assertThat(sourceFolders).contains(mainSrc);
assertThat(sourceFolders).containsNoneOf(androidTestSrc, unitTestSrc);
Collection<String> testSourceFolders = guiTest.ideFrame().getSourceFolderRelativePaths(MODULE_NAME, TEST_SOURCE);
assertThat(testSourceFolders).contains(androidTestSrc);
assertThat(testSourceFolders).containsNoneOf(unitTestSrc, mainSrc);
if (compareVersions(pluginVersion, "1.1") >= 0) {
buildVariants.selectTestArtifact("Unit Tests");
sourceFolders = guiTest.ideFrame().getSourceFolderRelativePaths(MODULE_NAME, SOURCE);
assertThat(sourceFolders).contains(mainSrc);
assertThat(sourceFolders).containsNoneOf(androidTestSrc, unitTestSrc);
testSourceFolders = guiTest.ideFrame().getSourceFolderRelativePaths(MODULE_NAME, TEST_SOURCE);
if (compareVersions(pluginVersion, "1.3") >= 0) {
// In 1.3 we started to include unit testing generated folders in the model.
assertThat(testSourceFolders).contains(unitTestSrc);
assertThat(testSourceFolders).containsNoneOf(androidTestSrc, mainSrc);
} else {
assertThat(testSourceFolders).containsNoneOf(unitTestSrc, androidTestSrc, mainSrc);
}
}
}
use of com.android.tools.idea.tests.gui.framework.fixture.BuildVariantsToolWindowFixture in project android by JetBrains.
the class BuildVariantsTest method switchingTestArtifacts.
@Ignore("failed in http://go/aj/job/studio-ui-test/389 and from IDEA")
@Test
public void switchingTestArtifacts() throws IOException {
guiTest.importProjectAndWaitForProjectSyncToFinish("SimpleApplication");
BuildVariantsToolWindowFixture buildVariants = guiTest.ideFrame().getBuildVariantsWindow();
assertEquals("Android Instrumentation Tests", buildVariants.getSelectedTestArtifact());
String androidTestSrc = MODULE_NAME + "/src/androidTest/java";
String unitTestSrc = MODULE_NAME + "/src/test/java";
Collection<String> testSourceFolders = guiTest.ideFrame().getSourceFolderRelativePaths(MODULE_NAME, TEST_SOURCE);
assertThat(testSourceFolders).contains(androidTestSrc);
assertThat(testSourceFolders).doesNotContain(unitTestSrc);
buildVariants.selectTestArtifact("Unit Tests");
testSourceFolders = guiTest.ideFrame().getSourceFolderRelativePaths(MODULE_NAME, TEST_SOURCE);
assertThat(testSourceFolders).contains(unitTestSrc);
assertThat(testSourceFolders).doesNotContain(androidTestSrc);
}
Aggregations