1
0
Fork 0

For #9631: replace assertk assertions with junit.

I created a series of editor macros to do this with minimal errors (and
to do it quickly!).
master
Michael Comella 2020-04-02 09:52:56 -07:00 committed by Michael Comella
parent c632b93ee7
commit 376740cd2c
17 changed files with 270 additions and 417 deletions

View File

@ -6,8 +6,6 @@ package org.mozilla.fenix
import android.net.ConnectivityManager import android.net.ConnectivityManager
import androidx.core.content.getSystemService import androidx.core.content.getSystemService
import assertk.assertThat
import assertk.assertions.isEqualTo
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
import io.mockk.mockkStatic import io.mockk.mockkStatic
@ -15,6 +13,7 @@ import mozilla.components.browser.errorpages.ErrorPages
import mozilla.components.browser.errorpages.ErrorType import mozilla.components.browser.errorpages.ErrorType
import mozilla.components.concept.engine.request.RequestInterceptor import mozilla.components.concept.engine.request.RequestInterceptor
import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@ -67,7 +66,7 @@ class AppRequestInterceptorTest {
html = LOW_AND_MEDIUM_RISK_ERROR_PAGES html = LOW_AND_MEDIUM_RISK_ERROR_PAGES
) )
assertThat(actualPage).isEqualTo(expectedPage) assertEquals(expectedPage, actualPage)
} }
} }
@ -84,7 +83,7 @@ class AppRequestInterceptorTest {
html = LOW_AND_MEDIUM_RISK_ERROR_PAGES html = LOW_AND_MEDIUM_RISK_ERROR_PAGES
) )
assertThat(actualPage).isEqualTo(expectedPage) assertEquals(expectedPage, actualPage)
} }
} }
@ -102,7 +101,7 @@ class AppRequestInterceptorTest {
html = HIGH_RISK_ERROR_PAGES html = HIGH_RISK_ERROR_PAGES
) )
assertThat(actualPage).isEqualTo(expectedPage) assertEquals(expectedPage, actualPage)
} }
} }

View File

@ -4,12 +4,6 @@
package org.mozilla.fenix.collections package org.mozilla.fenix.collections
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import assertk.assertThat
import assertk.assertions.isNotNull
import assertk.assertions.isNull
import assertk.assertions.isTrue
import mozilla.components.support.test.robolectric.createAddedTestFragment
import io.mockk.MockKAnnotations import io.mockk.MockKAnnotations
import io.mockk.every import io.mockk.every
import io.mockk.impl.annotations.MockK import io.mockk.impl.annotations.MockK
@ -23,10 +17,15 @@ import mozilla.components.browser.state.state.BrowserState
import mozilla.components.browser.state.store.BrowserStore import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.feature.tab.collections.Tab import mozilla.components.feature.tab.collections.Tab
import mozilla.components.lib.publicsuffixlist.PublicSuffixList import mozilla.components.lib.publicsuffixlist.PublicSuffixList
import mozilla.components.support.test.robolectric.createAddedTestFragment
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
private const val URL_MOZILLA = "www.mozilla.org" private const val URL_MOZILLA = "www.mozilla.org"
private const val SESSION_ID_MOZILLA = "0" private const val SESSION_ID_MOZILLA = "0"
@ -72,10 +71,10 @@ class CollectionCreationFragmentTest {
} }
} }
assertThat(fragment.dialog).isNotNull() assertNotNull(fragment.dialog)
assertThat(fragment.requireDialog().isShowing).isTrue() assertTrue(fragment.requireDialog().isShowing)
fragment.dismiss() fragment.dismiss()
assertThat(fragment.dialog).isNull() assertNull(fragment.dialog)
} }
@Test @Test

View File

