Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright 2021 - The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of 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, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | |
| 18 | import time |
| 19 | import datetime |
| 20 | import logging |
| 21 | |
| 22 | from acts import asserts |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 23 | from acts.test_decorators import test_info |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 24 | from acts.test_decorators import test_tracker_info |
| 25 | |
| 26 | from acts.base_test import BaseTestClass |
| 27 | from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest |
| 28 | from acts_contrib.test_utils.tel.GFTInOutBaseTest import GFTInOutBaseTest |
| 29 | |
| 30 | from acts_contrib.test_utils.tel.tel_test_utils import get_service_state_by_adb |
| 31 | from acts_contrib.test_utils.tel.tel_test_utils import multithread_func |
| 32 | from acts_contrib.test_utils.tel.tel_test_utils import run_multithread_func |
| 33 | from acts_contrib.test_utils.tel.tel_test_utils import ensure_wifi_connected |
| 34 | from acts_contrib.test_utils.tel.tel_test_utils import get_screen_shot_log |
| 35 | from acts_contrib.test_utils.tel.tel_test_utils import get_screen_shot_logs |
| 36 | from acts_contrib.test_utils.tel.tel_test_utils import log_screen_shot |
| 37 | from acts_contrib.test_utils.tel.tel_test_utils import hangup_call |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 38 | from acts_contrib.test_utils.tel.tel_test_utils import active_file_download_test |
| 39 | |
| 40 | from acts_contrib.test_utils.tel.tel_data_utils import wait_for_cell_data_connection |
| 41 | from acts_contrib.test_utils.tel.gft_inout_utils import check_no_service_time |
| 42 | from acts_contrib.test_utils.tel.gft_inout_utils import check_back_to_service_time |
| 43 | from acts_contrib.test_utils.tel.gft_inout_utils import mo_voice_call |
| 44 | from acts_contrib.test_utils.tel.gft_inout_utils import get_voice_call_type |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 45 | |
| 46 | from acts_contrib.test_utils.tel.tel_defines import DATA_STATE_CONNECTED |
| 47 | from acts_contrib.test_utils.tel.tel_defines import DATA_STATE_DISCONNECTED |
| 48 | from acts_contrib.test_utils.tel.tel_defines import SERVICE_STATE_EMERGENCY_ONLY |
| 49 | from acts_contrib.test_utils.tel.tel_defines import SERVICE_STATE_IN_SERVICE |
| 50 | from acts_contrib.test_utils.tel.tel_defines import SERVICE_STATE_UNKNOWN |
| 51 | from acts_contrib.test_utils.tel.tel_defines import SERVICE_STATE_OUT_OF_SERVICE |
| 52 | from acts_contrib.test_utils.tel.tel_defines import SERVICE_STATE_POWER_OFF |
| 53 | |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 54 | from acts_contrib.test_utils.tel.gft_inout_defines import VOICE_CALL |
| 55 | from acts_contrib.test_utils.tel.gft_inout_defines import VOLTE_CALL |
| 56 | from acts_contrib.test_utils.tel.gft_inout_defines import CSFB_CALL |
| 57 | from acts_contrib.test_utils.tel.gft_inout_defines import WFC_CALL |
| 58 | from acts_contrib.test_utils.tel.gft_inout_defines import NO_SERVICE_POWER_LEVEL |
| 59 | from acts_contrib.test_utils.tel.gft_inout_defines import IN_SERVICE_POWER_LEVEL |
| 60 | from acts_contrib.test_utils.tel.gft_inout_defines import NO_SERVICE_AREA |
| 61 | from acts_contrib.test_utils.tel.gft_inout_defines import IN_SERVICE_AREA |
| 62 | from acts_contrib.test_utils.tel.gft_inout_defines import WIFI_AREA |
| 63 | from acts_contrib.test_utils.tel.gft_inout_defines import NO_WIFI_AREA |
| 64 | from acts_contrib.test_utils.tel.gft_inout_defines import NO_SERVICE_TIME |
| 65 | from acts_contrib.test_utils.tel.gft_inout_defines import WAIT_FOR_SERVICE_TIME |
| 66 | |
| 67 | |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 68 | IDLE_CASE = 1 |
| 69 | DATA_TRANSFER_CASE = 2 |
| 70 | PDP_OFF_CASE = 3 |
| 71 | IN_CALL_CASE = 4 |
| 72 | CALL_DATA_CASE = 5 |
| 73 | |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 74 | class TelLabGFTInOutServiceTest(GFTInOutBaseTest): |
| 75 | def __init__(self, controllers): |
| 76 | GFTInOutBaseTest.__init__(self, controllers) |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 77 | self.my_error_msg = "" |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 78 | |
| 79 | def setup_test(self): |
| 80 | self.adjust_cellular_signal(IN_SERVICE_POWER_LEVEL) |
| 81 | self.adjust_wifi_signal(IN_SERVICE_POWER_LEVEL) |
| 82 | GFTInOutBaseTest.setup_test(self) |
| 83 | self.check_network() |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 84 | self.my_error_msg = "" |
| 85 | |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 86 | |
| 87 | @test_tracker_info(uuid="c602e556-8273-4c75-b8fa-4d51ba514654") |
| 88 | @TelephonyBaseTest.tel_test_wrap |
| 89 | def test_in_out_no_service_idle_1min(self, idle_time=60): |
| 90 | """ UE is in idle |
| 91 | Move UE from coverage area to no service area and UE shows no service |
| 92 | Wait for 1 min, then re-enter coverage area |
| 93 | |
| 94 | Args: |
| 95 | idle_time: idle time in service area |
| 96 | |
| 97 | Returns: |
| 98 | True if pass; False if fail. |
| 99 | """ |
| 100 | return self._test_in_out_service_idle(idle_time) |
| 101 | |
| 102 | @test_tracker_info(uuid="c602e556-8273-4c75-b8fa-4d51ba514654") |
| 103 | @TelephonyBaseTest.tel_test_wrap |
| 104 | def test_in_out_no_service_idle_2min(self, idle_time=120): |
| 105 | """ UE is in idle |
| 106 | Move UE from coverage area to no service area and UE shows no service |
| 107 | Wait for 2 min, then re-enter coverage area |
| 108 | |
| 109 | Args: |
| 110 | idle_time: idle time in service area |
| 111 | |
| 112 | Returns: |
| 113 | True if pass; False if fail. |
| 114 | """ |
| 115 | return self._test_in_out_service_idle(idle_time) |
| 116 | |
| 117 | |
| 118 | @test_tracker_info(uuid="1d437482-caff-4695-9f3f-f3daf6793540") |
| 119 | @TelephonyBaseTest.tel_test_wrap |
| 120 | def test_in_out_no_service_idle_5min(self, idle_time=300): |
| 121 | """ UE is in idle |
| 122 | Move UE from coverage area to no service area and UE shows no service |
| 123 | Wait for 5 min, then re-enter coverage area |
| 124 | |
| 125 | Args: |
| 126 | loop: cycle |
| 127 | idle_time: idle time in service area |
| 128 | |
| 129 | Returns: |
| 130 | True if pass; False if fail. |
| 131 | """ |
| 132 | return self._test_in_out_service_idle(idle_time) |
| 133 | |
| 134 | @test_tracker_info(uuid="339b4bf5-57a1-48f0-b26a-83a7db21b08b") |
| 135 | @TelephonyBaseTest.tel_test_wrap |
| 136 | def test_in_out_no_service_idle_10min(self, idle_time=600): |
| 137 | """ UE is in idle |
| 138 | Move UE from coverage area to no service area and UE shows no service |
| 139 | Wait for 10 min, then re-enter coverage area |
| 140 | |
| 141 | Args: |
| 142 | loop: cycle |
| 143 | idle_time: idle time in service area |
| 144 | |
| 145 | Returns: |
| 146 | True if pass; False if fail. |
| 147 | """ |
| 148 | return self._test_in_out_service_idle(idle_time) |
| 149 | |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 150 | |
| 151 | @test_tracker_info(uuid="65ebac02-8d5a-48c2-bd26-6d931d6048f1") |
| 152 | @TelephonyBaseTest.tel_test_wrap |
| 153 | def test_in_out_no_service_data_transfer_1min(self, idle_time=60): |
| 154 | """ In/Out service - Stationary data transfer - 1 min |
| 155 | UE is performing data transfer (E.g. Use FTP or browse tools) |
| 156 | move UE from coverage area to no service area and UE shows no service |
| 157 | Wait for 1 min, then re-enter coverage area |
| 158 | |
| 159 | Args: |
| 160 | idle_time: idle time in service area |
| 161 | |
| 162 | Returns: |
| 163 | True if pass; False if fail. |
| 164 | """ |
| 165 | return self._test_in_out_service_idle(idle_time, DATA_TRANSFER_CASE) |
| 166 | |
| 167 | |
| 168 | @test_tracker_info(uuid="ec3e7de4-bcf6-4a8a-ae04-868bd7925191") |
| 169 | @TelephonyBaseTest.tel_test_wrap |
| 170 | def test_in_out_no_service_data_transfer_2min(self, idle_time=120): |
| 171 | """ In/Out service - Stationary data transfer - 2 min |
| 172 | |
| 173 | Args: |
| 174 | idle_time: idle time in service area |
| 175 | |
| 176 | Returns: |
| 177 | True if pass; False if fail. |
| 178 | """ |
| 179 | return self._test_in_out_service_idle(idle_time, DATA_TRANSFER_CASE) |
| 180 | |
| 181 | |
| 182 | @test_tracker_info(uuid="8bd7017d-0a88-4423-a94b-1e37060bba1d") |
| 183 | @TelephonyBaseTest.tel_test_wrap |
| 184 | def test_in_out_no_service_data_transfer_5min(self, idle_time=300): |
| 185 | """ In/Out service - Stationary data transfer - 5 min |
| 186 | |
| 187 | Args: |
| 188 | idle_time: idle time in service area |
| 189 | |
| 190 | Returns: |
| 191 | True if pass; False if fail. |
| 192 | """ |
| 193 | return self._test_in_out_service_idle(idle_time, DATA_TRANSFER_CASE) |
| 194 | |
| 195 | |
| 196 | @test_tracker_info(uuid="c3b9c52d-41d3-449c-99ff-4bb830ca0219") |
| 197 | @TelephonyBaseTest.tel_test_wrap |
| 198 | def test_in_out_no_service_data_transfer_10min(self, idle_time=600): |
| 199 | """ In/Out service - Stationary data transfer - 10 min |
| 200 | |
| 201 | Args: |
| 202 | idle_time: idle time in service area |
| 203 | file_name: download filename |
| 204 | |
| 205 | Returns: |
| 206 | True if pass; False if fail. |
| 207 | """ |
| 208 | return self._test_in_out_service_idle(idle_time, DATA_TRANSFER_CASE) |
| 209 | |
| 210 | |
| 211 | @test_tracker_info(uuid="86a6b3b3-e754-4bde-b418-d4273b1ad907") |
| 212 | @TelephonyBaseTest.tel_test_wrap |
| 213 | def test_in_out_service_incall_1min(self, idle_time=60): |
| 214 | """ In/Out service - Stationary incall - 1 min |
| 215 | |
| 216 | Args: |
| 217 | idle_time: idle time in service area |
| 218 | |
| 219 | Returns: |
| 220 | True if pass; False if fail. |
| 221 | """ |
| 222 | return self._test_in_out_service_idle(idle_time, IN_CALL_CASE) |
| 223 | |
| 224 | |
| 225 | @test_tracker_info(uuid="0f8772cd-6f86-48eb-b583-4cbaf80a21a9") |
| 226 | @TelephonyBaseTest.tel_test_wrap |
| 227 | def test_in_out_service_incall_2min(self, idle_time=120): |
| 228 | """ In/Out service - Stationary incall - 2 min |
| 229 | |
| 230 | Args: |
| 231 | idle_time: idle time in service area |
| 232 | |
| 233 | Returns: |
| 234 | True if pass; False if fail. |
| 235 | """ |
| 236 | return self._test_in_out_service_idle(idle_time, IN_CALL_CASE) |
| 237 | |
| 238 | |
| 239 | @test_tracker_info(uuid="11f24c0f-db33-4eb3-b847-9aed447eb820") |
| 240 | @TelephonyBaseTest.tel_test_wrap |
| 241 | def test_in_out_service_incall_5min(self, idle_time=300): |
| 242 | """ In/Out service - Stationary incall - 5 min |
| 243 | |
| 244 | Args: |
| 245 | idle_time: idle time in service area |
| 246 | |
| 247 | Returns: |
| 248 | True if pass; False if fail. |
| 249 | """ |
| 250 | return self._test_in_out_service_idle(idle_time, IN_CALL_CASE) |
| 251 | |
| 252 | |
| 253 | @test_tracker_info(uuid="e318921b-de6b-428b-b2c4-3db7786d7558") |
| 254 | @TelephonyBaseTest.tel_test_wrap |
| 255 | def test_in_out_service_incall_10min(self, idle_time=600): |
| 256 | """ In/Out service - Stationary incall - 10 min |
| 257 | |
| 258 | Args: |
| 259 | idle_time: idle time in service area |
| 260 | |
| 261 | Returns: |
| 262 | True if pass; False if fail. |
| 263 | """ |
| 264 | return self._test_in_out_service_idle(idle_time, IN_CALL_CASE) |
| 265 | |
| 266 | |
| 267 | @test_tracker_info(uuid="f6cf0019-e123-4ebd-990b-0fa5b236840c") |
| 268 | @TelephonyBaseTest.tel_test_wrap |
| 269 | def test_in_out_service_call_date_1min(self, idle_time=60): |
| 270 | """ In/Out service - Stationary incall + data transfer - 1 mins |
| 271 | |
| 272 | Args: |
| 273 | idle_time: idle time in service area |
| 274 | |
| 275 | Returns: |
| 276 | True if pass; False if fail. |
| 277 | """ |
| 278 | return self._test_in_out_service_idle(idle_time, CALL_DATA_CASE) |
| 279 | |
| 280 | |
| 281 | @test_tracker_info(uuid="2f49a9de-0383-4ec6-a8ee-c62f52ea0cf2") |
| 282 | @TelephonyBaseTest.tel_test_wrap |
| 283 | def test_in_out_service_call_date_2min(self, idle_time=120): |
| 284 | """ In/Out service - Stationary incall + data transfer - 2 mins |
| 285 | |
| 286 | Args: |
| 287 | idle_time: idle time in service area |
| 288 | |
| 289 | Returns: |
| 290 | True if pass; False if fail. |
| 291 | """ |
| 292 | return self._test_in_out_service_idle(idle_time, CALL_DATA_CASE) |
| 293 | |
| 294 | |
| 295 | @test_tracker_info(uuid="73a6eedb-791f-4486-b815-8067a95efd5c") |
| 296 | @TelephonyBaseTest.tel_test_wrap |
| 297 | def test_in_out_service_call_date_5min(self, idle_time=300): |
| 298 | """ In/Out service - Stationary incall + data transfer - 5 mins |
| 299 | |
| 300 | Args: |
| 301 | idle_time: idle time in service area |
| 302 | |
| 303 | Returns: |
| 304 | True if pass; False if fail. |
| 305 | """ |
| 306 | return self._test_in_out_service_idle(idle_time, CALL_DATA_CASE) |
| 307 | |
| 308 | @test_tracker_info(uuid="5cfbc90a-97e1-43e9-a69e-4ce2815c544d") |
| 309 | @TelephonyBaseTest.tel_test_wrap |
| 310 | def test_in_out_service_call_date_10min(self, idle_time=600): |
| 311 | """ In/Out service - Stationary incall + data transfer - 10 mins |
| 312 | |
| 313 | Args: |
| 314 | idle_time: idle time in service area |
| 315 | |
| 316 | Returns: |
| 317 | True if pass; False if fail. |
| 318 | """ |
| 319 | return self._test_in_out_service_idle(idle_time, CALL_DATA_CASE) |
| 320 | |
| 321 | |
| 322 | |
| 323 | @test_tracker_info(uuid="c70180c9-5a36-4dc5-9ccc-3e6c0b5e6d37") |
| 324 | @TelephonyBaseTest.tel_test_wrap |
| 325 | def test_in_out_service_pdp_off_1min(self, idle_time=60): |
| 326 | """ In/Out service - Stationary data off - 1 min |
| 327 | Disable UE mobile data |
| 328 | Move UE from coverage area to no service area and UE shows no service |
| 329 | Wait for 1 min, then re-enter coverage area |
| 330 | |
| 331 | Args: |
| 332 | idle_time: idle time in service area |
| 333 | |
| 334 | Returns: |
| 335 | True if pass; False if fail. |
| 336 | """ |
| 337 | return self._test_in_out_service_idle(idle_time, PDP_OFF_CASE) |
| 338 | |
| 339 | |
| 340 | @test_tracker_info(uuid="50cc8e73-d96f-45a6-91cd-bf51de5241d2") |
| 341 | @TelephonyBaseTest.tel_test_wrap |
| 342 | def test_in_out_service_pdp_off_2min(self, idle_time=120): |
| 343 | """ In/Out service - Stationary data off - 2 min |
| 344 | |
| 345 | Args: |
| 346 | idle_time: idle time in service area |
| 347 | |
| 348 | Returns: |
| 349 | True if pass; False if fail. |
| 350 | """ |
| 351 | return self._test_in_out_service_idle(idle_time, PDP_OFF_CASE) |
| 352 | |
| 353 | |
| 354 | @test_tracker_info(uuid="1f25d40c-1bfe-4d18-b57c-d7be69664f0d") |
| 355 | @TelephonyBaseTest.tel_test_wrap |
| 356 | def test_in_out_service_pdp_off_5min(self, idle_time=300): |
| 357 | """ In/Out service - Stationary data off - 5 min |
| 358 | |
| 359 | Args: |
| 360 | idle_time: idle time in service area |
| 361 | |
| 362 | Returns: |
| 363 | True if pass; False if fail. |
| 364 | """ |
| 365 | return self._test_in_out_service_idle(idle_time, PDP_OFF_CASE) |
| 366 | |
| 367 | |
| 368 | @test_tracker_info(uuid="b076b0d0-a105-4be9-aa0b-db0d782f70f2") |
| 369 | @TelephonyBaseTest.tel_test_wrap |
| 370 | def test_in_out_service_pdp_off_10min(self, idle_time=600): |
| 371 | """ In/Out service - Stationary data off - 10 min |
| 372 | |
| 373 | Args: |
| 374 | idle_time: idle time in service area |
| 375 | |
| 376 | Returns: |
| 377 | True if pass; False if fail. |
| 378 | """ |
| 379 | return self._test_in_out_service_idle(idle_time, PDP_OFF_CASE) |
| 380 | |
| 381 | |
| 382 | |
| 383 | def _test_in_out_service_idle(self, idle_time, case= IDLE_CASE, loop=1): |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 384 | """ UE is in idle |
| 385 | Move UE from coverage area to no service area and UE shows no service |
| 386 | Args: |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 387 | idle_time: idle time in service area |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 388 | case: include IDLE_CAS, DATA_TRANSFER_CASE, PDP_OFF_CASE, |
| 389 | IN_CALL_CASE, CALL_DATA_CASE |
| 390 | loop: cycle |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 391 | Returns: |
| 392 | True if pass; False if fail. |
| 393 | """ |
| 394 | test_result = True |
| 395 | if 'autoio_cycle' in self.user_params: |
| 396 | loop = self.user_params.get('autoio_cycle') |
| 397 | |
| 398 | for x in range (loop): |
| 399 | self.log.info("%s loop: %s/%s" %(self.current_test_name,x+1, loop)) |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 400 | if case == IDLE_CASE: |
| 401 | if not self._in_out_service_idle_only(idle_time): |
| 402 | test_result = False |
| 403 | elif case == DATA_TRANSFER_CASE: |
| 404 | if not self._data_transfer_mode(idle_time): |
| 405 | test_result = False |
| 406 | elif case == PDP_OFF_CASE: |
| 407 | if not self._in_out_service_pdp_off(idle_time): |
| 408 | test_result = False |
| 409 | elif case == IN_CALL_CASE: |
| 410 | if not self._in_call_in_out_service(idle_time): |
| 411 | test_result = False |
| 412 | elif case == CALL_DATA_CASE: |
| 413 | if not self._call_data_in_out_service(idle_time): |
| 414 | test_result = False |
| 415 | asserts.assert_true(test_result, "Fail: %s." %(self.my_error_msg), |
| 416 | extras={"failure_cause": self.my_error_msg}) |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 417 | return test_result |
| 418 | |
| 419 | |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 420 | def _in_out_service_idle_only(self, no_service_time=60, check_back_to_service=True, |
| 421 | check_no_service=True): |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 422 | """ Move UE from coverage area to no service area and UE shows no service |
| 423 | Wait for no_service_time sec , then re-enter coverage area |
| 424 | |
| 425 | Args: |
| 426 | no_service_time: stay at no service area time in sec |
| 427 | check_back_to_service: check device is back to service flag |
| 428 | check_no_service: check device is no service flag |
| 429 | |
| 430 | Returns: |
| 431 | True if pass; False if fail. |
| 432 | """ |
| 433 | test_result = True |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 434 | error_msg = "" |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 435 | for ad in self.android_devices: |
| 436 | network_type = ad.droid.telephonyGetNetworkType() |
| 437 | service_state = get_service_state_by_adb(self.log,ad) |
| 438 | ad.log.info("service_state=%s. network_type=%s" |
| 439 | %(service_state ,network_type)) |
| 440 | if service_state != SERVICE_STATE_IN_SERVICE: |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 441 | error_msg = "Device is not ready for test. Service_state=%s." %(service_state) |
| 442 | ad.log.info("Device is not ready for test. Service_state=%s." %(service_state)) |
| 443 | self.my_error_msg += error_msg |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 444 | return False |
| 445 | |
| 446 | self.log.info("Move UE from coverage area to no service area") |
| 447 | self.adjust_cellular_signal(NO_SERVICE_POWER_LEVEL) |
| 448 | |
| 449 | if check_no_service: |
| 450 | tasks = [(check_no_service_time, (ad, )) for ad in self.android_devices] |
| 451 | if not multithread_func(self.log, tasks): |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 452 | self.check_network() |
| 453 | error_msg = "Device does not become no service" |
| 454 | self.my_error_msg += error_msg |
| 455 | self.log.info(error_msg) |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 456 | return False |
| 457 | else: |
| 458 | self.log.info("wait for %s sec in no/limited service area" %(no_service_time)) |
| 459 | time.sleep(no_service_time) |
| 460 | self.log.info("Move UE back to service area") |
| 461 | self.adjust_cellular_signal(IN_SERVICE_POWER_LEVEL) |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 462 | if check_back_to_service: |
| 463 | test_result = self._check_after_no_service() |
| 464 | return test_result |
Molly Chang | 7adf9df | 2021-04-22 14:49:59 +0800 | [diff] [blame] | 465 | |
Molly Chang | bf5ffb7 | 2021-04-24 00:51:22 +0800 | [diff] [blame] | 466 | def _data_transfer_mode(self, idle_time, file_name="10MB"): |
| 467 | """ Download file and in/out service |
| 468 | |
| 469 | Args: |
| 470 | idle_time: stay at no service area time in sec |
| 471 | file_name: file to be download |
| 472 | |
| 473 | Returns: |
| 474 | True if pass; False if fail. |
| 475 | """ |
| 476 | error_msg ="" |
| 477 | tasks_a = [(self._in_out_service_idle_only, (idle_time, False,))] |
| 478 | tasks_b = [(active_file_download_test, (self.log, ad, file_name)) |
| 479 | for ad in self.android_devices] |
| 480 | tasks_b.extend(tasks_a) |
| 481 | if not multithread_func(self.log, tasks_b): |
| 482 | error_msg = " data transfer fail. " |
| 483 | self.my_error_msg += error_msg |
| 484 | self.log.info(error_msg) |
| 485 | return False |
| 486 | return self._check_after_no_service() |
| 487 | |
| 488 | def _in_out_service_pdp_off(self, idle_time): |
| 489 | """ UE is in idle |
| 490 | Disable UE mobile data |
| 491 | Move UE from coverage area to no/limited service area |
| 492 | enable UE mobile data |
| 493 | After UE show no service, re-enter coverage area |
| 494 | |
| 495 | Args: |
| 496 | idle_time: idle time in service area |
| 497 | |
| 498 | Returns: |
| 499 | True if pass; False if fail. |
| 500 | """ |
| 501 | error_msg ="" |
| 502 | for ad in self.android_devices: |
| 503 | ad.log.info("Turn off mobile data") |
| 504 | ad.droid.telephonyToggleDataConnection(False) |
| 505 | if not wait_for_cell_data_connection(self.log, ad, False): |
| 506 | self.my_error_msg += "fail to turn off mobile data" |
| 507 | return False |
| 508 | |
| 509 | if not self._in_out_service_idle_only(idle_time, False): |
| 510 | return False |
| 511 | |
| 512 | for ad in self.android_devices: |
| 513 | ad.log.info("Turn on mobile data") |
| 514 | ad.droid.telephonyToggleDataConnection(True) |
| 515 | #If True, it will wait for status to be DATA_STATE_CONNECTED |
| 516 | if not wait_for_cell_data_connection(self.log, ad, True): |
| 517 | self.my_error_msg += "fail to turn on mobile data" |
| 518 | return False |
| 519 | return self._check_after_no_service() |
| 520 | |
| 521 | def _in_call_in_out_service(self, idle_time): |
| 522 | """ UE is in call |
| 523 | Move UE from coverage area to no/limited service area |
| 524 | After UE show no service, re-enter coverage area |
| 525 | |
| 526 | Args: |
| 527 | idle_time: idle time in service area |
| 528 | |
| 529 | Returns: |
| 530 | True if pass; False if fail. |
| 531 | """ |
| 532 | error_msg = "" |
| 533 | tasks = [(mo_voice_call, (self.log, ad, VOICE_CALL, False)) for ad in self.android_devices] |
| 534 | if not multithread_func(self.log, tasks): |
| 535 | error_msg = "MO voice call fail" |
| 536 | self.my_error_msg += error_msg |
| 537 | self.log.info(error_msg) |
| 538 | return False |
| 539 | |
| 540 | if not self._in_out_service_idle_only(idle_time, False): |
| 541 | return False |
| 542 | return self._check_after_no_service() |
| 543 | |
| 544 | def _call_data_in_out_service(self, idle_time): |
| 545 | """ UE is performing data transfer (E.g. Use FTP or browse tools) |
| 546 | UE makes a MO call |
| 547 | Move UE from coverage area to no/limited service area |
| 548 | After UE show no service, re-enter coverage area |
| 549 | |
| 550 | Args: |
| 551 | idle_time: idle time in service area |
| 552 | |
| 553 | Returns: |
| 554 | True if pass; False if fail. |
| 555 | """ |
| 556 | tasks_a = [(active_file_download_test, (self.log, ad, )) for ad in self.android_devices] |
| 557 | tasks_b= [(mo_voice_call, (self.log, ad, VOICE_CALL, False)) for ad in self.android_devices] |
| 558 | tasks_b.extend(tasks_a) |
| 559 | if not multithread_func(self.log, tasks_b): |
| 560 | error_msg = "fail to perfrom data transfer/voice call" |
| 561 | self.my_error_msg += error_msg |
| 562 | return False |
| 563 | |
| 564 | if not self._in_out_service_idle_only(idle_time, False): |
| 565 | return False |
| 566 | return self._check_after_no_service() |
| 567 | |
| 568 | def _check_after_no_service(self): |
| 569 | """ check device is back to service or not |
| 570 | |
| 571 | Returns: |
| 572 | True if pass; False if fail. |
| 573 | """ |
| 574 | tasks = [(check_back_to_service_time, (ad,)) for ad in self.android_devices] |
| 575 | if not multithread_func(self.log, tasks): |
| 576 | error_msg = "Device is not back to the service" |
| 577 | self.my_error_msg += error_msg |
| 578 | self.log.info(error_msg) |
| 579 | return False |
| 580 | return True |