Fix CaptivePortalDataTest on R-
The new venue friendly name field is not present on R- Bug: 162783305 Change-Id: I63bd9c61d27c7d3b07826053373c9c5e38666948 Test: atest FrameworksNetTests
This commit is contained in:
@@ -24,6 +24,7 @@ java_library {
|
|||||||
"androidx.test.rules",
|
"androidx.test.rules",
|
||||||
"junit",
|
"junit",
|
||||||
"mockito-target-minus-junit4",
|
"mockito-target-minus-junit4",
|
||||||
|
"modules-utils-build",
|
||||||
"net-tests-utils",
|
"net-tests-utils",
|
||||||
"net-utils-framework-common",
|
"net-utils-framework-common",
|
||||||
"platform-test-annotations",
|
"platform-test-annotations",
|
||||||
|
|||||||
@@ -18,12 +18,15 @@ package android.net
|
|||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
|
import com.android.modules.utils.build.SdkLevel
|
||||||
import com.android.testutils.assertParcelSane
|
import com.android.testutils.assertParcelSane
|
||||||
import com.android.testutils.assertParcelingIsLossless
|
import com.android.testutils.assertParcelingIsLossless
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule
|
||||||
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.assertFalse
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Rule
|
||||||
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
|
||||||
@@ -33,6 +36,9 @@ import kotlin.test.assertNotEquals
|
|||||||
@RunWith(DevSdkIgnoreRunner::class)
|
@RunWith(DevSdkIgnoreRunner::class)
|
||||||
@IgnoreUpTo(Build.VERSION_CODES.Q)
|
@IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
class CaptivePortalDataTest {
|
class CaptivePortalDataTest {
|
||||||
|
@Rule @JvmField
|
||||||
|
val ignoreRule = DevSdkIgnoreRule()
|
||||||
|
|
||||||
private val data = CaptivePortalData.Builder()
|
private val data = CaptivePortalData.Builder()
|
||||||
.setRefreshTime(123L)
|
.setRefreshTime(123L)
|
||||||
.setUserPortalUrl(Uri.parse("https://portal.example.com/test"))
|
.setUserPortalUrl(Uri.parse("https://portal.example.com/test"))
|
||||||
@@ -41,7 +47,11 @@ class CaptivePortalDataTest {
|
|||||||
.setBytesRemaining(456L)
|
.setBytesRemaining(456L)
|
||||||
.setExpiryTime(789L)
|
.setExpiryTime(789L)
|
||||||
.setCaptive(true)
|
.setCaptive(true)
|
||||||
.setVenueFriendlyName("venue friendly name")
|
.apply {
|
||||||
|
if (SdkLevel.isAtLeastS()) {
|
||||||
|
setVenueFriendlyName("venue friendly name")
|
||||||
|
}
|
||||||
|
}
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
private fun makeBuilder() = CaptivePortalData.Builder(data)
|
private fun makeBuilder() = CaptivePortalData.Builder(data)
|
||||||
@@ -67,9 +77,12 @@ class CaptivePortalDataTest {
|
|||||||
assertNotEqualsAfterChange { it.setBytesRemaining(789L) }
|
assertNotEqualsAfterChange { it.setBytesRemaining(789L) }
|
||||||
assertNotEqualsAfterChange { it.setExpiryTime(12L) }
|
assertNotEqualsAfterChange { it.setExpiryTime(12L) }
|
||||||
assertNotEqualsAfterChange { it.setCaptive(false) }
|
assertNotEqualsAfterChange { it.setCaptive(false) }
|
||||||
|
|
||||||
|
if (SdkLevel.isAtLeastS()) {
|
||||||
assertNotEqualsAfterChange { it.setVenueFriendlyName("another friendly name") }
|
assertNotEqualsAfterChange { it.setVenueFriendlyName("another friendly name") }
|
||||||
assertNotEqualsAfterChange { it.setVenueFriendlyName(null) }
|
assertNotEqualsAfterChange { it.setVenueFriendlyName(null) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testUserPortalUrl() {
|
fun testUserPortalUrl() {
|
||||||
@@ -111,7 +124,7 @@ class CaptivePortalDataTest {
|
|||||||
assertFalse(makeBuilder().setCaptive(false).build().isCaptive)
|
assertFalse(makeBuilder().setCaptive(false).build().isCaptive)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
|
||||||
fun testVenueFriendlyName() {
|
fun testVenueFriendlyName() {
|
||||||
assertEquals("venue friendly name", data.venueFriendlyName)
|
assertEquals("venue friendly name", data.venueFriendlyName)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user