From f59072db0431955513e71ad3f25d9a21c2a2c714 Mon Sep 17 00:00:00 2001 From: mlykotom Date: Wed, 23 Nov 2022 10:31:31 +0100 Subject: [PATCH] Select random authors from the feed --- .../apps/nowinandroid/foryou/ForYouActions.kt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --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.kt index 9fd9b76b1..7dbe3c836 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 @@ -31,11 +31,19 @@ fun MacrobenchmarkScope.forYouWaitForContent() { fun MacrobenchmarkScope.forYouSelectAuthors() { val authors = device.findObject(By.res("forYou:authors")) - // select some authors to show some feed content - repeat(3) { index -> - val author = authors.children[index % authors.childCount] + + // set gesture margin from sides not to trigger system gesture navigation + val horizontalMargin = 10 * authors.visibleBounds.width() / 100 + authors.setGestureMargins(horizontalMargin, 0, horizontalMargin, 0) + + // select some random authors to show some feed content + repeat(3) { + // picks randomly from visible authors + val randomChild = nextInt(0, authors.childCount) + val author = authors.children[randomChild] author.click() device.waitForIdle() + authors.fling(RIGHT) } }