1#!/usr/bin/env python3 2# 3# Copyright (C) 2018 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); you may not 6# use this file except in compliance with the License. You may obtain a copy of 7# the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14# License for the specific language governing permissions and limitations under 15# the License. 16""" 17Test suite to check Basic Functionality with Wlan. 18 19Test Setup: 20 21One Android device. 22""" 23 24from acts.test_utils.coex.CoexBaseTest import CoexBaseTest 25from acts.test_utils.coex.coex_test_utils import multithread_func 26from acts.test_utils.coex.coex_test_utils import perform_classic_discovery 27from acts.test_utils.coex.coex_test_utils import toggle_bluetooth 28from acts.test_utils.coex.coex_test_utils import start_fping 29 30 31class CoexBasicFunctionalityTest(CoexBaseTest): 32 33 def setup_class(self): 34 super().setup_class() 35 36 req_params = ["iterations", "fping_params"] 37 self.unpack_userparams(req_params) 38 39 def toogle_bluetooth_with_iperf(self): 40 """Wrapper function to start iperf traffic and toggling bluetooth.""" 41 self.run_iperf_and_get_result() 42 if not toggle_bluetooth(self.pri_ad, self.iperf["duration"]): 43 return False 44 return self.teardown_result() 45 46 def start_discovery_with_iperf(self): 47 """Wrapper function to starts iperf traffic and bluetooth discovery, 48 gets all the devices discovered, stops discovery. 49 """ 50 self.run_iperf_and_get_result() 51 for i in range(self.iterations): 52 self.log.info("Bluetooth discovery iteration : {}".format(i)) 53 if not perform_classic_discovery( 54 self.pri_ad, self.iperf["duration"], self.json_file, 55 self.dev_list): 56 return False 57 return self.teardown_result() 58 59 def test_toogle_bluetooth_with_tcp_ul(self): 60 """Starts TCP-uplink traffic, when toggling bluetooth. 61 62 This test is to start TCP-uplink traffic between host machine and 63 android device when toggling bluetooth. 64 65 Steps: 66 1. Start TCP-uplink traffic at background. 67 2. Enable bluetooth. 68 3. Disable bluetooth. 69 4. Repeat steps 3 and 4 for n iterations. 70 71 Returns: 72 True if successful, False otherwise. 73 74 Test Id: Bt_CoEx_001 75 """ 76 if not self.toogle_bluetooth_with_iperf(): 77 return False 78 return True 79 80 def test_toogle_bluetooth_with_tcp_dl(self): 81 """Starts TCP-downlink traffic, when toggling bluetooth. 82 83 This test is to start TCP-downlink traffic between host machine and 84 android device when toggling bluetooth. 85 86 Steps: 87 1. Start TCP-downlink traffic at background. 88 2. Enable bluetooth. 89 3. Disable bluetooth. 90 4. Repeat steps 3 and 4 for n iterations 91 92 Returns: 93 True if successful, False otherwise. 94 95 Test Id: Bt_CoEx_002 96 """ 97 if not self.toogle_bluetooth_with_iperf(): 98 return False 99 return True 100 101 def test_toogle_bluetooth_with_udp_ul(self): 102 """Starts UDP-uplink traffic, when toggling bluetooth. 103 104 This test is to start UDP-uplink traffic between host machine and 105 android device when toggling bluetooth. 106 107 Steps: 108 1. Start UDP-uplink traffic at background. 109 2. Enable bluetooth. 110 3. Disable bluetooth. 111 4. Repeat steps 3 and 4 for n iterations 112 113 Returns: 114 True if successful, False otherwise. 115 116 Test Id: Bt_CoEx_003 117 """ 118 if not self.toogle_bluetooth_with_iperf(): 119 return False 120 return True 121 122 def test_toogle_bluetooth_with_udp_dl(self): 123 """Starts UDP-downlink traffic, when toggling bluetooth. 124 125 This test is to start UDP-downlink traffic between host machine and 126 android device when toggling bluetooth. 127 128 Steps: 129 1. Start UDP-downlink traffic at background. 130 2. Enable bluetooth. 131 3. Disable bluetooth. 132 4. Repeat steps 3 and 4 for n iterations 133 134 Returns: 135 True if successful, False otherwise. 136 137 Test Id: Bt_CoEx_004 138 """ 139 if not self.toogle_bluetooth_with_iperf(): 140 return False 141 return True 142 143 def test_bluetooth_discovery_with_tcp_ul(self): 144 """Starts TCP-uplink traffic, along with bluetooth discovery. 145 146 This test is to start TCP-uplink traffic between host machine and 147 android device test the functional behaviour of bluetooth discovery. 148 149 Steps: 150 1. Run TCP-uplink traffic at background. 151 2. Enable bluetooth 152 3. Start bluetooth discovery. 153 4. List all discovered devices. 154 5. Repeat step 3 and 4 for n iterations. 155 156 Returns: 157 True if successful, False otherwise. 158 159 Test Id: Bt_CoEx_005 160 """ 161 if not self.start_discovery_with_iperf(): 162 return False 163 return True 164 165 def test_bluetooth_discovery_with_tcp_dl(self): 166 """Starts TCP-downlink traffic, along with bluetooth discovery. 167 168 This test is to start TCP-downlink traffic between host machine and 169 android device test the functional behaviour of bluetooth discovery. 170 171 Steps: 172 1. Run TCP-downlink traffic at background. 173 2. Enable bluetooth 174 3. Start bluetooth discovery. 175 4. List all discovered devices. 176 5. Repeat step 3 and 4 for n iterations. 177 178 Returns: 179 True if successful, False otherwise. 180 181 Test Id: Bt_CoEx_006 182 """ 183 if not self.start_discovery_with_iperf(): 184 return False 185 return True 186 187 def test_bluetooth_discovery_with_udp_ul(self): 188 """Starts UDP-uplink traffic, along with bluetooth discovery. 189 190 This test is to start UDP-uplink traffic between host machine and 191 android device test the functional behaviour of bluetooth discovery. 192 193 Steps: 194 1. Run UDP-uplink traffic at background. 195 2. Enable bluetooth 196 3. Start bluetooth discovery. 197 4. List all discovered devices. 198 5. Repeat step 3 and 4 for n iterations. 199 200 Returns: 201 True if successful, False otherwise. 202 203 Test Id: Bt_CoEx_007 204 """ 205 if not self.start_discovery_with_iperf(): 206 return False 207 return True 208 209 def test_bluetooth_discovery_with_udp_dl(self): 210 """Starts UDP-downlink traffic, along with bluetooth discovery. 211 212 This test is to start UDP-downlink traffic between host machine and 213 android device and test the functional behaviour of bluetooth discovery. 214 215 Steps: 216 1. Run UDP-downlink traffic at background. 217 2. Enable bluetooth. 218 3. Start bluetooth discovery. 219 4. List all discovered devices. 220 5. Repeat step 3 and 4 for n iterations. 221 222 Returns: 223 True if successful, False otherwise. 224 225 Test Id: Bt_CoEx_008 226 """ 227 if not self.start_discovery_with_iperf(): 228 return False 229 return True 230 231 def test_toogle_bluetooth_with_fping(self): 232 """Starts fping, while toggling bluetooth. 233 234 This test is to start fping between host machine and android device 235 while toggling bluetooth. 236 237 Steps: 238 1. Start fping on background. 239 2. Enable bluetooth. 240 3. Disable bluetooth. 241 4. Repeat steps 3 and 4 for n iterations. 242 243 Returns: 244 True if successful, False otherwise. 245 246 Test Id: Bt_CoEx_070 247 """ 248 tasks = [(start_fping, (self.pri_ad, self.iperf["duration"], 249 self.fping_params)), 250 (toggle_bluetooth, (self.pri_ad, self.iperf["duration"]))] 251 if not multithread_func(self.log, tasks): 252 return False 253 return True 254 255 def test_bluetooth_discovery_with_fping(self): 256 """Starts fping, along with bluetooth discovery. 257 258 This test is to start fping between host machine and android device 259 and test functional behaviour of bluetooth discovery. 260 261 Steps: 262 1. Start fping on background. 263 2. Enable bluetooth. 264 3. Start bluetooth discovery. 265 4. Repeat step 3 for n iterations. 266 267 Returns: 268 True if successful, False otherwise. 269 270 Test Id: Bt_CoEx_071 271 """ 272 tasks = [(start_fping, (self.pri_ad, self.iperf["duration"], 273 self.fping_params)), 274 (perform_classic_discovery, 275 (self.pri_ad, self.iperf["duration"], self.json_file, 276 self.dev_list))] 277 if not multithread_func(self.log, tasks): 278 return False 279 return True 280