From 53c0e021ded80e26650ca68043c761a6b2bab8ac Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Mon, 11 Mar 2024 14:07:39 +0200 Subject: [PATCH] Bug 1884653 - Remove redundant assertion functions from AccountSettingsRobot --- .../fenix/ui/robots/AccountSettingsRobot.kt | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/AccountSettingsRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/AccountSettingsRobot.kt index 32918b2c2..12164ca64 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/AccountSettingsRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/AccountSettingsRobot.kt @@ -5,8 +5,9 @@ package org.mozilla.fenix.ui.robots import androidx.test.espresso.Espresso -import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility import org.hamcrest.CoreMatchers import org.mozilla.fenix.R import org.mozilla.fenix.helpers.click @@ -15,12 +16,27 @@ import org.mozilla.fenix.helpers.click * Implementation of Robot Pattern for the URL toolbar. */ class AccountSettingsRobot { - fun verifyBookmarksCheckbox() = assertBookmarksCheckbox() + fun verifyBookmarksCheckbox() = + bookmarksCheckbox().check( + matches( + withEffectiveVisibility( + ViewMatchers.Visibility.VISIBLE, + ), + ), + ) - fun verifyHistoryCheckbox() = assertHistoryCheckbox() + fun verifyHistoryCheckbox() = + historyCheckbox().check( + matches( + withEffectiveVisibility( + ViewMatchers.Visibility.VISIBLE, + ), + ), + ) - fun verifySignOutButton() = assertSignOutButton() - fun verifyDeviceName() = assertDeviceName() + fun verifySignOutButton() = + signOutButton().check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + fun verifyDeviceName() = deviceName().check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) class Transition { @@ -46,22 +62,3 @@ private fun signOutButton() = Espresso.onView(CoreMatchers.allOf(ViewMatchers.wi private fun deviceName() = Espresso.onView(CoreMatchers.allOf(ViewMatchers.withText("Device name"))) private fun disconnectButton() = Espresso.onView(CoreMatchers.allOf(ViewMatchers.withId(R.id.signOutDisconnect))) - -private fun assertBookmarksCheckbox() = bookmarksCheckbox().check( - ViewAssertions.matches( - ViewMatchers.withEffectiveVisibility( - ViewMatchers.Visibility.VISIBLE, - ), - ), -) - -private fun assertHistoryCheckbox() = historyCheckbox().check( - ViewAssertions.matches( - ViewMatchers.withEffectiveVisibility( - ViewMatchers.Visibility.VISIBLE, - ), - ), -) - -private fun assertSignOutButton() = signOutButton().check(ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) -private fun assertDeviceName() = deviceName().check(ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))