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 Aware MCC when STAs are connected to 2G/5G. 16 17The device requirements: 18 support 5G: true 19The AP requirements: 20 wifi channel: 36 (5180) and 6 (2437) in the same subnet 21""" 22import logging 23import os 24import sys 25 26# Allows local imports to be resolved via relative path, so the test can be run 27# without building. 28_betocq_dir = os.path.dirname(os.path.dirname(__file__)) 29if _betocq_dir not in sys.path: 30 sys.path.append(_betocq_dir) 31 32from mobly import base_test 33from mobly import test_runner 34 35from betocq import d2d_performance_test_base 36from betocq import nc_constants 37 38 39class MccAware2g5gStaTest(d2d_performance_test_base.D2dPerformanceTestBase): 40 """Test class for Aware MCC with the STA connected to 2G/5G channels.""" 41 42 def _get_country_code(self) -> str: 43 return 'US' 44 45 def setup_class(self): 46 super().setup_class() 47 self._is_mcc = True 48 self.performance_test_iterations = getattr( 49 self.test_mcc_aware_2g_5g_sta, base_test.ATTR_REPEAT_CNT 50 ) 51 logging.info( 52 'performance test iterations: %s', self.performance_test_iterations 53 ) 54 55 @base_test.repeat( 56 count=nc_constants.MCC_PERFORMANCE_TEST_COUNT, 57 max_consecutive_error=nc_constants.MCC_PERFORMANCE_TEST_MAX_CONSECUTIVE_ERROR, 58 ) 59 def test_mcc_aware_2g_5g_sta(self): 60 """Test the performance for Aware MCC.""" 61 self._test_connection_medium_performance( 62 upgrade_medium_under_test=nc_constants.NearbyMedium.WIFIAWARE_ONLY, 63 wifi_ssid=self.test_parameters.wifi_5g_ssid, 64 wifi_password=self.test_parameters.wifi_5g_password, 65 force_disable_bt_multiplex=True, 66 connection_medium=nc_constants.NearbyMedium( 67 self.test_parameters.connection_medium 68 ), 69 wifi_ssid2=self.test_parameters.wifi_2g_ssid, 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 MCC 5G test case with Aware' 81 ' and STA operating at different 5G channels. Check with the wifi chip' 82 ' vendor about the possible firmware Tx/Rx issues in this mode.' 83 ' Also check if the AP channel is set correctly and is supported by the' 84 ' used wifi medium.' 85 ) 86 87 def _is_wifi_ap_ready(self) -> bool: 88 return ( 89 True 90 if self.test_parameters.wifi_5g_ssid 91 and self.test_parameters.wifi_2g_ssid 92 else False 93 ) 94 95 @property 96 def _devices_capabilities_definition(self) -> dict[str, dict[str, bool]]: 97 return { 98 'discoverer': { 99 'supports_5g': True, 100 }, 101 'advertiser': { 102 'supports_5g': True, 103 }, 104 } 105 106 107if __name__ == '__main__': 108 test_runner.main() 109