1
0
Fork 0
fenix/app/src/test/java/org/mozilla/fenix/customtabs/PoweredByNotificationTest.kt

60 lines
2.0 KiB
Kotlin

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.customtabs
import mozilla.components.browser.state.state.BrowserState
import mozilla.components.browser.state.state.CustomTabConfig
import mozilla.components.browser.state.state.ExternalAppType
import mozilla.components.browser.state.state.createCustomTab
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.TestApplication
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(application = TestApplication::class)
class PoweredByNotificationTest {
@Test
fun `register receiver on resume`() {
val config = CustomTabConfig(externalAppType = ExternalAppType.TRUSTED_WEB_ACTIVITY)
val store = BrowserStore(
BrowserState(
customTabs = listOf(
createCustomTab("https://mozilla.org", config = config)
)
)
)
val feature = PoweredByNotification(testContext, store, "session-id")
feature.onResume()
}
@Test
fun `don't register receiver if not in a TWA`() {
val config = CustomTabConfig(externalAppType = ExternalAppType.PROGRESSIVE_WEB_APP)
val store = BrowserStore(
BrowserState(
customTabs = listOf(
createCustomTab("https://mozilla.org", config = config)
)
)
)
val feature = PoweredByNotification(testContext, store, "session-id")
feature.onResume()
}
@Test
fun `unregister receiver on pause`() {
val feature = PoweredByNotification(testContext, mock(), "session-id")
feature.onPause()
}
}