diff --git a/app/src/androidTest/java/org/mozilla/fenix/syncintegration/SyncIntegrationTest.kt b/app/src/androidTest/java/org/mozilla/fenix/syncintegration/SyncIntegrationTest.kt index 3b5ab3aff..26af5901b 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/syncintegration/SyncIntegrationTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/syncintegration/SyncIntegrationTest.kt @@ -18,6 +18,7 @@ import org.junit.Rule import org.junit.Test import org.mozilla.fenix.helpers.HomeActivityTestRule import org.mozilla.fenix.ui.robots.homeScreen +import org.mozilla.fenix.ui.robots.accountSettings import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice @@ -27,6 +28,7 @@ import androidx.test.uiautomator.Until import org.hamcrest.Matchers.allOf import org.mozilla.fenix.R import org.mozilla.fenix.helpers.TestAssetHelper + import org.mozilla.fenix.helpers.ext.waitNotNull @Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") @@ -58,6 +60,27 @@ class SyncIntegrationTest { bookmarkAfterSyncIsShown() } + @Test + fun checkAccountSettings() { + signInFxSync() + mDevice.waitNotNull(Until.findObjects(By.text("Settings")), TestAssetHelper.waitingTime) + + goToAccountSettings() + // This function to be added to the robot once the status of checkboxes can be checked + // currently is not possible to select each one (History/Bookmark) and verify its status + // verifyCheckBoxesSelected() + // Then select/unselect each one and verify again that its status is correct + accountSettings { + verifyBookmarksCheckbox() + verifyHistoryCheckbox() + verifySignOutButton() + verifyDeviceName() + }.disconnectAccount { + sleep(TestAssetHelper.waitingTime) + verifySettingsView() + } + } + /* These tests will be running in the future // once the test above runs successfully and // the environment is stable @@ -155,9 +178,15 @@ class SyncIntegrationTest { sleep(TestAssetHelper.waitingTimeShort) tapOnSignIn() } + + fun goToAccountSettings() { + enterAccountSettings() + mDevice.waitNotNull(Until.findObjects(By.text("Device name")), TestAssetHelper.waitingTime) + } } fun settingsAccount() = onView(allOf(withText("Turn on Sync"))).perform(click()) fun tapInToolBar() = onView(withId(org.mozilla.fenix.R.id.toolbar_wrapper)) fun awesomeBar() = onView(withId(org.mozilla.fenix.R.id.mozac_browser_toolbar_edit_url_view)) fun useEmailInsteadButton() = onView(withId(R.id.signInEmailButton)).perform(click()) +fun enterAccountSettings() = onView(withId(R.id.email)).perform(click()) diff --git a/app/src/androidTest/java/org/mozilla/fenix/syncintegration/test_integration.py b/app/src/androidTest/java/org/mozilla/fenix/syncintegration/test_integration.py index 0183bf00b..4305b2f3e 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/syncintegration/test_integration.py +++ b/app/src/androidTest/java/org/mozilla/fenix/syncintegration/test_integration.py @@ -2,7 +2,11 @@ import os import sys +def test_sync_account_settings(tps, gradlewbuild): + gradlewbuild.test('checkAccountSettings') + def test_sync_history_from_desktop(tps, gradlewbuild): + os.chdir('app/src/androidTest/java/org/mozilla/fenix/syncintegration/') tps.run('test_history.js') gradlewbuild.test('checkHistoryFromDesktopTest') 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 new file mode 100644 index 000000000..62e8ca844 --- /dev/null +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/AccountSettingsRobot.kt @@ -0,0 +1,63 @@ +package org.mozilla.fenix.ui.robots + +import androidx.test.espresso.Espresso +import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.matcher.ViewMatchers +import org.hamcrest.CoreMatchers +import org.mozilla.fenix.R +import org.mozilla.fenix.helpers.click + +/** + * Implementation of Robot Pattern for the URL toolbar. + */ +class AccountSettingsRobot { + fun verifyBookmarksCheckbox() = assertBookmarksCheckbox() + + fun verifyHistoryCheckbox() = assertHistoryCheckbox() + + fun verifySignOutButton() = assertSignOutButton() + fun verifyDeviceName() = assertDeviceName() + + class Transition { + + fun disconnectAccount(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { + signOutButton().click() + disconnectButton().click() + + SettingsRobot().interact() + return SettingsRobot.Transition() + } + } +} + +fun accountSettings(interact: AccountSettingsRobot.() -> Unit): AccountSettingsRobot.Transition { + AccountSettingsRobot().interact() + return AccountSettingsRobot.Transition() +} + +private fun bookmarksCheckbox() = Espresso.onView(CoreMatchers.allOf(ViewMatchers.withText("Bookmarks"))) +private fun historyCheckbox() = Espresso.onView(CoreMatchers.allOf(ViewMatchers.withText("History"))) + +private fun signOutButton() = Espresso.onView(CoreMatchers.allOf(ViewMatchers.withText("Sign out"))) +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)))