diff --git a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/index/TutorialIndexScreen.kt b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/index/TutorialIndexScreen.kt index ecff4b7..a48d1b0 100644 --- a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/index/TutorialIndexScreen.kt +++ b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/index/TutorialIndexScreen.kt @@ -144,6 +144,7 @@ private fun MenuItem( ) { Text( modifier = Modifier + .testTag(item.testTag) .fillMaxWidth(), text = buildAnnotatedString { append(item.name) diff --git a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/index/TutorialList.kt b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/index/TutorialList.kt index baa48de..b2661c7 100644 --- a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/index/TutorialList.kt +++ b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/index/TutorialList.kt @@ -58,7 +58,8 @@ data class Tutorial( val name: String, val description: String? = null, val route: TutorialsScreen, - val level: TutorialLevel + val level: TutorialLevel, + val testTag: String = "tutorial-${route.route}" ) { companion object { val tutorialList = listOf( @@ -150,7 +151,8 @@ data class Tutorial( name = "Navigation blank screen issue", description = "Solutions for `popBackStack()` blank screen issue.", route = TutorialsScreen.TutorialPopBackStack, - level = TutorialLevel.Intermediate + level = TutorialLevel.Intermediate, + testTag = "tutorial-popbackstack" ), Tutorial( name = "Baseline profiles", diff --git a/benchmarks/src/main/kotlin/org/imaginativeworld/whynotcompose/benchmarks/baselineprofile/TutorialsModuleBaselineProfile.kt b/benchmarks/src/main/kotlin/org/imaginativeworld/whynotcompose/benchmarks/baselineprofile/TutorialsModuleBaselineProfile.kt index 3293fff..1f573c6 100644 --- a/benchmarks/src/main/kotlin/org/imaginativeworld/whynotcompose/benchmarks/baselineprofile/TutorialsModuleBaselineProfile.kt +++ b/benchmarks/src/main/kotlin/org/imaginativeworld/whynotcompose/benchmarks/baselineprofile/TutorialsModuleBaselineProfile.kt @@ -26,14 +26,18 @@ package org.imaginativeworld.whynotcompose.benchmarks.baselineprofile +import android.util.Log import androidx.benchmark.macro.junit4.BaselineProfileRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.By -import org.imaginativeworld.whynotcompose.benchmarks.commonModuleTraverseActions +import org.imaginativeworld.whynotcompose.benchmarks.clickAndWaitForIdle +import org.imaginativeworld.whynotcompose.benchmarks.dumpWindowHierarchy +import org.imaginativeworld.whynotcompose.benchmarks.pressBackAndWaitForIdle import org.imaginativeworld.whynotcompose.benchmarks.startActivityAndAllowNotifications import org.imaginativeworld.whynotcompose.benchmarks.waitAndFindObject +import org.imaginativeworld.whynotcompose.benchmarks.waitAndFindObjects import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -97,10 +101,34 @@ class TutorialsModuleBaselineProfile { // Wait for home screen device.waitAndFindObject(By.res("screen:home"), 5_000) - commonModuleTraverseActions( - moduleButtonText = "Tutorials", - screenTag = "screen:tutorials:index" - ) + val moduleButtonText = "Tutorials" + val screenTag = "screen:tutorials:index" + + val moduleButton = device.findObject(By.text(moduleButtonText)) + device.clickAndWaitForIdle(moduleButton) + + val items = device.waitAndFindObjects(By.res("list-item"), 5_000) + + Log.d("BaselineProfileGenerator", "hierarchy: ${device.dumpWindowHierarchy()}") + + val count = items.count() + + for (i in 0..