1#!/usr/bin/env python3.4 2# 3# Copyright 2016 - 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 17import math 18import os 19from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest 20from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED 21from acts.test_utils.tel.tel_test_utils import call_setup_teardown 22from acts.test_utils.tel.tel_test_utils import ensure_phones_default_state 23from acts.test_utils.tel.tel_test_utils import ensure_phones_idle 24from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected 25from acts.test_utils.tel.tel_test_utils import hangup_call 26from acts.test_utils.tel.tel_test_utils import is_wfc_enabled 27from acts.test_utils.tel.tel_test_utils import set_phone_screen_on 28from acts.test_utils.tel.tel_test_utils import set_wfc_mode 29from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode 30from acts.test_utils.tel.tel_test_utils import verify_incall_state 31from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_3g 32from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_2g 33from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan 34from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_volte 35from acts.test_utils.tel.tel_voice_utils import phone_idle_2g 36from acts.test_utils.tel.tel_voice_utils import phone_idle_3g 37from acts.test_utils.tel.tel_voice_utils import phone_idle_iwlan 38from acts.test_utils.tel.tel_voice_utils import phone_idle_volte 39from acts.test_utils.tel.tel_voice_utils import phone_setup_csfb 40from acts.test_utils.tel.tel_voice_utils import phone_setup_iwlan 41from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g 42from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_2g 43from acts.test_utils.tel.tel_voice_utils import phone_setup_volte 44from acts.utils import create_dir 45from acts.utils import disable_doze 46from acts.utils import get_current_human_time 47from acts.utils import set_adaptive_brightness 48from acts.utils import set_ambient_display 49from acts.utils import set_auto_rotate 50from acts.utils import set_location_service 51from acts.utils import set_mobile_data_always_on 52 53# Monsoon output Voltage in V 54MONSOON_OUTPUT_VOLTAGE = 4.2 55# Monsoon output max current in A 56MONSOON_MAX_CURRENT = 7.8 57 58# Default power test pass criteria 59DEFAULT_POWER_PASS_CRITERIA = 999 60 61# Sampling rate in Hz 62ACTIVE_CALL_TEST_SAMPLING_RATE = 100 63# Sample duration in seconds 64ACTIVE_CALL_TEST_SAMPLE_TIME = 300 65# Offset time in seconds 66ACTIVE_CALL_TEST_OFFSET_TIME = 180 67 68# Sampling rate in Hz 69IDLE_TEST_SAMPLING_RATE = 100 70# Sample duration in seconds 71IDLE_TEST_SAMPLE_TIME = 2400 72# Offset time in seconds 73IDLE_TEST_OFFSET_TIME = 360 74 75# Constant for RAT 76RAT_LTE = 'lte' 77RAT_3G = '3g' 78RAT_2G = '2g' 79# Constant for WIFI 80WIFI_5G = '5g' 81WIFI_2G = '2g' 82 83# For wakeup ping test, the frequency to wakeup. In unit of second. 84WAKEUP_PING_TEST_WAKEUP_FREQ = 60 85 86WAKEUP_PING_TEST_NUMBER_OF_ALARM = math.ceil( 87 (IDLE_TEST_SAMPLE_TIME * 60 + IDLE_TEST_OFFSET_TIME) / 88 WAKEUP_PING_TEST_WAKEUP_FREQ) 89 90 91class TelPowerTest(TelephonyBaseTest): 92 def __init__(self, controllers): 93 TelephonyBaseTest.__init__(self, controllers) 94 95 def setup_class(self): 96 super().setup_class() 97 self.mon = self.monsoons[0] 98 self.mon.set_voltage(MONSOON_OUTPUT_VOLTAGE) 99 self.mon.set_max_current(MONSOON_MAX_CURRENT) 100 # Monsoon phone 101 self.mon.dut = self.ad = self.android_devices[0] 102 self.ad.reboot() 103 set_adaptive_brightness(self.ad, False) 104 set_ambient_display(self.ad, False) 105 set_auto_rotate(self.ad, False) 106 set_location_service(self.ad, False) 107 # This is not needed for AOSP build 108 disable_doze(self.ad) 109 set_phone_screen_on(self.log, self.ad, 15) 110 111 self.wifi_network_ssid_2g = self.user_params["wifi_network_ssid_2g"] 112 self.wifi_network_pass_2g = self.user_params["wifi_network_pass_2g"] 113 self.wifi_network_ssid_5g = self.user_params["wifi_network_ssid_5g"] 114 self.wifi_network_pass_5g = self.user_params["wifi_network_pass_5g"] 115 116 self.monsoon_log_path = os.path.join(self.log_path, "MonsoonLog") 117 create_dir(self.monsoon_log_path) 118 return True 119 120 def _save_logs_for_power_test(self, monsoon_result, bug_report): 121 if monsoon_result and "monsoon_log_for_power_test" in self.user_params: 122 monsoon_result.save_to_text_file( 123 [monsoon_result], 124 os.path.join(self.monsoon_log_path, self.test_id)) 125 if bug_report and "bug_report_for_power_test" in self.user_params: 126 self.android_devices[0].take_bug_report(self.test_name, 127 self.begin_time) 128 129 def _setup_apm(self): 130 if not toggle_airplane_mode(self.log, self.ad, True): 131 self.log.error("Phone failed to turn on airplane mode.") 132 return False 133 else: 134 self.log.info("Airplane mode is enabled successfully.") 135 return True 136 137 def _setup_wifi(self, wifi): 138 if wifi == WIFI_5G: 139 network_ssid = self.wifi_network_ssid_5g 140 network_pass = self.wifi_network_pass_5g 141 else: 142 network_ssid = self.wifi_network_ssid_2g 143 network_pass = self.wifi_network_pass_2g 144 if not ensure_wifi_connected( 145 self.log, self.ad, network_ssid, network_pass, retry=3): 146 self.log.error("Wifi %s connection fails." % wifi) 147 return False 148 self.log.info("WIFI %s is connected successfully." % wifi) 149 return True 150 151 def _setup_wfc(self): 152 if not set_wfc_mode(self.log, self.ad, WFC_MODE_WIFI_PREFERRED): 153 self.log.error("Phone failed to enable Wifi-Calling.") 154 return False 155 self.log.info("Phone is set in Wifi-Calling successfully.") 156 if not phone_idle_iwlan(self.log, self.ad): 157 self.log.error("DUT not in WFC enabled state.") 158 return False 159 return True 160 161 def _setup_lte_volte_enabled(self): 162 if not phone_setup_volte(self.log, self.ad): 163 self.log.error("Phone failed to enable VoLTE.") 164 return False 165 self.log.info("VOLTE is enabled successfully.") 166 return True 167 168 def _setup_lte_volte_disabled(self): 169 if not phone_setup_csfb(self.log, self.ad): 170 self.log.error("Phone failed to setup CSFB.") 171 return False 172 self.log.info("VOLTE is disabled successfully.") 173 return True 174 175 def _setup_3g(self): 176 if not phone_setup_voice_3g(self.log, self.ad): 177 self.log.error("Phone failed to setup 3g.") 178 return False 179 self.log.info("RAT 3G is enabled successfully.") 180 return True 181 182 def _setup_2g(self): 183 if not phone_setup_voice_2g(self.log, self.ad): 184 self.log.error("Phone failed to setup 2g.") 185 return False 186 self.log.info("RAT 2G is enabled successfully.") 187 return True 188 189 def _setup_rat(self, rat, volte): 190 if rat == RAT_3G: 191 return self._setup_3g() 192 elif rat == RAT_2G: 193 return self._setup_2g() 194 elif rat == RAT_LTE and volte: 195 return self._setup_lte_volte_enabled() 196 elif rat == RAT_LTE and not volte: 197 return self._setup_lte_volte_disabled() 198 199 def _start_alarm(self): 200 # TODO: This one works with a temporary SL4A API to start alarm. 201 # https://googleplex-android-review.git.corp.google.com/#/c/1562684/ 202 # simulate normal user behavior -- wake up every 1 minutes and do ping 203 # (transmit data) 204 try: 205 alarm_id = self.ad.droid.telephonyStartRecurringAlarm( 206 WAKEUP_PING_TEST_NUMBER_OF_ALARM, 207 1000 * WAKEUP_PING_TEST_WAKEUP_FREQ, "PING_GOOGLE", None) 208 except: 209 self.log.error("Failed to setup periodic ping.") 210 return False 211 if alarm_id is None: 212 self.log.error("Start alarm for periodic ping failed.") 213 return False 214 self.log.info("Set up periodic ping successfully.") 215 return True 216 217 def _setup_phone_active_call(self): 218 if not call_setup_teardown( 219 self.log, self.ad, self.android_devices[1], ad_hangup=None): 220 self.log.error("Setup Call failed.") 221 return False 222 self.log.info("Setup active call successfully.") 223 return True 224 225 def _test_setup(self, 226 apm=False, 227 rat=None, 228 volte=False, 229 wifi=None, 230 wfc=False, 231 mobile_data_always_on=False, 232 periodic_ping=False, 233 active_call=False): 234 if not ensure_phones_default_state(self.log, self.android_devices): 235 self.log.error("Fail to set phones in default state") 236 return False 237 else: 238 self.log.info("Set phones in default state successfully") 239 if apm and not self._setup_apm(): return False 240 if rat and not self._setup_rat(rat, volte): return False 241 if wifi and not self._setup_wifi(wifi): return False 242 if wfc and not self._setup_wfc(): return False 243 if mobile_data_always_on: set_mobile_data_always_on(self.ad, True) 244 if periodic_ping and not self._start_alarm(): return False 245 if active_call and not self._setup_phone_active_call(): return False 246 self.ad.droid.goToSleepNow() 247 return True 248 249 def _power_test(self, phone_check_func_after_power_test=None, **kwargs): 250 # Test passing criteria can be defined in test config file with the 251 # maximum mA allowed for the test case in "pass_criteria"->test_name 252 # field. By default it will set to 999. 253 pass_criteria = self._get_pass_criteria(self.test_name) 254 bug_report = True 255 active_call = kwargs.get('active_call') 256 average_current = 0 257 result = None 258 self.log.info("Test %s: %s" % (self.test_name, kwargs)) 259 if active_call: 260 sample_rate = ACTIVE_CALL_TEST_SAMPLING_RATE 261 sample_time = ACTIVE_CALL_TEST_SAMPLE_TIME 262 offset_time = ACTIVE_CALL_TEST_OFFSET_TIME 263 else: 264 sample_rate = IDLE_TEST_SAMPLING_RATE 265 sample_time = IDLE_TEST_SAMPLE_TIME 266 offset_time = IDLE_TEST_OFFSET_TIME 267 try: 268 if not self._test_setup(**kwargs): 269 self.log.error("DUT Failed to Set Up Properly.") 270 return False 271 272 if ((phone_check_func_after_power_test is not None) and 273 (not phone_check_func_after_power_test( 274 self.log, self.android_devices[0]))): 275 self.log.error( 276 "Phone is not in correct status before power test.") 277 return False 278 279 result = self.mon.measure_power(sample_rate, sample_time, 280 self.test_id, offset_time) 281 average_current = result.average_current 282 if ((phone_check_func_after_power_test is not None) and 283 (not phone_check_func_after_power_test( 284 self.log, self.android_devices[0]))): 285 self.log.error( 286 "Phone is not in correct status after power test.") 287 return False 288 if active_call: 289 if not verify_incall_state(self.log, [ 290 self.android_devices[0], self.android_devices[1] 291 ], True): 292 self.log.error("Call drop during power test.") 293 return False 294 else: 295 hangup_call(self.log, self.android_devices[1]) 296 if (average_current <= pass_criteria): 297 bug_report = False 298 return True 299 finally: 300 self._save_logs_for_power_test(result, bug_report) 301 self.log.info("{} Result: {} mA, pass criteria: {} mA".format( 302 self.test_id, average_current, pass_criteria)) 303 304 def _get_pass_criteria(self, test_name): 305 """Get the test passing criteria. 306 Test passing criteria can be defined in test config file with the 307 maximum mA allowed for the test case in "pass_criteria"->test_name 308 field. By default it will set to 999. 309 """ 310 try: 311 pass_criteria = int(self.user_params["pass_criteria"][test_name]) 312 except KeyError: 313 pass_criteria = DEFAULT_POWER_PASS_CRITERIA 314 return pass_criteria 315 316 @TelephonyBaseTest.tel_test_wrap 317 def test_power_active_call_volte(self): 318 """Power measurement test for active VoLTE call. 319 320 Steps: 321 1. DUT idle, in LTE mode, VoLTE enabled. 322 2. Make a phone Call from DUT to PhoneB. Answer on PhoneB. 323 Make sure DUT is in VoLTE call. 324 3. Turn off screen and wait for 3 minutes. 325 Then measure power consumption for 5 minutes and get average. 326 327 Expected Results: 328 Average power consumption should be within pre-defined limit. 329 330 Returns: 331 True if Pass, False if Fail. 332 333 Note: Please calibrate your test environment and baseline pass criteria. 334 Pass criteria info should be in test config file. 335 """ 336 return self._power_test( 337 rat=RAT_LTE, 338 volte=True, 339 active_call=True, 340 phone_check_func_after_power_test=is_phone_in_call_volte) 341 342 @TelephonyBaseTest.tel_test_wrap 343 def test_power_active_call_3g(self): 344 """Power measurement test for active CS(3G) call. 345 346 Steps: 347 1. DUT idle, in 3G mode. 348 2. Make a phone Call from DUT to PhoneB. Answer on PhoneB. 349 Make sure DUT is in CS(3G) call. 350 3. Turn off screen and wait for 3 minutes. 351 Then measure power consumption for 5 minutes and get average. 352 353 Expected Results: 354 Average power consumption should be within pre-defined limit. 355 356 Returns: 357 True if Pass, False if Fail. 358 359 Note: Please calibrate your test environment and baseline pass criteria. 360 Pass criteria info should be in test config file. 361 """ 362 return self._power_test( 363 rat=RAT_3G, 364 active_call=True, 365 phone_check_func_after_power_test=is_phone_in_call_3g) 366 367 @TelephonyBaseTest.tel_test_wrap 368 def test_power_active_call_2g(self): 369 """Power measurement test for active CS(2G) call. 370 371 Steps: 372 1. DUT idle, in 2G mode. 373 2. Make a phone Call from DUT to PhoneB. Answer on PhoneB. 374 Make sure DUT is in CS(2G) call. 375 3. Turn off screen and wait for 3 minutes. 376 Then measure power consumption for 5 minutes and get average. 377 378 Expected Results: 379 Average power consumption should be within pre-defined limit. 380 381 Returns: 382 True if Pass, False if Fail. 383 384 Note: Please calibrate your test environment and baseline pass criteria. 385 Pass criteria info should be in test config file. 386 """ 387 return self._power_test( 388 rat=RAT_2G, 389 active_call=True, 390 phone_check_func_after_power_test=is_phone_in_call_2g) 391 392 @TelephonyBaseTest.tel_test_wrap 393 def test_power_active_call_wfc_wifi2g_apm(self): 394 """Power measurement test for active WiFi call. 395 396 Steps: 397 1. DUT idle, in Airplane mode, connect to 2G WiFi, 398 WiFi Calling enabled (WiFi-preferred mode). 399 2. Make a phone Call from DUT to PhoneB. Answer on PhoneB. 400 Make sure DUT is in WFC call. 401 3. Turn off screen and wait for 3 minutes. 402 Then measure power consumption for 5 minutes and get average. 403 404 Expected Results: 405 Average power consumption should be within pre-defined limit. 406 407 Returns: 408 True if Pass, False if Fail. 409 410 Note: Please calibrate your test environment and baseline pass criteria. 411 Pass criteria info should be in test config file. 412 """ 413 return self._power_test( 414 apm=True, 415 wifi=WIFI_2G, 416 wfc=True, 417 active_call=True, 418 phone_check_func_after_power_test=is_phone_in_call_iwlan) 419 420 @TelephonyBaseTest.tel_test_wrap 421 def test_power_active_call_wfc_wifi2g_lte_volte_enabled(self): 422 """Power measurement test for active WiFi call. 423 424 Steps: 425 1. DUT idle, LTE cellular data network, VoLTE is On, connect to 2G WiFi, 426 WiFi Calling enabled (WiFi-preferred). 427 2. Make a phone Call from DUT to PhoneB. Answer on PhoneB. 428 Make sure DUT is in WFC call. 429 3. Turn off screen and wait for 3 minutes. 430 Then measure power consumption for 5 minutes and get average. 431 432 Expected Results: 433 Average power consumption should be within pre-defined limit. 434 435 Returns: 436 True if Pass, False if Fail. 437 438 Note: Please calibrate your test environment and baseline pass criteria. 439 Pass criteria info should be in test config file. 440 """ 441 return self._power_test( 442 rat=RAT_LTE, 443 volte=True, 444 wifi=WIFI_2G, 445 wfc=True, 446 active_call=True, 447 phone_check_func_after_power_test=is_phone_in_call_iwlan) 448 449 @TelephonyBaseTest.tel_test_wrap 450 def test_power_active_call_wfc_wifi5g_apm(self): 451 """Power measurement test for active WiFi call. 452 453 Steps: 454 1. DUT idle, in Airplane mode, connect to 5G WiFi, 455 WiFi Calling enabled (WiFi-preferred mode). 456 2. Make a phone Call from DUT to PhoneB. Answer on PhoneB. 457 Make sure DUT is in WFC call. 458 3. Turn off screen and wait for 3 minutes. 459 Then measure power consumption for 5 minutes and get average. 460 461 Expected Results: 462 Average power consumption should be within pre-defined limit. 463 464 Returns: 465 True if Pass, False if Fail. 466 467 Note: Please calibrate your test environment and baseline pass criteria. 468 Pass criteria info should be in test config file. 469 """ 470 return self._power_test( 471 apm=True, 472 wifi=WIFI_5G, 473 wfc=True, 474 active_call=True, 475 phone_check_func_after_power_test=is_phone_in_call_iwlan) 476 477 @TelephonyBaseTest.tel_test_wrap 478 def test_power_active_call_wfc_wifi5g_lte_volte_enabled(self): 479 """Power measurement test for active WiFi call. 480 481 Steps: 482 1. DUT idle, LTE cellular data network, VoLTE is On, connect to 5G WiFi, 483 WiFi Calling enabled (WiFi-preferred). 484 2. Make a phone Call from DUT to PhoneB. Answer on PhoneB. 485 Make sure DUT is in WFC call. 486 3. Turn off screen and wait for 3 minutes. 487 Then measure power consumption for 5 minutes and get average. 488 489 Expected Results: 490 Average power consumption should be within pre-defined limit. 491 492 Returns: 493 True if Pass, False if Fail. 494 495 Note: Please calibrate your test environment and baseline pass criteria. 496 Pass criteria info should be in test config file. 497 """ 498 return self._power_test( 499 rat=RAT_LTE, 500 volte=True, 501 wifi=WIFI_5G, 502 wfc=True, 503 active_call=True, 504 phone_check_func_after_power_test=is_phone_in_call_iwlan) 505 506 @TelephonyBaseTest.tel_test_wrap 507 def test_power_idle_baseline(self): 508 """Power measurement test for phone idle baseline. 509 510 Steps: 511 1. DUT idle, in Airplane mode. WiFi disabled, WiFi Calling disabled. 512 2. Turn off screen and wait for 6 minutes. Then measure power 513 consumption for 40 minutes and get average. 514 515 Expected Results: 516 Average power consumption should be within pre-defined limit. 517 518 Returns: 519 True if Pass, False if Fail. 520 521 Note: Please calibrate your test environment and baseline pass criteria. 522 Pass criteria info should be in test config file. 523 """ 524 return self._power_test(apm=True) 525 526 @TelephonyBaseTest.tel_test_wrap 527 def test_power_idle_baseline_wifi2g_connected(self): 528 """Power measurement test for phone idle baseline (WiFi connected). 529 530 Steps: 531 1. DUT idle, in Airplane mode. WiFi connected to 2.4G WiFi, 532 WiFi Calling disabled. 533 2. Turn off screen and wait for 6 minutes. Then measure power 534 consumption for 40 minutes and get average. 535 536 Expected Results: 537 Average power consumption should be within pre-defined limit. 538 539 Returns: 540 True if Pass, False if Fail. 541 542 Note: Please calibrate your test environment and baseline pass criteria. 543 Pass criteria info should be in test config file. 544 """ 545 return self._power_test(apm=True, wifi=WIFI_2G) 546 547 @TelephonyBaseTest.tel_test_wrap 548 def test_power_idle_wfc_wifi2g_apm(self): 549 """Power measurement test for phone idle WiFi Calling Airplane Mode. 550 551 Steps: 552 1. DUT idle, in Airplane mode. Connected to 2G WiFi, 553 WiFi Calling enabled (WiFi preferred). 554 2. Turn off screen and wait for 6 minutes. Then measure power 555 consumption for 40 minutes and get average. 556 557 Expected Results: 558 Average power consumption should be within pre-defined limit. 559 560 Returns: 561 True if Pass, False if Fail. 562 563 Note: Please calibrate your test environment and baseline pass criteria. 564 Pass criteria info should be in test config file. 565 """ 566 return self._power_test( 567 apm=True, 568 wifi=WIFI_2G, 569 wfc=True, 570 phone_check_func_after_power_test=phone_idle_iwlan) 571 572 @TelephonyBaseTest.tel_test_wrap 573 def test_power_idle_wfc_wifi2g_lte_volte_enabled(self): 574 """Power measurement test for phone idle WiFi Calling LTE VoLTE enabled. 575 576 Steps: 577 1. DUT idle, in LTE mode, VoLTE enabled. Connected to 2G WiFi, 578 WiFi Calling enabled (WiFi preferred). 579 2. Turn off screen and wait for 6 minutes. Then measure power 580 consumption for 40 minutes and get average. 581 582 Expected Results: 583 Average power consumption should be within pre-defined limit. 584 585 Returns: 586 True if Pass, False if Fail. 587 588 Note: Please calibrate your test environment and baseline pass criteria. 589 Pass criteria info should be in test config file. 590 """ 591 return self._power_test( 592 rat=RAT_LTE, 593 volte=True, 594 wifi=WIFI_2G, 595 wfc=True, 596 phone_check_func_after_power_test=phone_idle_iwlan) 597 598 @TelephonyBaseTest.tel_test_wrap 599 def test_power_idle_lte_volte_enabled(self): 600 """Power measurement test for phone idle LTE VoLTE enabled. 601 602 Steps: 603 1. DUT idle, in LTE mode, VoLTE enabled. WiFi disabled, 604 WiFi Calling disabled. 605 2. Turn off screen and wait for 6 minutes. Then measure power 606 consumption for 40 minutes and get average. 607 608 Expected Results: 609 Average power consumption should be within pre-defined limit. 610 611 Returns: 612 True if Pass, False if Fail. 613 614 Note: Please calibrate your test environment and baseline pass criteria. 615 Pass criteria info should be in test config file. 616 """ 617 return self._power_test( 618 rat=RAT_LTE, 619 volte=True, 620 phone_check_func_after_power_test=phone_idle_volte) 621 622 @TelephonyBaseTest.tel_test_wrap 623 def test_power_idle_lte_volte_enabled_wifi2g(self): 624 """Power measurement test for phone idle LTE VoLTE enabled. 625 626 Steps: 627 1. DUT idle, in LTE mode, VoLTE enabled. WiFi enabled, 628 WiFi Calling disabled. 629 2. Turn off screen and wait for 6 minutes. Then measure power 630 consumption for 40 minutes and get average. 631 632 Expected Results: 633 Average power consumption should be within pre-defined limit. 634 635 Returns: 636 True if Pass, False if Fail. 637 638 Note: Please calibrate your test environment and baseline pass criteria. 639 Pass criteria info should be in test config file. 640 """ 641 return self._power_test( 642 rat=RAT_LTE, 643 volte=True, 644 wifi=WIFI_2G, 645 phone_check_func_after_power_test=phone_idle_volte) 646 647 @TelephonyBaseTest.tel_test_wrap 648 def test_power_idle_lte_volte_disabled(self): 649 """Power measurement test for phone idle LTE VoLTE disabled. 650 651 Steps: 652 1. DUT idle, in LTE mode, VoLTE disabled. WiFi disabled, 653 WiFi Calling disabled. 654 2. Turn off screen and wait for 6 minutes. Then measure power 655 consumption for 40 minutes and get average. 656 657 Expected Results: 658 Average power consumption should be within pre-defined limit. 659 660 Returns: 661 True if Pass, False if Fail. 662 663 Note: Please calibrate your test environment and baseline pass criteria. 664 Pass criteria info should be in test config file. 665 """ 666 return self._power_test(rat=RAT_LTE) 667 668 @TelephonyBaseTest.tel_test_wrap 669 def test_power_idle_3g(self): 670 """Power measurement test for phone idle 3G. 671 672 Steps: 673 1. DUT idle, in 3G mode. WiFi disabled, WiFi Calling disabled. 674 2. Turn off screen and wait for 6 minutes. Then measure power 675 consumption for 40 minutes and get average. 676 677 Expected Results: 678 Average power consumption should be within pre-defined limit. 679 680 Returns: 681 True if Pass, False if Fail. 682 683 Note: Please calibrate your test environment and baseline pass criteria. 684 Pass criteria info should be in test config file. 685 """ 686 return self._power_test( 687 rat=RAT_3G, phone_check_func_after_power_test=phone_idle_3g) 688 689 @TelephonyBaseTest.tel_test_wrap 690 def test_power_idle_3g_wifi2g(self): 691 """Power measurement test for phone idle 3G. 692 693 Steps: 694 1. DUT idle, in 3G mode. WiFi enabled, WiFi Calling disabled. 695 2. Turn off screen and wait for 6 minutes. Then measure power 696 consumption for 40 minutes and get average. 697 698 Expected Results: 699 Average power consumption should be within pre-defined limit. 700 701 Returns: 702 True if Pass, False if Fail. 703 704 Note: Please calibrate your test environment and baseline pass criteria. 705 Pass criteria info should be in test config file. 706 """ 707 return self._power_test( 708 rat=RAT_3G, 709 wifi=WIFI_2G, 710 phone_check_func_after_power_test=phone_idle_3g) 711 712 @TelephonyBaseTest.tel_test_wrap 713 def test_power_idle_2g(self): 714 """Power measurement test for phone idle 3G. 715 716 Steps: 717 1. DUT idle, in 2G mode. WiFi disabled, WiFi Calling disabled. 718 2. Turn off screen and wait for 6 minutes. Then measure power 719 consumption for 40 minutes and get average. 720 721 Expected Results: 722 Average power consumption should be within pre-defined limit. 723 724 Returns: 725 True if Pass, False if Fail. 726 727 Note: Please calibrate your test environment and baseline pass criteria. 728 Pass criteria info should be in test config file. 729 """ 730 return self._power_test( 731 rat=RAT_2G, phone_check_func_after_power_test=phone_idle_2g) 732 733 @TelephonyBaseTest.tel_test_wrap 734 def test_power_idle_2g_wifi2g(self): 735 """Power measurement test for phone idle 3G. 736 737 Steps: 738 1. DUT idle, in 2G mode. WiFi disabled, WiFi Calling disabled. 739 2. Turn off screen and wait for 6 minutes. Then measure power 740 consumption for 40 minutes and get average. 741 742 Expected Results: 743 Average power consumption should be within pre-defined limit. 744 745 Returns: 746 True if Pass, False if Fail. 747 748 Note: Please calibrate your test environment and baseline pass criteria. 749 Pass criteria info should be in test config file. 750 """ 751 return self._power_test( 752 rat=RAT_2G, 753 wifi=WIFI_2G, 754 phone_check_func_after_power_test=phone_idle_2g) 755 756 # TODO: This one is not working right now. Requires SL4A API to start alarm. 757 @TelephonyBaseTest.tel_test_wrap 758 def test_power_idle_lte_volte_enabled_wakeup_ping(self): 759 """Power measurement test for phone LTE VoLTE enabled Wakeup Ping every 760 1 minute. 761 762 Steps: 763 1. DUT idle, in LTE mode, VoLTE enabled. WiFi disabled, 764 WiFi Calling disabled. 765 2. Start script to wake up AP every 1 minute, after wakeup, 766 DUT send http Request to Google.com then go to sleep. 767 3. Turn off screen and wait for 6 minutes. Then measure power 768 consumption for 40 minutes and get average. 769 770 Expected Results: 771 Average power consumption should be within pre-defined limit. 772 773 Returns: 774 True if Pass, False if Fail. 775 776 Note: Please calibrate your test environment and baseline pass criteria. 777 Pass criteria info should be in test config file. 778 """ 779 return self._power_test( 780 rat=RAT_LTE, 781 volte=True, 782 periodic_ping=True, 783 phone_check_func_after_power_test=phone_idle_iwlan) 784 785 # TODO: This one is not working right now. Requires SL4A API to start alarm. 786 @TelephonyBaseTest.tel_test_wrap 787 def test_power_idle_lte_volte_disabled_wakeup_ping(self): 788 """Power measurement test for phone LTE VoLTE disabled Wakeup Ping every 789 1 minute. 790 791 Steps: 792 1. DUT idle, in LTE mode, VoLTE disabled. WiFi disabled, 793 WiFi Calling disabled. 794 2. Start script to wake up AP every 1 minute, after wakeup, 795 DUT send http Request to Google.com then go to sleep. 796 3. Turn off screen and wait for 6 minutes. Then measure power 797 consumption for 40 minutes and get average. 798 799 Expected Results: 800 Average power consumption should be within pre-defined limit. 801 802 Returns: 803 True if Pass, False if Fail. 804 805 Note: Please calibrate your test environment and baseline pass criteria. 806 Pass criteria info should be in test config file. 807 """ 808 return self._power_test(rat=RAT_LTE, periodic_ping=True) 809 810 # TODO: This one is not working right now. Requires SL4A API to start alarm. 811 @TelephonyBaseTest.tel_test_wrap 812 def test_power_idle_3g_wakeup_ping(self): 813 """Power measurement test for phone 3G Wakeup Ping every 1 minute. 814 815 Steps: 816 1. DUT idle, in 3G mode. WiFi disabled, WiFi Calling disabled. 817 2. Start script to wake up AP every 1 minute, after wakeup, 818 DUT send http Request to Google.com then go to sleep. 819 3. Turn off screen and wait for 6 minutes. Then measure power 820 consumption for 40 minutes and get average. 821 822 Expected Results: 823 Average power consumption should be within pre-defined limit. 824 825 Returns: 826 True if Pass, False if Fail. 827 828 Note: Please calibrate your test environment and baseline pass criteria. 829 Pass criteria info should be in test config file. 830 """ 831 return self._power_test( 832 rat=RAT_3G, 833 periodic_ping=True, 834 phone_check_func_after_power_test=phone_idle_3g) 835 836 @TelephonyBaseTest.tel_test_wrap 837 def test_power_idle_lte_volte_enabled_mobile_data_always_on(self): 838 """Power measurement test for phone idle LTE VoLTE enabled. 839 840 Steps: 841 1. DUT idle, in LTE mode, VoLTE enabled. WiFi disabled, 842 WiFi Calling disabled. 843 2. Turn on mobile data always on 844 3. Turn off screen and wait for 6 minutes. Then measure power 845 consumption for 40 minutes and get average. 846 847 Expected Results: 848 Average power consumption should be within pre-defined limit. 849 850 Returns: 851 True if Pass, False if Fail. 852 853 Note: Please calibrate your test environment and baseline pass criteria. 854 Pass criteria info should be in test config file. 855 """ 856 return self._power_test( 857 rat=RAT_LTE, 858 volte=True, 859 mobile_data_always_on=True, 860 phone_check_func_after_power_test=phone_idle_volte) 861 862 @TelephonyBaseTest.tel_test_wrap 863 def test_power_idle_lte_volte_enabled_wifi2g_mobile_data_always_on(self): 864 """Power measurement test for phone idle LTE VoLTE enabled. 865 866 Steps: 867 1. DUT idle, in LTE mode, VoLTE enabled. WiFi enabled, 868 WiFi Calling disabled. 869 2. Turn on mobile data always on 870 3. Turn off screen and wait for 6 minutes. Then measure power 871 consumption for 40 minutes and get average. 872 873 Expected Results: 874 Average power consumption should be within pre-defined limit. 875 876 Returns: 877 True if Pass, False if Fail. 878 879 Note: Please calibrate your test environment and baseline pass criteria. 880 Pass criteria info should be in test config file. 881 """ 882 return self._power_test( 883 rat=RAT_LTE, 884 volte=True, 885 wifi=WIFI_2G, 886 mobile_data_always_on=True, 887 phone_check_func_after_power_test=phone_idle_volte) 888 889 @TelephonyBaseTest.tel_test_wrap 890 def test_power_idle_lte_volte_disabled_mobile_data_always_on(self): 891 """Power measurement test for phone idle LTE VoLTE disabled. 892 893 Steps: 894 1. DUT idle, in LTE mode, VoLTE disabled. WiFi disabled, 895 WiFi Calling disabled. 896 2. Turn on mobile data always on 897 3. Turn off screen and wait for 6 minutes. Then measure power 898 consumption for 40 minutes and get average. 899 900 Expected Results: 901 Average power consumption should be within pre-defined limit. 902 903 Returns: 904 True if Pass, False if Fail. 905 906 Note: Please calibrate your test environment and baseline pass criteria. 907 Pass criteria info should be in test config file. 908 """ 909 return self._power_test(rat=RAT_LTE, mobile_data_always_on=True) 910 911 @TelephonyBaseTest.tel_test_wrap 912 def test_power_idle_3g_mobile_data_always_on(self): 913 """Power measurement test for phone idle 3G. 914 915 Steps: 916 1. DUT idle, in 3G mode. WiFi disabled, WiFi Calling disabled. 917 2. Turn on mobile data always on 918 3. Turn off screen and wait for 6 minutes. Then measure power 919 consumption for 40 minutes and get average. 920 921 Expected Results: 922 Average power consumption should be within pre-defined limit. 923 924 Returns: 925 True if Pass, False if Fail. 926 927 Note: Please calibrate your test environment and baseline pass criteria. 928 Pass criteria info should be in test config file. 929 """ 930 return self._power_test( 931 rat=RAT_3G, 932 mobile_data_always_on=True, 933 phone_check_func_after_power_test=phone_idle_3g) 934 935 @TelephonyBaseTest.tel_test_wrap 936 def test_power_idle_3g_wifi2g_mobile_data_always_on(self): 937 """Power measurement test for phone idle 3G. 938 939 Steps: 940 1. DUT idle, in 3G mode. WiFi enabled, WiFi Calling disabled. 941 2. Turn on mobile data always on 942 3. Turn off screen and wait for 6 minutes. Then measure power 943 consumption for 40 minutes and get average. 944 945 Expected Results: 946 Average power consumption should be within pre-defined limit. 947 948 Returns: 949 True if Pass, False if Fail. 950 951 Note: Please calibrate your test environment and baseline pass criteria. 952 Pass criteria info should be in test config file. 953 """ 954 return self._power_test( 955 rat=RAT_3G, 956 wifi=WIFI_2G, 957 mobile_data_always_on=True, 958 phone_check_func_after_power_test=phone_idle_3g) 959 960 @TelephonyBaseTest.tel_test_wrap 961 def test_power_idle_2g_mobile_data_always_on(self): 962 """Power measurement test for phone idle 3G. 963 964 Steps: 965 1. DUT idle, in 2G mode. WiFi disabled, WiFi Calling disabled. 966 2. Turn on mobile data always on 967 3. Turn off screen and wait for 6 minutes. Then measure power 968 consumption for 40 minutes and get average. 969 970 Expected Results: 971 Average power consumption should be within pre-defined limit. 972 973 Returns: 974 True if Pass, False if Fail. 975 976 Note: Please calibrate your test environment and baseline pass criteria. 977 Pass criteria info should be in test config file. 978 """ 979 return self._power_test( 980 rat=RAT_2G, 981 mobile_data_always_on=True, 982 phone_check_func_after_power_test=phone_idle_2g) 983 984 @TelephonyBaseTest.tel_test_wrap 985 def test_power_idle_2g_wifi2g_mobile_data_always_on(self): 986 """Power measurement test for phone idle 3G. 987 988 Steps: 989 1. DUT idle, in 2G mode. WiFi enabled, WiFi Calling disabled. 990 2. Turn on mobile data always on 991 3. Turn off screen and wait for 6 minutes. Then measure power 992 consumption for 40 minutes and get average. 993 994 Expected Results: 995 Average power consumption should be within pre-defined limit. 996 997 Returns: 998 True if Pass, False if Fail. 999 1000 Note: Please calibrate your test environment and baseline pass criteria. 1001 Pass criteria info should be in test config file. 1002 """ 1003 return self._power_test( 1004 rat=RAT_2G, 1005 wifi=WIFI_2G, 1006 mobile_data_always_on=True, 1007 phone_check_func_after_power_test=phone_idle_2g) 1008 1009 # TODO: This one is not working right now. Requires SL4A API to start alarm. 1010 @TelephonyBaseTest.tel_test_wrap 1011 def test_power_idle_lte_volte_enabled_wakeup_ping_mobile_data_always_on( 1012 self): 1013 """Power measurement test for phone LTE VoLTE enabled Wakeup Ping every 1014 1 minute. 1015 1016 Steps: 1017 1. DUT idle, in LTE mode, VoLTE enabled. WiFi disabled, 1018 WiFi Calling disabled. 1019 2. Start script to wake up AP every 1 minute, after wakeup, 1020 DUT send http Request to Google.com then go to sleep. 1021 3. Turn off screen and wait for 6 minutes. Then measure power 1022 consumption for 40 minutes and get average. 1023 1024 Expected Results: 1025 Average power consumption should be within pre-defined limit. 1026 1027 Returns: 1028 True if Pass, False if Fail. 1029 1030 Note: Please calibrate your test environment and baseline pass criteria. 1031 Pass criteria info should be in test config file. 1032 """ 1033 return self._power_test( 1034 rat=RAT_LTE, 1035 volte=True, 1036 mobile_data_always_on=True, 1037 periodic_ping=True, 1038 phone_check_func_after_power_test=phone_idle_volte) 1039 1040 # TODO: This one is not working right now. Requires SL4A API to start alarm. 1041 @TelephonyBaseTest.tel_test_wrap 1042 def test_power_idle_lte_volte_enabled_wifi2g_wakeup_ping_mobile_data_always_on( 1043 self): 1044 """Power measurement test for phone LTE VoLTE enabled Wakeup Ping every 1045 1 minute. 1046 1047 Steps: 1048 1. DUT idle, in LTE mode, VoLTE enabled. WiFi enabled, 1049 WiFi Calling disabled. 1050 2. Start script to wake up AP every 1 minute, after wakeup, 1051 DUT send http Request to Google.com then go to sleep. 1052 3. Turn off screen and wait for 6 minutes. Then measure power 1053 consumption for 40 minutes and get average. 1054 1055 Expected Results: 1056 Average power consumption should be within pre-defined limit. 1057 1058 Returns: 1059 True if Pass, False if Fail. 1060 1061 Note: Please calibrate your test environment and baseline pass criteria. 1062 Pass criteria info should be in test config file. 1063 """ 1064 return self._power_test( 1065 rat=RAT_LTE, 1066 volte=True, 1067 wifi=WIFI_2G, 1068 mobile_data_always_on=True, 1069 periodic_ping=True, 1070 phone_check_func_after_power_test=phone_idle_volte) 1071 1072 # TODO: This one is not working right now. Requires SL4A API to start alarm. 1073 @TelephonyBaseTest.tel_test_wrap 1074 def test_power_idle_lte_volte_disabled_wakeup_ping_mobile_data_always_on( 1075 self): 1076 """Power measurement test for phone LTE VoLTE disabled Wakeup Ping every 1077 1 minute. 1078 1079 Steps: 1080 1. DUT idle, in LTE mode, VoLTE disabled. WiFi disabled, 1081 WiFi Calling disabled. 1082 2. Start script to wake up AP every 1 minute, after wakeup, 1083 DUT send http Request to Google.com then go to sleep. 1084 3. Turn off screen and wait for 6 minutes. Then measure power 1085 consumption for 40 minutes and get average. 1086 1087 Expected Results: 1088 Average power consumption should be within pre-defined limit. 1089 1090 Returns: 1091 True if Pass, False if Fail. 1092 1093 Note: Please calibrate your test environment and baseline pass criteria. 1094 Pass criteria info should be in test config file. 1095 """ 1096 return self._power_test( 1097 rat=RAT_LTE, mobile_data_always_on=True, periodic_ping=True) 1098 1099 # TODO: This one is not working right now. Requires SL4A API to start alarm. 1100 @TelephonyBaseTest.tel_test_wrap 1101 def test_power_idle_3g_wakeup_ping_mobile_data_always_on(self): 1102 """Power measurement test for phone 3G Wakeup Ping every 1 minute. 1103 1104 Steps: 1105 1. DUT idle, in 3G mode. WiFi disabled, WiFi Calling disabled. 1106 2. Start script to wake up AP every 1 minute, after wakeup, 1107 DUT send http Request to Google.com then go to sleep. 1108 3. Turn off screen and wait for 6 minutes. Then measure power 1109 consumption for 40 minutes and get average. 1110 1111 Expected Results: 1112 Average power consumption should be within pre-defined limit. 1113 1114 Returns: 1115 True if Pass, False if Fail. 1116 1117 Note: Please calibrate your test environment and baseline pass criteria. 1118 Pass criteria info should be in test config file. 1119 """ 1120 return self._power_test( 1121 rat=RAT_3G, 1122 mobile_data_always_on=True, 1123 periodic_ping=True, 1124 phone_check_func_after_power_test=phone_idle_3g) 1125 1126 # TODO: This one is not working right now. Requires SL4A API to start alarm. 1127 @TelephonyBaseTest.tel_test_wrap 1128 def test_power_idle_3g_wifi2g_wakeup_ping_mobile_data_always_on(self): 1129 """Power measurement test for phone 3G Wakeup Ping every 1 minute. 1130 1131 Steps: 1132 1. DUT idle, in 3G mode. WiFi enabled, WiFi Calling disabled. 1133 2. Start script to wake up AP every 1 minute, after wakeup, 1134 DUT send http Request to Google.com then go to sleep. 1135 3. Turn off screen and wait for 6 minutes. Then measure power 1136 consumption for 40 minutes and get average. 1137 1138 Expected Results: 1139 Average power consumption should be within pre-defined limit. 1140 1141 Returns: 1142 True if Pass, False if Fail. 1143 1144 Note: Please calibrate your test environment and baseline pass criteria. 1145 Pass criteria info should be in test config file. 1146 """ 1147 return self._power_test( 1148 rat=RAT_3G, 1149 wifi=WIFI_2G, 1150 mobile_data_always_on=True, 1151 periodic_ping=True, 1152 phone_check_func_after_power_test=phone_idle_3g) 1153 1154 # TODO: This one is not working right now. Requires SL4A API to start alarm. 1155 @TelephonyBaseTest.tel_test_wrap 1156 def test_power_idle_2g_wakeup_ping_mobile_data_always_on(self): 1157 """Power measurement test for phone 3G Wakeup Ping every 1 minute. 1158 1159 Steps: 1160 1. DUT idle, in 2G mode. WiFi disabled, WiFi Calling disabled. 1161 2. Start script to wake up AP every 1 minute, after wakeup, 1162 DUT send http Request to Google.com then go to sleep. 1163 3. Turn off screen and wait for 6 minutes. Then measure power 1164 consumption for 40 minutes and get average. 1165 1166 Expected Results: 1167 Average power consumption should be within pre-defined limit. 1168 1169 Returns: 1170 True if Pass, False if Fail. 1171 1172 Note: Please calibrate your test environment and baseline pass criteria. 1173 Pass criteria info should be in test config file. 1174 """ 1175 return self._power_test( 1176 rat=RAT_2G, 1177 mobile_data_always_on=True, 1178 periodic_ping=True, 1179 phone_check_func_after_power_test=phone_idle_2g) 1180 1181 # TODO: This one is not working right now. Requires SL4A API to start alarm. 1182 @TelephonyBaseTest.tel_test_wrap 1183 def test_power_idle_2g_wifi2g_wakeup_ping_mobile_data_always_on(self): 1184 """Power measurement test for phone 3G Wakeup Ping every 1 minute. 1185 1186 Steps: 1187 1. DUT idle, in 2G mode. WiFi enabled, WiFi Calling disabled. 1188 2. Start script to wake up AP every 1 minute, after wakeup, 1189 DUT send http Request to Google.com then go to sleep. 1190 3. Turn off screen and wait for 6 minutes. Then measure power 1191 consumption for 40 minutes and get average. 1192 1193 Expected Results: 1194 Average power consumption should be within pre-defined limit. 1195 1196 Returns: 1197 True if Pass, False if Fail. 1198 1199 Note: Please calibrate your test environment and baseline pass criteria. 1200 Pass criteria info should be in test config file. 1201 """ 1202 return self._power_test( 1203 rat=RAT_2G, 1204 wifi=WIFI_2G, 1205 mobile_data_always_on=True, 1206 periodic_ping=True, 1207 phone_check_func_after_power_test=phone_idle_2g) 1208 1209