From db5fe96c4ccf247190db8316ee7632ffb3c024cb Mon Sep 17 00:00:00 2001 From: mlykotom Date: Tue, 6 Dec 2022 11:21:45 +0100 Subject: [PATCH] Fix interests actions Change-Id: I3583d6c7c904f0cf1bf21892721551f41d89796f --- .../baselineprofile/BaselineProfileGenerator.kt | 12 ++---------- .../nowinandroid/interests/InterestsActions.kt | 15 ++++++++++----- 2 files changed, 12 insertions(+), 15 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 58380d437..334ab5418 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 @@ -23,7 +23,7 @@ import com.google.samples.apps.nowinandroid.PACKAGE_NAME import com.google.samples.apps.nowinandroid.foryou.forYouScrollFeedDownUp import com.google.samples.apps.nowinandroid.foryou.forYouSelectTopics import com.google.samples.apps.nowinandroid.foryou.forYouWaitForContent -import com.google.samples.apps.nowinandroid.interests.interestsScrollPeopleDownUp +import com.google.samples.apps.nowinandroid.interests.goToInterestsScreen import com.google.samples.apps.nowinandroid.interests.interestsScrollTopicsDownUp import org.junit.Rule import org.junit.Test @@ -57,15 +57,7 @@ class BaselineProfileGenerator { // bookmarksScrollFeedDownUp() // Navigate to interests screen - device.findObject(By.text("Interests")).click() - device.waitForIdle() - + goToInterestsScreen() interestsScrollTopicsDownUp() - - // Navigate to people tab - device.findObject(By.text("People")).click() - device.waitForIdle() - - interestsScrollPeopleDownUp() } } diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt index b68dfea26..e595ae4e4 100644 --- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt +++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt @@ -21,16 +21,21 @@ import androidx.test.uiautomator.By import androidx.test.uiautomator.Until import com.google.samples.apps.nowinandroid.flingElementDownUp +fun MacrobenchmarkScope.goToInterestsScreen() { + device.findObject(By.text("Interests")).click() + device.waitForIdle() + // Wait until interests are shown on screen + val topAppBar = device.findObject(By.res("niaTopAppBar")) + topAppBar.wait(Until.hasObject(By.text("Interests")), 2_000) + // Wait until content is loaded by checking if interests are loaded + device.wait(Until.gone(By.res("loadingWheel")), 5_000) +} + fun MacrobenchmarkScope.interestsScrollTopicsDownUp() { val topicsList = device.findObject(By.res("interests:topics")) device.flingElementDownUp(topicsList) } -fun MacrobenchmarkScope.interestsScrollPeopleDownUp() { - val peopleList = device.findObject(By.res("interests:people")) - device.flingElementDownUp(peopleList) -} - fun MacrobenchmarkScope.interestsWaitForTopics() { device.wait(Until.hasObject(By.text("Accessibility")), 30_000) }