A fully functional Android app built entirely with Kotlin and Jetpack Compose
Select topics to be able to scroll
mlykotom039ec8e959a3
diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.ktindex f9399d4c3..58380d437 100644--- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.kt+++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.kt@@ -21,6 +21,7 @@ import androidx.benchmark.macro.junit4.BaselineProfileRuleimport androidx.test.uiautomator.Byimport com.google.samples.apps.nowinandroid.PACKAGE_NAMEimport com.google.samples.apps.nowinandroid.foryou.forYouScrollFeedDownUp+import com.google.samples.apps.nowinandroid.foryou.forYouSelectTopicsimport com.google.samples.apps.nowinandroid.foryou.forYouWaitForContentimport com.google.samples.apps.nowinandroid.interests.interestsScrollPeopleDownUpimport com.google.samples.apps.nowinandroid.interests.interestsScrollTopicsDownUp@@ -46,6 +47,7 @@ class BaselineProfileGenerator {// Scroll the feed critical user journeyforYouWaitForContent()+ forYouSelectTopics(true)forYouScrollFeedDownUp()// Navigate to saved screendiff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/foryou/ForYouActions.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/foryou/ForYouActions.ktindex bba1218c1..8d66efc9c 100644--- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/foryou/ForYouActions.kt+++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/foryou/ForYouActions.kt@@ -23,15 +23,52 @@ import androidx.test.uiautomator.untilHasChildrenimport com.google.samples.apps.nowinandroid.flingElementDownUpfun MacrobenchmarkScope.forYouWaitForContent() {- // Wait until content is loaded by checking if authors are loaded+ // Wait until content is loaded by checking if topics are loadeddevice.wait(Until.gone(By.res("forYou:loadingWheel")), 5_000)// Sometimes, the loading wheel is gone, but the content is not loaded yet- // So we'll wait here for authors to be sure+ // So we'll wait here for topics to be sureval obj = device.findObject(By.res("forYou:topicSelection"))// Timeout here is quite big, because sometimes data loading takes a long time!obj.wait(untilHasChildren(), 60_000)}+/**+ * Selects some topics, which will show the feed content for them.+ * [recheckTopicsIfChecked] Topics may be already checked from the previous iteration.+ */+fun MacrobenchmarkScope.forYouSelectTopics(recheckTopicsIfChecked: Boolean = false) {+ val topics = device.findObject(By.res("forYou:topicSelection"))++ // Set gesture margin from sides not to trigger system gesture navigation+ val horizontalMargin = 10 * topics.visibleBounds.width() / 100+ topics.setGestureMargins(horizontalMargin, 0, horizontalMargin, 0)++ // Select some topics to show some feed content+ repeat(3) { index ->+ val topic = topics.children[index % topics.childCount]++ when {+ // Topic wasn't checked, so just do that+ !topic.isChecked -> {+ topic.click()+ device.waitForIdle()+ }++ // Topic was checked already and we want to recheck it, so just do it twice+ recheckTopicsIfChecked -> {+ repeat(2) {+ topic.click()+ device.waitForIdle()+ }+ }++ else -> {+ // Topic is checked, but we don't recheck it+ }+ }+ }+}+fun MacrobenchmarkScope.forYouScrollFeedDownUp() {val feedList = device.findObject(By.res("forYou:feed"))device.flingElementDownUp(feedList)