@ -4,14 +4,10 @@
package org.mozilla.fenix.ext package org.mozilla.fenix.ext
import assertk.assertThat
import assertk.assertions.contains
import assertk.assertions.doesNotContain
import assertk.assertions.isEqualTo
import assertk.assertions.isFalse
import assertk.assertions.isTrue
import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Ignore import org.junit.Ignore
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@ -50,13 +46,13 @@ class StringTest {
val split = display.split(".") val split = display.split(".")
// If the list ends with 25.com... // If the list ends with 25.com...
assertThat(split.dropLast(1).last()).isEqualTo("25") assertEquals("25", split.dropLast(1).last())
// ...and each value is 1 larger than the last... // ...and each value is 1 larger than the last...
split.dropLast(1) split.dropLast(1)
.map { it.toInt() } .map { it.toInt() }
.windowed(2, 1) .windowed(2, 1)
.forEach { (prev, next) -> .forEach { (prev, next) ->
assertThat(prev + 1).isEqualTo(next) assertEquals(next, prev + 1)
} }
// ...that means that all removed values came from the front of the list // ...that means that all removed values came from the front of the list
} }
@ -67,7 +63,7 @@ class StringTest {
// See https://chromium.googlesource.com/chromium/src/+/master/docs/security/url_display_guidelines/url_display_guidelines.md#eliding-urls // See https://chromium.googlesource.com/chromium/src/+/master/docs/security/url_display_guidelines/url_display_guidelines.md#eliding-urls
val bigRegistrableDomain = "evil-but-also-shockingly-long-registrable-domain.com" val bigRegistrableDomain = "evil-but-also-shockingly-long-registrable-domain.com"
assertThat("https://login.your-bank.com.$bigRegistrableDomain/enter/your/password".shortened()).contains(bigRegistrableDomain) assertTrue("https://login.your-bank.com.$bigRegistrableDomain/enter/your/password".shortened().contains(bigRegistrableDomain))
} }
@Test @Test
@ -75,10 +71,10 @@ class StringTest {
// See https://url.spec.whatwg.org/#url-rendering-simplification // See https://url.spec.whatwg.org/#url-rendering-simplification
// See https://chromium.googlesource.com/chromium/src/+/master/docs/security/url_display_guidelines/url_display_guidelines.md#simplify // See https://chromium.googlesource.com/chromium/src/+/master/docs/security/url_display_guidelines/url_display_guidelines.md#simplify
assertThat("https://examplecorp.com@attacker.example/".shortened()).doesNotContain("examplecorp") assertFalse("https://examplecorp.com@attacker.example/".shortened().contains("examplecorp"))
assertThat("https://examplecorp.com@attacker.example/".shortened()).doesNotContain("com") assertFalse("https://examplecorp.com@attacker.example/".shortened().contains("com"))
assertThat("https://user:password@example.com/".shortened()).doesNotContain("user") assertFalse("https://user:password@example.com/".shortened().contains("user"))
assertThat("https://user:password@example.com/".shortened()).doesNotContain("password") assertFalse("https://user:password@example.com/".shortened().contains("password"))
} }
@Test @Test
@ -207,39 +203,39 @@ class StringTest {
// (https://searchfox.org/mozilla-mobile/source/firefox-echo-show/app/src/test/java/org/mozilla/focus/utils/TestFormattedDomain.java#228) // (https://searchfox.org/mozilla-mobile/source/firefox-echo-show/app/src/test/java/org/mozilla/focus/utils/TestFormattedDomain.java#228)
@Test @Test
fun testIsIPv4RealAddress() { fun testIsIPv4RealAddress() {
assertThat("192.168.1.1".isIpv4()).isTrue() assertTrue("192.168.1.1".isIpv4())
assertThat("8.8.8.8".isIpv4()).isTrue() assertTrue("8.8.8.8".isIpv4())
assertThat("63.245.215.20".isIpv4()).isTrue() assertTrue("63.245.215.20".isIpv4())
} }
@Test @Test
fun testIsIPv4WithProtocol() { fun testIsIPv4WithProtocol() {
assertThat("http://8.8.8.8".isIpv4()).isFalse() assertFalse("http://8.8.8.8".isIpv4())
assertThat("https://8.8.8.8".isIpv4()).isFalse() assertFalse("https://8.8.8.8".isIpv4())
} }
@Test @Test
fun testIsIPv4WithPort() { fun testIsIPv4WithPort() {
assertThat("8.8.8.8:400".isIpv4()).isFalse() assertFalse("8.8.8.8:400".isIpv4())
assertThat("8.8.8.8:1337".isIpv4()).isFalse() assertFalse("8.8.8.8:1337".isIpv4())
} }
@Test @Test
fun testIsIPv4WithPath() { fun testIsIPv4WithPath() {
assertThat("8.8.8.8/index.html".isIpv4()).isFalse() assertFalse("8.8.8.8/index.html".isIpv4())
assertThat("8.8.8.8/".isIpv4()).isFalse() assertFalse("8.8.8.8/".isIpv4())
} }
@Test @Test
fun testIsIPv4WithIPv6() { fun testIsIPv4WithIPv6() {
assertThat("2001:db8::1 ".isIpv4()).isFalse() assertFalse("2001:db8::1 ".isIpv4())
assertThat("2001:db8:0:1:1:1:1:1".isIpv4()).isFalse() assertFalse("2001:db8:0:1:1:1:1:1".isIpv4())
assertThat("[2001:db8:a0b:12f0::1]".isIpv4()).isFalse() assertFalse("[2001:db8:a0b:12f0::1]".isIpv4())
} }
// END test cases borrowed from FFTV // END test cases borrowed from FFTV
private infix fun String.shortenedShouldBecome(expect: String) { private infix fun String.shortenedShouldBecome(expect: String) {
assertThat(this.shortened()).isEqualTo(expect) assertEquals(expect, this.shortened())
} }
private fun String.shortened() = this.toShortUrl(publicSuffixList) private fun String.shortened() = this.toShortUrl(publicSuffixList)

View File

@ -5,8 +5,6 @@
package org.mozilla.fenix.home package org.mozilla.fenix.home
import android.content.Context import android.content.Context
import assertk.assertThat
import assertk.assertions.isEqualTo
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
@ -65,26 +63,26 @@ class HomeFragmentStoreTest {
@Test @Test
fun `Test toggling the mode in HomeFragmentStore`() = runBlocking { fun `Test toggling the mode in HomeFragmentStore`() = runBlocking {
// Verify that the default mode and tab states of the HomeFragment are correct. // Verify that the default mode and tab states of the HomeFragment are correct.
assertThat(homeFragmentStore.state.mode).isEqualTo(Mode.Normal) assertEquals(Mode.Normal, homeFragmentStore.state.mode)
assertEquals(0, homeFragmentStore.state.tabs.size) assertEquals(0, homeFragmentStore.state.tabs.size)
// Change the HomeFragmentStore to Private mode. // Change the HomeFragmentStore to Private mode.
homeFragmentStore.dispatch(HomeFragmentAction.ModeChange(Mode.Private)).join() homeFragmentStore.dispatch(HomeFragmentAction.ModeChange(Mode.Private)).join()
assertThat(homeFragmentStore.state.mode).isEqualTo(Mode.Private) assertEquals(Mode.Private, homeFragmentStore.state.mode)
assertEquals(0, homeFragmentStore.state.tabs.size) assertEquals(0, homeFragmentStore.state.tabs.size)
// Change the HomeFragmentStore back to Normal mode. // Change the HomeFragmentStore back to Normal mode.
homeFragmentStore.dispatch(HomeFragmentAction.ModeChange(Mode.Normal)).join() homeFragmentStore.dispatch(HomeFragmentAction.ModeChange(Mode.Normal)).join()
assertThat(homeFragmentStore.state.mode).isEqualTo(Mode.Normal) assertEquals(Mode.Normal, homeFragmentStore.state.mode)
assertEquals(0, homeFragmentStore.state.tabs.size) assertEquals(0, homeFragmentStore.state.tabs.size)
} }
@Test @Test
fun `Test toggling the mode with tabs in HomeFragmentStore`() = runBlocking { fun `Test toggling the mode with tabs in HomeFragmentStore`() = runBlocking {
// Verify that the default mode and tab states of the HomeFragment are correct. // Verify that the default mode and tab states of the HomeFragment are correct.
assertThat(homeFragmentStore.state.mode).isEqualTo(Mode.Normal) assertEquals(Mode.Normal, homeFragmentStore.state.mode)
assertEquals(0, homeFragmentStore.state.tabs.size) assertEquals(0, homeFragmentStore.state.tabs.size)
// Add 2 Tabs to the HomeFragmentStore. // Add 2 Tabs to the HomeFragmentStore.
@ -96,7 +94,7 @@ class HomeFragmentStoreTest {
// Change the HomeFragmentStore to Private mode. // Change the HomeFragmentStore to Private mode.
homeFragmentStore.dispatch(HomeFragmentAction.ModeChange(Mode.Private)).join() homeFragmentStore.dispatch(HomeFragmentAction.ModeChange(Mode.Private)).join()
assertThat(homeFragmentStore.state.mode).isEqualTo(Mode.Private) assertEquals(Mode.Private, homeFragmentStore.state.mode)
assertEquals(0, homeFragmentStore.state.tabs.size) assertEquals(0, homeFragmentStore.state.tabs.size)
} }
@ -108,7 +106,7 @@ class HomeFragmentStoreTest {
val tabCollections: List<TabCollection> = listOf(mockk(), mockk()) val tabCollections: List<TabCollection> = listOf(mockk(), mockk())
homeFragmentStore.dispatch(HomeFragmentAction.CollectionsChange(tabCollections)).join() homeFragmentStore.dispatch(HomeFragmentAction.CollectionsChange(tabCollections)).join()
assertThat(homeFragmentStore.state.collections).isEqualTo(tabCollections) assertEquals(tabCollections, homeFragmentStore.state.collections)
} }
@Test @Test
@ -119,7 +117,7 @@ class HomeFragmentStoreTest {
val topSites: List<TopSite> = listOf(mockk(), mockk()) val topSites: List<TopSite> = listOf(mockk(), mockk())
homeFragmentStore.dispatch(HomeFragmentAction.TopSitesChange(topSites)).join() homeFragmentStore.dispatch(HomeFragmentAction.TopSitesChange(topSites)).join()
assertThat(homeFragmentStore.state.topSites).isEqualTo(topSites) assertEquals(topSites, homeFragmentStore.state.topSites)
} }
@Test @Test
@ -154,7 +152,7 @@ class HomeFragmentStoreTest {
assertEquals(0, homeFragmentStore.state.collections.size) assertEquals(0, homeFragmentStore.state.collections.size)
assertEquals(0, homeFragmentStore.state.tabs.size) assertEquals(0, homeFragmentStore.state.tabs.size)
assertEquals(0, homeFragmentStore.state.topSites.size) assertEquals(0, homeFragmentStore.state.topSites.size)
assertThat(homeFragmentStore.state.mode).isEqualTo(Mode.Normal) assertEquals(Mode.Normal, homeFragmentStore.state.mode)
val collections: List<TabCollection> = listOf(mockk()) val collections: List<TabCollection> = listOf(mockk())
val tabs: List<Tab> = listOf(mockk(), mockk()) val tabs: List<Tab> = listOf(mockk(), mockk())
@ -170,7 +168,7 @@ class HomeFragmentStoreTest {
).join() ).join()
assertEquals(1, homeFragmentStore.state.collections.size) assertEquals(1, homeFragmentStore.state.collections.size)
assertThat(homeFragmentStore.state.mode).isEqualTo(Mode.Private) assertEquals(Mode.Private, homeFragmentStore.state.mode)
assertEquals(2, homeFragmentStore.state.tabs.size) assertEquals(2, homeFragmentStore.state.tabs.size)
assertEquals(2, homeFragmentStore.state.topSites.size) assertEquals(2, homeFragmentStore.state.topSites.size)
} }

View File

