Implement opt-in to custom tabs in captive portals.
This will allow portal operators to opt-in to custom tabs in captive portal, either across the board with "true" or with a version of the module above which it wants to opt-in. Ideally there could be a separate key to also list opted-in browsers and their versions, but this would become a lot more complex. To start with, there is no place in CaptivePortalData to store this kind of info, and that would mean adding API which would have to be supported forever. The constant inside the source represents a capport source that contains the custom tabs opt-in. This is not a great place to put this information in, but it has the characteristics of a benign and useful hack : - Time to market is 0 - It's easy to remove once we have a better API - It's not a large problem if it's never cleaned up Also, allowing to choose the browsers and the versions would be uncomfortable since the choice of the browser is the user's choice. On the one hand it does make some sense that the operator could test with a given browser, see the UX is not well adapted, and reject it, but on the other hand giving the operator the choice of what browser the user can choose to use on their portal is disputable, as this should generally be under the control of the user. In any case even if we decided to add a per-browser version check it should be done in some other change. Test: manual Flag: EXEMPT opt-in feature Change-Id: I540f4fcb6fb26f7f18077d9c8d06e5f7df206056
This commit is contained in:
parent
adfbfab056
commit
f2cb190a73
1 changed files with 132 additions and 26 deletions
|
|
@ -57,20 +57,35 @@ class CaptivePortalDataTest {
|
|||
.apply {
|
||||
if (SdkLevel.isAtLeastS()) {
|
||||
setVenueFriendlyName("venue friendly name")
|
||||
setUserPortalUrl(Uri.parse("https://tc.example.com/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT)
|
||||
setVenueInfoUrl(Uri.parse("https://venue.example.com/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT)
|
||||
setUserPortalUrl(
|
||||
Uri.parse("https://tc.example.com/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT
|
||||
)
|
||||
setVenueInfoUrl(
|
||||
Uri.parse("https://venue.example.com/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT
|
||||
)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
|
||||
private val optInData = CaptivePortalData.Builder().apply {
|
||||
setCaptive(true)
|
||||
if (SdkLevel.isAtLeastS()) {
|
||||
setUserPortalUrl(
|
||||
Uri.parse("https://tc.example.passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_CAPPORT_WITH_CUSTOM_TABS_OPTIN
|
||||
)
|
||||
}
|
||||
}.build()
|
||||
|
||||
private fun makeBuilder() = CaptivePortalData.Builder(data)
|
||||
|
||||
@Test
|
||||
fun testParcelUnparcel() {
|
||||
assertParcelingIsLossless(data)
|
||||
assertParcelingIsLossless(dataFromPasspoint)
|
||||
if (SdkLevel.isAtLeastS()) assertParcelingIsLossless(optInData)
|
||||
|
||||
assertParcelingIsLossless(makeBuilder().setUserPortalUrl(null).build())
|
||||
assertParcelingIsLossless(makeBuilder().setVenueInfoUrl(null).build())
|
||||
|
|
@ -96,24 +111,35 @@ class CaptivePortalDataTest {
|
|||
|
||||
assertEquals(dataFromPasspoint, CaptivePortalData.Builder(dataFromPasspoint).build())
|
||||
assertNotEqualsAfterChange { it.setUserPortalUrl(
|
||||
Uri.parse("https://tc.example.com/passpoint")) }
|
||||
Uri.parse("https://tc.example.com/passpoint")
|
||||
) }
|
||||
assertNotEqualsAfterChange { it.setUserPortalUrl(
|
||||
Uri.parse("https://tc.example.com/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER) }
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER
|
||||
) }
|
||||
assertNotEqualsAfterChange { it.setUserPortalUrl(
|
||||
Uri.parse("https://tc.example.com/other"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT) }
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT
|
||||
) }
|
||||
assertNotEqualsAfterChange { it.setUserPortalUrl(
|
||||
Uri.parse("https://tc.example.com/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER) }
|
||||
Uri.parse("https://tc.example.com/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER
|
||||
) }
|
||||
assertNotEqualsAfterChange { it.setUserPortalUrl(
|
||||
Uri.parse("https://tc.example.com/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_CAPPORT_WITH_CUSTOM_TABS_OPTIN
|
||||
) }
|
||||
assertNotEqualsAfterChange { it.setVenueInfoUrl(
|
||||
Uri.parse("https://venue.example.com/passpoint")) }
|
||||
Uri.parse("https://venue.example.com/passpoint")
|
||||
) }
|
||||
assertNotEqualsAfterChange { it.setVenueInfoUrl(
|
||||
Uri.parse("https://venue.example.com/other"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT) }
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT
|
||||
) }
|
||||
assertNotEqualsAfterChange { it.setVenueInfoUrl(
|
||||
Uri.parse("https://venue.example.com/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER) }
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER
|
||||
) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -164,18 +190,32 @@ class CaptivePortalDataTest {
|
|||
|
||||
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
|
||||
fun testGetVenueInfoUrlSource() {
|
||||
assertEquals(CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER,
|
||||
data.venueInfoUrlSource)
|
||||
assertEquals(CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT,
|
||||
dataFromPasspoint.venueInfoUrlSource)
|
||||
assertEquals(
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER,
|
||||
data.venueInfoUrlSource
|
||||
)
|
||||
assertEquals(
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT,
|
||||
dataFromPasspoint.venueInfoUrlSource
|
||||
)
|
||||
}
|
||||
|
||||
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
|
||||
fun testGetUserPortalUrlSource() {
|
||||
assertEquals(CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER,
|
||||
data.userPortalUrlSource)
|
||||
assertEquals(CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT,
|
||||
dataFromPasspoint.userPortalUrlSource)
|
||||
assertEquals(
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER,
|
||||
data.userPortalUrlSource
|
||||
)
|
||||
assertEquals(
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT,
|
||||
dataFromPasspoint.userPortalUrlSource
|
||||
)
|
||||
if (SdkLevel.isAtLeastS()) {
|
||||
assertEquals(
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_CAPPORT_WITH_CUSTOM_TABS_OPTIN,
|
||||
optInData.userPortalUrlSource
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun CaptivePortalData.mutate(mutator: (CaptivePortalData.Builder) -> Unit) =
|
||||
|
|
@ -184,4 +224,4 @@ class CaptivePortalDataTest {
|
|||
private fun assertNotEqualsAfterChange(mutator: (CaptivePortalData.Builder) -> Unit) {
|
||||
assertNotEquals(data, data.mutate(mutator))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue