Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / communicate-dev / src / test / java / com / vayunmathur / communicate / rcs / GbaBootstrapRcsPass3Test.kt
GbaBootstrapRcsPass3Test.kt40 lines · 1.6 KiBRaw
| 1 | package com.vayunmathur.communicate.rcs |
| 2 | |
| 3 | import android.content.Context |
| 4 | import androidx.test.core.app.ApplicationProvider |
| 5 | import com.vayunmathur.communicate.data.rcs.RcsGbaBootstrap |
| 6 | import kotlinx.coroutines.runBlocking |
| 7 | import org.junit.runner.RunWith |
| 8 | import org.robolectric.RobolectricTestRunner |
| 9 | import org.robolectric.shadows.ShadowSubscriptionManager |
| 10 | import kotlin.test.AfterTest |
| 11 | import kotlin.test.Test |
| 12 | import 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) |
| 23 | class 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 | } |