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 in a general case. 16 17In this case, even though the expected wifi medium is the WFD, but the wifi D2D 18could be any technologies, such as WFD, HOTSPOT, STA; Once the WFD is failed, 19other meidums will be tried. Both the D2D medium and STA are using the same 5G 20channel. 21 22The device requirements: 23 support 5G: true 24 country code: US 25The AP requirements: 26 wifi channel: 36 (5180) 27""" 28 29import logging 30import os 31import sys 32 33# Allows local imports to be resolved via relative path, so the test can be run 34# without building. 35_betocq_dir = os.path.dirname(os.path.dirname(__file__)) 36if _betocq_dir not in sys.path: 37 sys.path.append(_betocq_dir) 38 39from mobly import base_test 40from mobly import test_runner 41 42from betocq import d2d_performance_test_base 43from betocq import nc_constants 44 45 46class Scc5gAllWifiStaTest(d2d_performance_test_base.D2dPerformanceTestBase): 47 """Test class for Wifi SCC 5G test associated with a specified CUJ.""" 48 49 def _get_country_code(self) -> str: 50 return 'US' 51 52 def setup_class(self): 53 super().setup_class() 54 self.performance_test_iterations = getattr( 55 self.test_scc_5g_all_wifi_sta_test, base_test.ATTR_REPEAT_CNT 56 ) 57 logging.info( 58 'performance test iterations: %s', self.performance_test_iterations 59 ) 60 61 @base_test.repeat( 62 count=nc_constants.SCC_PERFORMANCE_TEST_COUNT, 63 max_consecutive_error=nc_constants.SCC_PERFORMANCE_TEST_MAX_CONSECUTIVE_ERROR, 64 ) 65 def test_scc_5g_all_wifi_sta_test(self): 66 self._test_connection_medium_performance( 67 upgrade_medium_under_test=nc_constants.NearbyMedium.UPGRADE_TO_ALL_WIFI, 68 wifi_ssid=self.test_parameters.wifi_5g_ssid, 69 wifi_password=self.test_parameters.wifi_5g_password, 70 ) 71 72 def _get_file_transfer_failure_tip(self) -> str: 73 upgraded_medium_name = None 74 if (self._current_test_result.quality_info.upgrade_medium 75 is not None): 76 upgraded_medium_name = ( 77 self._current_test_result.quality_info.upgrade_medium.name 78 ) 79 return ( 80 f'The upgraded wifi medium {upgraded_medium_name} might be broken, ' 81 f'check the related logs; Or {self._get_throughput_low_tip()}' 82 ) 83 84 def _get_throughput_low_tip(self) -> str: 85 upgraded_medium_name = None 86 if (self._current_test_result.quality_info.upgrade_medium 87 is not None): 88 upgraded_medium_name = ( 89 self._current_test_result.quality_info.upgrade_medium.name 90 ) 91 return ( 92 f'{self._throughput_low_string}. The upgraded medium is' 93 f' {upgraded_medium_name}.' 94 ' This is a 5G SCC case. Check with the wifi' 95 ' chip vendor for any possible FW issue.' 96 ) 97 98 def _is_wifi_ap_ready(self) -> bool: 99 return True if self.test_parameters.wifi_5g_ssid else False 100 101 @property 102 def _devices_capabilities_definition(self) -> dict[str, dict[str, bool]]: 103 return { 104 'discoverer': { 105 'supports_5g': True, 106 }, 107 'advertiser': { 108 'supports_5g': True, 109 }, 110 } 111 112 113if __name__ == '__main__': 114 test_runner.main() 115