mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/17917: Use View binding in Onboarding Tests
This commit is contained in:
parent
fc836a8ea4
commit
179dd793ad
@ -5,14 +5,12 @@
|
|||||||
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.coEvery
|
import io.mockk.coEvery
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.mockkObject
|
import io.mockk.mockkObject
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import io.mockk.unmockkObject
|
import io.mockk.unmockkObject
|
||||||
import kotlinx.android.synthetic.main.onboarding_automatic_signin.view.*
|
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.coroutines.test.runBlockingTest
|
import kotlinx.coroutines.test.runBlockingTest
|
||||||
@ -28,6 +26,7 @@ import org.junit.Test
|
|||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mozilla.fenix.components.BackgroundServices
|
import org.mozilla.fenix.components.BackgroundServices
|
||||||
import org.mozilla.fenix.components.FenixSnackbar
|
import org.mozilla.fenix.components.FenixSnackbar
|
||||||
|
import org.mozilla.fenix.databinding.OnboardingAutomaticSigninBinding
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
|
|
||||||
@ -35,14 +34,13 @@ import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
|||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class OnboardingAutomaticSignInViewHolderTest {
|
class OnboardingAutomaticSignInViewHolderTest {
|
||||||
|
|
||||||
private lateinit var view: View
|
|
||||||
private lateinit var backgroundServices: BackgroundServices
|
private lateinit var backgroundServices: BackgroundServices
|
||||||
private lateinit var snackbar: FenixSnackbar
|
private lateinit var snackbar: FenixSnackbar
|
||||||
|
private lateinit var binding: OnboardingAutomaticSigninBinding
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
view = LayoutInflater.from(testContext)
|
binding = OnboardingAutomaticSigninBinding.inflate(LayoutInflater.from(testContext))
|
||||||
.inflate(OnboardingAutomaticSignInViewHolder.LAYOUT_ID, null)
|
|
||||||
snackbar = mockk(relaxed = true)
|
snackbar = mockk(relaxed = true)
|
||||||
mockkObject(FenixSnackbar.Companion)
|
mockkObject(FenixSnackbar.Companion)
|
||||||
|
|
||||||
@ -57,7 +55,7 @@ class OnboardingAutomaticSignInViewHolderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `bind updates header text`() {
|
fun `bind updates header text`() {
|
||||||
val holder = OnboardingAutomaticSignInViewHolder(view)
|
val holder = OnboardingAutomaticSignInViewHolder(binding.root)
|
||||||
holder.bind(
|
holder.bind(
|
||||||
mockk {
|
mockk {
|
||||||
every { email } returns "email@example.com"
|
every { email } returns "email@example.com"
|
||||||
@ -65,9 +63,9 @@ class OnboardingAutomaticSignInViewHolderTest {
|
|||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"You are signed in as email@example.com on another Firefox browser on this device. Would you like to sign in with this account?",
|
"You are signed in as email@example.com on another Firefox browser on this device. Would you like to sign in with this account?",
|
||||||
view.header_text.text
|
binding.headerText.text
|
||||||
)
|
)
|
||||||
assertTrue(view.fxa_sign_in_button.isEnabled)
|
assertTrue(binding.fxaSignInButton.isEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -79,12 +77,12 @@ class OnboardingAutomaticSignInViewHolderTest {
|
|||||||
backgroundServices.accountManager.migrateFromAccount(account)
|
backgroundServices.accountManager.migrateFromAccount(account)
|
||||||
} returns MigrationResult.Success
|
} returns MigrationResult.Success
|
||||||
|
|
||||||
val holder = OnboardingAutomaticSignInViewHolder(view, scope = this)
|
val holder = OnboardingAutomaticSignInViewHolder(binding.root, scope = this)
|
||||||
holder.bind(account)
|
holder.bind(account)
|
||||||
holder.onClick(view.fxa_sign_in_button)
|
holder.onClick(binding.fxaSignInButton)
|
||||||
|
|
||||||
assertEquals("Signing in…", view.fxa_sign_in_button.text)
|
assertEquals("Signing in…", binding.fxaSignInButton.text)
|
||||||
assertFalse(view.fxa_sign_in_button.isEnabled)
|
assertFalse(binding.fxaSignInButton.isEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -96,12 +94,12 @@ class OnboardingAutomaticSignInViewHolderTest {
|
|||||||
backgroundServices.accountManager.migrateFromAccount(account)
|
backgroundServices.accountManager.migrateFromAccount(account)
|
||||||
} returns MigrationResult.WillRetry
|
} returns MigrationResult.WillRetry
|
||||||
|
|
||||||
val holder = OnboardingAutomaticSignInViewHolder(view, scope = this)
|
val holder = OnboardingAutomaticSignInViewHolder(binding.root, scope = this)
|
||||||
holder.bind(account)
|
holder.bind(account)
|
||||||
holder.onClick(view.fxa_sign_in_button)
|
holder.onClick(binding.fxaSignInButton)
|
||||||
|
|
||||||
assertEquals("Signing in…", view.fxa_sign_in_button.text)
|
assertEquals("Signing in…", binding.fxaSignInButton.text)
|
||||||
assertFalse(view.fxa_sign_in_button.isEnabled)
|
assertFalse(binding.fxaSignInButton.isEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -113,12 +111,12 @@ class OnboardingAutomaticSignInViewHolderTest {
|
|||||||
backgroundServices.accountManager.migrateFromAccount(account)
|
backgroundServices.accountManager.migrateFromAccount(account)
|
||||||
} returns MigrationResult.Failure
|
} returns MigrationResult.Failure
|
||||||
|
|
||||||
val holder = OnboardingAutomaticSignInViewHolder(view, scope = this)
|
val holder = OnboardingAutomaticSignInViewHolder(binding.root, scope = this)
|
||||||
holder.bind(account)
|
holder.bind(account)
|
||||||
holder.onClick(view.fxa_sign_in_button)
|
holder.onClick(binding.fxaSignInButton)
|
||||||
|
|
||||||
assertEquals("Yes, sign me in", view.fxa_sign_in_button.text)
|
assertEquals("Yes, sign me in", binding.fxaSignInButton.text)
|
||||||
assertTrue(view.fxa_sign_in_button.isEnabled)
|
assertTrue(binding.fxaSignInButton.isEnabled)
|
||||||
verify { snackbar.setText("Failed to sign-in") }
|
verify { snackbar.setText("Failed to sign-in") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,35 +5,33 @@
|
|||||||
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.android.synthetic.main.onboarding_finish.view.*
|
|
||||||
import mozilla.components.support.test.robolectric.testContext
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
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.databinding.OnboardingFinishBinding
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
import org.mozilla.fenix.home.sessioncontrol.OnboardingInteractor
|
import org.mozilla.fenix.home.sessioncontrol.OnboardingInteractor
|
||||||
|
|
||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class OnboardingFinishViewHolderTest {
|
class OnboardingFinishViewHolderTest {
|
||||||
|
|
||||||
private lateinit var view: View
|
private lateinit var binding: OnboardingFinishBinding
|
||||||
private lateinit var interactor: OnboardingInteractor
|
private lateinit var interactor: OnboardingInteractor
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
view = LayoutInflater.from(testContext)
|
binding = OnboardingFinishBinding.inflate(LayoutInflater.from(testContext))
|
||||||
.inflate(OnboardingFinishViewHolder.LAYOUT_ID, null)
|
|
||||||
interactor = mockk(relaxed = true)
|
interactor = mockk(relaxed = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `call interactor on click`() {
|
fun `call interactor on click`() {
|
||||||
OnboardingFinishViewHolder(view, interactor)
|
OnboardingFinishViewHolder(binding.root, interactor)
|
||||||
|
|
||||||
view.finish_button.performClick()
|
binding.finishButton.performClick()
|
||||||
verify { interactor.onStartBrowsingClicked() }
|
verify { interactor.onStartBrowsingClicked() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,25 +5,23 @@
|
|||||||
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import kotlinx.android.synthetic.main.onboarding_header.view.*
|
|
||||||
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.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.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.databinding.OnboardingHeaderBinding
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
|
|
||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class OnboardingHeaderViewHolderTest {
|
class OnboardingHeaderViewHolderTest {
|
||||||
|
|
||||||
private lateinit var view: View
|
private lateinit var binding: OnboardingHeaderBinding
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
view = LayoutInflater.from(testContext)
|
binding = OnboardingHeaderBinding.inflate(LayoutInflater.from(testContext))
|
||||||
.inflate(OnboardingHeaderViewHolder.LAYOUT_ID, null)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -31,8 +29,8 @@ class OnboardingHeaderViewHolderTest {
|
|||||||
val appName = testContext.getString(R.string.app_name)
|
val appName = testContext.getString(R.string.app_name)
|
||||||
val welcomeMessage = testContext.getString(R.string.onboarding_header, appName)
|
val welcomeMessage = testContext.getString(R.string.onboarding_header, appName)
|
||||||
|
|
||||||
OnboardingHeaderViewHolder(view)
|
OnboardingHeaderViewHolder(binding.root)
|
||||||
|
|
||||||
assertEquals(welcomeMessage, view.header_text.text)
|
assertEquals(welcomeMessage, binding.headerText.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.navigation.Navigation
|
import androidx.navigation.Navigation
|
||||||
@ -14,7 +13,6 @@ import io.mockk.mockk
|
|||||||
import io.mockk.mockkStatic
|
import io.mockk.mockkStatic
|
||||||
import io.mockk.unmockkStatic
|
import io.mockk.unmockkStatic
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.android.synthetic.main.onboarding_manual_signin.view.*
|
|
||||||
import mozilla.components.support.test.robolectric.testContext
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
@ -22,26 +20,26 @@ 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.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.databinding.OnboardingManualSigninBinding
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||||
|
|
||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class OnboardingManualSignInViewHolderTest {
|
class OnboardingManualSignInViewHolderTest {
|
||||||
|
|
||||||
private lateinit var view: View
|
private lateinit var binding: OnboardingManualSigninBinding
|
||||||
private lateinit var navController: NavController
|
private lateinit var navController: NavController
|
||||||
private lateinit var itemView: ViewGroup
|
private lateinit var itemView: ViewGroup
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
view = LayoutInflater.from(testContext)
|
binding = OnboardingManualSigninBinding.inflate(LayoutInflater.from(testContext))
|
||||||
.inflate(OnboardingManualSignInViewHolder.LAYOUT_ID, null)
|
|
||||||
navController = mockk(relaxed = true)
|
navController = mockk(relaxed = true)
|
||||||
itemView = mockk(relaxed = true)
|
itemView = mockk(relaxed = true)
|
||||||
|
|
||||||
mockkStatic(Navigation::class)
|
mockkStatic(Navigation::class)
|
||||||
every { itemView.context } returns testContext
|
every { itemView.context } returns testContext
|
||||||
every { Navigation.findNavController(view) } returns navController
|
every { Navigation.findNavController(binding.root) } returns navController
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@ -51,18 +49,18 @@ class OnboardingManualSignInViewHolderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `bind header text`() {
|
fun `bind header text`() {
|
||||||
OnboardingManualSignInViewHolder(view).bind()
|
OnboardingManualSignInViewHolder(binding.root).bind()
|
||||||
val string = testContext.getString(R.string.onboarding_account_sign_in_header_1)
|
val string = testContext.getString(R.string.onboarding_account_sign_in_header_1)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
string,
|
string,
|
||||||
view.header_text.text
|
binding.headerText.text
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `navigate on click`() {
|
fun `navigate on click`() {
|
||||||
OnboardingManualSignInViewHolder(view)
|
OnboardingManualSignInViewHolder(binding.root)
|
||||||
view.fxa_sign_in_button.performClick()
|
binding.fxaSignInButton.performClick()
|
||||||
|
|
||||||
verify { navController.navigate(HomeFragmentDirections.actionGlobalTurnOnSync()) }
|
verify { navController.navigate(HomeFragmentDirections.actionGlobalTurnOnSync()) }
|
||||||
}
|
}
|
||||||
|
@ -5,38 +5,36 @@
|
|||||||
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.android.synthetic.main.onboarding_private_browsing.view.*
|
|
||||||
import mozilla.components.support.test.robolectric.testContext
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
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.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.databinding.OnboardingPrivateBrowsingBinding
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
import org.mozilla.fenix.home.sessioncontrol.OnboardingInteractor
|
import org.mozilla.fenix.home.sessioncontrol.OnboardingInteractor
|
||||||
|
|
||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class OnboardingPrivacyBrowsingViewHolderTest {
|
class OnboardingPrivacyBrowsingViewHolderTest {
|
||||||
|
|
||||||
private lateinit var view: View
|
private lateinit var binding: OnboardingPrivateBrowsingBinding
|
||||||
private lateinit var interactor: OnboardingInteractor
|
private lateinit var interactor: OnboardingInteractor
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
val context = ContextThemeWrapper(testContext, R.style.NormalTheme)
|
val context = ContextThemeWrapper(testContext, R.style.NormalTheme)
|
||||||
view = LayoutInflater.from(context)
|
binding = OnboardingPrivateBrowsingBinding.inflate(LayoutInflater.from(context))
|
||||||
.inflate(OnboardingPrivateBrowsingViewHolder.LAYOUT_ID, null)
|
|
||||||
interactor = mockk(relaxed = true)
|
interactor = mockk(relaxed = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `call interactor on click`() {
|
fun `call interactor on click`() {
|
||||||
OnboardingPrivateBrowsingViewHolder(view, interactor)
|
OnboardingPrivateBrowsingViewHolder(binding.root, interactor)
|
||||||
|
|
||||||
view.open_settings_button.performClick()
|
binding.openSettingsButton.performClick()
|
||||||
verify { interactor.onOpenSettingsClicked() }
|
verify { interactor.onOpenSettingsClicked() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,38 +5,36 @@
|
|||||||
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.android.synthetic.main.onboarding_privacy_notice.view.*
|
|
||||||
import mozilla.components.support.test.robolectric.testContext
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
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.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.databinding.OnboardingPrivacyNoticeBinding
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
import org.mozilla.fenix.home.sessioncontrol.OnboardingInteractor
|
import org.mozilla.fenix.home.sessioncontrol.OnboardingInteractor
|
||||||
|
|
||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class OnboardingPrivacyNoticeViewHolderTest {
|
class OnboardingPrivacyNoticeViewHolderTest {
|
||||||
|
|
||||||
private lateinit var view: View
|
private lateinit var binding: OnboardingPrivacyNoticeBinding
|
||||||
private lateinit var interactor: OnboardingInteractor
|
private lateinit var interactor: OnboardingInteractor
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
val context = ContextThemeWrapper(testContext, R.style.NormalTheme)
|
val context = ContextThemeWrapper(testContext, R.style.NormalTheme)
|
||||||
view = LayoutInflater.from(context)
|
binding = OnboardingPrivacyNoticeBinding.inflate(LayoutInflater.from(context))
|
||||||
.inflate(OnboardingPrivacyNoticeViewHolder.LAYOUT_ID, null)
|
|
||||||
interactor = mockk(relaxed = true)
|
interactor = mockk(relaxed = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `call interactor on click`() {
|
fun `call interactor on click`() {
|
||||||
OnboardingPrivacyNoticeViewHolder(view, interactor)
|
OnboardingPrivacyNoticeViewHolder(binding.root, interactor)
|
||||||
|
|
||||||
view.read_button.performClick()
|
binding.readButton.performClick()
|
||||||
verify { interactor.onReadPrivacyNoticeClicked() }
|
verify { interactor.onReadPrivacyNoticeClicked() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,34 +5,32 @@
|
|||||||
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import kotlinx.android.synthetic.main.onboarding_section_header.view.*
|
|
||||||
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.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.databinding.OnboardingSectionHeaderBinding
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
|
|
||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class OnboardingSectionHeaderViewHolderTest {
|
class OnboardingSectionHeaderViewHolderTest {
|
||||||
|
|
||||||
private lateinit var view: View
|
private lateinit var binding: OnboardingSectionHeaderBinding
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
view = LayoutInflater.from(testContext)
|
binding = OnboardingSectionHeaderBinding.inflate(LayoutInflater.from(testContext))
|
||||||
.inflate(OnboardingSectionHeaderViewHolder.LAYOUT_ID, null)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `bind text`() {
|
fun `bind text`() {
|
||||||
val holder = OnboardingSectionHeaderViewHolder(view)
|
val holder = OnboardingSectionHeaderViewHolder(binding.root)
|
||||||
holder.bind { "Hello world" }
|
holder.bind { "Hello world" }
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Hello world",
|
"Hello world",
|
||||||
view.section_header_text.text
|
binding.sectionHeaderText.text
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import kotlinx.android.synthetic.main.onboarding_toolbar_position_picker.view.*
|
|
||||||
import mozilla.components.support.test.robolectric.testContext
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
import org.junit.Assert.assertFalse
|
import org.junit.Assert.assertFalse
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
@ -16,44 +14,44 @@ import org.junit.Test
|
|||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.components.toolbar.ToolbarPosition
|
import org.mozilla.fenix.components.toolbar.ToolbarPosition
|
||||||
|
import org.mozilla.fenix.databinding.OnboardingToolbarPositionPickerBinding
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.utils.Settings
|
||||||
|
|
||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class OnboardingToolbarPositionPickerViewHolderTest {
|
class OnboardingToolbarPositionPickerViewHolderTest {
|
||||||
|
|
||||||
private lateinit var view: View
|
private lateinit var binding: OnboardingToolbarPositionPickerBinding
|
||||||
private lateinit var settings: Settings
|
private lateinit var settings: Settings
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
val components = testContext.components
|
val components = testContext.components
|
||||||
view = LayoutInflater.from(testContext)
|
binding = OnboardingToolbarPositionPickerBinding.inflate(LayoutInflater.from(testContext))
|
||||||
.inflate(OnboardingToolbarPositionPickerViewHolder.LAYOUT_ID, null)
|
|
||||||
settings = components.settings
|
settings = components.settings
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `bottom illustration should select corresponding radio button`() {
|
fun `bottom illustration should select corresponding radio button`() {
|
||||||
every { settings.toolbarPosition } returns ToolbarPosition.TOP
|
every { settings.toolbarPosition } returns ToolbarPosition.TOP
|
||||||
OnboardingToolbarPositionPickerViewHolder(view)
|
OnboardingToolbarPositionPickerViewHolder(binding.root)
|
||||||
assertTrue(view.toolbar_top_radio_button.isChecked)
|
assertTrue(binding.toolbarTopRadioButton.isChecked)
|
||||||
assertFalse(view.toolbar_bottom_radio_button.isChecked)
|
assertFalse(binding.toolbarBottomRadioButton.isChecked)
|
||||||
|
|
||||||
view.toolbar_bottom_image.performClick()
|
binding.toolbarBottomImage.performClick()
|
||||||
assertFalse(view.toolbar_top_radio_button.isChecked)
|
assertFalse(binding.toolbarTopRadioButton.isChecked)
|
||||||
assertTrue(view.toolbar_bottom_radio_button.isChecked)
|
assertTrue(binding.toolbarBottomRadioButton.isChecked)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `top illustration should select corresponding radio button`() {
|
fun `top illustration should select corresponding radio button`() {
|
||||||
every { settings.toolbarPosition } returns ToolbarPosition.BOTTOM
|
every { settings.toolbarPosition } returns ToolbarPosition.BOTTOM
|
||||||
OnboardingToolbarPositionPickerViewHolder(view)
|
OnboardingToolbarPositionPickerViewHolder(binding.root)
|
||||||
assertFalse(view.toolbar_top_radio_button.isChecked)
|
assertFalse(binding.toolbarTopRadioButton.isChecked)
|
||||||
assertTrue(view.toolbar_bottom_radio_button.isChecked)
|
assertTrue(binding.toolbarBottomRadioButton.isChecked)
|
||||||
|
|
||||||
view.toolbar_top_image.performClick()
|
binding.toolbarTopImage.performClick()
|
||||||
assertTrue(view.toolbar_top_radio_button.isChecked)
|
assertTrue(binding.toolbarTopRadioButton.isChecked)
|
||||||
assertFalse(view.toolbar_bottom_radio_button.isChecked)
|
assertFalse(binding.toolbarBottomRadioButton.isChecked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,34 +5,32 @@
|
|||||||
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
import kotlinx.android.synthetic.main.onboarding_tracking_protection.view.*
|
|
||||||
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.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.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.databinding.OnboardingTrackingProtectionBinding
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
|
|
||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class OnboardingTrackingProtectionViewHolderTest {
|
class OnboardingTrackingProtectionViewHolderTest {
|
||||||
|
|
||||||
private lateinit var view: View
|
private lateinit var binding: OnboardingTrackingProtectionBinding
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
val context = ContextThemeWrapper(testContext, R.style.NormalTheme)
|
val context = ContextThemeWrapper(testContext, R.style.NormalTheme)
|
||||||
view = LayoutInflater.from(context)
|
binding = OnboardingTrackingProtectionBinding.inflate(LayoutInflater.from(context))
|
||||||
.inflate(OnboardingTrackingProtectionViewHolder.LAYOUT_ID, null)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `sets description text`() {
|
fun `sets description text`() {
|
||||||
OnboardingTrackingProtectionViewHolder(view)
|
OnboardingTrackingProtectionViewHolder(binding.root)
|
||||||
|
|
||||||
val string = testContext.getString(R.string.onboarding_tracking_protection_description_3)
|
val string = testContext.getString(R.string.onboarding_tracking_protection_description_3)
|
||||||
assertEquals(string, view.description_text.text)
|
assertEquals(string, binding.descriptionText.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
|||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
import androidx.core.text.HtmlCompat.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE
|
import androidx.core.text.HtmlCompat.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
@ -15,7 +14,6 @@ import io.mockk.mockk
|
|||||||
import io.mockk.mockkStatic
|
import io.mockk.mockkStatic
|
||||||
import io.mockk.unmockkStatic
|
import io.mockk.unmockkStatic
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.android.synthetic.main.onboarding_whats_new.view.*
|
|
||||||
import mozilla.components.support.ktx.android.content.res.resolveAttribute
|
import mozilla.components.support.ktx.android.content.res.resolveAttribute
|
||||||
import mozilla.components.support.test.robolectric.testContext
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
@ -25,20 +23,20 @@ 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.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.databinding.OnboardingWhatsNewBinding
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
import org.mozilla.fenix.home.sessioncontrol.OnboardingInteractor
|
import org.mozilla.fenix.home.sessioncontrol.OnboardingInteractor
|
||||||
|
|
||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class OnboardingWhatsNewViewHolderTest {
|
class OnboardingWhatsNewViewHolderTest {
|
||||||
|
|
||||||
private lateinit var view: View
|
private lateinit var binding: OnboardingWhatsNewBinding
|
||||||
private lateinit var interactor: OnboardingInteractor
|
private lateinit var interactor: OnboardingInteractor
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
mockkStatic("mozilla.components.support.ktx.android.content.res.ThemeKt")
|
mockkStatic("mozilla.components.support.ktx.android.content.res.ThemeKt")
|
||||||
view = LayoutInflater.from(testContext)
|
binding = OnboardingWhatsNewBinding.inflate(LayoutInflater.from(testContext))
|
||||||
.inflate(OnboardingWhatsNewViewHolder.LAYOUT_ID, null)
|
|
||||||
interactor = mockk(relaxed = true)
|
interactor = mockk(relaxed = true)
|
||||||
|
|
||||||
every {
|
every {
|
||||||
@ -53,22 +51,22 @@ class OnboardingWhatsNewViewHolderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `sets and styles strings`() {
|
fun `sets and styles strings`() {
|
||||||
OnboardingWhatsNewViewHolder(view, interactor)
|
OnboardingWhatsNewViewHolder(binding.root, interactor)
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Have questions about the redesigned Firefox Preview? Want to know what’s changed?",
|
"Have questions about the redesigned Firefox Preview? Want to know what’s changed?",
|
||||||
view.description_text.text
|
binding.descriptionText.text
|
||||||
)
|
)
|
||||||
|
|
||||||
val getAnswersHtml = HtmlCompat.toHtml(view.get_answers.text as Spanned, TO_HTML_PARAGRAPH_LINES_CONSECUTIVE)
|
val getAnswersHtml = HtmlCompat.toHtml(binding.getAnswers.text as Spanned, TO_HTML_PARAGRAPH_LINES_CONSECUTIVE)
|
||||||
assertTrue(getAnswersHtml, "<u>Get answers here</u>" in getAnswersHtml)
|
assertTrue(getAnswersHtml, "<u>Get answers here</u>" in getAnswersHtml)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `call interactor on click`() {
|
fun `call interactor on click`() {
|
||||||
OnboardingWhatsNewViewHolder(view, interactor)
|
OnboardingWhatsNewViewHolder(binding.root, interactor)
|
||||||
|
|
||||||
view.get_answers.performClick()
|
binding.getAnswers.performClick()
|
||||||
verify { interactor.onWhatsNewGetAnswersClicked() }
|
verify { interactor.onWhatsNewGetAnswersClicked() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user