diff options
author | Chiachang Wang <chiachangwang@google.com> | 2020-04-13 09:46:20 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-04-13 09:46:20 +0000 |
commit | 0bb146e48cbc0ad3441af848cb63b5408e099032 (patch) | |
tree | dfd8e8c9440065fe256050fb6b54d286a2bcdb96 | |
parent | fcdea07db41c32e424633a77c797e94252dd7e12 (diff) | |
parent | 55bde27f29990117f2d9cd4a913a605ebb27c256 (diff) |
Merge "Add more tests for CaptivePortalData"
-rw-r--r-- | tests/net/common/java/android/net/CaptivePortalDataTest.kt | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/net/common/java/android/net/CaptivePortalDataTest.kt b/tests/net/common/java/android/net/CaptivePortalDataTest.kt index 51068c2c575f..bd1847b7c440 100644 --- a/tests/net/common/java/android/net/CaptivePortalDataTest.kt +++ b/tests/net/common/java/android/net/CaptivePortalDataTest.kt @@ -22,6 +22,8 @@ import com.android.testutils.assertParcelSane import com.android.testutils.assertParcelingIsLossless import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo import com.android.testutils.DevSdkIgnoreRunner +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue import org.junit.Test import org.junit.runner.RunWith import kotlin.test.assertEquals @@ -66,6 +68,46 @@ class CaptivePortalDataTest { 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) = CaptivePortalData.Builder(this).apply { mutator(this) }.build() |