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, both the Aware and WLAN are using the same 5G channel. 18 19The device requirements: 20 support 5G: true 21The AP requirements: 22 wifi channel: 36 (5180) 23""" 24import logging 25import os 26import sys 27 28# Allows local imports to be resolved via relative path, so the test can be run 29# without building. 30_betocq_dir = os.path.dirname(os.path.dirname(__file__)) 31if _betocq_dir not in sys.path: 32 sys.path.append(_betocq_dir) 33 34from mobly import base_test 35from mobly import test_runner 36 37from betocq import d2d_performance_test_base 38from betocq import nc_constants 39 40 41class Scc5gAwareStaTest(d2d_performance_test_base.D2dPerformanceTestBase): 42 """Test class for Wifi SCC with 5G Aware and STA.""" 43 44 def _get_country_code(self) -> str: 45 return 'US' 46 47 def setup_class(self): 48 super().setup_class() 49 self.performance_test_iterations = getattr( 50 self.test_scc_5g_aware_sta, base_test.ATTR_REPEAT_CNT 51 ) 52 logging.info( 53 'performance test iterations: %s', self.performance_test_iterations 54 ) 55 56 @base_test.repeat( 57 count=nc_constants.SCC_PERFORMANCE_TEST_COUNT, 58 max_consecutive_error=nc_constants.SCC_PERFORMANCE_TEST_MAX_CONSECUTIVE_ERROR, 59 ) 60 def test_scc_5g_aware_sta(self): 61 """Test the performance for Wifi SCC with 5G Aware and STA.""" 62 self._test_connection_medium_performance( 63 upgrade_medium_under_test=nc_constants.NearbyMedium.WIFIAWARE_ONLY, 64 wifi_ssid=self.test_parameters.wifi_5g_ssid, 65 wifi_password=self.test_parameters.wifi_5g_password, 66 force_disable_bt_multiplex=True, 67 connection_medium=nc_constants.NearbyMedium( 68 self.test_parameters.connection_medium 69 ), 70 ) 71 72 def _get_file_transfer_failure_tip(self) -> str: 73 return ( 74 'The Wifi Aware connection might be broken, check related logs, ' 75 f'{self._get_throughput_low_tip()}' 76 ) 77 78 def _get_throughput_low_tip(self) -> str: 79 return ( 80 f'{self._throughput_low_string}. This is a SCC 5G test case with Aware' 81 ' and STA operating at the same 5G channel. Check STA and Aware' 82 ' frequencies in the target logs and ensure they' 83 ' have the same value. Check with the wifi chip vendor about the' 84 ' possible firmware Tx/Rx issues in this mode. Also check if the AP' 85 ' channel is set correctly and is supported by the used wifi medium.' 86 ) 87 88 def _is_wifi_ap_ready(self) -> bool: 89 return True if self.test_parameters.wifi_5g_ssid else False 90 91 @property 92 def _devices_capabilities_definition(self) -> dict[str, dict[str, bool]]: 93 return { 94 'discoverer': { 95 'supports_5g': True, 96 }, 97 'advertiser': { 98 'supports_5g': True, 99 }, 100 } 101 102 103if __name__ == '__main__': 104 test_runner.main() 105