Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa56a9c1 authored by Chiachang Wang's avatar Chiachang Wang Committed by Automerger Merge Worker
Browse files

Merge "Add more tests for CaptivePortalData" am: 0bb146e4 am: 0cae3ac0

Change-Id: If5c56ad5ee02acf5964d31eb2445e3cd52249dc5
parents d01fcc54 0cae3ac0
Loading
Loading
Loading
Loading
+42 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,8 @@ import com.android.testutils.assertParcelSane
import com.android.testutils.assertParcelingIsLossless
import com.android.testutils.assertParcelingIsLossless
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo
import com.android.testutils.DevSdkIgnoreRunner
import com.android.testutils.DevSdkIgnoreRunner
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 kotlin.test.assertEquals
import kotlin.test.assertEquals
@@ -66,6 +68,46 @@ class CaptivePortalDataTest {
        assertNotEqualsAfterChange { it.setCaptive(false) }
        assertNotEqualsAfterChange { it.setCaptive(false) }
    }
    }


    @Test
    fun testUserPortalUrl() {
        assertEquals(Uri.parse("https://portal.example.com/test"), data.userPortalUrl)
    }

    @Test
    fun testVenueInfoUrl() {
        assertEquals(Uri.parse("https://venue.example.com/test"), data.venueInfoUrl)
    }

    @Test
    fun testIsSessionExtendable() {
        assertTrue(data.isSessionExtendable)
    }

    @Test
    fun testByteLimit() {
        assertEquals(456L, data.byteLimit)
        // Test byteLimit unset.
        assertEquals(-1L, CaptivePortalData.Builder(null).build().byteLimit)
    }

    @Test
    fun testRefreshTimeMillis() {
        assertEquals(123L, data.refreshTimeMillis)
    }

    @Test
    fun testExpiryTimeMillis() {
        assertEquals(789L, data.expiryTimeMillis)
        // Test expiryTimeMillis unset.
        assertEquals(-1L, CaptivePortalData.Builder(null).build().expiryTimeMillis)
    }

    @Test
    fun testIsCaptive() {
        assertTrue(data.isCaptive)
        assertFalse(makeBuilder().setCaptive(false).build().isCaptive)
    }

    private fun CaptivePortalData.mutate(mutator: (CaptivePortalData.Builder) -> Unit) =
    private fun CaptivePortalData.mutate(mutator: (CaptivePortalData.Builder) -> Unit) =
            CaptivePortalData.Builder(this).apply { mutator(this) }.build()
            CaptivePortalData.Builder(this).apply { mutator(this) }.build()