MacroBenchmarkTest now targets the package `androidx.benchmark.integration.macro.target`
Test: Updated unit tests pass.
Bug: b/171325609
Change-Id: I7f8ce4150e4d114b26163cf972a2618d4d85c441
diff --git a/benchmark/benchmark-macro-runtime/src/androidTest/AndroidManifest.xml b/benchmark/benchmark-macro-runtime/src/androidTest/AndroidManifest.xml
new file mode 100644
index 0000000..11743e7
--- /dev/null
+++ b/benchmark/benchmark-macro-runtime/src/androidTest/AndroidManifest.xml
@@ -0,0 +1,20 @@
+<?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 xmlns:android="http://schemas.android.com/apk/res/android"
+ package="androidx.benchmark.macro.runtime.test">
+
+</manifest>
diff --git a/benchmark/benchmark-macro-runtime/src/main/AndroidManifest.xml b/benchmark/benchmark-macro-runtime/src/main/AndroidManifest.xml
index e156320..e956539 100644
--- a/benchmark/benchmark-macro-runtime/src/main/AndroidManifest.xml
+++ b/benchmark/benchmark-macro-runtime/src/main/AndroidManifest.xml
@@ -13,5 +13,5 @@
~ 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.benchmark.macro.runtime"/>
+-->
+<manifest package="androidx.benchmark.macro.runtime" />
diff --git a/benchmark/benchmark-macro-runtime/src/main/java/androidx/benchmark/macro/Actions.kt b/benchmark/benchmark-macro-runtime/src/main/java/androidx/benchmark/macro/Actions.kt
index eb7e5a5..89174e7 100644
--- a/benchmark/benchmark-macro-runtime/src/main/java/androidx/benchmark/macro/Actions.kt
+++ b/benchmark/benchmark-macro-runtime/src/main/java/androidx/benchmark/macro/Actions.kt
@@ -77,14 +77,14 @@
if (response.isNotBlank()) {
Log.d(TAG, "Received dump profile response $response")
} else {
- throw RuntimeException("Failed to dump profile for $packageName")
+ throw RuntimeException("Failed to dump profile for $packageName ($response)")
}
delay(profileSaveTimeout)
}
val response = device.executeShellCommand("cmd package compile -f -m $mode $packageName")
if (!response.contains("Success")) {
Log.d(TAG, "Received compile cmd response: $response")
- throw RuntimeException("Failed to compile $packageName")
+ throw RuntimeException("Failed to compile $packageName ($response)")
}
}
diff --git a/benchmark/benchmark-macro-runtime/src/main/java/androidx/benchmark/macro/Macrobenchmark.kt b/benchmark/benchmark-macro-runtime/src/main/java/androidx/benchmark/macro/Macrobenchmark.kt
index 7578e57..d07d5b9 100644
--- a/benchmark/benchmark-macro-runtime/src/main/java/androidx/benchmark/macro/Macrobenchmark.kt
+++ b/benchmark/benchmark-macro-runtime/src/main/java/androidx/benchmark/macro/Macrobenchmark.kt
@@ -34,8 +34,7 @@
private val device = UiDevice.getInstance(instrumentation)
fun launchPackageAndWait(block: (Intent) -> Unit) {
- val intent = context.packageManager
- .getLaunchIntentForPackage(packageName)!!
+ val intent = context.packageManager.getLaunchIntentForPackage(packageName)!!
block(intent)
context.startActivity(intent)
device.wait(
diff --git a/benchmark/benchmark-simple-macro-benchmark/build.gradle b/benchmark/benchmark-simple-macro-benchmark/build.gradle
new file mode 100644
index 0000000..7cb8d16
--- /dev/null
+++ b/benchmark/benchmark-simple-macro-benchmark/build.gradle
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
+import static androidx.build.dependencies.DependenciesKt.*
+import androidx.build.LibraryGroups
+import androidx.build.Publish
+
+plugins {
+ id("AndroidXPlugin")
+ id("com.android.library")
+ id("kotlin-android")
+}
+
+android {
+ defaultConfig {
+ minSdkVersion 28
+ }
+}
+
+dependencies {
+ androidTestImplementation(project(":benchmark:benchmark-macro-runtime"))
+ androidTestImplementation(ANDROIDX_TEST_RULES)
+ androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
+ androidTestImplementation(ANDROIDX_TEST_CORE)
+ androidTestImplementation(ANDROIDX_TEST_RUNNER)
+}
+
+// Define a task dependency so the app is installed before we run macro benchmarks.
+tasks.getByPath(':benchmark:benchmark-simple-macro-benchmark:connectedCheck')
+ .dependsOn(
+ tasks.getByPath(
+ ':benchmark:integration-tests:benchmark-simple-macro-benchmark-target:installRelease'
+ )
+ )
diff --git a/benchmark/benchmark-simple-macro-benchmark/src/androidTest/AndroidManifest.xml b/benchmark/benchmark-simple-macro-benchmark/src/androidTest/AndroidManifest.xml
new file mode 100644
index 0000000..69d043c
--- /dev/null
+++ b/benchmark/benchmark-simple-macro-benchmark/src/androidTest/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?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 xmlns:android="http://schemas.android.com/apk/res/android"
+ package="androidx.benchmark.macro.sample">
+
+ <!--
+ The Macro Benchmark Sample needs to launch activities in
+ `androidx.benchmark.integration.macro.target` APK.
+
+ The Macro Benchmark Library uses `PackageManager` to query for activities. This requires
+ the test APK to declare that `androidx.benchmark.integration.macro.target` be visible to
+ the APK (given Android 11's package visibility rules).
+ -->
+ <queries>
+ <package android:name="androidx.benchmark.integration.macro.target" />
+ </queries>
+</manifest>
diff --git a/benchmark/benchmark-macro-runtime/src/androidTest/java/androidx/benchmark/macro/MacroBenchmarkTest.kt b/benchmark/benchmark-simple-macro-benchmark/src/androidTest/java/androidx/benchmark/macro/sample/MacroBenchmarkTest.kt
similarity index 82%
rename from benchmark/benchmark-macro-runtime/src/androidTest/java/androidx/benchmark/macro/MacroBenchmarkTest.kt
rename to benchmark/benchmark-simple-macro-benchmark/src/androidTest/java/androidx/benchmark/macro/sample/MacroBenchmarkTest.kt
index ad64f07..4a2f637 100644
--- a/benchmark/benchmark-macro-runtime/src/androidTest/java/androidx/benchmark/macro/MacroBenchmarkTest.kt
+++ b/benchmark/benchmark-simple-macro-benchmark/src/androidTest/java/androidx/benchmark/macro/sample/MacroBenchmarkTest.kt
@@ -14,9 +14,13 @@
* limitations under the License.
*/
-package androidx.benchmark.macro
+package androidx.benchmark.macro.sample
import android.content.Intent
+import androidx.benchmark.macro.CompilationMode
+import androidx.benchmark.macro.CpuUsageMetric
+import androidx.benchmark.macro.StartupTimingMetric
+import androidx.benchmark.macro.macrobenchmark
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import org.junit.Ignore
@@ -31,7 +35,7 @@
@Ignore("Not running the test in CI")
fun basicTest() = macrobenchmark(
"benchmarkUniqueName",
- packageName = "com.android.settings",
+ packageName = "androidx.benchmark.integration.macro.target",
listOf(StartupTimingMetric(), CpuUsageMetric()),
CompilationMode.Speed,
killProcessEachIteration = true,
diff --git a/benchmark/benchmark-simple-macro-benchmark/src/main/AndroidManifest.xml b/benchmark/benchmark-simple-macro-benchmark/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..005f65e
--- /dev/null
+++ b/benchmark/benchmark-simple-macro-benchmark/src/main/AndroidManifest.xml
@@ -0,0 +1,16 @@
+<?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.benchmark.macro.sample" />
diff --git a/benchmark/integration-tests/macro-benchmark-target/README.md b/benchmark/integration-tests/benchmark-simple-macro-benchmark-target/README.md
similarity index 100%
rename from benchmark/integration-tests/macro-benchmark-target/README.md
rename to benchmark/integration-tests/benchmark-simple-macro-benchmark-target/README.md
diff --git a/benchmark/integration-tests/macro-benchmark-target/build.gradle b/benchmark/integration-tests/benchmark-simple-macro-benchmark-target/build.gradle
similarity index 100%
rename from benchmark/integration-tests/macro-benchmark-target/build.gradle
rename to benchmark/integration-tests/benchmark-simple-macro-benchmark-target/build.gradle
diff --git a/benchmark/integration-tests/macro-benchmark-target/src/main/AndroidManifest.xml b/benchmark/integration-tests/benchmark-simple-macro-benchmark-target/src/main/AndroidManifest.xml
similarity index 75%
rename from benchmark/integration-tests/macro-benchmark-target/src/main/AndroidManifest.xml
rename to benchmark/integration-tests/benchmark-simple-macro-benchmark-target/src/main/AndroidManifest.xml
index 30bd4e4..726a4df 100644
--- a/benchmark/integration-tests/macro-benchmark-target/src/main/AndroidManifest.xml
+++ b/benchmark/integration-tests/benchmark-simple-macro-benchmark-target/src/main/AndroidManifest.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?><!--
+<!--
~ Copyright 2020 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,22 +14,25 @@
~ limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="androidx.benchmark.integration.macro">
+ package="androidx.benchmark.integration.macro.target">
<application
android:allowBackup="false"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat">
- <activity android:name=".MainActivity">
+ <!--
+ The activity needs to be exported so the Macro Benchmark Sample can discover activities
+ under the new package visibility changes for Android 11.
+ -->
+ <activity
+ android:exported="true"
+ android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
-
<category android:name="android.intent.category.LAUNCHER" />
- <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
-
</manifest>
diff --git a/benchmark/integration-tests/macro-benchmark-target/src/main/java/androidx/benchmark/integration/macro/MainActivity.kt b/benchmark/integration-tests/benchmark-simple-macro-benchmark-target/src/main/java/androidx/benchmark/integration/macro/target/MainActivity.kt
similarity index 94%
rename from benchmark/integration-tests/macro-benchmark-target/src/main/java/androidx/benchmark/integration/macro/MainActivity.kt
rename to benchmark/integration-tests/benchmark-simple-macro-benchmark-target/src/main/java/androidx/benchmark/integration/macro/target/MainActivity.kt
index 780f79c..60477d9 100644
--- a/benchmark/integration-tests/macro-benchmark-target/src/main/java/androidx/benchmark/integration/macro/MainActivity.kt
+++ b/benchmark/integration-tests/benchmark-simple-macro-benchmark-target/src/main/java/androidx/benchmark/integration/macro/target/MainActivity.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package androidx.benchmark.integration.macro
+package androidx.benchmark.integration.macro.target
import android.os.Bundle
import android.widget.TextView
diff --git a/benchmark/integration-tests/macro-benchmark-target/src/main/res/layout/activity_main.xml b/benchmark/integration-tests/benchmark-simple-macro-benchmark-target/src/main/res/layout/activity_main.xml
similarity index 100%
rename from benchmark/integration-tests/macro-benchmark-target/src/main/res/layout/activity_main.xml
rename to benchmark/integration-tests/benchmark-simple-macro-benchmark-target/src/main/res/layout/activity_main.xml
diff --git a/benchmark/integration-tests/macro-benchmark-target/src/main/res/values/strings.xml b/benchmark/integration-tests/benchmark-simple-macro-benchmark-target/src/main/res/values/strings.xml
similarity index 100%
rename from benchmark/integration-tests/macro-benchmark-target/src/main/res/values/strings.xml
rename to benchmark/integration-tests/benchmark-simple-macro-benchmark-target/src/main/res/values/strings.xml
diff --git a/settings.gradle b/settings.gradle
index 40990315..7eabbef 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -149,10 +149,11 @@
includeProject(":benchmark:benchmark-junit4", "benchmark/junit4")
includeProject(":benchmark:benchmark-macro", "benchmark/macro", [BuildType.MAIN])
includeProject(":benchmark:benchmark-macro-runtime", "benchmark/benchmark-macro-runtime", [BuildType.MAIN])
+includeProject(":benchmark:benchmark-simple-macro-benchmark", "benchmark/benchmark-simple-macro-benchmark", [BuildType.MAIN])
includeProject(":benchmark:benchmark-perfetto", "benchmark/perfetto", [BuildType.MAIN])
includeProject(":benchmark:integration-tests:dry-run-benchmark", "benchmark/integration-tests/dry-run-benchmark", [BuildType.MAIN])
includeProject(":benchmark:integration-tests:startup-benchmark", "benchmark/integration-tests/startup-benchmark", [BuildType.MAIN])
-includeProject(":benchmark:integration-tests:macro-benchmark-target", "benchmark/integration-tests/macro-benchmark-target", [BuildType.MAIN])
+includeProject(":benchmark:integration-tests:benchmark-simple-macro-benchmark-target", "benchmark/integration-tests/benchmark-simple-macro-benchmark-target", [BuildType.MAIN])
includeProject(":biometric:biometric", "biometric/biometric", [BuildType.MAIN])
includeProject(":biometric:integration-tests:testapp", "biometric/integration-tests/testapp", [BuildType.MAIN])
includeProject(":browser:browser", "browser/browser", [BuildType.MAIN])