@ -6,11 +6,6 @@ package org.mozilla.fenix.home.intent
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import assertk.assertAll
import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isFalse
import assertk.assertions.isTrue
import io.mockk.Called import io.mockk.Called
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
@ -23,6 +18,9 @@ import mozilla.components.browser.session.SessionManager
import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.EngineSession
import mozilla.components.feature.intent.ext.getSessionId import mozilla.components.feature.intent.ext.getSessionId
import mozilla.components.feature.session.SessionUseCases import mozilla.components.feature.session.SessionUseCases
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mozilla.fenix.home.intent.FennecBookmarkShortcutsIntentProcessor.Companion.ACTION_FENNEC_HOMESCREEN_SHORTCUT import org.mozilla.fenix.home.intent.FennecBookmarkShortcutsIntentProcessor.Companion.ACTION_FENNEC_HOMESCREEN_SHORTCUT
@ -42,7 +40,7 @@ class FennecBookmarkShortcutsIntentProcessorTest {
val wasEmptyIntentProcessed = processor.process(Intent()) val wasEmptyIntentProcessed = processor.process(Intent())
assertThat(wasEmptyIntentProcessed).isFalse() assertFalse(wasEmptyIntentProcessed)
verify { verify {
sessionManager wasNot Called sessionManager wasNot Called
loadUrlUseCase wasNot Called loadUrlUseCase wasNot Called
@ -62,11 +60,9 @@ class FennecBookmarkShortcutsIntentProcessorTest {
val wasIntentProcessed = processor.process(fennecShortcutsIntent) val wasIntentProcessed = processor.process(fennecShortcutsIntent)
assertAll { assertTrue(wasIntentProcessed)
assertThat(wasIntentProcessed).isTrue() assertEquals(Intent.ACTION_VIEW, fennecShortcutsIntent.action)
assertThat(fennecShortcutsIntent.action).isEqualTo(Intent.ACTION_VIEW) assertEquals(expectedSession.id, fennecShortcutsIntent.getSessionId())
assertThat(fennecShortcutsIntent.getSessionId()).isEqualTo(expectedSession.id)
}
verifyAll { verifyAll {
sessionManager.add(expectedSession, true) sessionManager.add(expectedSession, true)
loadUrlUseCase(testUrl, expectedSession, EngineSession.LoadUrlFlags.external()) loadUrlUseCase(testUrl, expectedSession, EngineSession.LoadUrlFlags.external())

View File

@ -4,11 +4,10 @@
package org.mozilla.fenix.library.bookmarks package org.mozilla.fenix.library.bookmarks
import assertk.assertThat
import assertk.assertions.isEqualTo
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType import mozilla.components.concept.storage.BookmarkNodeType
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse import org.junit.Assert.assertFalse
import org.junit.Assert.assertSame import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
@ -21,12 +20,12 @@ class BookmarkFragmentStoreTest {
val initialState = BookmarkFragmentState(null) val initialState = BookmarkFragmentState(null)
val store = BookmarkFragmentStore(initialState) val store = BookmarkFragmentStore(initialState)
assertThat(BookmarkFragmentState(null, BookmarkFragmentState.Mode.Normal())).isEqualTo(store.state) assertEquals(store.state, BookmarkFragmentState(null, BookmarkFragmentState.Mode.Normal()))
store.dispatch(BookmarkFragmentAction.Change(tree)).join() store.dispatch(BookmarkFragmentAction.Change(tree)).join()
assertThat(tree).isEqualTo(store.state.tree) assertEquals(store.state.tree, tree)
assertThat(initialState.mode).isEqualTo(store.state.mode) assertEquals(store.state.mode, initialState.mode)
} }
@Test @Test
@ -34,12 +33,12 @@ class BookmarkFragmentStoreTest {
val initialState = BookmarkFragmentState(tree) val initialState = BookmarkFragmentState(tree)
val store = BookmarkFragmentStore(initialState) val store = BookmarkFragmentStore(initialState)
assertThat(BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Normal())).isEqualTo(store.state) assertEquals(store.state, BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Normal()))
store.dispatch(BookmarkFragmentAction.Change(newTree)).join() store.dispatch(BookmarkFragmentAction.Change(newTree)).join()
assertThat(newTree).isEqualTo(store.state.tree) assertEquals(store.state.tree, newTree)
assertThat(initialState.mode).isEqualTo(store.state.mode) assertEquals(store.state.mode, initialState.mode)
} }
@Test @Test
@ -47,12 +46,12 @@ class BookmarkFragmentStoreTest {
val initialState = BookmarkFragmentState(tree) val initialState = BookmarkFragmentState(tree)
val store = BookmarkFragmentStore(initialState) val store = BookmarkFragmentStore(initialState)
assertThat(BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Normal())).isEqualTo(store.state) assertEquals(store.state, BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Normal()))
store.dispatch(BookmarkFragmentAction.Change(tree)).join() store.dispatch(BookmarkFragmentAction.Change(tree)).join()
assertThat(initialState.tree).isEqualTo(store.state.tree) assertEquals(store.state.tree, initialState.tree)
assertThat(initialState.mode).isEqualTo(store.state.mode) assertEquals(store.state.mode, initialState.mode)
} }
@Test @Test
@ -62,8 +61,8 @@ class BookmarkFragmentStoreTest {
store.dispatch(BookmarkFragmentAction.Change(newTree)).join() store.dispatch(BookmarkFragmentAction.Change(newTree)).join()
assertThat(newTree).isEqualTo(store.state.tree) assertEquals(store.state.tree, newTree)
assertThat(BookmarkFragmentState.Mode.Selecting(setOf(subfolder))).isEqualTo(store.state.mode) assertEquals(store.state.mode, BookmarkFragmentState.Mode.Selecting(setOf(subfolder)))
} }
@Test @Test
@ -73,11 +72,11 @@ class BookmarkFragmentStoreTest {
store.dispatch(BookmarkFragmentAction.Select(childItem)).join() store.dispatch(BookmarkFragmentAction.Select(childItem)).join()
assertThat(BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Selecting(setOf(childItem)))).isEqualTo(store.state) assertEquals(store.state, BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Selecting(setOf(childItem))))
store.dispatch(BookmarkFragmentAction.Deselect(childItem)).join() store.dispatch(BookmarkFragmentAction.Deselect(childItem)).join()
assertThat(BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Normal())).isEqualTo(store.state) assertEquals(store.state, BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Normal()))
} }
@Test @Test
@ -117,7 +116,7 @@ class BookmarkFragmentStoreTest {
store.dispatch(BookmarkFragmentAction.DeselectAll).join() store.dispatch(BookmarkFragmentAction.DeselectAll).join()
assertThat(initialState.copy(mode = BookmarkFragmentState.Mode.Normal())).isEqualTo(store.state) assertEquals(store.state, initialState.copy(mode = BookmarkFragmentState.Mode.Normal()))
} }
@Test @Test
@ -138,8 +137,8 @@ class BookmarkFragmentStoreTest {
store.dispatch(BookmarkFragmentAction.Change(newTree)).join() store.dispatch(BookmarkFragmentAction.Change(newTree)).join()
store.state.run { store.state.run {
assertThat(newTree).isEqualTo(tree) assertEquals(tree, newTree)
assertThat(BookmarkFragmentState.Mode.Normal()).isEqualTo(mode) assertEquals(mode, BookmarkFragmentState.Mode.Normal())
} }
} }
@ -174,8 +173,8 @@ class BookmarkFragmentStoreTest {
store.dispatch(BookmarkFragmentAction.Change(rootFolder)).join() store.dispatch(BookmarkFragmentAction.Change(rootFolder)).join()
assertThat(rootFolder).isEqualTo(store.state.tree) assertEquals(store.state.tree, rootFolder)
assertThat(BookmarkFragmentState.Mode.Normal(false)).isEqualTo(store.state.mode) assertEquals(store.state.mode, BookmarkFragmentState.Mode.Normal(false))
} }
private val item = BookmarkNode(BookmarkNodeType.ITEM, "456", "123", 0, "Mozilla", "http://mozilla.org", null) private val item = BookmarkNode(BookmarkNodeType.ITEM, "456", "123", 0, "Mozilla", "http://mozilla.org", null)

View File

