parent
e1fc0cc038
commit
4dd0c0f224
|
@ -81,25 +81,28 @@ class AddonDetailsViewTest {
|
|||
|
||||
@Test
|
||||
fun `bind addons version`() {
|
||||
detailsView.bind(baseAddon.copy(
|
||||
val addon1 = baseAddon.copy(
|
||||
version = "1.0.0",
|
||||
installedState = null
|
||||
))
|
||||
)
|
||||
|
||||
detailsView.bind(addon1)
|
||||
assertEquals("1.0.0", view.version_text.text)
|
||||
view.version_text.performLongClick()
|
||||
verify(exactly = 0) { interactor.showUpdaterDialog(any()) }
|
||||
verify(exactly = 0) { interactor.showUpdaterDialog(addon1) }
|
||||
|
||||
detailsView.bind(baseAddon.copy(
|
||||
val addon2 = baseAddon.copy(
|
||||
version = "1.0.0",
|
||||
installedState = Addon.InstalledState(
|
||||
id = "",
|
||||
version = "2.0.0",
|
||||
optionsPageUrl = null
|
||||
)
|
||||
))
|
||||
)
|
||||
detailsView.bind(addon2)
|
||||
assertEquals("2.0.0", view.version_text.text)
|
||||
view.version_text.performLongClick()
|
||||
verify { interactor.showUpdaterDialog(any()) }
|
||||
verify { interactor.showUpdaterDialog(addon2) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -32,12 +32,12 @@ class DefaultBrowsingModeManagerTest {
|
|||
manager.mode = BrowsingMode.Private
|
||||
manager.mode = BrowsingMode.Private
|
||||
|
||||
verify(exactly = 3) { callback.invoke(any()) }
|
||||
verify(exactly = 3) { callback.invoke(BrowsingMode.Private) }
|
||||
|
||||
manager.mode = BrowsingMode.Normal
|
||||
manager.mode = BrowsingMode.Normal
|
||||
|
||||
verify(exactly = 5) { callback.invoke(any()) }
|
||||
verify(exactly = 2) { callback.invoke(BrowsingMode.Normal) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -13,6 +13,7 @@ import mozilla.components.lib.crash.Crash
|
|||
import mozilla.components.lib.crash.CrashReporter
|
||||
import mozilla.components.lib.crash.service.CrashReporterService
|
||||
import mozilla.components.support.base.crash.Breadcrumb
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
internal class BreadcrumbRecorderTest {
|
||||
|
@ -36,17 +37,18 @@ internal class BreadcrumbRecorderTest {
|
|||
)
|
||||
)
|
||||
|
||||
fun getBreadcrumbMessage(@Suppress("UNUSED_PARAMETER") destination: NavDestination): String {
|
||||
return "test"
|
||||
}
|
||||
|
||||
val navController: NavController = mockk()
|
||||
val navDestination: NavDestination = mockk()
|
||||
|
||||
val breadCrumbRecorder =
|
||||
BreadcrumbsRecorder(reporter, navController, ::getBreadcrumbMessage)
|
||||
val breadCrumbRecorder = BreadcrumbsRecorder(reporter, navController) { "test" }
|
||||
breadCrumbRecorder.onDestinationChanged(navController, navDestination, null)
|
||||
|
||||
verify { reporter.recordCrashBreadcrumb(any()) }
|
||||
verify {
|
||||
reporter.recordCrashBreadcrumb(withArg {
|
||||
assertEquals("test", it.message)
|
||||
assertEquals("DestinationChanged", it.category)
|
||||
assertEquals(Breadcrumb.Level.INFO, it.level)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.content.Intent.ACTION_VIEW
|
||||
import androidx.core.net.toUri
|
||||
import io.mockk.MockKMatcherScope
|
||||
import io.mockk.Runs
|
||||
import io.mockk.every
|
||||
import io.mockk.just
|
||||
|
@ -32,6 +31,7 @@ import org.mozilla.fenix.R
|
|||
import org.mozilla.fenix.components.metrics.MozillaProductDetector
|
||||
import org.mozilla.fenix.components.metrics.MozillaProductDetector.MozillaProducts
|
||||
import org.mozilla.fenix.components.tips.TipType
|
||||
import org.mozilla.fenix.ext.intentFilterEq
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||
import org.mozilla.fenix.settings.SupportUtils
|
||||
|
@ -205,7 +205,4 @@ class MigrationTipProviderTest {
|
|||
every { settings.shouldDisplayFenixMovingTip() } returns true
|
||||
assertTrue(MigrationTipProvider(context).shouldDisplay)
|
||||
}
|
||||
|
||||
private fun MockKMatcherScope.intentFilterEq(value: Intent): Intent =
|
||||
match { it.filterEquals(value) }
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.mozilla.fenix.ext
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.navigation.NavDirections
|
||||
import io.mockk.Matcher
|
||||
import io.mockk.MockKMatcherScope
|
||||
|
@ -11,6 +12,13 @@ import mozilla.components.support.ktx.android.os.contentEquals
|
|||
*/
|
||||
fun MockKMatcherScope.directionsEq(value: NavDirections) = match(EqNavDirectionsMatcher(value))
|
||||
|
||||
/**
|
||||
* Verify that two intents are the same for the purposes of intent resolution (filtering).
|
||||
* Checks if their action, data, type, identity, class, and categories are the same.
|
||||
* Does not compare extras.
|
||||
*/
|
||||
fun MockKMatcherScope.intentFilterEq(value: Intent) = match(EqIntentFilterMatcher(value))
|
||||
|
||||
private data class EqNavDirectionsMatcher(private val value: NavDirections) : Matcher<NavDirections> {
|
||||
|
||||
override fun match(arg: NavDirections?): Boolean =
|
||||
|
@ -19,3 +27,13 @@ private data class EqNavDirectionsMatcher(private val value: NavDirections) : Ma
|
|||
override fun substitute(map: Map<Any, Any>) =
|
||||
copy(value = value.internalSubstitute(map))
|
||||
}
|
||||
|
||||
private data class EqIntentFilterMatcher(private val value: Intent) : Matcher<Intent> {
|
||||
|
||||
override fun match(arg: Intent?): Boolean = value.filterEquals(arg)
|
||||
|
||||
override fun substitute(map: Map<Any, Any>) =
|
||||
copy(value = value.internalSubstitute(map))
|
||||
|
||||
override fun toString() = "intentFilterEq($value)"
|
||||
}
|
||||
|
|
|
@ -128,9 +128,21 @@ class DefaultSessionControlControllerTest {
|
|||
|
||||
@Test
|
||||
fun handleDeleteCollectionTapped() {
|
||||
val collection: TabCollection = mockk(relaxed = true)
|
||||
val collection = mockk<TabCollection> {
|
||||
every { title } returns "Collection"
|
||||
}
|
||||
every {
|
||||
activity.resources.getString(R.string.tab_collection_dialog_message, "Collection")
|
||||
} returns "Are you sure you want to delete Collection?"
|
||||
|
||||
controller.handleDeleteCollectionTapped(collection)
|
||||
verify { showDeleteCollectionPrompt(collection, null, any()) }
|
||||
verify {
|
||||
showDeleteCollectionPrompt(
|
||||
collection,
|
||||
null,
|
||||
"Are you sure you want to delete Collection?"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package org.mozilla.fenix.search
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavDirections
|
||||
import io.mockk.every
|
||||
|
@ -24,7 +25,9 @@ import org.mozilla.fenix.HomeActivity
|
|||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.components.metrics.MetricController
|
||||
import org.mozilla.fenix.crashes.CrashListActivity
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.intentFilterEq
|
||||
import org.mozilla.fenix.ext.metrics
|
||||
import org.mozilla.fenix.ext.navigateSafe
|
||||
import org.mozilla.fenix.ext.searchEngineManager
|
||||
|
@ -88,10 +91,13 @@ class DefaultSearchControllerTest {
|
|||
@Test
|
||||
fun handleCrashesUrlCommitted() {
|
||||
val url = "about:crashes"
|
||||
every { activity.packageName } returns testContext.packageName
|
||||
|
||||
controller.handleUrlCommitted(url)
|
||||
|
||||
verify { activity.startActivity(any()) }
|
||||
verify {
|
||||
activity.startActivity(intentFilterEq(Intent(testContext, CrashListActivity::class.java)))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -61,7 +61,7 @@ class InContentTelemetryTest {
|
|||
|
||||
telemetry.processMessage(message)
|
||||
|
||||
verify { telemetry.trackPartnerUrlTypeMetric(url, any()) }
|
||||
verify { telemetry.trackPartnerUrlTypeMetric(url, listOf(first, second)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -54,7 +54,7 @@ class DefaultDeleteBrowsingDataControllerTest {
|
|||
controller.deleteBrowsingData()
|
||||
|
||||
verify {
|
||||
context.components.core.engine.clearData(any())
|
||||
context.components.core.engine.clearData(Engine.BrowsingData.select(Engine.BrowsingData.DOM_STORAGES))
|
||||
context.components.core.historyStorage
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue