Bug 1804274: Adds entrypoints for firefox accounts

Co-authored-by: Matt Tighe <MatthewTighe>
Co-authored-by: Jonathan Almeida <jalmeida@mozilla.com>
Co-authored-by: Tarik Eshaq <teshaq@mozilla.com>
fenix/115.2.0
Tarik Eshaq 1 year ago committed by mergify[bot]
parent 72a6af1510
commit 624d444b03

@ -6,6 +6,7 @@ package org.mozilla.fenix
import androidx.navigation.NavDirections
import mozilla.appservices.places.BookmarkRoot
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
/**
* Used with [HomeActivity] global navigation to indicate which fragment is being opened.
@ -28,7 +29,7 @@ enum class GlobalDirections(val navDirections: NavDirections, val destinationId:
R.id.settingsFragment,
),
Sync(
NavGraphDirections.actionGlobalTurnOnSync(),
NavGraphDirections.actionGlobalTurnOnSync(entrypoint = FenixFxAEntryPoint.DeepLink),
R.id.turnOnSyncFragment,
),
SearchEngine(

@ -0,0 +1,119 @@
/* 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.components.accounts
import android.os.Parcel
import android.os.Parcelable
import mozilla.components.concept.sync.FxAEntryPoint
/**
* Fenix implementation of [FxAEntryPoint].
*/
enum class FenixFxAEntryPoint(override val entryName: String) : FxAEntryPoint, Parcelable {
/**
* New user onboarding, the user accessed the sign in through new user onboarding
*/
NewUserOnboarding("newuser-onboarding"),
/**
* Manual sign in from the onboarding menu
*/
OnboardingManualSignIn("onboarding-manual-sign-in"),
/**
* User used a deep link to get to firefox accounts authentication
*/
DeepLink("deep-link"),
/**
* Authenticating from the browser's toolbar
*/
BrowserToolbar("browser-toolbar"),
/**
* Authenticating from the home menu (the hamburger menu)
*/
HomeMenu("home-menu"),
/**
* Authenticating in the bookmark view, when getting attempting to get synced
* bookmarks
*/
BookmarkView("bookmark-view"),
/**
* Authenticating from the homepage onboarding dialog
*/
HomeOnboardingDialog("home-onboarding-dialog"),
/**
* Authenticating from the settings menu
*/
SettingsMenu("settings-menu"),
/**
* Authenticating from the autofill settings to enable synced
* credit cards/addresses
*/
AutofillSetting("autofill-setting"),
/**
* Authenticating from the saved logins menu to enable synced
* logins
*/
SavedLogins("saved-logins"),
/**
* Authenticating from the Share menu to enable send tab
*/
ShareMenu("share-menu"),
/**
* Authenticating as a navigation interaction
*/
NavigationInteraction("navigation-interaction"),
/**
* Authenticating from the synced tabs menu to enable synced tabs
*/
SyncedTabsMenu("synced-tabs-menu"),
/**
* When serializing the value after navigating, the result is a nullable value. We have this
* "unknown" as a default value in the odd chance that we receive an [entryName] is not part of this enum.
*
* Do not use within app code.
*/
Unknown("unknown"),
;
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeString(entryName)
}
override fun describeContents(): Int {
return 0
}
/**
* Override implementation of the [Parcelable.Creator].
*
* Implementation notes: We need to manually create an override for [Parcelable] instead of using the annotation,
* because this is an enum implementation of the API and the auto-generated code does not know how to choose a
* particular enum value in [Parcelable.Creator.createFromParcel].
* We also introduce an [FxAEntryPoint.Unknown] value to use as a default return value in the off-chance that we
* cannot safely serialize the enum value from the navigation library; this should be a rare case, if any.
*/
companion object CREATOR : Parcelable.Creator<FenixFxAEntryPoint> {
override fun createFromParcel(parcel: Parcel): FenixFxAEntryPoint {
val parcelEntryName = parcel.readString() ?: Unknown
return FenixFxAEntryPoint.values().first { it.entryName == parcelEntryName }
}
override fun newArray(size: Int): Array<FenixFxAEntryPoint?> {
return arrayOfNulls(size)
}
}
}

