Skip to content

Commit 3047515

Browse files
Update Baseline Profile generation
1 parent e4949fd commit 3047515

File tree

5 files changed

+24
-71
lines changed

5 files changed

+24
-71
lines changed

MacrobenchmarkSample/app/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ android {
5050
)
5151
// In real app, this would use its own release keystore
5252
signingConfig = signingConfigs.getByName("debug")
53+
baselineProfile.automaticGenerationDuringBuild = true
5354
}
5455
}
5556
// [END macrobenchmark_setup_app_build_type]
5657

5758
compileOptions {
58-
sourceCompatibility = JavaVersion.VERSION_21
59-
targetCompatibility = JavaVersion.VERSION_21
59+
sourceCompatibility = JavaVersion.VERSION_17
60+
targetCompatibility = JavaVersion.VERSION_17
6061
}
6162
}
6263

MacrobenchmarkSample/macrobenchmark/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ android {
4040
targetProjectPath = ":app"
4141

4242
compileOptions {
43-
sourceCompatibility = JavaVersion.VERSION_21
44-
targetCompatibility = JavaVersion.VERSION_21
43+
sourceCompatibility = JavaVersion.VERSION_17
44+
targetCompatibility = JavaVersion.VERSION_17
4545
}
4646

4747
testOptions.managedDevices.allDevices {
4848
create<ManagedVirtualDevice>("pixel6Api31") {
4949
device = "Pixel 6"
5050
apiLevel = 31
5151
systemImageSource = "aosp"
52+
testedAbi = "arm64-v8a"
5253
}
5354
}
5455
// [END_EXCLUDE]

MacrobenchmarkSample/macrobenchmark/src/main/kotlin/com/example/macrobenchmark/baselineprofile/LoginBaselineProfileGenerator.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ class LoginBaselineProfileGenerator {
4040
stableIterations = 3
4141
) {
4242
uiAutomator {
43-
clearAppData()
4443
startIntent(Intent("$packageName.LOGIN_ACTIVITY"))
45-
onElement { textAsString() == "User: " }.text = "user"
46-
onElement { textAsString() == "Password: " }.text = "password"
44+
onElement { isEditable and !isPassword }.text = "user"
45+
onElement { isEditable && isPassword }.text = "password"
4746
onElement { textAsString() == "Login" }.click()
4847
}
4948
}

MacrobenchmarkSample/macrobenchmark/src/main/kotlin/com/example/macrobenchmark/baselineprofile/RecyclerViewActivityBaselineProfileGenerator.kt

Lines changed: 0 additions & 54 deletions
This file was deleted.

MacrobenchmarkSample/macrobenchmark/src/main/kotlin/com/example/macrobenchmark/baselineprofile/ComposeActivityBaselineProfileGenerator.kt renamed to MacrobenchmarkSample/macrobenchmark/src/main/kotlin/com/example/macrobenchmark/baselineprofile/SampleBaselineProfileGenerator.kt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@
1616

1717
package com.example.macrobenchmark.baselineprofile
1818

19-
import android.content.Intent
2019
import androidx.benchmark.macro.junit4.BaselineProfileRule
2120
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
22-
import androidx.test.uiautomator.Direction
21+
import androidx.test.uiautomator.textAsString
2322
import androidx.test.uiautomator.uiAutomator
2423
import com.example.macrobenchmark.benchmark.util.TARGET_PACKAGE
25-
import org.junit.Ignore
2624
import org.junit.Rule
2725
import org.junit.Test
2826
import org.junit.runner.RunWith
2927

30-
@Ignore // TODO causing stale object excpetion on CI .. why?
3128
@RunWith(AndroidJUnit4ClassRunner::class)
32-
class ComposeActivityBaselineProfileGenerator {
29+
class SampleBaselineProfileGenerator {
3330

3431
@get:Rule
3532
val rule = BaselineProfileRule()
@@ -42,11 +39,20 @@ class ComposeActivityBaselineProfileGenerator {
4239
stableIterations = 3
4340
) {
4441
uiAutomator {
45-
// Start into the Compose Activity
46-
startIntent(Intent("$TARGET_PACKAGE.COMPOSE_ACTIVITY"))
47-
// Scrolling through the Compose journey
48-
onElement { viewIdResourceName == "myLazyColumn" }.fling(Direction.DOWN)
49-
onElement { viewIdResourceName == "myLazyColumn" }.fling(Direction.UP)
42+
startApp(TARGET_PACKAGE)
43+
listOf(
44+
"Login",
45+
"ListView",
46+
"Compose",
47+
"ScrollView",
48+
"Fully Drawn",
49+
"RecyclerView",
50+
"Nested RecyclerView",
51+
"Nested RecyclerView with Pools"
52+
).forEach {
53+
onElement { textAsString() == it }.click()
54+
pressBack()
55+
}
5056
}
5157
}
5258
}

0 commit comments

Comments
 (0)