For #19005: new tab three-dot menu sync sign in (#19037)

* Show synced tabs or sync account in new tab menu

* Sync sign in item navigates to account settings

* Check account auth and get sync item title

* Look for sync sign in item on home menu for UI test

* Sync sign in menu item UI test
upstream-sync
Elise Richards 3 years ago committed by GitHub
parent 90c9e634af
commit 59c94e447c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,6 +17,7 @@ import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
@ -227,11 +228,19 @@ class SmokeTest {
@Test
// Verifies the Synced tabs menu opens from a tab's 3 dot menu
fun openMainMenuSyncedTabsItemTest() {
homeScreen {
}.openThreeDotMenu {
}.openSyncedTabs {
verifySyncedTabsMenuHeader()
fun openMainMenuSyncItemTest() {
if (FeatureFlags.tabsTrayRewrite) {
homeScreen {
}.openThreeDotMenu {
}.openSyncSignIn {
verifyAccountSettingsMenuHeader()
}
} else {
homeScreen {
}.openThreeDotMenu {
}.openSyncedTabs {
verifySyncedTabsMenuHeader()
}
}
}

@ -9,6 +9,7 @@ import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.ui.robots.homeScreen
@ -48,7 +49,11 @@ class ThreeDotMenuMainTest {
verifyHistoryButton()
verifyDownloadsButton()
verifyAddOnsButton()
verifySyncedTabsButton()
if (FeatureFlags.tabsTrayRewrite) {
verifySyncSignInButton()
} else {
verifySyncedTabsButton()
}
verifyDesktopSite()
verifyWhatsNewButton()
verifyHelpButton()

@ -0,0 +1,46 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.ui.robots
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import org.hamcrest.CoreMatchers.allOf
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.click
/**
* Implementation of Robot Pattern for Sync Sign In sub menu.
*/
class SyncSignInRobot {
fun verifyAccountSettingsMenuHeader() = assertAccountSettingsMenuHeader()
class Transition {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
fun goBack(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
goBackButton().click()
BrowserRobot().interact()
return BrowserRobot.Transition()
}
}
}
private fun goBackButton() =
onView(allOf(withContentDescription("Navigate up")))
private fun assertAccountSettingsMenuHeader() {
// Replaced with the new string here, the test is assuming we are NOT signed in
// Sync tests in SettingsSyncTest are still TO-DO, so I'm not sure that we have a test for signing into Sync
onView(withText(R.string.preferences_account_settings))
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
}

@ -51,6 +51,7 @@ class ThreeDotMenuMainRobot {
fun verifyHistoryButton() = assertHistoryButton()
fun verifyBookmarksButton() = assertBookmarksButton()
fun verifySyncedTabsButton() = assertSyncedTabsButton()
fun verifySyncSignInButton() = assertSignInToSyncButton()
fun verifyHelpButton() = assertHelpButton()
fun verifyThreeDotMenuExists() = threeDotMenuRecyclerViewExists()
fun verifyForwardButton() = assertForwardButton()
@ -164,6 +165,15 @@ class ThreeDotMenuMainRobot {
return SyncedTabsRobot.Transition()
}
fun openSyncSignIn(interact: SyncSignInRobot.() -> Unit): SyncSignInRobot.Transition {
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(swipeDown())
mDevice.waitNotNull(Until.findObject(By.text("Sign in to sync")), waitingTime)
signInToSyncButton().click()
SyncSignInRobot().interact()
return SyncSignInRobot.Transition()
}
fun openBookmarks(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition {
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(swipeDown())
mDevice.waitNotNull(Until.findObject(By.text("Bookmarks")), waitingTime)

@ -792,6 +792,13 @@ class HomeFragment : Fragment() {
HomeFragmentDirections.actionGlobalSyncedTabsFragment()
)
}
HomeMenu.Item.SyncAccount -> {
hideOnboardingIfNeeded()
nav(
R.id.homeFragment,
HomeFragmentDirections.actionGlobalAccountSettingsFragment()
)
}
HomeMenu.Item.Bookmarks -> {
hideOnboardingIfNeeded()
nav(

@ -24,6 +24,7 @@ import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.support.ktx.android.content.getColorFromAttr
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.FeatureFlags.tabsTrayRewrite
import org.mozilla.fenix.R
import org.mozilla.fenix.experiments.ExperimentBranch
import org.mozilla.fenix.experiments.Experiments
@ -47,6 +48,7 @@ class HomeMenu(
object Downloads : Item()
object Extensions : Item()
object SyncTabs : Item()
object SyncAccount : Item()
object WhatsNew : Item()
object Help : Item()
object Settings : Item()
@ -55,8 +57,7 @@ class HomeMenu(
data class DesktopMode(val checked: Boolean) : Item()
}
private val primaryTextColor =
ThemeManager.resolveAttribute(R.attr.primaryText, context)
private val primaryTextColor = ThemeManager.resolveAttribute(R.attr.primaryText, context)
private val syncDisconnectedColor =
ThemeManager.resolveAttribute(R.attr.syncDisconnected, context)
private val syncDisconnectedBackgroundColor =
@ -92,17 +93,6 @@ class HomeMenu(
}
}
private fun getSyncItemTitle(): String {
val authenticatedAccount = accountManager.authenticatedAccount() != null
val email = accountManager.accountProfile()?.email
return if (authenticatedAccount && email != null) {
email
} else {
context.getString(R.string.sync_menu_sign_in)
}
}
private val oldCoreMenuItems by lazy {
val whatsNewItem = BrowserMenuHighlightableItem(
context.getString(R.string.browser_menu_whats_new),
@ -236,6 +226,17 @@ class HomeMenu(
onItemTapped.invoke(Item.DesktopMode(checked))
}
private fun getSyncItemTitle(): String {
val authenticatedAccount = accountManager.authenticatedAccount() != null
val email = accountManager.accountProfile()?.email
return if (authenticatedAccount && email != null) {
email
} else {
context.getString(R.string.sync_menu_sign_in)
}
}
@Suppress("ComplexMethod")
private fun newCoreMenuItems(): List<BrowserMenuItem> {
val experiments = context.components.analytics.experiments
@ -293,14 +294,22 @@ class HomeMenu(
onItemTapped.invoke(Item.Extensions)
}
val syncSignInItem = BrowserMenuImageText(
context.getString(R.string.library_synced_tabs),
val syncedTabsItem = BrowserMenuImageText(
context.getString(R.string.synced_tabs),
R.drawable.ic_synced_tabs,
primaryTextColor
) {
onItemTapped.invoke(Item.SyncTabs)
}
val syncSignInMenuItem = BrowserMenuImageText(
getSyncItemTitle(),
R.drawable.ic_synced_tabs,
primaryTextColor
) {
onItemTapped.invoke(Item.SyncAccount)
}
val whatsNewItem = BrowserMenuHighlightableItem(
context.getString(R.string.browser_menu_whats_new),
R.drawable.ic_whats_new,
@ -344,7 +353,7 @@ class HomeMenu(
historyItem,
downloadsItem,
extensionsItem,
syncSignInItem,
if (tabsTrayRewrite) syncSignInMenuItem else syncedTabsItem,
accountAuthItem,
BrowserMenuDivider(),
desktopItem,

Loading…
Cancel
Save