Skip to content

Commit

Permalink
feat(benchmarks): add scan to gradle commands, update running car ani…
Browse files Browse the repository at this point in the history
…mation, and add extra log text to `UiDevice.waitAndFindObject`
  • Loading branch information
ImaginativeShohag committed Jan 16, 2025
1 parent a012ab9 commit c9ec4d1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-beta-upload-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
--info
-Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
--scan

- name: Generate baseline profile
run: ./gradlew :app:generateBaselineProfile
Expand All @@ -72,6 +73,7 @@ jobs:
-Pandroid.experimental.androidTest.numManagedDeviceShards=1
-Pandroid.experimental.testOptions.managedDevices.maxConcurrentDevices=1
--stacktrace
--scan

- name: Build & deploy Android release
run: bundle exec fastlane android beta
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-production-upload-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
--info
-Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
--scan

- name: Generate baseline profile
run: ./gradlew :app:generateBaselineProfile
Expand All @@ -69,6 +70,7 @@ jobs:
-Pandroid.experimental.androidTest.numManagedDeviceShards=1
-Pandroid.experimental.testOptions.managedDevices.maxConcurrentDevices=1
--stacktrace
--scan

- name: Build & deploy Android release
run: bundle exec fastlane android deploy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -77,13 +80,18 @@ enum class CarState {

@Composable
fun RunningCarScreen() {
val animState = MutableStateFlow(CarState.INITIAL)
val animState = remember { MutableStateFlow(CarState.INITIAL) }
var isFirstTime by remember { mutableStateOf(true) }

LaunchedEffect(Unit) {
while (true) {
animState.value = CarState.INITIAL

delay(3000)
if (isFirstTime) {
isFirstTime = false
} else {
delay(3000)
}

animState.value = CarState.RUNNING

Expand Down
2 changes: 2 additions & 0 deletions benchmarks/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("UnstableApiUsage")

import com.android.build.api.dsl.ManagedVirtualDevice

plugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ fun UiDevice.flingElementDownUp(element: UiObject2) {
* Waits until an object with [selector] if visible on screen and returns the object.
* If the element is not available in [timeout], throws [AssertionError]
*/
fun UiDevice.waitAndFindObject(selector: BySelector, timeout: Long, extraLogText: String = "No"): UiObject2 {
fun UiDevice.waitAndFindObject(selector: BySelector, timeout: Long, extraLogText: String = ""): UiObject2 {
if (!wait(Until.hasObject(selector), timeout)) {
throw AssertionError("Element not found on screen in ${timeout}ms (selector=$selector) | $extraLogText")
val finalExtraLogText = if (extraLogText.isEmpty()) "" else " | $extraLogText"
throw AssertionError("Element not found on screen in ${timeout}ms (selector=$selector)$finalExtraLogText")
}

return findObject(selector)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class CompositionsModuleBaselineProfile {
// https://d.android.com/training/testing/other-components/ui-automator

// Wait for home screen
device.waitAndFindObject(By.res("screen:home"), 5_000)
device.waitAndFindObject(By.res("screen:home"), 5_000, "Initial home screen")

indexScreenTraverseActions(
moduleButtonText = "Compositions",
Expand Down

0 comments on commit c9ec4d1

Please sign in to comment.