@ -42,6 +42,7 @@ import org.mozilla.fenix.collections.SaveCollectionStep
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.TabCollectionStorage
import org.mozilla.fenix.components.accounts.AccountState
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.getRootView
import org.mozilla.fenix.ext.nav
@ -231,9 +232,11 @@ class DefaultBrowserToolbarMenuController(
AccountState.AUTHENTICATED ->
BrowserFragmentDirections.actionGlobalAccountSettingsFragment()
AccountState.NEEDS_REAUTHENTICATION ->
BrowserFragmentDirections.actionGlobalAccountProblemFragment()
BrowserFragmentDirections.actionGlobalAccountProblemFragment(
entrypoint = FenixFxAEntryPoint.BrowserToolbar,
)
AccountState.NO_ACCOUNT ->
BrowserFragmentDirections.actionGlobalTurnOnSync()
BrowserFragmentDirections.actionGlobalTurnOnSync(entrypoint = FenixFxAEntryPoint.BrowserToolbar)
}
browserAnimator.captureEngineViewAndDrawStatically {
navController.nav(

@ -14,6 +14,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavController
import mozilla.appservices.places.BookmarkRoot
import mozilla.components.browser.menu.view.MenuButton
import mozilla.components.concept.sync.FxAEntryPoint
import mozilla.components.service.glean.private.NoExtras
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.GleanMetrics.Events
@ -22,6 +23,7 @@ import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.accounts.AccountState
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.settings.SupportUtils
@ -52,6 +54,7 @@ class HomeMenuView(
private val navController: NavController,
private val menuButton: WeakReference<MenuButton>,
private val hideOnboardingIfNeeded: () -> Unit,
private val fxaEntrypoint: FxAEntryPoint = FenixFxAEntryPoint.HomeMenu,
) {
/**
@ -115,9 +118,13 @@ class HomeMenuView(
AccountState.AUTHENTICATED ->
HomeFragmentDirections.actionGlobalAccountSettingsFragment()
AccountState.NEEDS_REAUTHENTICATION ->
HomeFragmentDirections.actionGlobalAccountProblemFragment()
HomeFragmentDirections.actionGlobalAccountProblemFragment(
entrypoint = fxaEntrypoint as FenixFxAEntryPoint,
)
AccountState.NO_ACCOUNT ->
HomeFragmentDirections.actionGlobalTurnOnSync()
HomeFragmentDirections.actionGlobalTurnOnSync(
entrypoint = fxaEntrypoint as FenixFxAEntryPoint,
)
},
)
}
@ -187,7 +194,9 @@ class HomeMenuView(
HomeMenu.Item.ReconnectSync -> {
navController.nav(
R.id.homeFragment,
HomeFragmentDirections.actionGlobalAccountProblemFragment(),
HomeFragmentDirections.actionGlobalAccountProblemFragment(
entrypoint = fxaEntrypoint as FenixFxAEntryPoint,
),
)
}
HomeMenu.Item.Extensions -> {

@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
import mozilla.components.service.glean.private.NoExtras
import org.mozilla.fenix.GleanMetrics.Onboarding
import org.mozilla.fenix.R
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.databinding.OnboardingManualSigninBinding
import org.mozilla.fenix.home.HomeFragmentDirections
@ -20,7 +21,9 @@ class OnboardingManualSignInViewHolder(view: View) : RecyclerView.ViewHolder(vie
binding.fxaSignInButton.setOnClickListener {
Onboarding.fxaManualSignin.record(NoExtras())
val directions = HomeFragmentDirections.actionGlobalTurnOnSync()
val directions = HomeFragmentDirections.actionGlobalTurnOnSync(
entrypoint = FenixFxAEntryPoint.OnboardingManualSignIn,
)
Navigation.findNavController(view).navigate(directions)
}
}

@ -13,6 +13,7 @@ import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.support.base.feature.UserInteractionHandler
import org.mozilla.fenix.NavGraphDirections
import org.mozilla.fenix.R
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.databinding.ComponentBookmarkBinding
import org.mozilla.fenix.library.LibraryPageView
import org.mozilla.fenix.selection.SelectionInteractor
@ -140,7 +141,9 @@ class BookmarkView(
adapter = bookmarkAdapter
}
binding.bookmarkFoldersSignIn.setOnClickListener {
navController.navigate(NavGraphDirections.actionGlobalTurnOnSync())
navController.navigate(
NavGraphDirections.actionGlobalTurnOnSync(entrypoint = FenixFxAEntryPoint.BookmarkView),
)
}
binding.swipeRefresh.setOnRefreshListener {
interactor.onRequestSync()

@ -15,6 +15,7 @@ import androidx.fragment.app.DialogFragment
import androidx.navigation.fragment.findNavController
import mozilla.components.lib.state.ext.observeAsComposableState
import org.mozilla.fenix.R
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.components.components
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.settings
@ -53,7 +54,9 @@ class HomeOnboardingDialogFragment : DialogFragment() {
onSignInButtonClick = {
findNavController().nav(
R.id.homeOnboardingDialogFragment,
HomeOnboardingDialogFragmentDirections.actionGlobalTurnOnSync(),
HomeOnboardingDialogFragmentDirections.actionGlobalTurnOnSync(
entrypoint = FenixFxAEntryPoint.HomeOnboardingDialog,
),
)
onDismiss()
},

@ -20,6 +20,7 @@ import androidx.core.app.NotificationManagerCompat
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import org.mozilla.fenix.R
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.ext.areNotificationsEnabledSafe
import org.mozilla.fenix.ext.hideToolbar
import org.mozilla.fenix.ext.nav
@ -110,7 +111,9 @@ class JunoOnboardingFragment : Fragment() {
onSignInButtonClick = {
findNavController().nav(
id = R.id.junoOnboardingFragment,
directions = JunoOnboardingFragmentDirections.actionGlobalTurnOnSync(),
directions = JunoOnboardingFragmentDirections.actionGlobalTurnOnSync(
entrypoint = FenixFxAEntryPoint.NewUserOnboarding,
),
)
telemetryRecorder.onSyncSignInClick(
sequenceId = pagesToDisplay.telemetrySequenceId(),

@ -14,6 +14,7 @@ import androidx.core.content.ContextCompat
import androidx.core.content.getSystemService
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import mozilla.components.feature.qr.QrFeature
import mozilla.components.support.base.feature.UserInteractionHandler
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
@ -23,6 +24,7 @@ import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.showToolbar
class PairFragment : Fragment(R.layout.fragment_pair), UserInteractionHandler {
private val args by navArgs<PairFragmentArgs>()
private val qrFeature = ViewBoundFeatureWrapper<QrFeature>()
@ -51,6 +53,7 @@ class PairFragment : Fragment(R.layout.fragment_pair), UserInteractionHandler {
requireComponents.services.accountsAuthFeature.beginPairingAuthentication(
requireContext(),
pairingUrl,
args.entrypoint,
)
val vibrator = requireContext().getSystemService<Vibrator>()!!
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

@ -48,6 +48,7 @@ import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.TrackingProtection
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.databinding.AmoCollectionOverrideDialogBinding
import org.mozilla.fenix.ext.application
import org.mozilla.fenix.ext.components
@ -254,7 +255,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
val directions: NavDirections? = when (preference.key) {
resources.getString(R.string.pref_key_sign_in) -> {
SettingsFragmentDirections.actionSettingsFragmentToTurnOnSyncFragment()
SettingsFragmentDirections.actionSettingsFragmentToTurnOnSyncFragment(
entrypoint = FenixFxAEntryPoint.SettingsMenu,
)
}
resources.getString(R.string.pref_key_tabs) -> {
SettingsFragmentDirections.actionSettingsFragmentToTabsSettingsFragment()
@ -340,7 +343,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
SettingsFragmentDirections.actionSettingsFragmentToAccountSettingsFragment()
}
resources.getString(R.string.pref_key_account_auth_error) -> {
SettingsFragmentDirections.actionSettingsFragmentToAccountProblemFragment()
SettingsFragmentDirections.actionSettingsFragmentToAccountProblemFragment(
entrypoint = FenixFxAEntryPoint.SettingsMenu,
)
}
resources.getString(R.string.pref_key_delete_browsing_data) -> {
SettingsFragmentDirections.actionSettingsFragmentToDeleteBrowsingDataFragment()

@ -7,6 +7,7 @@ package org.mozilla.fenix.settings.account
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import kotlinx.coroutines.Dispatchers
@ -23,9 +24,10 @@ import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.showToolbar
class AccountProblemFragment : PreferenceFragmentCompat(), AccountObserver {
private val args by navArgs<AccountProblemFragmentArgs>()
private val signInClickListener = Preference.OnPreferenceClickListener {
requireComponents.services.accountsAuthFeature.beginAuthentication(requireContext())
requireComponents.services.accountsAuthFeature.beginAuthentication(requireContext(), args.entrypoint)
SyncAuth.useEmailProblem.record(NoExtras())
// TODO The sign-in web content populates session history,
// so pressing "back" after signing in won't take us back into the settings screen, but rather up the

@ -63,7 +63,9 @@ class TurnOnSyncFragment : Fragment(), AccountObserver {
private val binding get() = _binding!!
private fun navigateToPairFragment() {
val directions = TurnOnSyncFragmentDirections.actionTurnOnSyncFragmentToPairFragment()
val directions = TurnOnSyncFragmentDirections.actionTurnOnSyncFragmentToPairFragment(
entrypoint = args.entrypoint,
)
requireView().findNavController().navigate(directions)
SyncAuth.scanPairing.record(NoExtras())
}
@ -170,7 +172,10 @@ class TurnOnSyncFragment : Fragment(), AccountObserver {
}
private fun navigateToPairWithEmail() {
requireComponents.services.accountsAuthFeature.beginAuthentication(requireContext())
requireComponents.services.accountsAuthFeature.beginAuthentication(
requireContext(),
entrypoint = args.entrypoint,
)
SyncAuth.useEmail.record(NoExtras())
// TODO The sign-in web content populates session history,
// so pressing "back" after signing in won't take us back into the settings screen, but rather up the

@ -30,6 +30,7 @@ import mozilla.components.ui.widgets.withCenterAlignedButtons
import org.mozilla.fenix.NavGraphDirections
import org.mozilla.fenix.R
import org.mozilla.fenix.components.StoreProvider
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.runIfFragmentIsAttached
import org.mozilla.fenix.ext.secure
@ -165,12 +166,14 @@ class AutofillSettingFragment : BiometricPromptPreferenceFragment() {
.getString(R.string.preferences_credit_cards_sync_cards),
onSyncSignInClicked = {
findNavController().navigate(
NavGraphDirections.actionGlobalTurnOnSync(),
NavGraphDirections.actionGlobalTurnOnSync(entrypoint = FenixFxAEntryPoint.AutofillSetting),
)
},
onReconnectClicked = {
findNavController().navigate(
AutofillSettingFragmentDirections.actionGlobalAccountProblemFragment(),
AutofillSettingFragmentDirections.actionGlobalAccountProblemFragment(
entrypoint = FenixFxAEntryPoint.AutofillSetting,
),
)
},
)

@ -29,6 +29,7 @@ import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
import mozilla.components.ui.widgets.withCenterAlignedButtons
import org.mozilla.fenix.GleanMetrics.Logins
import org.mozilla.fenix.R
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.registerForActivityResult
import org.mozilla.fenix.ext.requireComponents
@ -159,12 +160,16 @@ class SavedLoginsAuthFragment : PreferenceFragmentCompat() {
.getString(R.string.preferences_passwords_sync_logins),
onSyncSignInClicked = {
val directions =
SavedLoginsAuthFragmentDirections.actionSavedLoginsAuthFragmentToTurnOnSyncFragment()
SavedLoginsAuthFragmentDirections.actionSavedLoginsAuthFragmentToTurnOnSyncFragment(
entrypoint = FenixFxAEntryPoint.SavedLogins,
)
findNavController().navigate(directions)
},
onReconnectClicked = {
val directions =
SavedLoginsAuthFragmentDirections.actionGlobalAccountProblemFragment()
SavedLoginsAuthFragmentDirections.actionGlobalAccountProblemFragment(
entrypoint = FenixFxAEntryPoint.SavedLogins,
)
findNavController().navigate(directions)
},
)

@ -27,6 +27,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import mozilla.components.concept.engine.prompt.ShareData
import mozilla.components.concept.sync.Device
import mozilla.components.concept.sync.FxAEntryPoint
import mozilla.components.concept.sync.TabData
import mozilla.components.feature.accounts.push.SendTabUseCases
import mozilla.components.feature.session.SessionUseCases
@ -37,6 +38,7 @@ import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.SyncAccount
import org.mozilla.fenix.R
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.share.listadapters.AppShareOption
@ -73,6 +75,7 @@ interface ShareController {
* @param sendTabUseCases instance of [SendTabUseCases] which allows sending tabs to account devices.
* @param snackbar - instance of [FenixSnackbar] for displaying styled snackbars
* @param navController - [NavController] used for navigation.
* @param fxaEntrypoint - the entrypoint if we need to authenticate, it will be reported in telemetry
* @param dismiss - callback signalling sharing can be closed.
*/
@Suppress("TooManyFunctions", "LongParameterList")
@ -87,11 +90,14 @@ class DefaultShareController(
private val recentAppsStorage: RecentAppsStorage,
private val viewLifecycleScope: CoroutineScope,
private val dispatcher: CoroutineDispatcher = Dispatchers.IO,
private val fxaEntrypoint: FxAEntryPoint = FenixFxAEntryPoint.ShareMenu,
private val dismiss: (ShareController.Result) -> Unit,
) : ShareController {
override fun handleReauth() {
val directions = ShareFragmentDirections.actionGlobalAccountProblemFragment()
val directions = ShareFragmentDirections.actionGlobalAccountProblemFragment(
entrypoint = fxaEntrypoint as FenixFxAEntryPoint,
)
navController.nav(R.id.shareFragment, directions)
dismiss(ShareController.Result.DISMISSED)
}
@ -161,8 +167,10 @@ class DefaultShareController(
override fun handleSignIn() {
SyncAccount.signInToSendTab.record(NoExtras())
val directions =
ShareFragmentDirections.actionGlobalTurnOnSync(padSnackbar = true)
val directions = ShareFragmentDirections.actionGlobalTurnOnSync(
padSnackbar = true,
entrypoint = fxaEntrypoint as FenixFxAEntryPoint,
)
navController.nav(R.id.shareFragment, directions)
dismiss(ShareController.Result.DISMISSED)
}

@ -12,6 +12,7 @@ import mozilla.components.service.fxa.manager.FxaAccountManager
import mozilla.components.service.glean.private.NoExtras
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.TabsTray
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.home.HomeFragment
import org.mozilla.fenix.tabstray.ext.isActiveDownload
@ -81,7 +82,7 @@ class DefaultNavigationInteractor(
val direction = if (isSignedIn) {
TabsTrayFragmentDirections.actionGlobalAccountSettingsFragment()
} else {
TabsTrayFragmentDirections.actionGlobalTurnOnSync()
TabsTrayFragmentDirections.actionGlobalTurnOnSync(entrypoint = FenixFxAEntryPoint.NavigationInteraction)
}
navController.navigate(direction)
}

@ -9,6 +9,7 @@ import androidx.navigation.NavController
import mozilla.components.feature.syncedtabs.view.SyncedTabsView
import org.mozilla.fenix.NavGraphDirections
import org.mozilla.fenix.R
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.tabstray.syncedtabs.SyncedTabsListItem
/**
@ -40,7 +41,11 @@ fun SyncedTabsView.ErrorType.toSyncedTabsListItem(context: Context, navControlle
errorButton = SyncedTabsListItem.ErrorButton(
buttonText = context.getString(R.string.synced_tabs_sign_in_button),
) {
navController.navigate(NavGraphDirections.actionGlobalTurnOnSync())
navController.navigate(
NavGraphDirections.actionGlobalTurnOnSync(
entrypoint = FenixFxAEntryPoint.SyncedTabsMenu,
),
)
},
)
}

@ -785,13 +785,20 @@
<action
android:id="@+id/action_turnOnSyncFragment_to_pairFragment"
app:destination="@id/pairFragment" />
<argument
android:name="entrypoint"
app:argType="org.mozilla.fenix.components.accounts.FenixFxAEntryPoint" />
</fragment>
<fragment
android:id="@+id/pairFragment"
android:name="org.mozilla.fenix.settings.PairFragment"
android:label="@string/preferences_sync_2"
tools:layout="@layout/fragment_pair" />
tools:layout="@layout/fragment_pair" >
<argument
android:name="entrypoint"
app:argType="org.mozilla.fenix.components.accounts.FenixFxAEntryPoint" />
</fragment>
<fragment
android:id="@+id/aboutFragment"
@ -986,6 +993,9 @@
<action
android:id="@+id/action_accountProblemFragment_to_signOutFragment"
app:destination="@id/signOutFragment" />
<argument
android:name="entrypoint"
app:argType="org.mozilla.fenix.components.accounts.FenixFxAEntryPoint" />
</fragment>
<dialog
android:id="@+id/signOutFragment"

@ -71,6 +71,7 @@ import org.mozilla.fenix.collections.SaveCollectionStep
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.TabCollectionStorage
import org.mozilla.fenix.components.accounts.AccountState
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.directionsEq
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@ -784,7 +785,9 @@ class DefaultBrowserToolbarMenuControllerTest {
@Test
fun `GIVEN account exists and the user is not signed in WHEN sign in to sync menu item is pressed THEN navigate to account problem fragment`() = runTest {
val item = ToolbarMenu.Item.SyncAccount(AccountState.NEEDS_REAUTHENTICATION)
val accountProblemDirections = BrowserFragmentDirections.actionGlobalAccountProblemFragment()
val accountProblemDirections = BrowserFragmentDirections.actionGlobalAccountProblemFragment(
entrypoint = FenixFxAEntryPoint.BrowserToolbar,
)
val controller = createController(scope = this, store = browserStore)
controller.handleToolbarItemInteraction(item)
@ -795,7 +798,9 @@ class DefaultBrowserToolbarMenuControllerTest {
@Test
fun `GIVEN account doesn't exist WHEN sign in to sync menu item is pressed THEN navigate to sign in`() = runTest {
val item = ToolbarMenu.Item.SyncAccount(AccountState.NO_ACCOUNT)
val turnOnSyncDirections = BrowserFragmentDirections.actionGlobalTurnOnSync()
val turnOnSyncDirections = BrowserFragmentDirections.actionGlobalTurnOnSync(
entrypoint = FenixFxAEntryPoint.BrowserToolbar,
)
val controller = createController(scope = this, store = browserStore)
controller.handleToolbarItemInteraction(item)

@ -28,6 +28,7 @@ import org.mozilla.fenix.GleanMetrics.HomeScreen
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.components.accounts.AccountState
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@ -127,7 +128,9 @@ class HomeMenuViewTest {
verify {
navController.nav(
R.id.homeFragment,
HomeFragmentDirections.actionGlobalAccountProblemFragment(),
HomeFragmentDirections.actionGlobalAccountProblemFragment(
entrypoint = FenixFxAEntryPoint.HomeMenu,
),
)
}
@ -136,7 +139,7 @@ class HomeMenuViewTest {
verify {
navController.nav(
R.id.homeFragment,
HomeFragmentDirections.actionGlobalTurnOnSync(),
HomeFragmentDirections.actionGlobalTurnOnSync(entrypoint = FenixFxAEntryPoint.HomeMenu),
)
}
}
@ -219,7 +222,9 @@ class HomeMenuViewTest {
verify {
navController.nav(
R.id.homeFragment,
HomeFragmentDirections.actionGlobalAccountProblemFragment(),
HomeFragmentDirections.actionGlobalAccountProblemFragment(
entrypoint = FenixFxAEntryPoint.HomeMenu,
),
)
}
}

@ -26,6 +26,7 @@ import org.mozilla.fenix.BuildConfig.DEEP_LINK_SCHEME
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.NavGraphDirections
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.settings.SupportUtils
import org.robolectric.annotation.Config
@ -119,7 +120,13 @@ class HomeDeepLinkIntentProcessorTest {
assertTrue(processorHome.process(testIntent("turn_on_sync"), navController, out))
verify { activity wasNot Called }
verify { navController.navigate(NavGraphDirections.actionGlobalTurnOnSync()) }
verify {
navController.navigate(
NavGraphDirections.actionGlobalTurnOnSync(
entrypoint = FenixFxAEntryPoint.DeepLink,
),
)
}
verify { out wasNot Called }
}

@ -23,6 +23,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.Onboarding
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.databinding.OnboardingManualSigninBinding
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@ -60,7 +61,13 @@ class OnboardingManualSignInViewHolderTest {
OnboardingManualSignInViewHolder(binding.root)
binding.fxaSignInButton.performClick()
verify { navController.navigate(HomeFragmentDirections.actionGlobalTurnOnSync()) }
verify {
navController.navigate(
HomeFragmentDirections.actionGlobalTurnOnSync(
entrypoint = FenixFxAEntryPoint.OnboardingManualSignIn,
),
)
}
// Check if the event was recorded
Assert.assertNotNull(Onboarding.fxaManualSignin.testGetValue())
assertEquals(1, Onboarding.fxaManualSignin.testGetValue()!!.size)

@ -30,6 +30,7 @@ import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.mozilla.fenix.R
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.settings.SyncPreference
import org.mozilla.fenix.settings.SyncPreferenceView
import org.mozilla.fenix.settings.logins.fragment.SavedLoginsAuthFragmentDirections
@ -98,7 +99,7 @@ class SyncPreferenceViewTest {
assertFalse(preferenceChangeListener.captured.onPreferenceChange(syncPreference, any()))
verify {
navController.navigate(
SavedLoginsAuthFragmentDirections.actionGlobalAccountProblemFragment(),
SavedLoginsAuthFragmentDirections.actionGlobalAccountProblemFragment(entrypoint = FenixFxAEntryPoint.SavedLogins),
)
}
}
@ -115,7 +116,9 @@ class SyncPreferenceViewTest {
assertFalse(preferenceChangeListener.captured.onPreferenceChange(syncPreference, any()))
verify {
navController.navigate(
SavedLoginsAuthFragmentDirections.actionGlobalAccountProblemFragment(),
SavedLoginsAuthFragmentDirections.actionGlobalAccountProblemFragment(
entrypoint = FenixFxAEntryPoint.SavedLogins,
),
)
}
}
@ -132,7 +135,9 @@ class SyncPreferenceViewTest {
assertFalse(preferenceChangeListener.captured.onPreferenceChange(syncPreference, any()))
verify {
navController.navigate(
SavedLoginsAuthFragmentDirections.actionSavedLoginsAuthFragmentToTurnOnSyncFragment(),
SavedLoginsAuthFragmentDirections.actionSavedLoginsAuthFragmentToTurnOnSyncFragment(
entrypoint = FenixFxAEntryPoint.SavedLogins,
),
)
}
}
@ -184,12 +189,16 @@ class SyncPreferenceViewTest {
loggedInTitle = loggedInTitle,
onSyncSignInClicked = {
val directions =
SavedLoginsAuthFragmentDirections.actionSavedLoginsAuthFragmentToTurnOnSyncFragment()
SavedLoginsAuthFragmentDirections.actionSavedLoginsAuthFragmentToTurnOnSyncFragment(
entrypoint = FenixFxAEntryPoint.SavedLogins,
)
navController.navigate(directions)
},
onReconnectClicked = {
val directions =
SavedLoginsAuthFragmentDirections.actionGlobalAccountProblemFragment()
SavedLoginsAuthFragmentDirections.actionGlobalAccountProblemFragment(
entrypoint = FenixFxAEntryPoint.SavedLogins,
)
navController.navigate(directions)
},
)

@ -42,6 +42,7 @@ import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.SyncAccount
import org.mozilla.fenix.R
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.share.listadapters.AppShareOption
@ -78,7 +79,7 @@ class ShareControllerTest {
private val testCoroutineScope = coroutinesTestRule.scope
private val controller = DefaultShareController(
context, shareSubject, shareData, sendTabUseCases, saveToPdfUseCase, snackbar, navController,
recentAppStorage, testCoroutineScope, testDispatcher, dismiss,
recentAppStorage, testCoroutineScope, testDispatcher, FenixFxAEntryPoint.ShareMenu, dismiss,
)
@Test
@ -102,7 +103,8 @@ class ShareControllerTest {
val activityContext: Context = mockk<Activity>()
val testController = DefaultShareController(
activityContext, shareSubject, shareData, mockk(), mockk(),
mockk(), mockk(), recentAppStorage, testCoroutineScope, testDispatcher, dismiss,
mockk(), mockk(), recentAppStorage, testCoroutineScope, testDispatcher,
FenixFxAEntryPoint.ShareMenu, dismiss,
)
every { activityContext.startActivity(capture(shareIntent)) } just Runs
every { recentAppStorage.updateRecentApp(appShareOption.activityName) } just Runs
@ -146,7 +148,8 @@ class ShareControllerTest {
val activityContext: Context = mockk<Activity>()
val testController = DefaultShareController(
activityContext, shareSubject, shareData, mockk(), mockk(),
mockk(), mockk(), recentAppStorage, testCoroutineScope, testDispatcher, dismiss,
mockk(), mockk(), recentAppStorage, testCoroutineScope, testDispatcher,
FenixFxAEntryPoint.ShareMenu, dismiss,
)
every { activityContext.startActivity(capture(shareIntent)) } just Runs
@ -172,7 +175,8 @@ class ShareControllerTest {
val activityContext: Context = mockk<Activity>()
val testController = DefaultShareController(
activityContext, shareSubject, shareData, mockk(), mockk(),
mockk(), mockk(), recentAppStorage, testCoroutineScope, testDispatcher, dismiss,
mockk(), mockk(), recentAppStorage, testCoroutineScope, testDispatcher,
FenixFxAEntryPoint.ShareMenu, dismiss,
)
every { activityContext.startActivity(capture(shareIntent)) } just Runs
@ -481,7 +485,9 @@ class ShareControllerTest {
verifyOrder {
navController.nav(
R.id.shareFragment,
ShareFragmentDirections.actionGlobalTurnOnSync(),
ShareFragmentDirections.actionGlobalTurnOnSync(
entrypoint = FenixFxAEntryPoint.ShareMenu,
),
)
dismiss(ShareController.Result.DISMISSED)
}
@ -494,7 +500,9 @@ class ShareControllerTest {
verifyOrder {
navController.nav(
R.id.shareFragment,
ShareFragmentDirections.actionGlobalAccountProblemFragment(),
ShareFragmentDirections.actionGlobalAccountProblemFragment(
entrypoint = FenixFxAEntryPoint.ShareMenu,
),
)
dismiss(ShareController.Result.DISMISSED)
}

@ -32,6 +32,7 @@ import org.junit.rules.RuleChain
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.TabsTray
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import mozilla.components.browser.state.state.createTab as createStateTab
@ -84,7 +85,13 @@ class NavigationInteractorTest {
createInteractor().onAccountSettingsClicked()
verify(exactly = 1) { navController.navigate(TabsTrayFragmentDirections.actionGlobalTurnOnSync()) }
verify(exactly = 1) {
navController.navigate(
TabsTrayFragmentDirections.actionGlobalTurnOnSync(
entrypoint = FenixFxAEntryPoint.NavigationInteraction,
),
)
}
}
@Test

Loading…
Cancel
Save