Skip to content

Commit

Permalink
For mozilla-mobile#24703 - Replace Mockito mocks with Mockk mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandru2909 authored and mergify[bot] committed Apr 11, 2022
1 parent 525188d commit 08ce8fb
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 26 deletions.
10 changes: 5 additions & 5 deletions app/src/test/java/org/mozilla/fenix/ext/SearchEngineTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

package org.mozilla.fenix.ext

import io.mockk.mockk
import mozilla.components.browser.state.search.SearchEngine
import mozilla.components.support.test.mock
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
Expand All @@ -18,7 +18,7 @@ class SearchEngineTest {
val searchEngine = SearchEngine(
id = UUID.randomUUID().toString(),
name = "Not custom",
icon = mock(),
icon = mockk(),
type = SearchEngine.Type.BUNDLED,
resultUrls = listOf(
"https://www.startpage.com/sp/search?q={searchTerms}"
Expand All @@ -28,7 +28,7 @@ class SearchEngineTest {
val customSearchEngine = SearchEngine(
id = UUID.randomUUID().toString(),
name = "Custom",
icon = mock(),
icon = mockk(),
type = SearchEngine.Type.CUSTOM,
resultUrls = listOf(
"https://www.startpage.com/sp/search?q={searchTerms}"
Expand All @@ -44,7 +44,7 @@ class SearchEngineTest {
val searchEngine = SearchEngine(
id = UUID.randomUUID().toString(),
name = "Not well known",
icon = mock(),
icon = mockk(),
type = SearchEngine.Type.BUNDLED,
resultUrls = listOf(
"https://www.random.com/sp/search?q={searchTerms}"
Expand All @@ -54,7 +54,7 @@ class SearchEngineTest {
val wellKnownSearchEngine = SearchEngine(
id = UUID.randomUUID().toString(),
name = "Well known",
icon = mock(),
icon = mockk(),
type = SearchEngine.Type.CUSTOM,
resultUrls = listOf(
"https://www.startpage.com/sp/search?q={searchTerms}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ package org.mozilla.fenix.settings.quicksettings
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.mockk
import mozilla.components.concept.engine.permission.SitePermissions
import mozilla.components.concept.engine.permission.SitePermissions.AutoplayStatus
import mozilla.components.feature.sitepermissions.SitePermissionsRules
import mozilla.components.feature.sitepermissions.SitePermissionsRules.AutoplayAction
import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertTrue
import org.junit.Assert.assertFalse
Expand Down Expand Up @@ -292,7 +292,7 @@ class AutoplayValueTest {

val value = AutoplayValue.AllowAll(
label = "label",
rules = mock(),
rules = mockk(),
sitePermission = null
)

Expand All @@ -319,7 +319,7 @@ class AutoplayValueTest {

val value = AutoplayValue.BlockAll(
label = "label",
rules = mock(),
rules = mockk(),
sitePermission = null
)

Expand All @@ -346,7 +346,7 @@ class AutoplayValueTest {

val value = AutoplayValue.BlockAudible(
label = "label",
rules = mock(),
rules = mockk(),
sitePermission = null
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import mozilla.components.concept.engine.permission.SitePermissions.Status.NO_DE
import mozilla.components.feature.session.SessionUseCases
import mozilla.components.feature.session.TrackingProtectionUseCases
import mozilla.components.service.glean.testing.GleanTestRule
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import org.junit.After
import org.junit.Assert.assertArrayEquals
Expand Down Expand Up @@ -231,7 +230,7 @@ class DefaultQuickSettingsControllerTest {
every { store.dispatch(any()) } returns mockk()
every { controller.handleAutoplayAdd(any()) } returns Unit
every { controller.handlePermissionsChange(any()) } returns Unit
every { autoplayValue.updateSitePermissions(any()) } returns mock()
every { autoplayValue.updateSitePermissions(any()) } returns mockk()

controller.handleAutoplayChanged(autoplayValue)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import mozilla.components.concept.engine.permission.SitePermissions
import mozilla.components.feature.sitepermissions.SitePermissionsRules
import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action
import mozilla.components.feature.sitepermissions.SitePermissionsRules.AutoplayAction
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
Expand Down Expand Up @@ -284,7 +283,7 @@ class QuickSettingsFragmentStoreTest {
val initialState = QuickSettingsFragmentState(
webInfoState = websiteInfoState,
websitePermissionsState = initialWebsitePermissionsState,
trackingProtectionState = mock()
trackingProtectionState = mockk()
)
val store = QuickSettingsFragmentStore(initialState)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import io.mockk.spyk
import io.mockk.MockKAnnotations
import io.mockk.verify
import io.mockk.impl.annotations.MockK
import io.mockk.mockk
import junit.framework.TestCase.assertFalse
import junit.framework.TestCase.assertTrue
import junit.framework.TestCase.assertEquals
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import org.junit.Before
import org.junit.Test
Expand Down Expand Up @@ -157,17 +157,17 @@ class WebsitePermissionViewTest {
val options = listOf(
AutoplayValue.BlockAll(
label = "BlockAll",
rules = mock(),
rules = mockk(),
sitePermission = null
),
AutoplayValue.AllowAll(
label = "AllowAll",
rules = mock(),
rules = mockk(),
sitePermission = null
),
AutoplayValue.BlockAudible(
label = "BlockAudible",
rules = mock(),
rules = mockk(),
sitePermission = null
)
)
Expand All @@ -189,7 +189,7 @@ class WebsitePermissionViewTest {
assertEquals(permission.autoplayValue, permissionView.status.selectedItem)

permissionView.status.onItemSelectedListener!!.onItemSelected(
mock(),
mockk(),
permissionView.status,
1,
0L
Expand All @@ -200,7 +200,7 @@ class WebsitePermissionViewTest {

permissionView.status.setSelection(2)
permissionView.status.onItemSelectedListener!!.onItemSelected(
mock(),
mockk(),
permissionView.status,
2,
0L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import mozilla.components.concept.engine.permission.SitePermissions.AutoplayStat
import mozilla.components.feature.sitepermissions.SitePermissionsRules
import mozilla.components.feature.sitepermissions.SitePermissionsRules.AutoplayAction
import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertTrue
import org.junit.Assert.assertFalse
Expand Down Expand Up @@ -448,7 +447,7 @@ class SitePermissionsManageExceptionsPhoneFeatureFragmentTest {

val value = AutoplayValue.AllowAll(
label = "label",
rules = mock(),
rules = mockk(),
sitePermission = null
)

Expand Down Expand Up @@ -476,7 +475,7 @@ class SitePermissionsManageExceptionsPhoneFeatureFragmentTest {

val value = AutoplayValue.BlockAll(
label = "label",
rules = mock(),
rules = mockk(),
sitePermission = null
)

Expand Down Expand Up @@ -504,7 +503,7 @@ class SitePermissionsManageExceptionsPhoneFeatureFragmentTest {

val value = AutoplayValue.BlockAudible(
label = "label",
rules = mock(),
rules = mockk(),
sitePermission = null
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.net.ConnectivityManager
import io.mockk.mockk
import io.mockk.spyk
import io.mockk.verify
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertTrue
import org.junit.Assert.assertFalse
Expand Down Expand Up @@ -142,7 +141,7 @@ class WifiConnectionMonitorTest {
val callback: (Boolean) -> Unit = { wasNotified = it }

wifiConnectionMonitor.addOnWifiConnectedChangedListener(callback)
wifiConnectionMonitor.frameworkListener.onLost(mock())
wifiConnectionMonitor.frameworkListener.onLost(mockk())

assertFalse(wasNotified!!)
}
Expand All @@ -154,7 +153,7 @@ class WifiConnectionMonitorTest {
val callback: (Boolean) -> Unit = { wasNotified = it }

wifiConnectionMonitor.addOnWifiConnectedChangedListener(callback)
wifiConnectionMonitor.frameworkListener.onAvailable(mock())
wifiConnectionMonitor.frameworkListener.onAvailable(mockk())

assertTrue(wasNotified!!)
}
Expand Down

0 comments on commit 08ce8fb

Please sign in to comment.