Merge "Fix test_hotspot_upstream_cellular failure" into main am: 0781c74af4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3127453 Change-Id: I04e5fe36b6eb88b1a38c941c30c1513b6ea2a0d3 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
4eb3a09d7f
3 changed files with 33 additions and 13 deletions
|
|
@ -34,6 +34,9 @@ class ConnectivityMultiDevicesTest(base_test.BaseTestClass):
|
|||
)
|
||||
|
||||
def test_hotspot_upstream_wifi(self):
|
||||
tether_utils.assume_hotspot_test_preconditions(
|
||||
self.serverDevice, self.clientDevice, UpstreamType.WIFI
|
||||
)
|
||||
try:
|
||||
# Connectivity of the client verified by asserting the validated capability.
|
||||
tether_utils.setup_hotspot_and_client_for_upstream_type(
|
||||
|
|
@ -45,6 +48,9 @@ class ConnectivityMultiDevicesTest(base_test.BaseTestClass):
|
|||
)
|
||||
|
||||
def test_hotspot_upstream_cellular(self):
|
||||
tether_utils.assume_hotspot_test_preconditions(
|
||||
self.serverDevice, self.clientDevice, UpstreamType.CELLULAR
|
||||
)
|
||||
try:
|
||||
# Connectivity of the client verified by asserting the validated capability.
|
||||
tether_utils.setup_hotspot_and_client_for_upstream_type(
|
||||
|
|
|
|||
|
|
@ -77,9 +77,9 @@ class ConnectivityMultiDevicesSnippet : Snippet {
|
|||
ctsNetUtils.expectNetworkIsSystemDefault(network)
|
||||
}
|
||||
|
||||
@Rpc(description = "Unrequest cellular connection.")
|
||||
fun unrequestCellular() {
|
||||
cbHelper.unrequestCell()
|
||||
@Rpc(description = "Unregister all connections.")
|
||||
fun unregisterAll() {
|
||||
cbHelper.unregisterAll()
|
||||
}
|
||||
|
||||
@Rpc(description = "Ensure any wifi is connected and is the default network.")
|
||||
|
|
|
|||
|
|
@ -46,6 +46,32 @@ def generate_uuid32_base64() -> str:
|
|||
return base64.b64encode(uuid.uuid1().bytes).decode("utf-8").strip("=")
|
||||
|
||||
|
||||
def assume_hotspot_test_preconditions(
|
||||
server_device: android_device,
|
||||
client_device: android_device,
|
||||
upstream_type: UpstreamType,
|
||||
) -> None:
|
||||
server = server_device.connectivity_multi_devices_snippet
|
||||
client = client_device.connectivity_multi_devices_snippet
|
||||
|
||||
# Assert pre-conditions specific to each upstream type.
|
||||
asserts.skip_if(not client.hasWifiFeature(), "Client requires Wifi feature")
|
||||
asserts.skip_if(
|
||||
not server.hasHotspotFeature(), "Server requires hotspot feature"
|
||||
)
|
||||
if upstream_type == UpstreamType.CELLULAR:
|
||||
asserts.skip_if(
|
||||
not server.hasTelephonyFeature(), "Server requires Telephony feature"
|
||||
)
|
||||
elif upstream_type == UpstreamType.WIFI:
|
||||
asserts.skip_if(
|
||||
not server.isStaApConcurrencySupported(),
|
||||
"Server requires Wifi AP + STA concurrency",
|
||||
)
|
||||
else:
|
||||
raise ValueError(f"Invalid upstream type: {upstream_type}")
|
||||
|
||||
|
||||
def setup_hotspot_and_client_for_upstream_type(
|
||||
server_device: android_device,
|
||||
client_device: android_device,
|
||||
|
|
@ -60,21 +86,9 @@ def setup_hotspot_and_client_for_upstream_type(
|
|||
server = server_device.connectivity_multi_devices_snippet
|
||||
client = client_device.connectivity_multi_devices_snippet
|
||||
|
||||
# Assert pre-conditions specific to each upstream type.
|
||||
asserts.skip_if(not client.hasWifiFeature(), "Client requires Wifi feature")
|
||||
asserts.skip_if(
|
||||
not server.hasHotspotFeature(), "Server requires hotspot feature"
|
||||
)
|
||||
if upstream_type == UpstreamType.CELLULAR:
|
||||
asserts.skip_if(
|
||||
not server.hasTelephonyFeature(), "Server requires Telephony feature"
|
||||
)
|
||||
server.requestCellularAndEnsureDefault()
|
||||
elif upstream_type == UpstreamType.WIFI:
|
||||
asserts.skip_if(
|
||||
not server.isStaApConcurrencySupported(),
|
||||
"Server requires Wifi AP + STA concurrency",
|
||||
)
|
||||
server.ensureWifiIsDefault()
|
||||
else:
|
||||
raise ValueError(f"Invalid upstream type: {upstream_type}")
|
||||
|
|
@ -98,6 +112,6 @@ def cleanup_tethering_for_upstream_type(
|
|||
) -> None:
|
||||
server = server_device.connectivity_multi_devices_snippet
|
||||
if upstream_type == UpstreamType.CELLULAR:
|
||||
server.unrequestCellular()
|
||||
server.unregisterAll()
|
||||
# Teardown the hotspot.
|
||||
server.stopAllTethering()
|
||||
|
|
|
|||
Loading…
Reference in a new issue