@ -5,8 +5,6 @@
package org.mozilla.fenix.library.bookmarks package org.mozilla.fenix.library.bookmarks
import android.content.Context import android.content.Context
import assertk.assertThat
import assertk.assertions.isEqualTo
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
import io.mockk.spyk import io.mockk.spyk
@ -16,6 +14,7 @@ import mozilla.components.browser.storage.sync.PlacesBookmarksStorage
import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType import mozilla.components.concept.storage.BookmarkNodeType
import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertSame import org.junit.Assert.assertSame
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
@ -52,32 +51,22 @@ class DesktopFoldersTest {
fun `withRootTitle and do showMobileRoot`() { fun `withRootTitle and do showMobileRoot`() {
val desktopFolders = DesktopFolders(context, showMobileRoot = true) val desktopFolders = DesktopFolders(context, showMobileRoot = true)
assertThat(desktopFolders.withRootTitle(mockNodeWithTitle("root")).title) assertEquals(testContext.getString(R.string.library_bookmarks), desktopFolders.withRootTitle(mockNodeWithTitle("root")).title)
.isEqualTo(testContext.getString(R.string.library_bookmarks)) assertEquals(testContext.getString(R.string.library_bookmarks), desktopFolders.withRootTitle(mockNodeWithTitle("mobile")).title)
assertThat(desktopFolders.withRootTitle(mockNodeWithTitle("mobile")).title) assertEquals(testContext.getString(R.string.library_desktop_bookmarks_menu), desktopFolders.withRootTitle(mockNodeWithTitle("menu")).title)
.isEqualTo(testContext.getString(R.string.library_bookmarks)) assertEquals(testContext.getString(R.string.library_desktop_bookmarks_toolbar), desktopFolders.withRootTitle(mockNodeWithTitle("toolbar")).title)
assertThat(desktopFolders.withRootTitle(mockNodeWithTitle("menu")).title) assertEquals(testContext.getString(R.string.library_desktop_bookmarks_unfiled), desktopFolders.withRootTitle(mockNodeWithTitle("unfiled")).title)
.isEqualTo(testContext.getString(R.string.library_desktop_bookmarks_menu))
assertThat(desktopFolders.withRootTitle(mockNodeWithTitle("toolbar")).title)
.isEqualTo(testContext.getString(R.string.library_desktop_bookmarks_toolbar))
assertThat(desktopFolders.withRootTitle(mockNodeWithTitle("unfiled")).title)
.isEqualTo(testContext.getString(R.string.library_desktop_bookmarks_unfiled))
} }
@Test @Test
fun `withRootTitle and do not showMobileRoot`() { fun `withRootTitle and do not showMobileRoot`() {
val desktopFolders = DesktopFolders(context, showMobileRoot = false) val desktopFolders = DesktopFolders(context, showMobileRoot = false)
assertThat(desktopFolders.withRootTitle(mockNodeWithTitle("root")).title) assertEquals(testContext.getString(R.string.library_desktop_bookmarks_root), desktopFolders.withRootTitle(mockNodeWithTitle("root")).title)
.isEqualTo(testContext.getString(R.string.library_desktop_bookmarks_root)) assertEquals(mockNodeWithTitle("mobile"), desktopFolders.withRootTitle(mockNodeWithTitle("mobile")))
assertThat(desktopFolders.withRootTitle(mockNodeWithTitle("mobile"))) assertEquals(testContext.getString(R.string.library_desktop_bookmarks_menu), desktopFolders.withRootTitle(mockNodeWithTitle("menu")).title)
.isEqualTo(mockNodeWithTitle("mobile")) assertEquals(testContext.getString(R.string.library_desktop_bookmarks_toolbar), desktopFolders.withRootTitle(mockNodeWithTitle("toolbar")).title)
assertThat(desktopFolders.withRootTitle(mockNodeWithTitle("menu")).title) assertEquals(testContext.getString(R.string.library_desktop_bookmarks_unfiled), desktopFolders.withRootTitle(mockNodeWithTitle("unfiled")).title)
.isEqualTo(testContext.getString(R.string.library_desktop_bookmarks_menu))
assertThat(desktopFolders.withRootTitle(mockNodeWithTitle("toolbar")).title)
.isEqualTo(testContext.getString(R.string.library_desktop_bookmarks_toolbar))
assertThat(desktopFolders.withRootTitle(mockNodeWithTitle("unfiled")).title)
.isEqualTo(testContext.getString(R.string.library_desktop_bookmarks_unfiled))
} }
@Test @Test

View File

@ -9,18 +9,14 @@ import android.content.ClipboardManager
import android.content.res.Resources import android.content.res.Resources
import androidx.navigation.NavController import androidx.navigation.NavController
import androidx.navigation.NavDirections import androidx.navigation.NavDirections
import assertk.assertAll
import assertk.assertThat
import assertk.assertions.hasSize
import assertk.assertions.isEqualTo
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
import io.mockk.slot import io.mockk.slot
import io.mockk.verify import io.mockk.verify
import mozilla.components.concept.engine.prompt.ShareData import mozilla.components.concept.engine.prompt.ShareData
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Assert.assertFalse import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@ -164,11 +160,9 @@ class HistoryControllerTest {
clipboardManager.primaryClip = capture(clipdata) clipboardManager.primaryClip = capture(clipdata)
snackbar.show() snackbar.show()
} }
assertAll { assertEquals(1, clipdata.captured.itemCount)
assertEquals(clipdata.captured.itemCount, 1) assertEquals(historyItem.url, clipdata.captured.description.label)
assertThat(clipdata.captured.description.label).isEqualTo(historyItem.url) assertEquals(historyItem.url, clipdata.captured.getItemAt(0).text)
assertThat(clipdata.captured.getItemAt(0).text).isEqualTo(historyItem.url)
}
} }
@Test @Test
@ -186,17 +180,13 @@ class HistoryControllerTest {
capture(directions) capture(directions)
) )
} }
assertAll {
// The below class is private, can't easily assert using `instanceOf`
assertEquals( assertEquals(
directions.captured::class.simpleName, directions.captured::class.simpleName,
"ActionHistoryFragmentToShareFragment" "ActionHistoryFragmentToShareFragment"
) )
assertThat(directions.captured.arguments["data"] as Array<ShareData>).hasSize(1) assertEquals(1, (directions.captured.arguments["data"] as Array<ShareData>).size)
assertThat(((directions.captured.arguments["data"] as Array<ShareData>)[0]).title) assertEquals(historyItem.title, (directions.captured.arguments["data"] as Array<ShareData>)[0].title)
.isEqualTo(historyItem.title) assertEquals(historyItem.url, (directions.captured.arguments["data"] as Array<ShareData>)[0].url)
assertThat(((directions.captured.arguments["data"] as Array<ShareData>)[0]).url)
.isEqualTo(historyItem.url)
}
} }
} }

View File

@ -4,11 +4,10 @@
package org.mozilla.fenix.library.history package org.mozilla.fenix.library.history
import assertk.assertThat
import assertk.assertions.isTrue
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
import io.mockk.verifyAll import io.mockk.verifyAll
import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test
import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.browser.browsingmode.BrowsingMode
@ -55,7 +54,7 @@ class HistoryInteractorTest {
verifyAll { verifyAll {
controller.handleBackPressed() controller.handleBackPressed()
} }
assertThat(backpressHandled).isTrue() assertTrue(backpressHandled)
} }
@Test @Test

View File

@ -6,8 +6,6 @@ package org.mozilla.fenix.settings.about
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import assertk.assertThat
import assertk.assertions.isEqualTo
import io.mockk.Runs import io.mockk.Runs
import io.mockk.every import io.mockk.every
import io.mockk.just import io.mockk.just
@ -16,6 +14,7 @@ import io.mockk.spyk
import io.mockk.verify import io.mockk.verify
import kotlinx.android.synthetic.main.about_list_item.view.* import kotlinx.android.synthetic.main.about_list_item.view.*
import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mozilla.fenix.settings.about.viewholders.AboutItemViewHolder import org.mozilla.fenix.settings.about.viewholders.AboutItemViewHolder
@ -39,7 +38,7 @@ class AboutPageAdapterTest {
fun `getItemCount on a default instantiated Adapter should return 0`() { fun `getItemCount on a default instantiated Adapter should return 0`() {
val adapter = AboutPageAdapter(listener) val adapter = AboutPageAdapter(listener)
assertThat(adapter.itemCount).isEqualTo(0) assertEquals(0, adapter.itemCount)
} }
@Test @Test
@ -48,7 +47,7 @@ class AboutPageAdapterTest {
adapter.submitList(aboutList) adapter.submitList(aboutList)
assertThat(adapter.itemCount).isEqualTo(2) assertEquals(2, adapter.itemCount)
} }
@Test @Test
@ -59,7 +58,7 @@ class AboutPageAdapterTest {
val viewHolder = adapter.onCreateViewHolder(parentView, AboutItemViewHolder.LAYOUT_ID) val viewHolder = adapter.onCreateViewHolder(parentView, AboutItemViewHolder.LAYOUT_ID)
assertThat(viewHolder::class).isEqualTo(AboutItemViewHolder::class) assertEquals(AboutItemViewHolder::class, viewHolder::class)
} }
@Test @Test

View File

