1# Copyright (C) 2024 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15from net_tests_utils.host.python import mdns_utils, multi_devices_test_base, tether_utils 16from net_tests_utils.host.python import wifip2p_utils 17from net_tests_utils.host.python.tether_utils import UpstreamType 18 19 20class ConnectivityMultiDevicesTest( 21 multi_devices_test_base.MultiDevicesTestBase 22): 23 24 def test_hotspot_upstream_wifi(self): 25 tether_utils.assume_hotspot_test_preconditions( 26 self.serverDevice, self.clientDevice, UpstreamType.WIFI 27 ) 28 try: 29 # Connectivity of the client verified by asserting the validated capability. 30 tether_utils.setup_hotspot_and_client_for_upstream_type( 31 self.serverDevice, self.clientDevice, UpstreamType.WIFI 32 ) 33 finally: 34 tether_utils.cleanup_tethering_for_upstream_type( 35 self.serverDevice, UpstreamType.WIFI 36 ) 37 38 def test_hotspot_upstream_cellular(self): 39 tether_utils.assume_hotspot_test_preconditions( 40 self.serverDevice, self.clientDevice, UpstreamType.CELLULAR 41 ) 42 try: 43 # Connectivity of the client verified by asserting the validated capability. 44 tether_utils.setup_hotspot_and_client_for_upstream_type( 45 self.serverDevice, self.clientDevice, UpstreamType.CELLULAR 46 ) 47 finally: 48 tether_utils.cleanup_tethering_for_upstream_type( 49 self.serverDevice, UpstreamType.CELLULAR 50 ) 51 52 def test_mdns_via_hotspot(self): 53 tether_utils.assume_hotspot_test_preconditions( 54 self.serverDevice, self.clientDevice, UpstreamType.NONE 55 ) 56 mdns_utils.assume_mdns_test_preconditions( 57 self.clientDevice, self.serverDevice 58 ) 59 try: 60 # Connectivity of the client verified by asserting the validated capability. 61 tether_utils.setup_hotspot_and_client_for_upstream_type( 62 self.serverDevice, self.clientDevice, UpstreamType.NONE 63 ) 64 mdns_utils.register_mdns_service_and_discover_resolve( 65 self.clientDevice, self.serverDevice 66 ) 67 finally: 68 mdns_utils.cleanup_mdns_service(self.clientDevice, self.serverDevice) 69 tether_utils.cleanup_tethering_for_upstream_type( 70 self.serverDevice, UpstreamType.NONE 71 ) 72 73 def test_mdns_via_wifip2p(self): 74 wifip2p_utils.assume_wifi_p2p_test_preconditions( 75 self.serverDevice, self.clientDevice 76 ) 77 mdns_utils.assume_mdns_test_preconditions( 78 self.clientDevice, self.serverDevice 79 ) 80 try: 81 wifip2p_utils.setup_wifi_p2p_server_and_client( 82 self.serverDevice, self.clientDevice 83 ) 84 mdns_utils.register_mdns_service_and_discover_resolve( 85 self.clientDevice, self.serverDevice 86 ) 87 finally: 88 mdns_utils.cleanup_mdns_service(self.clientDevice, self.serverDevice) 89 wifip2p_utils.cleanup_wifi_p2p(self.serverDevice, self.clientDevice) 90