Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / communicate-dev / src / test / java / com / vayunmathur / communicate / rcs / GbaBootstrapRcsPass3Test.kt

GbaBootstrapRcsPass3Test.kt40 lines · 1.6 KiBRaw
1package com.vayunmathur.communicate.rcs
2
3import android.content.Context
4import androidx.test.core.app.ApplicationProvider
5import com.vayunmathur.communicate.data.rcs.RcsGbaBootstrap
6import kotlinx.coroutines.runBlocking
7import org.junit.runner.RunWith
8import org.robolectric.RobolectricTestRunner
9import org.robolectric.shadows.ShadowSubscriptionManager
10import kotlin.test.AfterTest
11import kotlin.test.Test
12import kotlin.test.assertNull
13
14/**
15 * Pass 3: GBA bootstrap fail-fast guards. The modem round trip itself
16 * (TelephonyManager.bootstrapAuthenticationRequest, reached
17 * reflectively by production) silently no-ops under Robolectric —
18 * neither the default shadow nor an exact-signature custom shadow
19 * receives the reflective call — so onKeysAvailable delivery cannot
20 * be driven on the JVM; that path is exercised on-device only.
21 */
22@RunWith(RobolectricTestRunner::class)
23class GbaBootstrapRcsPass3Test {
24 private val context: Context get() = ApplicationProvider.getApplicationContext()
25
26 @AfterTest fun tearDown() {
27 ShadowSubscriptionManager.setDefaultSmsSubscriptionId(-1)
28 }
29
30 @Test fun blankUrlFailsFast() = runBlocking {
31 ShadowSubscriptionManager.setDefaultSmsSubscriptionId(1)
32 assertNull(RcsGbaBootstrap.bootstrap(context, "", force = false))
33 assertNull(RcsGbaBootstrap.bootstrap(context, " ", force = true))
34 }
35
36 @Test fun invalidSubscriptionFailsFast() = runBlocking {
37 ShadowSubscriptionManager.setDefaultSmsSubscriptionId(-1)
38 assertNull(RcsGbaBootstrap.bootstrap(context, "https://naf.example.com", force = false))
39 }
40}