diff options
author | Raymond Chiu <chiur@google.com> | 2015-04-25 03:21:00 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-04-25 03:21:00 +0000 |
commit | e447b4d9c721023f38dfdc1b285192ba09bd46c1 (patch) | |
tree | da30d928f51509fe12128f7da8aed7650ae93cab | |
parent | 9c00589d02b81cad8e5af88028737c72991c882b (diff) | |
parent | e43978ff782669da0a4aa48b22e9f7b3eaded58e (diff) | |
download | base-marshmallow-mr3-release.tar.gz |
am e43978ff: am 089924a0: Merge "Create multi projects multi variants test." into studio-1.3-dev automerge: d9a5f37 automerge: 5be2756android-cts-6.0_r9android-cts-6.0_r8android-cts-6.0_r7android-cts-6.0_r6android-cts-6.0_r5android-cts-6.0_r4android-cts-6.0_r32android-cts-6.0_r31android-cts-6.0_r30android-cts-6.0_r3android-cts-6.0_r29android-cts-6.0_r28android-cts-6.0_r27android-cts-6.0_r26android-cts-6.0_r25android-cts-6.0_r24android-cts-6.0_r23android-cts-6.0_r22android-cts-6.0_r21android-cts-6.0_r20android-cts-6.0_r2android-cts-6.0_r19android-cts-6.0_r18android-cts-6.0_r17android-cts-6.0_r16android-cts-6.0_r15android-cts-6.0_r14android-cts-6.0_r13android-cts-6.0_r12android-cts-6.0_r1android-6.0.1_r9android-6.0.1_r81android-6.0.1_r80android-6.0.1_r8android-6.0.1_r79android-6.0.1_r78android-6.0.1_r77android-6.0.1_r74android-6.0.1_r73android-6.0.1_r72android-6.0.1_r70android-6.0.1_r7android-6.0.1_r69android-6.0.1_r66android-6.0.1_r65android-6.0.1_r63android-6.0.1_r61android-6.0.1_r60android-6.0.1_r59android-6.0.1_r58android-6.0.1_r57android-6.0.1_r56android-6.0.1_r55android-6.0.1_r52android-6.0.1_r51android-6.0.1_r50android-6.0.1_r5android-6.0.1_r49android-6.0.1_r48android-6.0.1_r47android-6.0.1_r46android-6.0.1_r43android-6.0.1_r42android-6.0.1_r41android-6.0.1_r40android-6.0.1_r4android-6.0.1_r33android-6.0.1_r32android-6.0.1_r31android-6.0.1_r30android-6.0.1_r3android-6.0.1_r28android-6.0.1_r27android-6.0.1_r26android-6.0.1_r20android-6.0.1_r18android-6.0.1_r17android-6.0.1_r16android-6.0.1_r13android-6.0.1_r12android-6.0.1_r11android-6.0.1_r10android-6.0.1_r1android-6.0.0_r7android-6.0.0_r6android-6.0.0_r5android-6.0.0_r41android-6.0.0_r4android-6.0.0_r3android-6.0.0_r26android-6.0.0_r25android-6.0.0_r24android-6.0.0_r23android-6.0.0_r2android-6.0.0_r13android-6.0.0_r12android-6.0.0_r11android-6.0.0_r1marshmallow-releasemarshmallow-mr3-releasemarshmallow-mr2-releasemarshmallow-mr1-releasemarshmallow-dr-releasemarshmallow-dr-dragon-releasemarshmallow-dr-devmarshmallow-devmarshmallow-cts-release
* commit 'e43978ff782669da0a4aa48b22e9f7b3eaded58e':
Create multi projects multi variants test.
5 files changed, 178 insertions, 2 deletions
diff --git a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/common/fixture/app/MultiModuleTestProject.java b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/common/fixture/app/MultiModuleTestProject.java index 73f36a2647..56ce8058e8 100644 --- a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/common/fixture/app/MultiModuleTestProject.java +++ b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/common/fixture/app/MultiModuleTestProject.java @@ -16,7 +16,7 @@ import java.util.Map; */ public class MultiModuleTestProject implements TestProject { - private Map<String, ? extends TestProject> subprojects; + private Map<String, TestProject> subprojects; /** * Creates a MultiModuleTestProject. @@ -24,11 +24,25 @@ public class MultiModuleTestProject implements TestProject { * @param subprojects a map with gradle project path as key and the corresponding TestProject as * value. */ - public MultiModuleTestProject(Map<String, ? extends TestProject> subprojects) { + public MultiModuleTestProject(Map<String, TestProject> subprojects) { this.subprojects = Maps.newHashMap(subprojects); } /** + * Creates a MultiModuleTestProject with multiple subproject of the same TestProject. + * + * @param baseName Base name of the subproject. Actual project name will be baseName + index. + * @param subproject A TestProject. + * @param count Number of subprojects to create. + */ + public MultiModuleTestProject(String baseName, TestProject subproject, int count) { + subprojects = Maps.newHashMapWithExpectedSize(count); + for (int i = 0; i < count; i++) { + subprojects.put(baseName + i, subproject); + } + } + + /** * Return the test project with the given project path. */ public TestProject getSubproject(String subprojectPath) { diff --git a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidComponentTest.groovy b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidComponentTest.groovy index 6ea0d645c2..91b57b9122 100644 --- a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidComponentTest.groovy +++ b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidComponentTest.groovy @@ -57,6 +57,8 @@ class LargeVariantAndroidComponentTest { } } """.stripIndent()).createBuildScript() + + // Execute before performance test to warm up the cache. project.execute("help"); } diff --git a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidTest.groovy b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidTest.groovy index 40a1a4c39f..b617d14a14 100644 --- a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidTest.groovy +++ b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidTest.groovy @@ -54,6 +54,8 @@ class LargeVariantAndroidTest { } } """.stripIndent()).createBuildScript() + + // Execute before performance test to warm up the cache. project.execute("help"); } diff --git a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/MultiProjectsAndroidComponentTest.groovy b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/MultiProjectsAndroidComponentTest.groovy new file mode 100644 index 0000000000..2698c8f0b4 --- /dev/null +++ b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/MultiProjectsAndroidComponentTest.groovy @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.build.gradle.integration.performance + +import com.android.build.gradle.integration.common.fixture.GradleTestProject +import com.android.build.gradle.integration.common.fixture.TestProject +import com.android.build.gradle.integration.common.fixture.app.AndroidTestApp +import com.android.build.gradle.integration.common.fixture.app.HelloWorldApp +import com.android.build.gradle.integration.common.fixture.app.MultiModuleTestProject +import com.android.build.gradle.integration.common.fixture.app.TestSourceFile +import com.android.build.gradle.integration.common.fixture.app.VariantBuildScriptGenerator +import org.junit.AfterClass +import org.junit.ClassRule +import org.junit.Test + +/** + * Performance test on gradle experimantal plugin with multiple subprojects and multiple variants. + */ +class MultiProjectsAndroidComponentTest { + public static AndroidTestApp app = new HelloWorldApp() + static { + app.addFile(new TestSourceFile("", "build.gradle", + new VariantBuildScriptGenerator( + buildTypes: VariantBuildScriptGenerator.MEDIUM_NUMBER, + productFlavors: VariantBuildScriptGenerator.MEDIUM_NUMBER, + """ + apply plugin: "com.android.model.application" + + model { + android.config { + compileSdkVersion $GradleTestProject.DEFAULT_COMPILE_SDK_VERSION + buildToolsVersion "$GradleTestProject.DEFAULT_BUILD_TOOL_VERSION" + } + + android.buildTypes { + \${buildTypes} + } + + android.productFlavors { + \${productFlavors} + } + } + """.stripIndent()).createBuildScript()) + ) + } + + public static TestProject baseProject = new MultiModuleTestProject("app", app, 10) + + @ClassRule + public static GradleTestProject project = GradleTestProject.builder() + .fromTestApp(baseProject) + .forExpermimentalPlugin(true) + .create() + + @AfterClass + static void cleanUp() { + app = null; + baseProject = null; + project = null; + } + + @Test + void performanceTest() { + project.execute("help") + } +} diff --git a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/MultiProjectsAndroidTest.groovy b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/MultiProjectsAndroidTest.groovy new file mode 100644 index 0000000000..3fabb6939d --- /dev/null +++ b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/MultiProjectsAndroidTest.groovy @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.build.gradle.integration.performance + +import com.android.build.gradle.integration.common.fixture.GradleTestProject +import com.android.build.gradle.integration.common.fixture.TestProject +import com.android.build.gradle.integration.common.fixture.app.AndroidTestApp +import com.android.build.gradle.integration.common.fixture.app.HelloWorldApp +import com.android.build.gradle.integration.common.fixture.app.MultiModuleTestProject +import com.android.build.gradle.integration.common.fixture.app.TestSourceFile +import com.android.build.gradle.integration.common.fixture.app.VariantBuildScriptGenerator +import org.junit.AfterClass +import org.junit.BeforeClass +import org.junit.ClassRule +import org.junit.Test + +/** + * Performance test on gradle plugin with multiple subprojects and multiple variants. + */ +class MultiProjectsAndroidTest { + public static AndroidTestApp app = new HelloWorldApp() + static { + app.addFile(new TestSourceFile("", "build.gradle", + new VariantBuildScriptGenerator( + buildTypes: VariantBuildScriptGenerator.MEDIUM_NUMBER, + productFlavors: VariantBuildScriptGenerator.MEDIUM_NUMBER, + """ + apply plugin: "com.android.application" + + android { + compileSdkVersion $GradleTestProject.DEFAULT_COMPILE_SDK_VERSION + buildToolsVersion "$GradleTestProject.DEFAULT_BUILD_TOOL_VERSION" + + buildTypes { + \${buildTypes} + } + + productFlavors { + \${productFlavors} + } + } + """.stripIndent()).createBuildScript()) + ) + } + + public static TestProject baseProject = new MultiModuleTestProject("app", app, 10) + + @ClassRule + public static GradleTestProject project = GradleTestProject.builder() + .fromTestApp(baseProject) + .create() + + @AfterClass + static void cleanUp() { + app = null; + baseProject = null; + project = null; + } + + @Test + void performanceTest() { + project.execute("help") + } +} |