@ -6,12 +6,6 @@ package org.mozilla.fenix.settings.quicksettings
import androidx.navigation.NavController import androidx.navigation.NavController
import androidx.navigation.NavDirections import androidx.navigation.NavDirections
import assertk.assertAll
import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isInstanceOf
import assertk.assertions.isSameAs
import assertk.assertions.isTrue
import io.mockk.Runs import io.mockk.Runs
import io.mockk.every import io.mockk.every
import io.mockk.just import io.mockk.just
@ -29,6 +23,10 @@ import mozilla.components.feature.sitepermissions.SitePermissions
import mozilla.components.feature.sitepermissions.SitePermissions.Status.NO_DECISION import mozilla.components.feature.sitepermissions.SitePermissions.Status.NO_DECISION
import mozilla.components.feature.tabs.TabsUseCases import mozilla.components.feature.tabs.TabsUseCases
import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue
import org.junit.Ignore import org.junit.Ignore
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@ -94,10 +92,9 @@ class DefaultQuickSettingsControllerTest {
verify { verify {
controller.handleAndroidPermissionRequest(capture(androidPermissions)) controller.handleAndroidPermissionRequest(capture(androidPermissions))
} }
assertAll {
assertThat(androidPermissions.isCaptured).isTrue() assertTrue(androidPermissions.isCaptured)
assertThat(androidPermissions.captured).isEqualTo(cameraFeature.androidPermissionsList) assertArrayEquals(cameraFeature.androidPermissionsList, androidPermissions.captured)
}
} }
@Test @Test
@ -116,7 +113,7 @@ class DefaultQuickSettingsControllerTest {
controller.handlePermissionToggled(websitePermission) controller.handlePermissionToggled(websitePermission)
// We want to verify that the Status is toggled and this event is passed to Controller also. // We want to verify that the Status is toggled and this event is passed to Controller also.
assertThat(sitePermissions.camera).isSameAs(NO_DECISION) assertSame(NO_DECISION, sitePermissions.camera)
verifyOrder { verifyOrder {
val permission = sitePermissions.toggle(capture(toggledFeature)) val permission = sitePermissions.toggle(capture(toggledFeature))
controller.handlePermissionsChange(permission) controller.handlePermissionsChange(permission)
@ -125,15 +122,14 @@ class DefaultQuickSettingsControllerTest {
verify { verify {
store.dispatch(capture(action)) store.dispatch(capture(action))
} }
assertAll {
assertThat(toggledFeature.isCaptured).isTrue()
assertThat(toggledFeature.captured).isSameAs(PhoneFeature.CAMERA)
assertThat(action.isCaptured).isTrue() assertTrue(toggledFeature.isCaptured)
assertThat(action.captured).isInstanceOf(WebsitePermissionAction.TogglePermission::class) assertSame(PhoneFeature.CAMERA, toggledFeature.captured)
assertThat((action.captured as WebsitePermissionAction.TogglePermission).websitePermission)
.isInstanceOf(websitePermission::class) assertTrue(action.isCaptured)
} assertEquals(WebsitePermissionAction.TogglePermission::class, action.captured::class)
assertEquals(websitePermission::class,
(action.captured as WebsitePermissionAction.TogglePermission).websitePermission::class)
} }
@Test @Test
@ -183,19 +179,12 @@ class DefaultQuickSettingsControllerTest {
verify { verify {
store.dispatch(capture(action)) store.dispatch(capture(action))
} }
assertAll {
assertThat(action.isCaptured).isTrue() assertTrue(action.isCaptured)
assertThat(action.captured).isInstanceOf(WebsitePermissionAction.TogglePermission::class) assertEquals(WebsitePermissionAction.TogglePermission::class, action.captured::class)
assertThat((action.captured as WebsitePermissionAction.TogglePermission).websitePermission).isEqualTo( assertEquals(permission, (action.captured as WebsitePermissionAction.TogglePermission).websitePermission)
permission assertEquals(permissionStatus, (action.captured as WebsitePermissionAction.TogglePermission).updatedStatus)
) assertEquals(permissionEnabled, (action.captured as WebsitePermissionAction.TogglePermission).updatedEnabledStatus)
assertThat((action.captured as WebsitePermissionAction.TogglePermission).updatedStatus).isEqualTo(
permissionStatus
)
assertThat((action.captured as WebsitePermissionAction.TogglePermission).updatedEnabledStatus).isEqualTo(
permissionEnabled
)
}
} }
@Test @Test
@ -207,10 +196,9 @@ class DefaultQuickSettingsControllerTest {
controller.handleAndroidPermissionRequest(testPermissions) controller.handleAndroidPermissionRequest(testPermissions)
verify { requestPermissions(capture(requiredPermissions)) } verify { requestPermissions(capture(requiredPermissions)) }
assertAll {
assertThat(requiredPermissions.isCaptured).isTrue() assertTrue(requiredPermissions.isCaptured)
assertThat(requiredPermissions.captured).isEqualTo(testPermissions) assertArrayEquals(testPermissions, requiredPermissions.captured)
}
} }
@Test @Test
@ -228,12 +216,11 @@ class DefaultQuickSettingsControllerTest {
permissionStorage.updateSitePermissions(capture(permissions)) permissionStorage.updateSitePermissions(capture(permissions))
reload(capture(session)) reload(capture(session))
} }
assertAll {
assertThat(permissions.isCaptured).isTrue() assertTrue(permissions.isCaptured)
assertThat(permissions.captured).isEqualTo(testPermissions) assertEquals(testPermissions, permissions.captured)
assertThat(session.isCaptured).isTrue() assertTrue(session.isCaptured)
assertThat(session.captured).isEqualTo(browserSession) assertEquals(browserSession, session.captured)
}
} }
@Test @Test
@ -244,32 +231,22 @@ class DefaultQuickSettingsControllerTest {
val locationPermission = mockk<WebsitePermission.Location>() val locationPermission = mockk<WebsitePermission.Location>()
with(controller) { with(controller) {
assertAll { assertSame(PhoneFeature.CAMERA, cameraPermission.getBackingFeature())
assertThat(cameraPermission.getBackingFeature()).isSameAs(PhoneFeature.CAMERA) assertSame(PhoneFeature.MICROPHONE, microphonePermission.getBackingFeature())
assertThat(microphonePermission.getBackingFeature()).isSameAs(PhoneFeature.MICROPHONE) assertSame(PhoneFeature.NOTIFICATION, notificationPermission.getBackingFeature())
assertThat(notificationPermission.getBackingFeature()).isSameAs(PhoneFeature.NOTIFICATION) assertSame(PhoneFeature.LOCATION, locationPermission.getBackingFeature())
assertThat(locationPermission.getBackingFeature()).isSameAs(PhoneFeature.LOCATION)
}
} }
} }
@Test @Test
fun `PhoneFeature#getCorrespondingPermission should return the WebsitePermission which it maps to`() { fun `PhoneFeature#getCorrespondingPermission should return the WebsitePermission which it maps to`() {
with(controller) { with(controller) {
assertAll { assertEquals(WebsitePermission.Camera::class, PhoneFeature.CAMERA.getCorrespondingPermission()::class)
assertThat(PhoneFeature.CAMERA.getCorrespondingPermission()) assertEquals(WebsitePermission.Microphone::class, PhoneFeature.MICROPHONE.getCorrespondingPermission()::class)
.isInstanceOf(WebsitePermission.Camera::class) assertEquals(WebsitePermission.Notification::class, PhoneFeature.NOTIFICATION.getCorrespondingPermission()::class)
assertThat(PhoneFeature.MICROPHONE.getCorrespondingPermission()) assertEquals(WebsitePermission.Location::class, PhoneFeature.LOCATION.getCorrespondingPermission()::class)
.isInstanceOf(WebsitePermission.Microphone::class) assertEquals(WebsitePermission.AutoplayAudible::class, PhoneFeature.AUTOPLAY_AUDIBLE.getCorrespondingPermission()::class)
assertThat(PhoneFeature.NOTIFICATION.getCorrespondingPermission()) assertEquals(WebsitePermission.AutoplayInaudible::class, PhoneFeature.AUTOPLAY_INAUDIBLE.getCorrespondingPermission()::class)
.isInstanceOf(WebsitePermission.Notification::class)
assertThat(PhoneFeature.LOCATION.getCorrespondingPermission())
.isInstanceOf(WebsitePermission.Location::class)
assertThat(PhoneFeature.AUTOPLAY_AUDIBLE.getCorrespondingPermission())
.isInstanceOf(WebsitePermission.AutoplayAudible::class)
assertThat(PhoneFeature.AUTOPLAY_INAUDIBLE.getCorrespondingPermission())
.isInstanceOf(WebsitePermission.AutoplayInaudible::class)
}
} }
} }
} }

View File

