From 5687c8d33a7f12fc30ff7cbeae2ee381519ec6c8 Mon Sep 17 00:00:00 2001 From: mlykotom Date: Tue, 6 Dec 2022 11:22:02 +0100 Subject: [PATCH] Fix bookmarks actions Change-Id: I415d651414d68a312498d5faff799d72145a53ed --- .../baselineprofile/BaselineProfileGenerator.kt | 5 ++--- .../apps/nowinandroid/bookmarks/BookmarksActions.kt | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) 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.kt index 334ab5418..3dfafd647 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 @@ -18,8 +18,8 @@ package com.google.samples.apps.nowinandroid.baselineprofile import androidx.benchmark.macro.ExperimentalBaselineProfilesApi import androidx.benchmark.macro.junit4.BaselineProfileRule -import androidx.test.uiautomator.By import com.google.samples.apps.nowinandroid.PACKAGE_NAME +import com.google.samples.apps.nowinandroid.bookmarks.goToBookmarksScreen import com.google.samples.apps.nowinandroid.foryou.forYouScrollFeedDownUp import com.google.samples.apps.nowinandroid.foryou.forYouSelectTopics import com.google.samples.apps.nowinandroid.foryou.forYouWaitForContent @@ -51,8 +51,7 @@ class BaselineProfileGenerator { forYouScrollFeedDownUp() // Navigate to saved screen - device.findObject(By.text("Saved")).click() - device.waitForIdle() + goToBookmarksScreen() // TODO: we need to implement adding stuff to bookmarks before able to scroll it // bookmarksScrollFeedDownUp() diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/bookmarks/BookmarksActions.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/bookmarks/BookmarksActions.kt index b2e99d8cc..83ad48398 100644 --- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/bookmarks/BookmarksActions.kt +++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/bookmarks/BookmarksActions.kt @@ -18,8 +18,17 @@ package com.google.samples.apps.nowinandroid.bookmarks import androidx.benchmark.macro.MacrobenchmarkScope import androidx.test.uiautomator.By +import androidx.test.uiautomator.Until import com.google.samples.apps.nowinandroid.flingElementDownUp +fun MacrobenchmarkScope.goToBookmarksScreen() { + device.findObject(By.text("Saved")).click() + device.waitForIdle() + // Wait until saved title are shown on screen + val topAppBar = device.findObject(By.res("niaTopAppBar")) + topAppBar.wait(Until.hasObject(By.text("Saved")), 2_000) +} + fun MacrobenchmarkScope.bookmarksScrollFeedDownUp() { val feedList = device.findObject(By.res("bookmarks:feed")) device.flingElementDownUp(feedList)