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