@ -5,15 +5,6 @@
package org.mozilla.fenix.settings.quicksettings package org.mozilla.fenix.settings.quicksettings
import android.content.pm.PackageManager import android.content.pm.PackageManager
import assertk.assertAll
import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isFalse
import assertk.assertions.isInstanceOf
import assertk.assertions.isNotNull
import assertk.assertions.isNotSameAs
import assertk.assertions.isSameAs
import assertk.assertions.isTrue
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
import io.mockk.spyk import io.mockk.spyk
@ -22,10 +13,16 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import mozilla.components.feature.sitepermissions.SitePermissions import mozilla.components.feature.sitepermissions.SitePermissions
import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNotSame
import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.settings.PhoneFeature import org.mozilla.fenix.settings.PhoneFeature
import org.mozilla.fenix.settings.quicksettings.QuickSettingsFragmentStore.Companion.getInsecureWebsiteUiValues import org.mozilla.fenix.settings.quicksettings.QuickSettingsFragmentStore.Companion.getInsecureWebsiteUiValues
import org.mozilla.fenix.settings.quicksettings.QuickSettingsFragmentStore.Companion.getPermissionStatus import org.mozilla.fenix.settings.quicksettings.QuickSettingsFragmentStore.Companion.getPermissionStatus
@ -35,7 +32,6 @@ import org.mozilla.fenix.settings.quicksettings.ext.shouldBeEnabled
import org.mozilla.fenix.settings.quicksettings.ext.shouldBeVisible import org.mozilla.fenix.settings.quicksettings.ext.shouldBeVisible
import org.mozilla.fenix.settings.sitepermissions.AUTOPLAY_BLOCK_ALL import org.mozilla.fenix.settings.sitepermissions.AUTOPLAY_BLOCK_ALL
import org.mozilla.fenix.utils.Settings import org.mozilla.fenix.utils.Settings
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@RunWith(FenixRobolectricTestRunner::class) @RunWith(FenixRobolectricTestRunner::class)
class QuickSettingsFragmentStoreTest { class QuickSettingsFragmentStoreTest {
@ -58,12 +54,10 @@ class QuickSettingsFragmentStoreTest {
context, "url", "Hello", "issuer", true, permissions, settings context, "url", "Hello", "issuer", true, permissions, settings
) )
assertAll { assertNotNull(store)
assertThat(store).isNotNull() assertNotNull(store.state)
assertThat(store.state).isNotNull() assertNotNull(store.state.webInfoState)
assertThat(store.state.webInfoState).isNotNull() assertNotNull(store.state.websitePermissionsState)
assertThat(store.state.websitePermissionsState).isNotNull()
}
} }
@Test @Test
@ -75,14 +69,12 @@ class QuickSettingsFragmentStoreTest {
val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, websiteTitle, securedStatus, certificateIssuer) val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, websiteTitle, securedStatus, certificateIssuer)
assertAll { assertNotNull(state)
assertThat(state).isNotNull() assertSame(websiteUrl, state.websiteUrl)
assertThat(state.websiteUrl).isSameAs(websiteUrl) assertSame(websiteTitle, state.websiteTitle)
assertThat(state.websiteTitle).isSameAs(websiteTitle) assertEquals(secureStringRes, state.securityInfoRes)
assertThat(state.securityInfoRes).isEqualTo(secureStringRes) assertEquals(secureDrawableRes, state.iconRes)
assertThat(state.iconRes).isEqualTo(secureDrawableRes) assertEquals(secureColorRes, state.iconTintRes)
assertThat(state.iconTintRes).isEqualTo(secureColorRes)
}
} }
@Test @Test
@ -94,14 +86,12 @@ class QuickSettingsFragmentStoreTest {
val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, websiteTitle, securedStatus, certificateIssuer) val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, websiteTitle, securedStatus, certificateIssuer)
assertAll { assertNotNull(state)
assertThat(state).isNotNull() assertSame(websiteUrl, state.websiteUrl)
assertThat(state.websiteUrl).isSameAs(websiteUrl) assertSame(websiteTitle, state.websiteTitle)
assertThat(state.websiteTitle).isSameAs(websiteTitle) assertEquals(insecureStringRes, state.securityInfoRes)
assertThat(state.securityInfoRes).isEqualTo(insecureStringRes) assertEquals(insecureDrawableRes, state.iconRes)
assertThat(state.iconRes).isEqualTo(insecureDrawableRes) assertEquals(insecureColorRes, state.iconTintRes)
assertThat(state.iconTintRes).isEqualTo(insecureColorRes)
}
} }
@Test @Test
@ -127,15 +117,13 @@ class QuickSettingsFragmentStoreTest {
// Just need to know that the WebsitePermissionsState properties are initialized. // Just need to know that the WebsitePermissionsState properties are initialized.
// Making sure they are correctly initialized is tested in the `initWebsitePermission` test. // Making sure they are correctly initialized is tested in the `initWebsitePermission` test.
assertAll { assertNotNull(state)
assertThat(state).isNotNull() assertNotNull(state.camera)
assertThat(state.camera).isNotNull() assertNotNull(state.microphone)
assertThat(state.microphone).isNotNull() assertNotNull(state.notification)
assertThat(state.notification).isNotNull() assertNotNull(state.location)
assertThat(state.location).isNotNull() assertNotNull(state.autoplayAudible)
assertThat(state.autoplayAudible).isNotNull() assertNotNull(state.autoplayInaudible)
assertThat(state.autoplayInaudible).isNotNull()
}
} }
@Test @Test
@ -153,14 +141,12 @@ class QuickSettingsFragmentStoreTest {
val websitePermission = cameraFeature.toWebsitePermission(context, permissions, appSettings) val websitePermission = cameraFeature.toWebsitePermission(context, permissions, appSettings)
assertAll { assertNotNull(websitePermission)
assertThat(websitePermission).isNotNull() assertEquals(WebsitePermission.Camera::class, websitePermission::class)
assertThat(websitePermission).isInstanceOf(WebsitePermission.Camera::class) assertEquals(allowedStatus, websitePermission.status)
assertThat(websitePermission.status).isEqualTo(allowedStatus) assertTrue(websitePermission.isVisible)
assertThat(websitePermission.isVisible).isTrue() assertTrue(websitePermission.isEnabled)
assertThat(websitePermission.isEnabled).isTrue() assertFalse(websitePermission.isBlockedByAndroid)
assertThat(websitePermission.isBlockedByAndroid).isFalse()
}
} }
@Test @Test
@ -177,12 +163,11 @@ class QuickSettingsFragmentStoreTest {
phoneFeature.shouldBeEnabled(context, permissions, appSettings) phoneFeature.shouldBeEnabled(context, permissions, appSettings)
phoneFeature.isAndroidPermissionGranted(context) phoneFeature.isAndroidPermissionGranted(context)
} }
assertAll {
// Check that we only have a non-null permission status. // Check that we only have a non-null permission status.
// Having each property calculated in a separate delegate means their correctness is // Having each property calculated in a separate delegate means their correctness is
// to be tested in that delegated method. // to be tested in that delegated method.
assertThat(permissionsStatus).isNotNull() assertNotNull(permissionsStatus)
}
} }
@Test @Test
@ -247,105 +232,58 @@ class QuickSettingsFragmentStoreTest {
) )
).join() ).join()
assertAll { assertNotNull(store.state)
assertThat(store.state).isNotNull() assertNotSame(initialState, store.state)
assertThat(store.state).isNotSameAs(initialState) assertNotSame(initialWebsitePermissionsState, store.state.websitePermissionsState)
assertThat(store.state.websitePermissionsState).isNotSameAs( assertSame(websiteInfoState, store.state.webInfoState)
initialWebsitePermissionsState
)
assertThat(store.state.webInfoState).isSameAs(websiteInfoState)
assertThat(store.state.websitePermissionsState.camera).isNotNull() assertNotNull(store.state.websitePermissionsState.camera)
assertThat((store.state.websitePermissionsState.camera as WebsitePermission.Camera).name).isEqualTo( assertEquals(cameraPermissionName, (store.state.websitePermissionsState.camera as WebsitePermission.Camera).name)
cameraPermissionName assertEquals(initialCameraStatus, store.state.websitePermissionsState.camera.status)
) assertEquals(defaultVisibilityStatus, store.state.websitePermissionsState.camera.isVisible)
assertThat(store.state.websitePermissionsState.camera.status).isEqualTo( assertEquals(defaultEnabledStatus, store.state.websitePermissionsState.camera.isEnabled)
initialCameraStatus assertEquals(defaultBlockedByAndroidStatus, store.state.websitePermissionsState.camera.isBlockedByAndroid)
)
assertThat(store.state.websitePermissionsState.camera.isVisible).isEqualTo( assertNotNull(store.state.websitePermissionsState.microphone)
defaultVisibilityStatus assertEquals(microphonePermissionName, (store.state.websitePermissionsState.microphone as WebsitePermission.Microphone).name)
)
assertThat(store.state.websitePermissionsState.camera.isEnabled).isEqualTo(
defaultEnabledStatus
)
assertThat(store.state.websitePermissionsState.camera.isBlockedByAndroid).isEqualTo(
defaultBlockedByAndroidStatus
)
assertThat(store.state.websitePermissionsState.microphone).isNotNull()
assertThat((store.state.websitePermissionsState.microphone as WebsitePermission.Microphone).name).isEqualTo(
microphonePermissionName
)
// Only the following two properties must have been changed! // Only the following two properties must have been changed!
assertThat(store.state.websitePermissionsState.microphone.status).isEqualTo( assertEquals(updatedMicrophoneStatus, store.state.websitePermissionsState.microphone.status)
updatedMicrophoneStatus assertEquals(updatedMicrophoneEnabledStatus, store.state.websitePermissionsState.microphone.isEnabled)
)
assertThat(store.state.websitePermissionsState.microphone.isEnabled).isEqualTo(
updatedMicrophoneEnabledStatus
)
assertThat(store.state.websitePermissionsState.microphone.isVisible).isEqualTo( assertEquals(defaultVisibilityStatus, store.state.websitePermissionsState.microphone.isVisible)
defaultVisibilityStatus assertEquals(defaultBlockedByAndroidStatus, store.state.websitePermissionsState.microphone.isBlockedByAndroid)
)
assertThat(store.state.websitePermissionsState.microphone.isBlockedByAndroid).isEqualTo(
defaultBlockedByAndroidStatus
)
assertThat(store.state.websitePermissionsState.notification).isNotNull() assertNotNull(store.state.websitePermissionsState.notification)
assertThat((store.state.websitePermissionsState.notification as WebsitePermission.Notification).name).isEqualTo( assertEquals(notificationPermissionName, (store.state.websitePermissionsState.notification as WebsitePermission.Notification).name)
notificationPermissionName assertEquals(initialNotificationStatus, store.state.websitePermissionsState.notification.status)
) assertEquals(defaultVisibilityStatus, store.state.websitePermissionsState.notification.isVisible)
assertThat(store.state.websitePermissionsState.notification.status).isEqualTo( assertEquals(defaultEnabledStatus, store.state.websitePermissionsState.notification.isEnabled)
initialNotificationStatus assertEquals(defaultBlockedByAndroidStatus, store.state.websitePermissionsState.notification.isBlockedByAndroid)
)
assertThat(store.state.websitePermissionsState.notification.isVisible).isEqualTo(
defaultVisibilityStatus
)
assertThat(store.state.websitePermissionsState.notification.isEnabled).isEqualTo(
defaultEnabledStatus
)
assertThat(store.state.websitePermissionsState.notification.isBlockedByAndroid).isEqualTo(
defaultBlockedByAndroidStatus
)
assertThat(store.state.websitePermissionsState.location).isNotNull() assertNotNull(store.state.websitePermissionsState.location)
assertThat((store.state.websitePermissionsState.location as WebsitePermission.Location).name).isEqualTo( assertEquals(locationPermissionName, (store.state.websitePermissionsState.location as WebsitePermission.Location).name)
locationPermissionName assertEquals(initialLocationStatus, store.state.websitePermissionsState.location.status)
) assertEquals(defaultVisibilityStatus, store.state.websitePermissionsState.location.isVisible)
assertThat(store.state.websitePermissionsState.location.status).isEqualTo( assertEquals(defaultEnabledStatus, store.state.websitePermissionsState.location.isEnabled)
initialLocationStatus assertEquals(defaultBlockedByAndroidStatus, store.state.websitePermissionsState.location.isBlockedByAndroid)
)
assertThat(store.state.websitePermissionsState.location.isVisible).isEqualTo(
defaultVisibilityStatus
)
assertThat(store.state.websitePermissionsState.location.isEnabled).isEqualTo(
defaultEnabledStatus
)
assertThat(store.state.websitePermissionsState.location.isBlockedByAndroid).isEqualTo(
defaultBlockedByAndroidStatus
)
}
} }
@Test @Test
fun `getSecuredWebsiteUiValues() should return the right values`() { fun `getSecuredWebsiteUiValues() should return the right values`() {
val uiValues = getSecuredWebsiteUiValues val uiValues = getSecuredWebsiteUiValues
assertAll { assertEquals(secureStringRes, uiValues.first)
assertThat(uiValues.first).isEqualTo(secureStringRes) assertEquals(secureDrawableRes, uiValues.second)
assertThat(uiValues.second).isEqualTo(secureDrawableRes) assertEquals(secureColorRes, uiValues.third)
assertThat(uiValues.third).isEqualTo(secureColorRes)
}
} }
@Test @Test
fun `getInsecureWebsiteUiValues() should return the right values`() { fun `getInsecureWebsiteUiValues() should return the right values`() {
val uiValues = getInsecureWebsiteUiValues val uiValues = getInsecureWebsiteUiValues
assertAll { assertEquals(insecureStringRes, uiValues.first)
assertThat(uiValues.first).isEqualTo(insecureStringRes) assertEquals(insecureDrawableRes, uiValues.second)
assertThat(uiValues.second).isEqualTo(insecureDrawableRes) assertEquals(insecureColorRes, uiValues.third)
assertThat(uiValues.third).isEqualTo(insecureColorRes)
}
} }
} }

