Run ktlintFormat to adapt to latest formatting rules.

upstream-sync
Sebastian Kaspari 3 years ago committed by mergify[bot]
parent 94f9c23721
commit 971b419d77

@ -79,9 +79,11 @@ class BaselinePingTest {
@JvmStatic
@OptIn(DelicateCoroutinesApi::class) // GlobalScope usage
fun setupOnce() {
val httpClient = ConceptFetchHttpUploader(lazy {
val httpClient = ConceptFetchHttpUploader(
lazy {
GeckoViewFetchClient(ApplicationProvider.getApplicationContext())
})
}
)
// Fenix does not initialize the Glean SDK in tests/debug builds, but this test
// requires Glean to be initialized so we need to do it manually. Additionally,
@ -151,8 +153,11 @@ class BaselinePingTest {
// sending the ping that was submitted on background. This can go away once bug 1634375
// is fixed.
device.pressRecentApps()
device.findObject(UiSelector().descriptionContains(
ApplicationProvider.getApplicationContext<Context>().getString(R.string.app_name)))
device.findObject(
UiSelector().descriptionContains(
ApplicationProvider.getApplicationContext<Context>().getString(R.string.app_name)
)
)
.click()
// Validate the received data.

@ -173,9 +173,11 @@ class SyncIntegrationTest {
// Useful functions for the tests
fun typeEmail() {
val emailInput = mDevice.findObject(UiSelector()
val emailInput = mDevice.findObject(
UiSelector()
.instance(0)
.className(EditText::class.java))
.className(EditText::class.java)
)
emailInput.waitForExists(TestAssetHelper.waitingTime)
val emailAddress = javaClass.classLoader!!.getResource("email.txt").readText()
@ -188,9 +190,11 @@ class SyncIntegrationTest {
}
fun typePassword() {
val passwordInput = mDevice.findObject(UiSelector()
val passwordInput = mDevice.findObject(
UiSelector()
.instance(0)
.className(EditText::class.java))
.className(EditText::class.java)
)
val passwordValue = javaClass.classLoader!!.getResource("password.txt").readText()
passwordInput.setText(passwordValue)

@ -91,8 +91,12 @@ fun addToHomeScreen(interact: AddToHomeScreenRobot.() -> Unit): AddToHomeScreenR
private fun shortcutNameField() = onView(withId(R.id.shortcut_text))
private fun assertShortcutNameField(expectedText: String) {
onView(allOf(withId(R.id.shortcut_text),
withText(expectedText)))
onView(
allOf(
withId(R.id.shortcut_text),
withText(expectedText)
)
)
.check(matches(isCompletelyDisplayed()))
}

@ -105,8 +105,10 @@ class BookmarksRobot {
fun verifySelectDefaultFolderSnackBarText() = assertSnackBarText("Cant edit default folders")
fun verifyCurrentFolderTitle(title: String) {
mDevice.findObject(UiSelector().resourceId("$packageName:id/navigationToolbar")
.textContains(title))
mDevice.findObject(
UiSelector().resourceId("$packageName:id/navigationToolbar")
.textContains(title)
)
.waitForExists(waitingTime)
onView(
@ -119,8 +121,10 @@ class BookmarksRobot {
}
fun waitForBookmarksFolderContentToExist(parentFolderName: String, childFolderName: String) {
mDevice.findObject(UiSelector().resourceId("$packageName:id/navigationToolbar")
.textContains(parentFolderName))
mDevice.findObject(
UiSelector().resourceId("$packageName:id/navigationToolbar")
.textContains(parentFolderName)
)
.waitForExists(waitingTime)
mDevice.waitNotNull(Until.findObject(By.text(childFolderName)), waitingTime)

@ -509,8 +509,10 @@ class BrowserRobot {
fun openTabDrawer(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
mDevice.waitForIdle(waitingTime)
tabsCounter().click()
mDevice.waitNotNull(Until.findObject(By.res("$packageName:id/tab_layout")),
waitingTime)
mDevice.waitNotNull(
Until.findObject(By.res("$packageName:id/tab_layout")),
waitingTime
)
TabDrawerRobot().interact()
return TabDrawerRobot.Transition()

@ -58,8 +58,10 @@ class DownloadRobot {
}
fun waitForDownloadsListToExist() =
assertTrue(mDevice.findObject(UiSelector().resourceId("$packageName:id/download_list"))
.waitForExists(waitingTime))
assertTrue(
mDevice.findObject(UiSelector().resourceId("$packageName:id/download_list"))
.waitForExists(waitingTime)
)
class Transition {
fun clickDownload(interact: DownloadRobot.() -> Unit): Transition {

@ -383,7 +383,8 @@ private fun assertCollectionsHeader() =
private fun assertNoCollectionsText() =
onView(
withText(
containsString("Collect the things that matter to you.\n" +
containsString(
"Collect the things that matter to you.\n" +
"Group together similar searches, sites, and tabs for quick access later."
)
)

@ -58,7 +58,8 @@ class LibrarySubMenusMultipleSelectionToolbarRobot {
mDevice.waitNotNull(
Until.findObject(
By.text("ALL ACTIONS")
), waitingTime
),
waitingTime
)
}
@ -68,7 +69,8 @@ class LibrarySubMenusMultipleSelectionToolbarRobot {
mDevice.waitNotNull(
Until.findObject(
By.text("ALL ACTIONS")
), waitingTime
),
waitingTime
)
}

@ -70,8 +70,10 @@ class NavigationToolbarRobot {
fun typeSearchTerm(searchTerm: String) = awesomeBar().perform(typeText(searchTerm))
fun toggleReaderView() {
mDevice.findObject(UiSelector()
.resourceId("$packageName:id/mozac_browser_toolbar_page_actions"))
mDevice.findObject(
UiSelector()
.resourceId("$packageName:id/mozac_browser_toolbar_page_actions")
)
.waitForExists(waitingTime)
readerViewToggle().click()
@ -133,7 +135,8 @@ class NavigationToolbarRobot {
when (etpEnabled) {
true ->
try {
assertTrue("Onboarding message not displayed",
assertTrue(
"Onboarding message not displayed",
onboardingDisplayed
)
} catch (e: AssertionError) {
@ -184,8 +187,10 @@ class NavigationToolbarRobot {
fun openTabTray(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
mDevice.waitForIdle(waitingTime)
tabTrayButton().click()
mDevice.waitNotNull(Until.findObject(By.res("$packageName:id/tab_layout")),
waitingTime)
mDevice.waitNotNull(
Until.findObject(By.res("$packageName:id/tab_layout")),
waitingTime
)
TabDrawerRobot().interact()
return TabDrawerRobot.Transition()
@ -251,7 +256,8 @@ class NavigationToolbarRobot {
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
hasDescendant(
withText("Close tab")
), ViewActions.click()
),
ViewActions.click()
)
)
@ -267,7 +273,8 @@ class NavigationToolbarRobot {
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
hasDescendant(
withText("New tab")
), ViewActions.click()
),
ViewActions.click()
)
)
@ -283,7 +290,8 @@ class NavigationToolbarRobot {
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
hasDescendant(
withText("New private tab")
), ViewActions.click()
),
ViewActions.click()
)
)
@ -352,8 +360,10 @@ private fun readerViewToggle() =
onView(withParent(withId(R.id.mozac_browser_toolbar_page_actions)))
private fun assertReaderViewDetected(visible: Boolean) {
mDevice.findObject(UiSelector()
.description("Reader view"))
mDevice.findObject(
UiSelector()
.description("Reader view")
)
.waitForExists(waitingTime)
onView(
@ -368,8 +378,10 @@ private fun assertReaderViewDetected(visible: Boolean) {
}
private fun assertCloseReaderViewDetected(visible: Boolean) {
mDevice.findObject(UiSelector()
.description("Close reader view"))
mDevice.findObject(
UiSelector()
.description("Close reader view")
)
.waitForExists(waitingTime)
onView(

@ -94,7 +94,8 @@ private fun assertRecentlyClosedTabsMenuView() {
)
)
.check(
matches(withEffectiveVisibility(Visibility.VISIBLE)))
matches(withEffectiveVisibility(Visibility.VISIBLE))
)
}
private fun assertEmptyRecentlyClosedTabsList() =
@ -105,7 +106,8 @@ private fun assertEmptyRecentlyClosedTabsList() =
)
)
.check(
matches(withText("No recently closed tabs here")))
matches(withText("No recently closed tabs here"))
)
private fun assertPageUrl(expectedUrl: Uri) = onView(
allOf(
@ -116,7 +118,8 @@ private fun assertPageUrl(expectedUrl: Uri) = onView(
)
)
.check(
matches(withText(Matchers.containsString(expectedUrl.toString()))))
matches(withText(Matchers.containsString(expectedUrl.toString())))
)
private fun recentlyClosedTabsPageTitle() = onView(
allOf(
@ -128,9 +131,11 @@ private fun recentlyClosedTabsPageTitle() = onView(
private fun assertRecentlyClosedTabsPageTitle(title: String) {
recentlyClosedTabsPageTitle()
.check(
matches(withEffectiveVisibility(Visibility.VISIBLE)))
matches(withEffectiveVisibility(Visibility.VISIBLE))
)
.check(
matches(withText(title)))
matches(withText(title))
)
}
private fun recentlyClosedTabsThreeDotButton() =
@ -147,19 +152,24 @@ private fun assertRecentlyClosedTabsMenuCopy() =
onView(withText("Copy"))
.check(
matches(
withEffectiveVisibility(Visibility.VISIBLE)))
withEffectiveVisibility(Visibility.VISIBLE)
)
)
private fun assertRecentlyClosedTabsMenuShare() =
onView(withText("Share"))
.check(
matches(
withEffectiveVisibility(Visibility.VISIBLE)))
withEffectiveVisibility(Visibility.VISIBLE)
)
)
private fun assertRecentlyClosedTabsOverlayNewTab() =
onView(withText("Open in new tab"))
.check(
matches(
withEffectiveVisibility(Visibility.VISIBLE))
withEffectiveVisibility(Visibility.VISIBLE)
)
)
private fun assertRecentlyClosedTabsMenuPrivateTab() =
@ -185,26 +195,31 @@ private fun copySnackBarText() = onView(withId(R.id.snackbar_text))
private fun assertCopySnackBarText() = copySnackBarText()
.check(
matches
(withText("URL copied")))
(withText("URL copied"))
)
private fun recentlyClosedTabsShareButton() = onView(withText("Share"))
private fun assertRecentlyClosedShareOverlay() =
onView(withId(R.id.shareWrapper))
.check(
matches(ViewMatchers.isDisplayed()))
matches(ViewMatchers.isDisplayed())
)
private fun assetRecentlyClosedShareTitle(title: String) =
onView(withId(R.id.share_tab_title))
.check(
matches(ViewMatchers.isDisplayed()))
matches(ViewMatchers.isDisplayed())
)
.check(
matches(withText(title)))
matches(withText(title))
)
private fun assertRecentlyClosedShareFavicon() =
onView(withId(R.id.share_tab_favicon))
.check(
matches(ViewMatchers.isDisplayed()))
matches(ViewMatchers.isDisplayed())
)
private fun assertRecentlyClosedShareUrl(expectedUrl: Uri) =
onView(
@ -214,7 +229,8 @@ private fun assertRecentlyClosedShareUrl(expectedUrl: Uri) =
)
)
.check(
matches(withText(Matchers.containsString(expectedUrl.toString()))))
matches(withText(Matchers.containsString(expectedUrl.toString())))
)
private fun recentlyClosedTabsNewTabButton() = onView(withText("Open in new tab"))

@ -73,8 +73,10 @@ class SearchRobot {
selectDefaultSearchEngine(searchEngineName)
fun clickSearchEngineShortcutButton() {
val searchEnginesShortcutButton = mDevice.findObject(UiSelector()
.resourceId("$packageName:id/search_engines_shortcut_button"))
val searchEnginesShortcutButton = mDevice.findObject(
UiSelector()
.resourceId("$packageName:id/search_engines_shortcut_button")
)
searchEnginesShortcutButton.waitForExists(waitingTime)
searchEnginesShortcutButton.click()
}
@ -270,7 +272,8 @@ private fun assertKeyboardVisibility(isExpectedToBeVisible: Boolean) = {
mDevice.waitNotNull(
Until.findObject(
By.text("Search Engine")
), waitingTime
),
waitingTime
)
assertEquals(
isExpectedToBeVisible,

@ -59,8 +59,11 @@ private fun goBackButton() =
onView(withContentDescription("Navigate up"))
private fun assertNavigationToolBarHeader() = onView(
allOf(withParent(withId(R.id.navigationToolbar)),
withText(R.string.preferences_data_collection)))
allOf(
withParent(withId(R.id.navigationToolbar)),
withText(R.string.preferences_data_collection)
)
)
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertDataCollectionOptions() {

@ -62,18 +62,27 @@ class SettingsSubMenuDeleteBrowsingDataOnQuitRobot {
private fun goBackButton() = onView(withContentDescription("Navigate up"))
private fun assertNavigationToolBarHeader() = onView(allOf(withId(R.id.navigationToolbar),
withChild(withText(R.string.preferences_delete_browsing_data_on_quit))))
private fun assertNavigationToolBarHeader() = onView(
allOf(
withId(R.id.navigationToolbar),
withChild(withText(R.string.preferences_delete_browsing_data_on_quit))
)
)
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun deleteBrowsingOnQuitButton() = onView(allOf(withParentIndex(0),
withChild(withText(R.string.preferences_delete_browsing_data_on_quit))))
private fun deleteBrowsingOnQuitButton() = onView(
allOf(
withParentIndex(0),
withChild(withText(R.string.preferences_delete_browsing_data_on_quit))
)
)
private fun assertDeleteBrowsingOnQuitButton() = deleteBrowsingOnQuitButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertDeleteBrowsingOnQuitButtonSummary() = onView(
withText(R.string.preference_summary_delete_browsing_data_on_quit_2))
withText(R.string.preference_summary_delete_browsing_data_on_quit_2)
)
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertDeleteBrowsingOnQuitButtonSwitchDefault() = onView(withResourceName("switch_widget"))

@ -86,8 +86,12 @@ private fun goBackButton() =
onView(allOf(withContentDescription("Navigate up")))
private fun assertNavigationToolBarHeader() {
onView(allOf(withId(R.id.navigationToolbar),
withChild(withText(R.string.preferences_delete_browsing_data))))
onView(
allOf(
withId(R.id.navigationToolbar),
withChild(withText(R.string.preferences_delete_browsing_data))
)
)
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
}

@ -111,8 +111,12 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot {
}
private fun assertNavigationToolBarHeader() {
onView(allOf(withParent(withId(org.mozilla.fenix.R.id.navigationToolbar)),
withText("Enhanced Tracking Protection")))
onView(
allOf(
withParent(withId(org.mozilla.fenix.R.id.navigationToolbar)),
withText("Enhanced Tracking Protection")
)
)
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
@ -122,21 +126,32 @@ private fun assertEnhancedTrackingProtectionHeader() {
}
private fun assertEnhancedTrackingProtectionHeaderDescription() {
onView(allOf(withParent(withParentIndex(0)),
withText("Keep your data to yourself. $appName protects you from many of the most common trackers that follow what you do online.")))
onView(
allOf(
withParent(withParentIndex(0)),
withText("Keep your data to yourself. $appName protects you from many of the most common trackers that follow what you do online.")
)
)
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertLearnMoreText() {
onView(allOf(withParent(withParentIndex(0)),
withText("Learn more")))
onView(
allOf(
withParent(withParentIndex(0)),
withText("Learn more")
)
)
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertEnhancedTrackingProtectionTextWithSwitchWidget() {
onView(allOf(
onView(
allOf(
withParentIndex(1),
withChild(withText("Enhanced Tracking Protection"))))
withChild(withText("Enhanced Tracking Protection"))
)
)
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
@ -195,7 +210,8 @@ private fun assertTrackingProtectionSwitchEnabled() {
}
private fun assertRadioButtonDefaults() {
onView(withText("Strict")
onView(
withText("Strict")
).assertIsChecked(false)
onView(
@ -205,7 +221,8 @@ private fun assertRadioButtonDefaults() {
)
).assertIsChecked(true)
onView(withText("Custom")
onView(
withText("Custom")
).assertIsChecked(false)
}

@ -39,7 +39,8 @@ fun systemSettings(interact: SystemSettingsRobot.() -> Unit): SystemSettingsRobo
private fun assertSystemNotificationsView() {
mDevice.findObject(UiSelector().resourceId("com.android.settings:id/list"))
.waitForExists(waitingTime)
assertTrue(mDevice.findObject(UiSelector().textContains("Show notifications"))
assertTrue(
mDevice.findObject(UiSelector().textContains("Show notifications"))
.waitForExists(waitingTime)
)
}

@ -230,8 +230,10 @@ class TabDrawerRobot {
fun openTabDrawer(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
mDevice.waitForIdle(waitingTime)
tabsCounter().click()
mDevice.waitNotNull(Until.findObject(By.res("$packageName:id/tab_layout")),
waitingTime)
mDevice.waitNotNull(
Until.findObject(By.res("$packageName:id/tab_layout")),
waitingTime
)
TabDrawerRobot().interact()
return TabDrawerRobot.Transition()
@ -395,9 +397,11 @@ private fun threeDotMenu() = onView(withId(R.id.tab_tray_overflow))
private fun assertExistingOpenTabs(title: String) {
try {
mDevice.findObject(UiSelector()
mDevice.findObject(
UiSelector()
.resourceId("$packageName:id/mozac_browser_tabstray_title")
.textContains(title))
.textContains(title)
)
.waitForExists(waitingTime)
tab(title).check(matches(isDisplayed()))

@ -34,7 +34,8 @@ class ThreeDotMenuHistoryItemRobot {
mDevice.waitNotNull(
Until.findObject(
By.text("ALL ACTIONS")
), TestAssetHelper.waitingTime
),
TestAssetHelper.waitingTime
)
LibrarySubMenusMultipleSelectionToolbarRobot().interact()

@ -512,7 +512,8 @@ private fun tabSettingsButton() =
private fun assertTabSettingsButton() {
tabSettingsButton()
.check(
matches(isDisplayed()))
matches(isDisplayed())
)
}
private fun recentlyClosedTabsButton() =
@ -521,7 +522,8 @@ private fun recentlyClosedTabsButton() =
private fun assertRecentlyClosedTabsButton() {
recentlyClosedTabsButton()
.check(
matches(isDisplayed()))
matches(isDisplayed())
)
}
private fun shareAllTabsButton() =
@ -530,7 +532,8 @@ private fun shareAllTabsButton() =
private fun assertShareAllTabsButton() {
shareAllTabsButton()
.check(
matches(isDisplayed()))
matches(isDisplayed())
)
}
private fun assertNewTabButton() = onView(withText("New tab")).check(matches(isDisplayed()))

@ -140,7 +140,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
channel = BuildConfig.BUILD_TYPE,
httpClient = ConceptFetchHttpUploader(
lazy(LazyThreadSafetyMode.NONE) { components.core.client }
)),
)
),
uploadEnabled = telemetryEnabled,
buildInfo = GleanBuildInfo.buildInfo
)
@ -392,7 +393,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
logger.info("onTrimMemory(), level=$level, main=${isMainProcess()}")
components.analytics.crashReporter.recordCrashBreadcrumb(Breadcrumb(
components.analytics.crashReporter.recordCrashBreadcrumb(
Breadcrumb(
category = "Memory",
message = "onTrimMemory()",
data = mapOf(
@ -400,7 +402,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
"main" to isMainProcess().toString()
),
level = Breadcrumb.Level.INFO
))
)
)
runOnlyInMainProcess {
components.core.icons.onTrimMemory(level)
@ -485,10 +488,12 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
)
},
onCloseTabOverride = {
_, sessionId -> components.useCases.tabsUseCases.removeTab(sessionId)
_, sessionId ->
components.useCases.tabsUseCases.removeTab(sessionId)
},
onSelectTabOverride = {
_, sessionId -> components.useCases.tabsUseCases.selectTab(sessionId)
_, sessionId ->
components.useCases.tabsUseCases.selectTab(sessionId)
},
onExtensionsLoaded = { extensions ->
components.addonUpdater.registerForFutureUpdates(extensions)

@ -18,7 +18,8 @@ import org.mozilla.fenix.ext.showToolbar
/**
* A fragment to show the permissions of an add-on.
*/
class AddonPermissionsDetailsFragment : Fragment(R.layout.fragment_add_on_permissions),
class AddonPermissionsDetailsFragment :
Fragment(R.layout.fragment_add_on_permissions),
AddonPermissionsDetailsInteractor {
private val args by navArgs<AddonPermissionsDetailsFragmentArgs>()

@ -45,7 +45,8 @@ abstract class AddonPopupBaseFragment : Fragment(), EngineSession.Observer, User
fragmentManager = parentFragmentManager,
onNeedToRequestPermissions = { permissions ->
requestPermissions(permissions, REQUEST_CODE_PROMPT_PERMISSIONS)
}),
}
),
owner = this,
view = view
)

@ -108,7 +108,8 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
val addons = requireContext().components.addonManager.getAddons(allowCache = allowCache)
// Add-ons that should be excluded in Mozilla Online builds
val excludedAddonIDs = if (Config.channel.isMozillaOnline &&
!BuildConfig.MOZILLA_ONLINE_ADDON_EXCLUSIONS.isNullOrEmpty()) {
!BuildConfig.MOZILLA_ONLINE_ADDON_EXCLUSIONS.isNullOrEmpty()
) {
BuildConfig.MOZILLA_ONLINE_ADDON_EXCLUSIONS.toList()
} else {
emptyList<String>()

@ -148,8 +148,12 @@ import mozilla.components.feature.session.behavior.ToolbarPosition as MozacToolb
*/
@ExperimentalCoroutinesApi
@Suppress("TooManyFunctions", "LargeClass")
abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, ActivityResultHandler,
OnBackLongPressedListener, AccessibilityManager.AccessibilityStateChangeListener {
abstract class BaseBrowserFragment :
Fragment(),
UserInteractionHandler,
ActivityResultHandler,
OnBackLongPressedListener,
AccessibilityManager.AccessibilityStateChangeListener {
private lateinit var browserFragmentStore: BrowserFragmentStore
private lateinit var browserAnimator: BrowserAnimator
@ -823,10 +827,12 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
internal fun expandToolbarOnNavigation(store: BrowserStore) {
consumeFlow(store) { flow ->
flow.mapNotNull {
state -> state.findCustomTabOrSelectedTab(customTabSessionId)
state ->
state.findCustomTabOrSelectedTab(customTabSessionId)
}
.ifAnyChanged {
tab -> arrayOf(tab.content.url, tab.content.loadRequest)
tab ->
arrayOf(tab.content.url, tab.content.loadRequest)
}
.collect {
findInPageIntegration.onBackPressed()

@ -28,7 +28,8 @@ class FenixSnackbarDelegate(private val view: View) : ContextMenuCandidate.Snack
.setAction(view.context.getString(action)) { listener.invoke(view) }
.show()
} else {
FenixSnackbar.make(view,
FenixSnackbar.make(
view,
duration = FenixSnackbar.LENGTH_SHORT,
isDisplayedWithBrowserToolbar = true
)

@ -59,7 +59,8 @@ class OpenInAppOnboardingObserver(
state.selectedTab
}
.ifAnyChanged {
tab -> arrayOf(tab.content.url, tab.content.loading)
tab ->
arrayOf(tab.content.url, tab.content.loading)
}
.collect { tab ->
if (tab.content.url != currentUrl) {

@ -214,8 +214,10 @@ class ToolbarGestureHandler(
val reverseFling =
abs(velocityX) >= minimumFlingVelocity && !velocityMatchesDirection
return !reverseFling && (previewWidth / windowWidth >= GESTURE_FINISH_PERCENT ||
abs(velocityX) >= minimumFlingVelocity)
return !reverseFling && (
previewWidth / windowWidth >= GESTURE_FINISH_PERCENT ||
abs(velocityX) >= minimumFlingVelocity
)
}
private fun getAnimator(finalContextX: Float, duration: Long): ValueAnimator {

@ -170,9 +170,12 @@ class CollectionCreationView(
setOnClickListener {
name_collection_edittext.hideKeyboard()
val handler = Handler(Looper.getMainLooper())
handler.postDelayed({
handler.postDelayed(
{
interactor.onBackPressed(SaveCollectionStep.NameCollection)
}, TRANSITION_DURATION)
},
TRANSITION_DURATION
)
}
}
@ -216,9 +219,12 @@ class CollectionCreationView(
setOnClickListener {
name_collection_edittext.hideKeyboard()
val handler = Handler(Looper.getMainLooper())
handler.postDelayed({
handler.postDelayed(
{
interactor.onBackPressed(SaveCollectionStep.RenameCollection)
}, TRANSITION_DURATION)
},
TRANSITION_DURATION
)
}
}
transition.addListener(object : Transition.TransitionListener {

@ -129,7 +129,8 @@ class Components(private val context: Context) {
@Suppress("MagicNumber")
val supportedAddonsChecker by lazyMonitored {
DefaultSupportedAddonsChecker(context, SupportedAddonsChecker.Frequency(12, TimeUnit.HOURS),
DefaultSupportedAddonsChecker(
context, SupportedAddonsChecker.Frequency(12, TimeUnit.HOURS),
onNotificationClickIntent = Intent(context, HomeActivity::class.java).apply {
action = Intent.ACTION_VIEW
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK

@ -38,7 +38,8 @@ object PrivateShortcutCreateManager {
)
)
.setIcon(icon)
.setIntent(Intent(context, HomeActivity::class.java).apply {
.setIntent(
Intent(context, HomeActivity::class.java).apply {
action = Intent.ACTION_VIEW
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
putExtra(HomeActivity.PRIVATE_BROWSING_MODE, true)
@ -46,7 +47,8 @@ object PrivateShortcutCreateManager {
HomeActivity.OPEN_TO_SEARCH,
StartSearchIntentProcessor.PRIVATE_BROWSING_PINNED_SHORTCUT
)
})
}
)
.build()
val homeScreenIntent = Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME)

@ -41,7 +41,8 @@ class Services(
interceptLinkClicks = true,
launchInApp = {
PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
context.getPreferenceKey(R.string.pref_key_open_links_in_external_app), false)
context.getPreferenceKey(R.string.pref_key_open_links_in_external_app), false
)
}
)
}

@ -25,7 +25,8 @@ class ActivationPing(private val context: Context) {
private val prefs: SharedPreferences by lazy {
context.getSharedPreferences(
"${this.javaClass.canonicalName}.prefs", Context.MODE_PRIVATE)
"${this.javaClass.canonicalName}.prefs", Context.MODE_PRIVATE
)
}
/**

@ -92,9 +92,11 @@ class MigrationTipProvider(private val context: Context) : TipProvider {
return if (MozillaProductDetector.packageIsInstalled(context, FENIX.productName)) {
context.startActivity(context.packageManager.getLaunchIntentForPackage(FENIX.productName))
} else {
context.startActivity(Intent(
context.startActivity(
Intent(
Intent.ACTION_VIEW, Uri.parse(SupportUtils.FIREFOX_NIGHTLY_PLAY_STORE_URL)
))
)
)
}
}

@ -180,8 +180,10 @@ private fun BrowserStore.updateSearchTermsOfSelectedSession(
) {
val selectedTabId = state.selectedTabId ?: return
dispatch(ContentAction.UpdateSearchTermsAction(
dispatch(
ContentAction.UpdateSearchTermsAction(
selectedTabId,
searchTerms
))
)
)
}

@ -118,13 +118,15 @@ class DefaultBrowserToolbarMenuController(
customTabUseCases.migrate(customTabSessionId, select = true)
// Switch to the actual browser which should now display our new selected session
activity.startActivity(openInFenixIntent.apply {
activity.startActivity(
openInFenixIntent.apply {
// We never want to launch the browser in the same task as the external app
// activity. So we force a new task here. IntentReceiverActivity will do the
// right thing and take care of routing to an already existing browser and avoid
// cloning a new one.
flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK
})
}
)
// Close this activity (and the task) since it is no longer displaying any session
activity.finishAndRemoveTask()

@ -37,11 +37,13 @@ fun Activity.enterToImmersiveMode() {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
// This will be addressed on https://github.com/mozilla-mobile/fenix/issues/17804
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
window.decorView.systemUiVisibility = (
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
)
}
fun Activity.breadcrumb(

@ -31,9 +31,15 @@ fun TabCollection.getIconColor(context: Context): Int {
* Then get the numbers from all these default names, compute the maximum number and add one.
*/
fun List<TabCollection>.getDefaultCollectionNumber(): Int {
return (this
return (
this
.map { it.title }
.filter { it.matches(Regex("Collection\\s\\d+")) }
.map { Integer.valueOf(it.split(" ")[DefaultCollectionCreationController.DEFAULT_COLLECTION_NUMBER_POSITION]) }
.maxOrNull() ?: 0) + DefaultCollectionCreationController.DEFAULT_INCREMENT_VALUE
.map {
Integer.valueOf(
it.split(" ")[DefaultCollectionCreationController.DEFAULT_COLLECTION_NUMBER_POSITION]
)
}
.maxOrNull() ?: 0
) + DefaultCollectionCreationController.DEFAULT_INCREMENT_VALUE
}

@ -77,16 +77,19 @@ object GeckoProvider {
.getHashUrl(CN_GET_HASH_URL)
.build()
runtimeSettings.contentBlocking.setSafeBrowsingProviders(mozcn,
runtimeSettings.contentBlocking.setSafeBrowsingProviders(
mozcn,
// Keep the existing configuration
ContentBlocking.GOOGLE_SAFE_BROWSING_PROVIDER,
ContentBlocking.GOOGLE_LEGACY_SAFE_BROWSING_PROVIDER)
ContentBlocking.GOOGLE_LEGACY_SAFE_BROWSING_PROVIDER
)
runtimeSettings.contentBlocking.setSafeBrowsingPhishingTable(
"m6eb-phish-shavar",
"m6ib-phish-shavar",
// Existing configuration
"goog-phish-proto")
"goog-phish-proto"
)
}
val geckoRuntime = GeckoRuntime.create(context, runtimeSettings)

@ -198,7 +198,8 @@ class HomeFragment : Fragment() {
if (!onboarding.userHasBeenOnboarded() &&
requireContext().settings().shouldShowPrivacyPopWindow &&
Config.channel.isMozillaOnline) {
Config.channel.isMozillaOnline
) {
showPrivacyPopWindow(requireContext(), requireActivity())
}
}
@ -665,7 +666,8 @@ class HomeFragment : Fragment() {
currentMode,
owner = this@HomeFragment.viewLifecycleOwner
)
requireComponents.backgroundServices.accountManager.register(object : AccountObserver {
requireComponents.backgroundServices.accountManager.register(
object : AccountObserver {
override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
if (authType != AuthType.Existing) {
view?.let {
@ -680,7 +682,9 @@ class HomeFragment : Fragment() {
}
}
}
}, owner = this@HomeFragment.viewLifecycleOwner)
},
owner = this@HomeFragment.viewLifecycleOwner
)
}
if (browsingModeManager.mode.isPrivate &&
@ -701,7 +705,8 @@ class HomeFragment : Fragment() {
private fun navToSavedLogins() {
findNavController().navigate(
HomeFragmentDirections.actionGlobalSavedLoginsAuthFragment())
HomeFragmentDirections.actionGlobalSavedLoginsAuthFragment()
)
}
private fun dispatchModeChanges(mode: Mode) {

@ -181,7 +181,8 @@ class HomeMenu(
// We don't want to cause its initialization just for this check.
val accountAuthItem =
if (context.components.backgroundServices.accountManagerAvailableQueue.isReady() &&
context.components.backgroundServices.accountManager.accountNeedsReauth()) {
context.components.backgroundServices.accountManager.accountNeedsReauth()
) {
reconnectToSyncItem
} else {
null
@ -220,7 +221,8 @@ class HomeMenu(
if (lifecycleOwner.lifecycle.currentState == Lifecycle.State.DESTROYED) {
return@runIfReadyOrQueue
}
context.components.backgroundServices.accountManager.register(object : AccountObserver {
context.components.backgroundServices.accountManager.register(
object : AccountObserver {
override fun onAuthenticationProblems() {
lifecycleOwner.lifecycleScope.launch(Dispatchers.Main) {
onMenuBuilderChanged(
@ -250,7 +252,9 @@ class HomeMenu(
)
}
}
}, lifecycleOwner)
},
lifecycleOwner
)
}
}
}

@ -29,21 +29,31 @@ fun showPrivacyPopWindow(context: Context, activity: Activity) {
val clickableSpan2 = PrivacyContentSpan(Position.POS2, context)
val clickableSpan3 = PrivacyContentSpan(Position.POS3, context)
messageSpannable.setSpan(clickableSpan1, content.indexOf(messageClickable1),
content.indexOf(messageClickable1) + messageClickable1.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
messageSpannable.setSpan(clickableSpan2, content.indexOf(messageClickable2),
content.indexOf(messageClickable2) + messageClickable2.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
messageSpannable.setSpan(clickableSpan3, content.indexOf(messageClickable3),
content.indexOf(messageClickable3) + messageClickable3.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
messageSpannable.setSpan(
clickableSpan1, content.indexOf(messageClickable1),
content.indexOf(messageClickable1) + messageClickable1.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE
)
messageSpannable.setSpan(
clickableSpan2, content.indexOf(messageClickable2),
content.indexOf(messageClickable2) + messageClickable2.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE
)
messageSpannable.setSpan(
clickableSpan3, content.indexOf(messageClickable3),
content.indexOf(messageClickable3) + messageClickable3.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE
)
// Users can only use fenix after they agree with the privacy notice
val builder = AlertDialog.Builder(activity)
.setPositiveButton(context.getString(R.string.privacy_notice_positive_button),
.setPositiveButton(
context.getString(R.string.privacy_notice_positive_button),
DialogInterface.OnClickListener { _, _ ->
context.settings().shouldShowPrivacyPopWindow = false
})
.setNeutralButton(context.getString(R.string.privacy_notice_neutral_button),
DialogInterface.OnClickListener { _, _ -> exitProcess(0) })
}
)
.setNeutralButton(
context.getString(R.string.privacy_notice_neutral_button),
DialogInterface.OnClickListener { _, _ -> exitProcess(0) }
)
.setTitle(context.getString(R.string.privacy_notice_title))
.setMessage(messageSpannable)
.setCancelable(false)

@ -401,9 +401,11 @@ class DefaultSessionControlController(
val searchAccessPoint = Event.PerformedSearch.SearchAccessPoint.TOPSITE
val event =
availableEngines.firstOrNull {
engine -> engine.resultUrls.firstOrNull { it.contains(url) } != null
engine ->
engine.resultUrls.firstOrNull { it.contains(url) } != null
}?.let {
searchEngine -> searchAccessPoint.let { sap ->
searchEngine ->
searchAccessPoint.let { sap ->
MetricsUtils.createSearchEvent(searchEngine, store, sap)
}
}

@ -222,9 +222,16 @@ class SessionControlInteractor(
private val recentTabController: RecentTabController,
private val recentBookmarksController: RecentBookmarksController,
private val historyMetadataController: HistoryMetadataController
) : CollectionInteractor, OnboardingInteractor, TopSiteInteractor, TipInteractor,
TabSessionInteractor, ToolbarInteractor, ExperimentCardInteractor, RecentTabInteractor,
RecentBookmarksInteractor, HistoryMetadataInteractor {
) : CollectionInteractor,
OnboardingInteractor,
TopSiteInteractor,
TipInteractor,
TabSessionInteractor,
ToolbarInteractor,
ExperimentCardInteractor,
RecentTabInteractor,
RecentBookmarksInteractor,
HistoryMetadataInteractor {
override fun onCollectionAddTabTapped(collection: TabCollection) {
controller.handleCollectionAddTabTapped(collection)

@ -295,10 +295,12 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), UserInteractionHan
}
private fun deleteMulti(selected: Set<BookmarkNode>, eventType: Event = Event.RemoveBookmarks) {
selected.iterator().forEach { if (it.type == BookmarkNodeType.FOLDER) {
selected.iterator().forEach {
if (it.type == BookmarkNodeType.FOLDER) {
showRemoveFolderDialog(selected)
return
} }
}
}
updatePendingBookmarksToDelete(selected)
pendingBookmarkDeletionJob = getDeleteOperation(eventType)
@ -320,9 +322,11 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), UserInteractionHan
viewLifecycleOwner.lifecycleScope.allowUndo(
requireView(), message,
getString(R.string.bookmark_undo_deletion), {
getString(R.string.bookmark_undo_deletion),
{
undoPendingDeletion(selected)
}, operation = getDeleteOperation(eventType)
},
operation = getDeleteOperation(eventType)
)
}

@ -77,8 +77,12 @@ class SelectBookmarkFolderAdapter(private val sharedViewModel: BookmarksSharedVi
containerView.context,
R.drawable.ic_folder_icon
)?.apply {
setTint(ContextCompat.getColor(containerView.context,
R.color.primary_text_light_theme))
setTint(
ContextCompat.getColor(
containerView.context,
R.color.primary_text_light_theme
)
)
}
)
view.titleView.text = folder.node.title

@ -231,7 +231,8 @@ class DownloadFragment : LibraryPageFragment<DownloadItem>(), UserInteractionHan
String.format(
requireContext().getString(
R.string.download_delete_single_item_snackbar
), downloadItems.first().fileName
),
downloadItems.first().fileName
)
}
}

@ -122,9 +122,12 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
requireComponents.core.historyStorage.createSynchronousPagedHistoryProvider()
)
viewModel.userHasHistory.observe(this, Observer {
viewModel.userHasHistory.observe(
this,
Observer {
historyView.updateEmptyState(it)
})
}
)
requireComponents.analytics.metrics.track(Event.HistoryOpened)
@ -154,9 +157,12 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
historyView.update(it)
}
viewModel.history.observe(viewLifecycleOwner, Observer {
viewModel.history.observe(
viewLifecycleOwner,
Observer {
historyView.historyAdapter.submitList(it)
})
}
)
}
override fun onResume() {
@ -229,7 +235,8 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
String.format(
requireContext().getString(
R.string.history_delete_single_item_snackbar
), historyItems.first().url.toShortUrl(requireComponents.publicSuffixList)
),
historyItems.first().url.toShortUrl(requireComponents.publicSuffixList)
)
}
}

@ -175,7 +175,8 @@ class HistoryView(
view.context.getString(
if (numRecentTabs == 1)
R.string.recently_closed_tab else R.string.recently_closed_tabs
), numRecentTabs
),
numRecentTabs
)
isVisible = !userHasHistory
}

@ -116,7 +116,8 @@ class HistoryListItemViewHolder(
itemView.context.getString(
if (numRecentTabs == 1)
R.string.recently_closed_tab else R.string.recently_closed_tabs
), numRecentTabs
),
numRecentTabs
)
itemView.findViewById<ConstraintLayout>(R.id.recently_closed_nav).run {
if (isNormalMode) {

@ -62,9 +62,11 @@ class DefaultBrowserNotificationWorker(
return NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.drawable.ic_status_logo)
.setContentTitle(
applicationContext.getString(R.string.notification_default_browser_title, appName))
applicationContext.getString(R.string.notification_default_browser_title, appName)
)
.setContentText(
applicationContext.getString(R.string.notification_default_browser_text, appName))
applicationContext.getString(R.string.notification_default_browser_text, appName)
)
.setBadgeIconType(NotificationCompat.BADGE_ICON_SMALL)
.setColor(ContextCompat.getColor(this, R.color.primary_text_light_theme))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)

@ -52,13 +52,15 @@ class StartupActivityLog {
return
}
val transformedEntries = log.map { when (it) {
val transformedEntries = log.map {
when (it) {
is LogEntry.AppStarted -> "App-STARTED"
is LogEntry.AppStopped -> "App-STOPPED"
is LogEntry.ActivityCreated -> "${it.activityClass.simpleName}-CREATED"
is LogEntry.ActivityStarted -> "${it.activityClass.simpleName}-STARTED"
is LogEntry.ActivityStopped -> "${it.activityClass.simpleName}-STOPPED"
} }
}
}
loggerArg.debug(transformedEntries.toString())
}

@ -33,7 +33,8 @@ class StartupReportFullyDrawn {
*/
fun onActivityCreateEndHome(state: StartupState, activity: HomeActivity) {
if (!isInstrumented &&
state is StartupState.Cold && state.destination == APP_LINK) {
state is StartupState.Cold && state.destination == APP_LINK
) {
// Instrumenting the first frame drawn should be good enough for app link for now.
isInstrumented = true
attachReportFullyDrawn(activity, activity.findViewById(R.id.rootContainer))
@ -50,7 +51,8 @@ class StartupReportFullyDrawn {
*/
fun onTopSitesItemBound(state: StartupState, holder: TopSiteItemViewHolder) {
if (!isInstrumented &&
state is StartupState.Cold && state.destination == HOMESCREEN) {
state is StartupState.Cold && state.destination == HOMESCREEN
) {
isInstrumented = true
// Ideally we wouldn't cast to HomeActivity but we want to save implementation time.

@ -25,9 +25,12 @@ class VisualCompletenessQueue(val queue: RunWhenReadyQueue) {
containerWeakReference.get()?.doOnPreDraw {
// This delay is temporary. We are delaying 5 seconds until the performance
// team can locate the real point of visual completeness.
it.postDelayed({
it.postDelayed(
{
queue.ready()
}, delay)
},
delay
)
}
}
}

@ -81,7 +81,8 @@ internal class WebPushEngineDelegate(
},
onSubscribe = { subscription ->
onSubscribe(subscription.toEnginePushSubscription())
})
}
)
}
override fun onUnsubscribe(scope: String, onUnsubscribe: (Boolean) -> Unit) {
@ -93,7 +94,8 @@ internal class WebPushEngineDelegate(
},
onUnsubscribe = { result ->
onUnsubscribe(result)
})
}
)
}
}

@ -116,16 +116,20 @@ class CustomizationFragment : PreferenceFragmentCompat() {
private fun setupToolbarCategory() {
val topPreference = requirePreference<RadioButtonPreference>(R.string.pref_key_toolbar_top)
topPreference.onClickListener {
requireContext().components.analytics.metrics.track(Event.ToolbarPositionChanged(
requireContext().components.analytics.metrics.track(
Event.ToolbarPositionChanged(
Event.ToolbarPositionChanged.Position.TOP
))
)
)
}
val bottomPreference = requirePreference<RadioButtonPreference>(R.string.pref_key_toolbar_bottom)
bottomPreference.onClickListener {
requireContext().components.analytics.metrics.track(Event.ToolbarPositionChanged(
requireContext().components.analytics.metrics.track(
Event.ToolbarPositionChanged(
Event.ToolbarPositionChanged.Position.BOTTOM
))
)
)
}
val toolbarPosition = requireContext().settings().toolbarPosition

@ -20,8 +20,10 @@ fun SitePermissions.toggle(featurePhone: PhoneFeature): SitePermissions {
fun SitePermissions.get(field: PhoneFeature) = when (field) {
PhoneFeature.AUTOPLAY ->
throw IllegalAccessException("AUTOPLAY can't be accessed via get try " +
"using AUTOPLAY_AUDIBLE and AUTOPLAY_INAUDIBLE")
throw IllegalAccessException(
"AUTOPLAY can't be accessed via get try " +
"using AUTOPLAY_AUDIBLE and AUTOPLAY_INAUDIBLE"
)
PhoneFeature.CAMERA -> camera
PhoneFeature.LOCATION -> location
PhoneFeature.MICROPHONE -> microphone
@ -33,8 +35,10 @@ fun SitePermissions.get(field: PhoneFeature) = when (field) {
}
fun SitePermissions.update(field: PhoneFeature, value: SitePermissions.Status) = when (field) {
PhoneFeature.AUTOPLAY -> throw IllegalAccessException("AUTOPLAY can't be accessed via update " +
"try using AUTOPLAY_AUDIBLE and AUTOPLAY_INAUDIBLE")
PhoneFeature.AUTOPLAY -> throw IllegalAccessException(
"AUTOPLAY can't be accessed via update " +
"try using AUTOPLAY_AUDIBLE and AUTOPLAY_INAUDIBLE"
)
PhoneFeature.CAMERA -> copy(camera = value)
PhoneFeature.LOCATION -> copy(location = value)
PhoneFeature.MICROPHONE -> copy(microphone = value)

@ -71,7 +71,8 @@ class PairFragment : Fragment(R.layout.fragment_pair), UserInteractionHandler {
},
scanMessage =
if (requireContext().settings().allowDomesticChinaFxaServer &&
org.mozilla.fenix.Config.channel.isMozillaOnline)
org.mozilla.fenix.Config.channel.isMozillaOnline
)
R.string.pair_instructions_2_cn
else R.string.pair_instructions_2
),

@ -55,7 +55,8 @@ private fun DebugInfo() {
)
Text(
text = store.state.search.region?.home ?: "Unknown",
modifier = Modifier.padding(4.dp))
modifier = Modifier.padding(4.dp)
)
Text(
text = stringResource(R.string.debug_info_region_current),
style = MaterialTheme.typography.h6,

@ -370,9 +370,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
Toast.LENGTH_LONG
).show()
Handler(Looper.getMainLooper()).postDelayed({
Handler(Looper.getMainLooper()).postDelayed(
{
exitProcess(0)
}, AMO_COLLECTION_OVERRIDE_EXIT_DELAY)
},
AMO_COLLECTION_OVERRIDE_EXIT_DELAY
)
}
binding.customAmoCollection.setText(context.settings().overrideAmoCollection)
@ -435,9 +438,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
getString(R.string.toast_override_fxa_sync_server_done),
Toast.LENGTH_LONG
).show()
Handler(Looper.getMainLooper()).postDelayed({
Handler(Looper.getMainLooper()).postDelayed(
{
exitProcess(0)
}, FXA_SYNC_OVERRIDE_EXIT_DELAY)
},
FXA_SYNC_OVERRIDE_EXIT_DELAY
)
}
}
}
@ -560,8 +566,10 @@ class SettingsFragment : PreferenceFragmentCompat() {
val preferenceAmoCollectionOverride =
findPreference<Preference>(getPreferenceKey(R.string.pref_key_override_amo_collection))
val show = (Config.channel.isNightlyOrDebug && (
settings.amoCollectionOverrideConfigured() || settings.showSecretDebugMenuThisSession)
val show = (
Config.channel.isNightlyOrDebug && (
settings.amoCollectionOverrideConfigured() || settings.showSecretDebugMenuThisSession
)
)
preferenceAmoCollectionOverride?.apply {
isVisible = show
@ -589,9 +597,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
getString(R.string.toast_override_fxa_sync_server_done),
Toast.LENGTH_LONG
).show()
Handler(Looper.getMainLooper()).postDelayed({
Handler(Looper.getMainLooper()).postDelayed(
{
exitProcess(0)
}, FXA_SYNC_OVERRIDE_EXIT_DELAY)
},
FXA_SYNC_OVERRIDE_EXIT_DELAY
)
}
}
}

@ -44,7 +44,8 @@ class SyncPreferenceView(
) {
init {
accountManager.register(object : AccountObserver {
accountManager.register(
object : AccountObserver {
override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
MainScope().launch { updateSyncPreferenceStatus() }
}
@ -56,7 +57,9 @@ class SyncPreferenceView(
override fun onAuthenticationProblems() {
MainScope().launch { updateSyncPreferenceNeedsReauth() }
}
}, owner = lifecycleOwner)
},
owner = lifecycleOwner
)
val accountExists = accountManager.authenticatedAccount() != null
val needsReauth = accountManager.accountNeedsReauth()

@ -138,13 +138,15 @@ class AboutFragment : Fragment(), AboutPageListener {
AboutItem.ExternalLink(
WHATS_NEW,
SupportUtils.getWhatsNewUrl(context)
), getString(R.string.about_whats_new, getString(R.string.app_name))
),
getString(R.string.about_whats_new, getString(R.string.app_name))
),
AboutPageItem(
AboutItem.ExternalLink(
SUPPORT,
SupportUtils.getSumoURLForTopic(context, SupportUtils.SumoTopic.HELP)
), getString(R.string.about_support)
),
getString(R.string.about_support)
),
AboutPageItem(
AboutItem.Crashes,
@ -154,13 +156,15 @@ class AboutFragment : Fragment(), AboutPageListener {
AboutItem.ExternalLink(
PRIVACY_NOTICE,
SupportUtils.getMozillaPageUrl(SupportUtils.MozillaPage.PRIVATE_NOTICE)
), getString(R.string.about_privacy_notice)
),
getString(R.string.about_privacy_notice)
),
AboutPageItem(
AboutItem.ExternalLink(
RIGHTS,
SupportUtils.getSumoURLForTopic(context, SupportUtils.SumoTopic.YOUR_RIGHTS)
), getString(R.string.about_know_your_rights)
),
getString(R.string.about_know_your_rights)
),
AboutPageItem(
AboutItem.ExternalLink(LICENSING_INFO, ABOUT_LICENSE_URL),

@ -24,7 +24,8 @@ class DefaultLocaleSettingsController(
override fun handleLocaleSelected(locale: Locale) {
if (localeSettingsStore.state.selectedLocale == locale &&
!LocaleManager.isDefaultLocaleSelected(activity)) {
!LocaleManager.isDefaultLocaleSelected(activity)
) {
return
}
localeSettingsStore.dispatch(LocaleSettingsAction.Select(locale))

@ -17,14 +17,18 @@ fun LocaleManager.getSupportedLocales(): List<Locale> {
val resultLocaleList: MutableList<Locale> = ArrayList()
resultLocaleList.add(0, getSystemDefault())
resultLocaleList.addAll(BuildConfig.SUPPORTED_LOCALE_ARRAY
resultLocaleList.addAll(
BuildConfig.SUPPORTED_LOCALE_ARRAY
.toList()
.map {
it.toLocale()
}.sortedWith(compareBy(
}.sortedWith(
compareBy(
{ it.displayLanguage },
{ it.displayCountry }
)))
)
)
)
return resultLocaleList
}

@ -187,7 +187,8 @@ open class SavedLoginsStorageController(
withContext(Dispatchers.Main) {
loginsFragmentStore.dispatch(
LoginsAction.UpdateLoginsList(
logins.map { it.mapToSavedLogin() })
logins.map { it.mapToSavedLogin() }
)
)
}
}

@ -198,12 +198,15 @@ class SavedLoginsFragment : Fragment() {
}
private fun attachMenu() {
sortingStrategyMenu.menuController.register(object : MenuController.Observer {
sortingStrategyMenu.menuController.register(
object : MenuController.Observer {
override fun onDismiss() {
// Deactivate button on dismiss
sortLoginsMenuRoot.isActivated = false
}
}, view = sortLoginsMenuRoot)
},
view = sortLoginsMenuRoot
)
sortLoginsMenuRoot.setOnClickListener {
// Activate button on show

@ -49,7 +49,8 @@ class SavedLoginsListView(
text = String.format(
context.getString(
R.string.preferences_passwords_saved_logins_description_empty_text
), appName
),
appName
)
}
}

@ -205,10 +205,12 @@ class QuickSettingsSheetDialogFragment : AppCompatDialogFragment() {
}
private fun openSystemSettings() {
startActivity(Intent().apply {
startActivity(
Intent().apply {
action = android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS
data = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null)
})
}
)
}
private companion object {

@ -43,7 +43,8 @@ import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.settings.SupportUtils
@SuppressWarnings("LargeClass", "TooManyFunctions")
class AddSearchEngineFragment : Fragment(R.layout.fragment_add_search_engine),
class AddSearchEngineFragment :
Fragment(R.layout.fragment_add_search_engine),
CompoundButton.OnCheckedChangeListener {
private var availableEngines: List<SearchEngine> = listOf()
private var selectedIndex: Int = -1

@ -30,7 +30,8 @@ object SearchStringValidator {
// read the response stream to ensure the body is closed correctly. workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1603114
response.body.string()
return if (response.isSuccess ||
isTestQueryParamNotFound(response.status)) Result.Success else Result.CannotReach
isTestQueryParamNotFound(response.status)
) Result.Success else Result.CannotReach
}
private fun createRequest(searchString: String): Request {

@ -67,7 +67,9 @@ class SitePermissionsExceptionsFragment :
val adapter = ExceptionsAdapter(this@SitePermissionsExceptionsFragment)
val liveData = LivePagedListBuilder(sitePermissionsPaged, MAX_ITEMS_PER_PAGE).build()
liveData.observe(viewLifecycleOwner, Observer<PagedList<SitePermissions>> {
liveData.observe(
viewLifecycleOwner,
Observer<PagedList<SitePermissions>> {
if (it.isEmpty()) {
showEmptyListMessage()
} else {
@ -75,7 +77,8 @@ class SitePermissionsExceptionsFragment :
adapter.submitList(it)
recyclerView.adapter = adapter
}
})
}
)
}
}
}

