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 15"""This Test is to test the Wifi SCC of LAN in a general case. 16 17In this case, both the D2D_LAN and WLAN are using the 5G channel, the D2d_LAN 18and WLAN should use the same channel. 19 20The device requirements: 21 support 5G: true 22The AP requirements: 23 wifi channel: 36 (5180) 24""" 25 26import logging 27import os 28import sys 29 30# Allows local imports to be resolved via relative path, so the test can be run 31# without building. 32_betocq_dir = os.path.dirname(os.path.dirname(__file__)) 33if _betocq_dir not in sys.path: 34 sys.path.append(_betocq_dir) 35 36from mobly import base_test 37from mobly import test_runner 38 39from betocq import d2d_performance_test_base 40from betocq import nc_constants 41 42 43class Scc5gWifiLanStaTest(d2d_performance_test_base.D2dPerformanceTestBase): 44 """Test class for Wifi SCC with 5G WifiLAN and STA.""" 45 46 def _get_country_code(self) -> str: 47 return 'US' 48 49 def setup_class(self): 50 super().setup_class() 51 self.performance_test_iterations = getattr( 52 self.test_scc_5g_wifilan_sta, base_test.ATTR_REPEAT_CNT 53 ) 54 logging.info( 55 'performance test iterations: %s', self.performance_test_iterations 56 ) 57 58 @base_test.repeat( 59 count=nc_constants.SCC_PERFORMANCE_TEST_COUNT, 60 max_consecutive_error=nc_constants.SCC_PERFORMANCE_TEST_MAX_CONSECUTIVE_ERROR, 61 ) 62 def test_scc_5g_wifilan_sta(self): 63 """Test the performance for Wifi SCC with 5G WifiLAN and STA.""" 64 self._test_connection_medium_performance( 65 nc_constants.NearbyMedium.WIFILAN_ONLY, 66 wifi_ssid=self.test_parameters.wifi_5g_ssid, 67 wifi_password=self.test_parameters.wifi_5g_password, 68 ) 69 70 def _get_file_transfer_failure_tip(self) -> str: 71 return ( 72 'The WLAN connection might be broken, check related logs, ' 73 f'{self._get_throughput_low_tip()}' 74 ) 75 76 def _get_throughput_low_tip(self) -> str: 77 return ( 78 f'{self._throughput_low_string}. This is 5G WLAN test case. Check with' 79 ' the wifi chip vendor if TDLS is supported correctly. Also check if' 80 ' the AP has the firewall which could block the mDNS traffic.' 81 ) 82 83 def _is_wifi_ap_ready(self) -> bool: 84 return True if self.test_parameters.wifi_5g_ssid else False 85 86 def _are_devices_capabilities_ok(self) -> bool: 87 return self.discoverer.supports_5g and self.advertiser.supports_5g 88 89 90if __name__ == '__main__': 91 test_runner.main() 92