View File

@ -4,13 +4,11 @@
package org.mozilla.fenix.settings.quicksettings package org.mozilla.fenix.settings.quicksettings
import assertk.assertAll
import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isTrue
import io.mockk.mockk import io.mockk.mockk
import io.mockk.slot import io.mockk.slot
import io.mockk.verify import io.mockk.verify
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test
class QuickSettingsInteractorTest { class QuickSettingsInteractorTest {
@ -36,9 +34,8 @@ class QuickSettingsInteractorTest {
verify { verify {
controller.handlePermissionToggled(capture(permission)) controller.handlePermissionToggled(capture(permission))
} }
assertAll {
assertThat(permission.isCaptured).isTrue() assertTrue(permission.isCaptured)
assertThat(permission.captured).isEqualTo(websitePermission) assertEquals(websitePermission, permission.captured)
}
} }
} }

View File

@ -6,13 +6,11 @@ package org.mozilla.fenix.settings.quicksettings.ext
import android.content.Context import android.content.Context
import android.content.pm.PackageManager import android.content.pm.PackageManager
import assertk.assertAll
import assertk.assertThat
import assertk.assertions.isFalse
import assertk.assertions.isTrue
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
import mozilla.components.feature.sitepermissions.SitePermissions import mozilla.components.feature.sitepermissions.SitePermissions
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test
import org.mozilla.fenix.settings.PhoneFeature import org.mozilla.fenix.settings.PhoneFeature
@ -26,11 +24,9 @@ class PhoneFeatureExtKtTest {
every { userAllowedPermission.camera } returns SitePermissions.Status.ALLOWED every { userAllowedPermission.camera } returns SitePermissions.Status.ALLOWED
every { userBlockedPermission.camera } returns SitePermissions.Status.BLOCKED every { userBlockedPermission.camera } returns SitePermissions.Status.BLOCKED
assertAll { assertFalse(PhoneFeature.CAMERA.shouldBeVisible(noDecisionForPermission, mockk()))
assertThat(PhoneFeature.CAMERA.shouldBeVisible(noDecisionForPermission, mockk())).isFalse() assertTrue(PhoneFeature.CAMERA.shouldBeVisible(userAllowedPermission, mockk()))
assertThat(PhoneFeature.CAMERA.shouldBeVisible(userAllowedPermission, mockk())).isTrue() assertTrue(PhoneFeature.CAMERA.shouldBeVisible(userBlockedPermission, mockk()))
assertThat(PhoneFeature.CAMERA.shouldBeVisible(userBlockedPermission, mockk())).isTrue()
}
} }
@Test @Test
@ -42,11 +38,9 @@ class PhoneFeatureExtKtTest {
every { userAllowedPermission.camera } returns SitePermissions.Status.ALLOWED every { userAllowedPermission.camera } returns SitePermissions.Status.ALLOWED
every { userBlockedPermission.camera } returns SitePermissions.Status.BLOCKED every { userBlockedPermission.camera } returns SitePermissions.Status.BLOCKED
assertAll { assertTrue(PhoneFeature.CAMERA.isUserPermissionGranted(userAllowedPermission, mockk()))
assertThat(PhoneFeature.CAMERA.isUserPermissionGranted(userAllowedPermission, mockk())).isTrue() assertFalse(PhoneFeature.CAMERA.isUserPermissionGranted(noDecisionForPermission, mockk()))
assertThat(PhoneFeature.CAMERA.isUserPermissionGranted(noDecisionForPermission, mockk())).isFalse() assertFalse(PhoneFeature.CAMERA.isUserPermissionGranted(userBlockedPermission, mockk()))
assertThat(PhoneFeature.CAMERA.isUserPermissionGranted(userBlockedPermission, mockk())).isFalse()
}
} }
@Test @Test
@ -64,22 +58,14 @@ class PhoneFeatureExtKtTest {
every { noDecisionForPermission.camera } returns SitePermissions.Status.NO_DECISION every { noDecisionForPermission.camera } returns SitePermissions.Status.NO_DECISION
every { userBlockedPermission.camera } returns SitePermissions.Status.BLOCKED every { userBlockedPermission.camera } returns SitePermissions.Status.BLOCKED
assertAll {
// Check result for when the Android permission is granted to the app // Check result for when the Android permission is granted to the app
assertThat(PhoneFeature.CAMERA.shouldBeEnabled( assertTrue(PhoneFeature.CAMERA.shouldBeEnabled(androidPermissionGrantedContext, userAllowedPermission, mockk()))
androidPermissionGrantedContext, userAllowedPermission, mockk())).isTrue() assertFalse(PhoneFeature.CAMERA.shouldBeEnabled(androidPermissionGrantedContext, noDecisionForPermission, mockk()))
assertThat(PhoneFeature.CAMERA.shouldBeEnabled( assertFalse(PhoneFeature.CAMERA.shouldBeEnabled(androidPermissionGrantedContext, userBlockedPermission, mockk()))
androidPermissionGrantedContext, noDecisionForPermission, mockk())).isFalse()
assertThat(PhoneFeature.CAMERA.shouldBeEnabled(
androidPermissionGrantedContext, userBlockedPermission, mockk())).isFalse()
// Check result for when the Android permission is denied to the app // Check result for when the Android permission is denied to the app
assertThat(PhoneFeature.CAMERA.shouldBeEnabled( assertFalse(PhoneFeature.CAMERA.shouldBeEnabled(androidPermissionDeniedContext, userAllowedPermission, mockk()))
androidPermissionDeniedContext, userAllowedPermission, mockk())).isFalse() assertFalse(PhoneFeature.CAMERA.shouldBeEnabled(androidPermissionDeniedContext, noDecisionForPermission, mockk()))
assertThat(PhoneFeature.CAMERA.shouldBeEnabled( assertFalse(PhoneFeature.CAMERA.shouldBeEnabled(androidPermissionDeniedContext, userBlockedPermission, mockk()))
androidPermissionDeniedContext, noDecisionForPermission, mockk())).isFalse()
assertThat(PhoneFeature.CAMERA.shouldBeEnabled(
androidPermissionDeniedContext, userBlockedPermission, mockk())).isFalse()
}
} }
} }

View File