@ -31,8 +31,10 @@ fun ErrorType.toAdapterItem(
ErrorType.MULTIPLE_DEVICES_UNAVAILABLE,
ErrorType.SYNC_ENGINE_UNAVAILABLE,
ErrorType.SYNC_NEEDS_REAUTHENTICATION,
ErrorType.NO_TABS_AVAILABLE -> SyncedTabsAdapter.AdapterItem
ErrorType.NO_TABS_AVAILABLE ->
SyncedTabsAdapter.AdapterItem
.Error(descriptionResId = stringResId)
ErrorType.SYNC_UNAVAILABLE -> SyncedTabsAdapter.AdapterItem
ErrorType.SYNC_UNAVAILABLE ->
SyncedTabsAdapter.AdapterItem
.Error(descriptionResId = stringResId, navController = navController)
}

@ -36,7 +36,8 @@ class SecureTabsTrayBinding(
}
.collect { state ->
if (state.selectedPage == Page.PrivateTabs &&
!settings.allowScreenshotsInPrivateMode) {
!settings.allowScreenshotsInPrivateMode
) {
fragment.secure()
dialog.window?.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
} else if (!settings.lastKnownMode.isPrivate) {

@ -75,7 +75,8 @@ class DefaultTabsTrayController(
val startTime = profiler?.getProfilerTime()
browsingModeManager.mode = BrowsingMode.fromBoolean(isPrivate)
navController.navigate(
TabsTrayFragmentDirections.actionGlobalHome(focusOnAddressBar = true))
TabsTrayFragmentDirections.actionGlobalHome(focusOnAddressBar = true)
)
navigationInteractor.onTabTrayDismissed()
profiler?.addMarker(
"DefaultTabTrayController.onNewTabTapped",

@ -216,7 +216,8 @@ class TabsTrayFragment : AppCompatDialogFragment() {
browsingModeManager = activity.browsingModeManager,
tabsTrayStore = tabsTrayStore,
metrics = requireComponents.analytics.metrics
), owner = this,
),
owner = this,
view = view
)

@ -34,7 +34,8 @@ class SyncedTabsTrayLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr), SyncedTabsView,
) : ConstraintLayout(context, attrs, defStyleAttr),
SyncedTabsView,
Observable<SyncedTabsView.Listener> by ObserverRegistry() {
private val lifecycleProvider = LifecycleViewProvider(this)

@ -40,10 +40,12 @@ abstract class AbstractBrowserPageViewHolder(
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder>,
layoutManager: RecyclerView.LayoutManager
) {
adapter.registerAdapterDataObserver(OneTimeAdapterObserver(adapter) {
adapter.registerAdapterDataObserver(
OneTimeAdapterObserver(adapter) {
trayList.scrollToPosition(currentTabIndex)
updateTrayVisibility(adapter.itemCount)
})
}
)
trayList.layoutManager = layoutManager
trayList.adapter = adapter
}

@ -27,7 +27,8 @@ class NormalBrowserPageViewHolder(
store,
interactor,
currentTabIndex
), SelectionHolder<Tab> {
),
SelectionHolder<Tab> {
init {
trayList.browserTabType = NORMAL

@ -37,7 +37,8 @@ class TelemetryLifecycleObserver(
@Suppress("DEPRECATION")
// FIXME(#19967): Migrate to non-deprecated API.
EngineMetrics.foregroundMetrics.record(mapOf(
EngineMetrics.foregroundMetrics.record(
mapOf(
MetricsKeys.backgroundActiveTabs to lastState.activeEngineTabs.toString(),
MetricsKeys.backgroundCrashedTabs to lastState.crashedTabs.toString(),
MetricsKeys.backgroundTotalTabs to lastState.totalTabs.toString(),
@ -45,7 +46,8 @@ class TelemetryLifecycleObserver(
MetricsKeys.foregroundCrashedTabs to currentState.crashedTabs.toString(),
MetricsKeys.foregroundTotalTabs to currentState.totalTabs.toString(),
MetricsKeys.timeInBackground to (currentState.timestamp - lastState.timestamp).toString()
))
)
)
pausedState = null
}

@ -127,11 +127,13 @@ class TrackingProtectionPanelView(
category_title.setText(category.title)
blocking_text_list.text = bucketedTrackers.get(category, categoryBlocked).joinToString("\n")
category_description.setText(category.description)
details_blocking_header.setText(if (categoryBlocked) {
details_blocking_header.setText(
if (categoryBlocked) {
R.string.enhanced_tracking_protection_blocked
} else {
R.string.enhanced_tracking_protection_allowed
})
}
)
details_back.requestFocus()
details_back.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
@ -249,7 +251,9 @@ class TrackingProtectionPanelView(
* Makes sure [view1] is followed by [view2] when navigating in accessibility mode.
* */
private fun setAccessibilityViewHierarchy(view1: View, view2: View) {
ViewCompat.setAccessibilityDelegate(view2, object : AccessibilityDelegateCompat() {
ViewCompat.setAccessibilityDelegate(
view2,
object : AccessibilityDelegateCompat() {
override fun onInitializeAccessibilityNodeInfo(
host: View?,
info: AccessibilityNodeInfoCompat
@ -257,7 +261,8 @@ class TrackingProtectionPanelView(
info.setTraversalAfter(view1)
super.onInitializeAccessibilityNodeInfo(host, info)
}
})
}
)
}
companion object {

@ -24,8 +24,10 @@ class ClipboardHandler(val context: Context) {
var text: String?
get() {
if (!clipboard.isPrimaryClipEmpty() &&
(clipboard.isPrimaryClipPlainText() ||
clipboard.isPrimaryClipHtmlText())
(
clipboard.isPrimaryClipPlainText() ||
clipboard.isPrimaryClipHtmlText()
)
) {
return firstSafePrimaryClipItemText
}

@ -242,8 +242,10 @@ class Settings(private val appContext: Context) : PreferencesHolder {
val shouldShowTrackingProtectionCfr: Boolean
get() = !isOverrideTPPopupsForPerformanceTest && canShowCfr &&
(trackingProtectionOnboardingCount.underMaxCount() &&
!trackingProtectionOnboardingShownThisSession)
(
trackingProtectionOnboardingCount.underMaxCount() &&
!trackingProtectionOnboardingShownThisSession
)
var showSecretDebugMenuThisSession = false

@ -29,7 +29,8 @@ class WhatsNew private constructor(private val storage: WhatsNewStorage) {
// Update the version and date if *just* updated
if (lastKnownAppVersion == null ||
currentVersion.majorVersionNumber > lastKnownAppVersion.majorVersionNumber) {
currentVersion.majorVersionNumber > lastKnownAppVersion.majorVersionNumber
) {
storage.setVersion(currentVersion)
storage.setDateOfUpdate(System.currentTimeMillis())
return true

@ -91,8 +91,10 @@ class SearchWidgetProvider : AppWidgetProvider() {
.let { intent ->
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
intent.putExtra(HomeActivity.OPEN_TO_SEARCH, StartSearchIntentProcessor.SEARCH_WIDGET)
PendingIntent.getActivity(context,
REQUEST_CODE_NEW_TAB, intent, PendingIntent.FLAG_UPDATE_CURRENT)
PendingIntent.getActivity(
context,
REQUEST_CODE_NEW_TAB, intent, PendingIntent.FLAG_UPDATE_CURRENT
)
}
}
@ -113,8 +115,10 @@ class SearchWidgetProvider : AppWidgetProvider() {
val intentSpeech = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
return intentSpeech.resolveActivity(context.packageManager)?.let {
PendingIntent.getActivity(context,
REQUEST_CODE_VOICE, voiceIntent, 0)
PendingIntent.getActivity(
context,
REQUEST_CODE_VOICE, voiceIntent, 0
)
}
}
@ -158,14 +162,16 @@ class SearchWidgetProvider : AppWidgetProvider() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
setImageViewResource(
R.id.button_search_widget_new_tab_icon,
R.drawable.ic_launcher_foreground)
R.drawable.ic_launcher_foreground
)
} else {
setImageViewBitmap(
R.id.button_search_widget_new_tab_icon,
AppCompatResources.getDrawable(
context,
R.drawable.ic_launcher_foreground
)?.toBitmap())
)?.toBitmap()
)
}
}

@ -45,17 +45,21 @@ class AddonDetailsViewTest {
@Test
fun `bind addons rating`() {
detailsView.bind(baseAddon.copy(
detailsView.bind(
baseAddon.copy(
rating = null
))
)
)
assertEquals(0f, view.rating_view.rating)
detailsView.bind(baseAddon.copy(
detailsView.bind(
baseAddon.copy(
rating = Addon.Rating(
average = 4.3f,
reviews = 100
)
))
)
)
assertEquals("4.30/5", view.rating_view.contentDescription)
assertEquals(4.5f, view.rating_view.rating)
assertEquals("100", view.users_count.text)
@ -63,9 +67,11 @@ class AddonDetailsViewTest {
@Test
fun `bind addons website`() {
detailsView.bind(baseAddon.copy(
detailsView.bind(
baseAddon.copy(
siteUrl = "https://mozilla.org"
))
)
)
view.home_page_label.performClick()
@ -108,12 +114,14 @@ class AddonDetailsViewTest {
@Test
fun `bind addons authors`() {
val baseAuthor = Addon.Author("", "", "", "")
detailsView.bind(baseAddon.copy(
detailsView.bind(
baseAddon.copy(
authors = listOf(
baseAuthor.copy(name = " Sarah Jane"),
baseAuthor.copy(name = "John Smith ")
)
))
)
)
assertEquals("Sarah Jane, John Smith", view.author_text.text)
}

@ -42,9 +42,11 @@ class AddonPermissionsDetailsViewTest {
@Test
fun `clicking learn more opens learn more page in browser`() {
permissionsDetailsView.bind(addon.copy(
permissionsDetailsView.bind(
addon.copy(
rating = null
))
)
)
permissionsDetailsView.learn_more_label.performClick()

@ -184,9 +184,11 @@ class BrowserFragmentTest {
val toolbar: BrowserToolbarView = mockk(relaxed = true)
every { browserFragment.browserToolbarView } returns toolbar
store.dispatch(ContentAction.UpdateLoadRequestAction(
store.dispatch(
ContentAction.UpdateLoadRequestAction(
testTab.id,
LoadRequestState("https://firefox.com", false, true))
LoadRequestState("https://firefox.com", false, true)
)
).joinBlocking()
verify(exactly = 1) { toolbar.expand() }
}

@ -102,11 +102,16 @@ class FenixSnackbarDelegateTest {
)
verify { snackbar.setText("Firefox") }
verify { snackbar.setAction("Edit", withArg {
verify {
snackbar.setAction(
"Edit",
withArg {
verify(exactly = 0) { listener(view) }
it.invoke()
verify { listener(view) }
}) }
}
)
}
verify { snackbar.show() }
}
}

@ -63,7 +63,8 @@ class OpenInAppOnboardingObserverTest {
BrowserState(
tabs = listOf(
createTab(url = "https://www.mozilla.org", id = "1")
), selectedTabId = "1"
),
selectedTabId = "1"
)
)
lifecycleOwner = MockedLifecycleOwner(Lifecycle.State.STARTED)
@ -73,7 +74,8 @@ class OpenInAppOnboardingObserverTest {
container = mockk(relaxed = true)
context = mockk(relaxed = true)
infoBanner = mockk(relaxed = true)
openInAppOnboardingObserver = spyk(OpenInAppOnboardingObserver(
openInAppOnboardingObserver = spyk(
OpenInAppOnboardingObserver(
context = context,
store = store,
lifecycleOwner = lifecycleOwner,
@ -82,7 +84,8 @@ class OpenInAppOnboardingObserverTest {
appLinksUseCases = appLinksUseCases,
container = container,
shouldScrollWithTopToolbar = true
))
)
)
every { openInAppOnboardingObserver.createInfoBanner() } returns infoBanner
}
@ -167,15 +170,19 @@ class OpenInAppOnboardingObserverTest {
// Mockk currently doesn't support verifying constructor parameters
// But we can check the values found in the constructed objects
openInAppOnboardingObserver = spyk(OpenInAppOnboardingObserver(
openInAppOnboardingObserver = spyk(
OpenInAppOnboardingObserver(
testContext, mockk(), mockk(), mockk(), mockk(), mockk(), mockk(), shouldScrollWithTopToolbar = true
))
)
)
val banner1 = openInAppOnboardingObserver.createInfoBanner()
assertTrue(banner1.shouldScrollWithTopToolbar)
openInAppOnboardingObserver = spyk(OpenInAppOnboardingObserver(
openInAppOnboardingObserver = spyk(
OpenInAppOnboardingObserver(
testContext, mockk(), mockk(), mockk(), mockk(), mockk(), mockk(), shouldScrollWithTopToolbar = false
))
)
)
val banner2 = openInAppOnboardingObserver.createInfoBanner()
assertFalse(banner2.shouldScrollWithTopToolbar)
}

@ -17,9 +17,11 @@ import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
class DynamicInfoBannerTest {
@Test
fun `showBanner should set DynamicInfoBannerBehavior as behavior if scrollWithTopToolbar`() {
val banner = spyk(DynamicInfoBanner(
val banner = spyk(
DynamicInfoBanner(
testContext, CoordinatorLayout(testContext), true, "", ""
))
)
)
banner.showBanner()
@ -28,9 +30,11 @@ class DynamicInfoBannerTest {
@Test
fun `showBanner should not set a behavior if not scrollWithTopToolbar`() {
val banner = spyk(DynamicInfoBanner(
val banner = spyk(
DynamicInfoBanner(
testContext, CoordinatorLayout(testContext), false, "", ""
))
)
)
banner.showBanner()

@ -103,10 +103,12 @@ class CollectionCreationStoreTest {
)
)
store.dispatch(CollectionCreationAction.StepChanged(
store.dispatch(
CollectionCreationAction.StepChanged(
saveCollectionStep = SaveCollectionStep.RenameCollection,
defaultCollectionNumber = 3
)).joinBlocking()
)
).joinBlocking()
assertEquals(SaveCollectionStep.RenameCollection, store.state.saveCollectionStep)
assertEquals(3, store.state.defaultCollectionNumber)
}
@ -207,11 +209,13 @@ class CollectionCreationStoreTest {
fun `toTab uses active reader URL`() {
val tabWithoutReaderState = createTab(url = "https://example.com", id = "1")
val tabWithInactiveReaderState = createTab(url = "https://blog.mozilla.org", id = "2",
val tabWithInactiveReaderState = createTab(
url = "https://blog.mozilla.org", id = "2",
readerState = ReaderState(active = false, activeUrl = null)
)
val tabWithActiveReaderState = createTab(url = "moz-extension://123", id = "3",
val tabWithActiveReaderState = createTab(
url = "moz-extension://123", id = "3",
readerState = ReaderState(active = true, activeUrl = "https://blog.mozilla.org/123")
)

@ -248,14 +248,16 @@ class DefaultCollectionCreationControllerTest {
@Test
fun `GIVEN list of collections WHEN saving tabs to collection THEN dispatch NameCollection step changed`() {
state = state.copy(tabCollections = listOf(
state = state.copy(
tabCollections = listOf(
mockk {
every { title } returns "Collection 1"
},
mockk {
every { title } returns "Random Collection"
}
))
)
)
controller.saveTabsToCollection(ArrayList())

@ -259,19 +259,23 @@ class TrackingProtectionPolicyFactoryTest {
settingsForCustom(shouldBlockCookiesInCustom = true, blockCookiesSelection = "some text!", blockTrackingContentInCustom = "private")
)
allSettings.map { TrackingProtectionPolicyFactory(it).createTrackingProtectionPolicy(
allSettings.map {
TrackingProtectionPolicyFactory(it).createTrackingProtectionPolicy(
normalMode = true,
privateMode = true
) }
)
}
.forEach {
assertTrue(it.useForRegularSessions)
assertTrue(it.useForPrivateSessions)
}
privateSettings.map { TrackingProtectionPolicyFactory(it).createTrackingProtectionPolicy(
privateSettings.map {
TrackingProtectionPolicyFactory(it).createTrackingProtectionPolicy(
normalMode = true,
privateMode = true
) }
)
}
.forEach {
assertFalse(it.useForRegularSessions)
assertTrue(it.useForPrivateSessions)

@ -67,11 +67,13 @@ class BreadcrumbRecorderTest {
breadCrumbRecorder.onDestinationChanged(navController, navDestination, null)
verify {
reporter.recordCrashBreadcrumb(withArg {
reporter.recordCrashBreadcrumb(
withArg {
assertEquals("test", it.message)
assertEquals("DestinationChanged", it.category)
assertEquals(Breadcrumb.Level.INFO, it.level)
})
}
)
}
}
}

@ -23,7 +23,8 @@ class ExtensionsTest {
@Test
fun `tryReloadTabBy reloads latest tab matching origin`() {
val store = BrowserStore(
BrowserState(tabs = listOf(
BrowserState(
tabs = listOf(
createTab(id = "1", url = "https://www.mozilla.org/1", lastAccess = 1),
createTab(id = "2", url = "https://www.mozilla.org/2", lastAccess = 2),
createTab(id = "3", url = "https://www.firefox.com")

@ -151,11 +151,14 @@ class DefaultBrowserToolbarMenuControllerTest {
BrowserStore(BrowserState(tabs = listOf(regularTab), selectedTabId = regularTab.id))
var bookmarkTappedInvoked = false
val controller = createController(scope = this, store = store, bookmarkTapped = { url, title ->
val controller = createController(
scope = this, store = store,
bookmarkTapped = { url, title ->
assertEquals(expectedTitle, title)
assertEquals(expectedUrl, url)
bookmarkTappedInvoked = true
})
}
)
controller.handleToolbarItemInteraction(item)
verify { metrics.track(Event.BrowserMenuItemTapped(Event.BrowserMenuItemTapped.Item.BOOKMARK)) }
@ -176,11 +179,14 @@ class DefaultBrowserToolbarMenuControllerTest {
BrowserStore(BrowserState(tabs = listOf(readerTab), selectedTabId = readerTab.id))
var bookmarkTappedInvoked = false
val controller = createController(scope = this, store = browserStore, bookmarkTapped = { url, title ->
val controller = createController(
scope = this, store = browserStore,
bookmarkTapped = { url, title ->
assertEquals(expectedTitle, title)
assertEquals(readerTab.readerState.activeUrl, url)
bookmarkTappedInvoked = true
})
}
)
controller.handleToolbarItemInteraction(item)
verify { metrics.track(Event.BrowserMenuItemTapped(Event.BrowserMenuItemTapped.Item.BOOKMARK)) }
@ -494,9 +500,12 @@ class DefaultBrowserToolbarMenuControllerTest {
val item = ToolbarMenu.Item.FindInPage
var launcherInvoked = false
val controller = createController(scope = this, store = browserStore, findInPageLauncher = {
val controller = createController(
scope = this, store = browserStore,
findInPageLauncher = {
launcherInvoked = true
})
}
)
controller.handleToolbarItemInteraction(item)
assertTrue(launcherInvoked)

@ -108,14 +108,16 @@ class ExternalAppBrowserActivityTest {
@Test
fun `ExternalAppBrowserActivity with matching external tab`() {
val store = BrowserStore(BrowserState(
val store = BrowserStore(
BrowserState(
customTabs = listOf(
createCustomTab(
url = "https://www.mozilla.org",
id = "mozilla"
)
)
))
)
)
val intent = Intent(Intent.ACTION_VIEW).apply { putSessionId("mozilla") }
@ -149,14 +151,16 @@ class ExternalAppBrowserActivityTest {
@Test
fun `ExternalAppBrowserActivity with matching regular tab`() {
val store = BrowserStore(BrowserState(
val store = BrowserStore(
BrowserState(
tabs = listOf(
createTab(
url = "https://www.mozilla.org",
id = "mozilla"
)
)
))
)
)
val intent = Intent(Intent.ACTION_VIEW).apply { putSessionId("mozilla") }

@ -65,8 +65,12 @@ class DynamicDownloadDialogBehaviorTest {
@Test
fun `Behavior will snap the dialog up if it is more than 50 percent visible`() {
val behavior = spyk(DynamicDownloadDialogBehavior<View>(testContext, attrs = null,
bottomToolbarHeight = 10f))
val behavior = spyk(
DynamicDownloadDialogBehavior<View>(
testContext, attrs = null,
bottomToolbarHeight = 10f
)
)
every { behavior.shouldScroll } returns true
val animator: ValueAnimator = mockk(relaxed = true)
@ -106,8 +110,12 @@ class DynamicDownloadDialogBehaviorTest {
@Test
fun `Behavior will snap the dialog down if translationY is at least equal to half the toolbarHeight`() {
val behavior = spyk(DynamicDownloadDialogBehavior<View>(testContext, attrs = null,
bottomToolbarHeight = 10f))
val behavior = spyk(
DynamicDownloadDialogBehavior<View>(
testContext, attrs = null,
bottomToolbarHeight = 10f
)
)
every { behavior.shouldScroll } returns true
val animator: ValueAnimator = mockk(relaxed = true)

@ -47,19 +47,25 @@ class TabCollectionTest {
)
assertEquals(4, collections.getDefaultCollectionNumber())
collections.add(mockk {
collections.add(
mockk {
every { title } returns "Collection 5"
})
}
)
assertEquals(6, collections.getDefaultCollectionNumber())
collections.add(mockk {
collections.add(
mockk {
every { title } returns "Random name"
})
}
)
assertEquals(6, collections.getDefaultCollectionNumber())
collections.add(mockk {
collections.add(
mockk {
every { title } returns "Collection 10 10"
})
}
)
assertEquals(6, collections.getDefaultCollectionNumber())
}

@ -398,7 +398,8 @@ class HistoryMetadataMiddlewareTest {
}
private fun setupGoogleSearchEngine() {
store.dispatch(SearchAction.SetSearchEnginesAction(
store.dispatch(
SearchAction.SetSearchEnginesAction(
regionSearchEngines = listOf(
SearchEngine(
id = "google",
@ -416,6 +417,7 @@ class HistoryMetadataMiddlewareTest {
additionalAvailableSearchEngines = emptyList(),
additionalSearchEngines = emptyList(),
regionSearchEnginesOrder = listOf("google")
)).joinBlocking()
)
).joinBlocking()
}
}

@ -145,7 +145,8 @@ class DefaultSessionControlControllerTest {
val restoreUseCase: TabsUseCases.RestoreUseCase = mockk(relaxed = true)
controller = spyk(DefaultSessionControlController(
controller = spyk(
DefaultSessionControlController(
activity = activity,
store = store,
settings = settings,
@ -164,7 +165,8 @@ class DefaultSessionControlControllerTest {
showDeleteCollectionPrompt = showDeleteCollectionPrompt,
showTabTray = showTabTray,
handleSwipedItemDeletionCancel = handleSwipedItemDeletionCancel
))
)
)
}
@After

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save