Move Compose Macrobenchmarks to a self-instrumenting test module.
Test: No longer need to install the target APK before running the Macrobenchmarks.
Bug: b/188699825
Change-Id: I477adf02407a43afcfad0cde0b28f00c6e3ba71c
diff --git a/buildSrc/private/src/main/kotlin/androidx/build/testConfiguration/TestSuiteConfiguration.kt b/buildSrc/private/src/main/kotlin/androidx/build/testConfiguration/TestSuiteConfiguration.kt
index db5e430..ed9c041 100644
--- a/buildSrc/private/src/main/kotlin/androidx/build/testConfiguration/TestSuiteConfiguration.kt
+++ b/buildSrc/private/src/main/kotlin/androidx/build/testConfiguration/TestSuiteConfiguration.kt
@@ -292,8 +292,10 @@
private fun Project.getOrCreateMacrobenchmarkConfigTask(variantName: String):
TaskProvider<GenerateTestConfigurationTask> {
val parentProject = this.parent!!
+ val taskCollection = parentProject.tasks.withType(GenerateTestConfigurationTask::class.java)
+ val taskNames = taskCollection.getNames()
return if (
- parentProject.tasks.withType(GenerateTestConfigurationTask::class.java).isEmpty()
+ "${AndroidXImplPlugin.GENERATE_TEST_CONFIGURATION_TASK}$variantName" !in taskNames
) {
parentProject.tasks.register(
"${AndroidXImplPlugin.GENERATE_TEST_CONFIGURATION_TASK}$variantName",
diff --git a/compose/integration-tests/macrobenchmark/build.gradle b/compose/integration-tests/macrobenchmark/build.gradle
index 4269659..6dfe087 100644
--- a/compose/integration-tests/macrobenchmark/build.gradle
+++ b/compose/integration-tests/macrobenchmark/build.gradle
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Android Open Source Project
+ * Copyright 2021 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.
@@ -16,26 +16,39 @@
plugins {
id("AndroidXPlugin")
- id("com.android.library")
+ id("com.android.test")
id("kotlin-android")
}
-android.defaultConfig {
- minSdkVersion 28
- testInstrumentationRunnerArgument "androidx.benchmark.output.enable", "true"
+android {
+ targetProjectPath = ":compose:integration-tests:macrobenchmark-target"
+ experimentalProperties["android.experimental.self-instrumenting"] = true
+
+ buildTypes {
+ release {
+ debuggable = true
+ }
+ }
+
+ defaultConfig {
+ minSdkVersion 28
+ testInstrumentationRunnerArgument "androidx.benchmark.output.enable", "true"
+ }
+}
+
+androidComponents {
+ beforeVariants(selector().all()) {
+ enabled = buildType == 'release'
+ }
}
dependencies {
- androidTestImplementation(project(":benchmark:benchmark-junit4"))
- androidTestImplementation(project(":benchmark:benchmark-macro-junit4"))
- androidTestImplementation(project(":internal-testutils-macrobenchmark"))
- androidTestImplementation(libs.testRules)
- androidTestImplementation(libs.testExtJunit)
- androidTestImplementation(libs.testCore)
- androidTestImplementation(libs.testRunner)
- androidTestImplementation(libs.testUiautomator)
+ implementation(project(":benchmark:benchmark-junit4"))
+ implementation(project(":benchmark:benchmark-macro-junit4"))
+ implementation(project(":internal-testutils-macrobenchmark"))
+ implementation(libs.testRules)
+ implementation(libs.testExtJunit)
+ implementation(libs.testCore)
+ implementation(libs.testRunner)
+ implementation(libs.testUiautomator)
}
-
-// Define a task dependency so the app is installed before we run macro benchmarks.
-tasks.getByPath(":compose:integration-tests:macrobenchmark:connectedCheck")
- .dependsOn(tasks.getByPath(":compose:integration-tests:macrobenchmark-target:installRelease"))
diff --git a/compose/integration-tests/macrobenchmark/src/androidTest/AndroidManifest.xml b/compose/integration-tests/macrobenchmark/src/androidTest/AndroidManifest.xml
deleted file mode 100644
index 0718de4..0000000
--- a/compose/integration-tests/macrobenchmark/src/androidTest/AndroidManifest.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2020 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.
- -->
-<manifest package="androidx.compose.integration.macrobenchmark.test"/>
diff --git a/compose/integration-tests/macrobenchmark/src/main/AndroidManifest.xml b/compose/integration-tests/macrobenchmark/src/main/AndroidManifest.xml
index 34af7ba..0718de4 100644
--- a/compose/integration-tests/macrobenchmark/src/main/AndroidManifest.xml
+++ b/compose/integration-tests/macrobenchmark/src/main/AndroidManifest.xml
@@ -14,4 +14,4 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<manifest package="androidx.compose.integration.macrobenchmark" />
+<manifest package="androidx.compose.integration.macrobenchmark.test"/>
diff --git a/compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/BenchmarkingUtils.kt b/compose/integration-tests/macrobenchmark/src/main/java/androidx/compose/integration/macrobenchmark/BenchmarkingUtils.kt
similarity index 100%
rename from compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/BenchmarkingUtils.kt
rename to compose/integration-tests/macrobenchmark/src/main/java/androidx/compose/integration/macrobenchmark/BenchmarkingUtils.kt
diff --git a/compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/IoSettingsStartupBenchmark.kt b/compose/integration-tests/macrobenchmark/src/main/java/androidx/compose/integration/macrobenchmark/IoSettingsStartupBenchmark.kt
similarity index 100%
rename from compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/IoSettingsStartupBenchmark.kt
rename to compose/integration-tests/macrobenchmark/src/main/java/androidx/compose/integration/macrobenchmark/IoSettingsStartupBenchmark.kt
diff --git a/compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/NestedListsScrollBenchmark.kt b/compose/integration-tests/macrobenchmark/src/main/java/androidx/compose/integration/macrobenchmark/NestedListsScrollBenchmark.kt
similarity index 100%
rename from compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/NestedListsScrollBenchmark.kt
rename to compose/integration-tests/macrobenchmark/src/main/java/androidx/compose/integration/macrobenchmark/NestedListsScrollBenchmark.kt
diff --git a/compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/SmallListStartupBenchmark.kt b/compose/integration-tests/macrobenchmark/src/main/java/androidx/compose/integration/macrobenchmark/SmallListStartupBenchmark.kt
similarity index 100%
rename from compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/SmallListStartupBenchmark.kt
rename to compose/integration-tests/macrobenchmark/src/main/java/androidx/compose/integration/macrobenchmark/SmallListStartupBenchmark.kt
diff --git a/compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/TrivialListScrollBenchmark.kt b/compose/integration-tests/macrobenchmark/src/main/java/androidx/compose/integration/macrobenchmark/TrivialListScrollBenchmark.kt
similarity index 100%
rename from compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/TrivialListScrollBenchmark.kt
rename to compose/integration-tests/macrobenchmark/src/main/java/androidx/compose/integration/macrobenchmark/TrivialListScrollBenchmark.kt
diff --git a/compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/TrivialStartupBenchmark.kt b/compose/integration-tests/macrobenchmark/src/main/java/androidx/compose/integration/macrobenchmark/TrivialStartupBenchmark.kt
similarity index 100%
rename from compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/TrivialStartupBenchmark.kt
rename to compose/integration-tests/macrobenchmark/src/main/java/androidx/compose/integration/macrobenchmark/TrivialStartupBenchmark.kt