@ -8,11 +8,6 @@ import android.app.Activity
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import androidx.navigation.NavController import androidx.navigation.NavController
import assertk.assertAll
import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isNotEqualTo
import assertk.assertions.isTrue
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import io.mockk.Runs import io.mockk.Runs
import io.mockk.every import io.mockk.every
@ -32,6 +27,9 @@ import mozilla.components.concept.sync.TabData
import mozilla.components.feature.accounts.push.SendTabUseCases import mozilla.components.feature.accounts.push.SendTabUseCases
import mozilla.components.feature.share.RecentAppsStorage import mozilla.components.feature.share.RecentAppsStorage
import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertTrue
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@ -101,15 +99,14 @@ class ShareControllerTest {
testController.handleShareToApp(appShareOption) testController.handleShareToApp(appShareOption)
// Check that the Intent used for querying apps has the expected structure // Check that the Intent used for querying apps has the expected structure
assertAll { assertTrue(shareIntent.isCaptured)
assertThat(shareIntent.isCaptured).isTrue() assertEquals(Intent.ACTION_SEND, shareIntent.captured.action)
assertThat(shareIntent.captured.action).isEqualTo(Intent.ACTION_SEND) assertEquals(textToShare, shareIntent.captured.extras!![Intent.EXTRA_TEXT])
assertThat(shareIntent.captured.extras!![Intent.EXTRA_TEXT]).isEqualTo(textToShare) assertEquals("text/plain", shareIntent.captured.type)
assertThat(shareIntent.captured.type).isEqualTo("text/plain") assertEquals(Intent.FLAG_ACTIVITY_NEW_TASK, shareIntent.captured.flags)
assertThat(shareIntent.captured.flags).isEqualTo(Intent.FLAG_ACTIVITY_NEW_TASK) assertEquals(appPackageName, shareIntent.captured.component!!.packageName)
assertThat(shareIntent.captured.component!!.packageName).isEqualTo(appPackageName) assertEquals(appClassName, shareIntent.captured.component!!.className)
assertThat(shareIntent.captured.component!!.className).isEqualTo(appClassName)
}
verifyOrder { verifyOrder {
recentAppStorage.updateRecentApp(appShareOption.activityName) recentAppStorage.updateRecentApp(appShareOption.activityName)
activityContext.startActivity(shareIntent.captured) activityContext.startActivity(shareIntent.captured)
@ -158,12 +155,11 @@ class ShareControllerTest {
sendTabUseCases.sendToDeviceAsync(capture(deviceId), capture(tabsShared)) sendTabUseCases.sendToDeviceAsync(capture(deviceId), capture(tabsShared))
// dismiss() is also to be called, but at the moment cannot test it in a coroutine. // dismiss() is also to be called, but at the moment cannot test it in a coroutine.
} }
assertAll {
assertThat(deviceId.isCaptured).isTrue() assertTrue(deviceId.isCaptured)
assertThat(deviceId.captured).isEqualTo(deviceToShareTo.id) assertEquals(deviceToShareTo.id, deviceId.captured)
assertThat(tabsShared.isCaptured).isTrue() assertTrue(tabsShared.isCaptured)
assertThat(tabsShared.captured).isEqualTo(tabsData) assertEquals(tabsData, tabsShared.captured)
}
} }
@Test @Test
@ -181,11 +177,10 @@ class ShareControllerTest {
sendTabUseCases.sendToAllAsync(capture(tabsShared)) sendTabUseCases.sendToAllAsync(capture(tabsShared))
// dismiss() is also to be called, but at the moment cannot test it in a coroutine. // dismiss() is also to be called, but at the moment cannot test it in a coroutine.
} }
assertAll {
// SendTabUseCases should send a the `shareTabs` mapped to tabData // SendTabUseCases should send a the `shareTabs` mapped to tabData
assertThat(tabsShared.isCaptured).isTrue() assertTrue(tabsShared.isCaptured)
assertThat(tabsShared.captured).isEqualTo(tabsData) assertEquals(tabsData, tabsShared.captured)
}
} }
@Test @Test
@ -267,16 +262,14 @@ class ShareControllerTest {
val tabSharedMessage = controllerWithOneSharedTab.getSuccessMessage() val tabSharedMessage = controllerWithOneSharedTab.getSuccessMessage()
val tabsSharedMessage = controllerWithMoreSharedTabs.getSuccessMessage() val tabsSharedMessage = controllerWithMoreSharedTabs.getSuccessMessage()
assertAll { assertNotEquals(tabsSharedMessage, tabSharedMessage)
assertThat(tabSharedMessage).isNotEqualTo(tabsSharedMessage) assertEquals(expectedTabSharedMessage, tabSharedMessage)
assertThat(tabSharedMessage).isEqualTo(expectedTabSharedMessage) assertEquals(expectedTabsSharedMessage, tabsSharedMessage)
assertThat(tabsSharedMessage).isEqualTo(expectedTabsSharedMessage)
}
} }
@Test @Test
fun `getShareText should respect concatenate shared tabs urls`() { fun `getShareText should respect concatenate shared tabs urls`() {
assertThat(controller.getShareText()).isEqualTo(textToShare) assertEquals(textToShare, controller.getShareText())
} }
@Test @Test
@ -287,7 +280,7 @@ class ShareControllerTest {
tabData = shareData.toTabData() tabData = shareData.toTabData()
} }
assertThat(tabData).isEqualTo(tabsData) assertEquals(tabsData, tabData)
} }
@Test @Test
@ -305,6 +298,6 @@ class ShareControllerTest {
).toTabData() ).toTabData()
} }
assertThat(tabData).isEqualTo(expected) assertEquals(expected, tabData)
} }
} }

View File

@ -5,8 +5,6 @@
package org.mozilla.fenix.share.listadapters package org.mozilla.fenix.share.listadapters
import android.view.ViewGroup import android.view.ViewGroup
import assertk.assertThat
import assertk.assertions.isEqualTo
import io.mockk.Runs import io.mockk.Runs
import io.mockk.every import io.mockk.every
import io.mockk.just import io.mockk.just
@ -14,6 +12,7 @@ import io.mockk.mockk
import io.mockk.spyk import io.mockk.spyk
import io.mockk.verify import io.mockk.verify
import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mozilla.fenix.share.ShareInteractor import org.mozilla.fenix.share.ShareInteractor
@ -28,7 +27,7 @@ class AccountDevicesShareAdapterTest {
fun `getItemCount on a default instantiated Adapter should return 0`() { fun `getItemCount on a default instantiated Adapter should return 0`() {
val adapter = AccountDevicesShareAdapter(mockk()) val adapter = AccountDevicesShareAdapter(mockk())
assertThat(adapter.itemCount).isEqualTo(0) assertEquals(0, adapter.itemCount)
} }
@Test @Test
@ -39,7 +38,7 @@ class AccountDevicesShareAdapterTest {
val viewHolder = adapter.onCreateViewHolder(parentView, 0) val viewHolder = adapter.onCreateViewHolder(parentView, 0)
assertThat(viewHolder::class).isEqualTo(AccountDeviceViewHolder::class) assertEquals(AccountDeviceViewHolder::class, viewHolder::class)
} }
@Test @Test
@ -50,7 +49,7 @@ class AccountDevicesShareAdapterTest {
val viewHolder = adapter.onCreateViewHolder(parentView, 0) val viewHolder = adapter.onCreateViewHolder(parentView, 0)
assertThat(viewHolder.interactor).isEqualTo(interactor) assertEquals(interactor, viewHolder.interactor)
} }
@Test @Test

View File

@ -5,8 +5,6 @@
package org.mozilla.fenix.share.listadapters package org.mozilla.fenix.share.listadapters
import android.view.ViewGroup import android.view.ViewGroup
import assertk.assertThat
import assertk.assertions.isEqualTo
import io.mockk.Runs import io.mockk.Runs
import io.mockk.every import io.mockk.every
import io.mockk.just import io.mockk.just
@ -15,6 +13,7 @@ import io.mockk.spyk
import io.mockk.verify import io.mockk.verify
import io.mockk.verifyOrder import io.mockk.verifyOrder
import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mozilla.fenix.share.ShareInteractor import org.mozilla.fenix.share.ShareInteractor
@ -49,14 +48,14 @@ class AppShareAdapterTest {
fun `getItemCount on a default instantiated Adapter should return 0`() { fun `getItemCount on a default instantiated Adapter should return 0`() {
val adapter = AppShareAdapter(mockk()) val adapter = AppShareAdapter(mockk())
assertThat(adapter.itemCount).isEqualTo(0) assertEquals(0, adapter.itemCount)
} }
@Test @Test
fun `getItemCount after updateData() call should return the the passed in list's size`() { fun `getItemCount after updateData() call should return the the passed in list's size`() {
val adapter = AppShareAdapter(mockk()).apply { submitList(appOptions) } val adapter = AppShareAdapter(mockk()).apply { submitList(appOptions) }
assertThat(adapter.itemCount).isEqualTo(2) assertEquals(2, adapter.itemCount)
} }
@Test @Test
@ -67,7 +66,7 @@ class AppShareAdapterTest {
val viewHolder = adapter.onCreateViewHolder(parentView, 0) val viewHolder = adapter.onCreateViewHolder(parentView, 0)
assertThat(viewHolder::class).isEqualTo(AppViewHolder::class) assertEquals(AppViewHolder::class, viewHolder::class)
} }
@Test @Test
@ -78,7 +77,7 @@ class AppShareAdapterTest {
val viewHolder = adapter.onCreateViewHolder(parentView, 0) val viewHolder = adapter.onCreateViewHolder(parentView, 0)
assertThat(viewHolder.interactor).isEqualTo(interactor) assertEquals(interactor, viewHolder.interactor)
} }
@Test @Test