1# /usr/bin/env python3.4 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 17from acts.test_utils.coex.CoexBaseTest import CoexBaseTest 18from acts.test_utils.coex.coex_test_utils import perform_classic_discovery 19from acts.test_utils.coex.coex_test_utils import toggle_bluetooth 20from acts.test_utils.coex.coex_test_utils import start_fping 21 22 23class CoexBasicFunctionalityTest(CoexBaseTest): 24 25 def __init__(self, controllers): 26 CoexBaseTest.__init__(self, controllers) 27 28 def setup_class(self): 29 CoexBaseTest.setup_class(self) 30 req_params = ["iterations"] 31 self.unpack_userparams(req_params) 32 33 def toogle_bluetooth_with_iperf(self): 34 """Wrapper function to start iperf traffic and toggling bluetooth.""" 35 self.run_iperf_and_get_result() 36 if not toggle_bluetooth(self.pri_ad, self.iterations): 37 return False 38 return self.teardown_result() 39 40 def start_discovery_with_iperf(self): 41 """Wrapper function to starts iperf traffic and bluetooth discovery, 42 gets all the devices discovered, stops discovery. 43 """ 44 self.run_iperf_and_get_result() 45 for i in range(self.iterations): 46 self.log.info("Bluetooth inquiry iteration : {}".format(i)) 47 if not perform_classic_discovery(self.pri_ad): 48 return False 49 return self.teardown_result() 50 51 def test_toogle_bluetooth_with_tcp_ul(self): 52 """Starts TCP-uplink traffic, when toggling bluetooth. 53 54 This test is to start TCP-uplink traffic between host machine and 55 android device when toggling bluetooth. 56 57 Steps: 58 1. Start TCP-uplink traffic at background. 59 2. Enable bluetooth. 60 3. Disable bluetooth. 61 4. Repeat steps 3 and 4 for n iterations 62 63 Returns: 64 True if successful, False otherwise. 65 66 Test Id: Bt_CoEx_001 67 """ 68 if not self.toogle_bluetooth_with_iperf(): 69 return False 70 return True 71 72 def test_toogle_bluetooth_with_tcp_dl(self): 73 """Starts TCP-downlink traffic, when toggling bluetooth. 74 75 This test is to start TCP-downlink traffic between host machine and 76 android device when toggling bluetooth. 77 78 Steps: 79 1. Start TCP-downlink traffic at background. 80 2. Enable bluetooth. 81 3. Disable bluetooth. 82 4. Repeat steps 3 and 4 for n iterations 83 84 Returns: 85 True if successful, False otherwise. 86 87 Test Id: Bt_CoEx_002 88 """ 89 if not self.toogle_bluetooth_with_iperf(): 90 return False 91 return True 92 93 def test_toogle_bluetooth_with_udp_ul(self): 94 """Starts UDP-uplink traffic, when toggling bluetooth. 95 96 This test is to start UDP-uplink traffic between host machine and 97 android device when toggling bluetooth. 98 99 Steps: 100 1. Start UDP-uplink traffic at background. 101 2. Enable bluetooth. 102 3. Disable bluetooth. 103 4. Repeat steps 3 and 4 for n iterations 104 105 Returns: 106 True if successful, False otherwise. 107 108 Test Id: Bt_CoEx_003 109 """ 110 if not self.toogle_bluetooth_with_iperf(): 111 return False 112 return True 113 114 def test_toogle_bluetooth_with_udp_dl(self): 115 """Starts UDP-downlink traffic, when toggling bluetooth. 116 117 This test is to start UDP-downlink traffic between host machine and 118 android device when toggling bluetooth. 119 120 Steps: 121 1. Start UDP-downlink traffic at background. 122 2. Enable bluetooth. 123 3. Disable bluetooth. 124 4. Repeat steps 3 and 4 for n iterations 125 126 Returns: 127 True if successful, False otherwise. 128 129 Test Id: Bt_CoEx_004 130 """ 131 if not self.toogle_bluetooth_with_iperf(): 132 return False 133 return True 134 135 def test_bluetooth_discovery_with_tcp_ul(self): 136 """Starts TCP-uplink traffic, along with bluetooth discovery. 137 138 This test is to start TCP-uplink traffic between host machine and 139 android device test the functional behaviour of bluetooth discovery. 140 141 Steps: 142 1. Run TCP-uplink traffic at background. 143 2. Enable bluetooth 144 3. Start bluetooth discovery. 145 4. List all discovered devices. 146 5. Repeat step 3 and 4 for n iterations. 147 148 Returns: 149 True if successful, False otherwise. 150 151 Test Id: Bt_CoEx_005 152 """ 153 if not self.start_discovery_with_iperf(): 154 return False 155 return True 156 157 def test_bluetooth_discovery_with_tcp_dl(self): 158 """Starts TCP-downlink traffic, along with bluetooth discovery. 159 160 This test is to start TCP-downlink traffic between host machine and 161 android device test the functional behaviour of bluetooth discovery. 162 163 Steps: 164 1. Run TCP-downlink traffic at background. 165 2. Enable bluetooth 166 3. Start bluetooth discovery. 167 4. List all discovered devices. 168 5. Repeat step 3 and 4 for n iterations. 169 170 Returns: 171 True if successful, False otherwise. 172 173 Test Id: Bt_CoEx_006 174 """ 175 if not self.start_discovery_with_iperf(): 176 return False 177 return True 178 179 def test_bluetooth_discovery_with_udp_ul(self): 180 """Starts UDP-uplink traffic, along with bluetooth discovery. 181 182 This test is to start UDP-uplink traffic between host machine and 183 android device test the functional behaviour of bluetooth discovery. 184 185 Steps: 186 1. Run UDP-uplink traffic at background. 187 2. Enable bluetooth 188 3. Start bluetooth discovery. 189 4. List all discovered devices. 190 5. Repeat step 3 and 4 for n iterations. 191 192 Returns: 193 True if successful, False otherwise. 194 195 Test Id: Bt_CoEx_007 196 """ 197 if not self.start_discovery_with_iperf(): 198 return False 199 return True 200 201 def test_bluetooth_discovery_with_udp_dl(self): 202 """Starts UDP-downlink traffic, along with bluetooth discovery. 203 204 This test is to start UDP-downlink traffic between host machine and 205 android device and test the functional behaviour of bluetooth discovery. 206 207 Steps: 208 1. Run UDP-downlink traffic at background. 209 2. Enable bluetooth. 210 3. Start bluetooth discovery. 211 4. List all discovered devices. 212 5. Repeat step 3 and 4 for n iterations. 213 214 Returns: 215 True if successful, False otherwise. 216 217 Test Id: Bt_CoEx_008 218 """ 219 if not self.start_discovery_with_iperf(): 220 return False 221 return True 222 223 def test_toogle_bluetooth_with_fping(self): 224 """Starts fping, while toggling bluetooth. 225 226 This test is to start fping between host machine and android device 227 while toggling bluetooth. 228 229 Steps: 230 1. Start fping on background. 231 2. Enable bluetooth. 232 3. Disable bluetooth. 233 4. Repeat steps 3 and 4 for n iterations. 234 235 Returns: 236 True if successful, False otherwise. 237 238 Test Id: Bt_CoEx_070 239 """ 240 args = [lambda: start_fping(self.pri_ad, self.iperf["duration"])] 241 self.run_thread(args) 242 if not self.toogle_bluetooth_with_iperf(): 243 return False 244 return self.teardown_thread() 245 246 def test_bluetooth_discovery_with_fping(self): 247 """Starts fping, along with bluetooth discovery. 248 249 This test is to start fping between host machine and android device 250 and test functional behaviour of bluetooth discovery. 251 252 Steps: 253 1. Start fping on background. 254 2. Enable bluetooth. 255 3. Start bluetooth discovery. 256 4. Repeat step 3 for n iterations. 257 258 Returns: 259 True if successful, False otherwise. 260 261 Test Id: Bt_CoEx_071 262 """ 263 args = [lambda: start_fping(self.pri_ad, self.iperf["duration"])] 264 self.run_thread(args) 265 if not self.start_discovery_with_iperf(): 266 return False 267 return self.teardown_thread() 268