tturney | 1bdf77d | 2015-12-28 17:46:13 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python3.4 |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 2 | # |
tturney | 1bdf77d | 2015-12-28 17:46:13 -0800 | [diff] [blame] | 3 | # Copyright 2016 - Google |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 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 | Test Script for Telephony Pre Flight check. |
| 18 | """ |
| 19 | |
| 20 | import time |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 21 | from queue import Empty |
Betty Zhou | 158c333 | 2017-06-02 17:08:09 -0700 | [diff] [blame] | 22 | |
| 23 | from acts.test_decorators import test_tracker_info |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 24 | from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 25 | from acts.test_utils.tel.tel_defines import AOSP_PREFIX |
| 26 | from acts.test_utils.tel.tel_defines import CAPABILITY_PHONE |
| 27 | from acts.test_utils.tel.tel_defines import CAPABILITY_VOLTE |
| 28 | from acts.test_utils.tel.tel_defines import CAPABILITY_VT |
| 29 | from acts.test_utils.tel.tel_defines import CAPABILITY_WFC |
| 30 | from acts.test_utils.tel.tel_defines import CAPABILITY_MSIM |
| 31 | from acts.test_utils.tel.tel_defines import CAPABILITY_OMADM |
Nathan Harold | 05a6c27 | 2016-10-17 13:55:53 -0700 | [diff] [blame] | 32 | from acts.test_utils.tel.tel_defines import INVALID_SUB_ID |
Yang Liu | df164e3 | 2016-01-07 16:49:32 -0800 | [diff] [blame] | 33 | from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_NW_SELECTION |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 34 | from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_BACKGROUND |
| 35 | from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_FOREGROUND |
| 36 | from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_RINGING |
| 37 | from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_REBOOT |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 38 | from acts.test_utils.tel.tel_lookup_tables import device_capabilities |
| 39 | from acts.test_utils.tel.tel_lookup_tables import operator_capabilities |
Betty Zhou | 5534e67 | 2017-03-07 13:47:10 -0800 | [diff] [blame] | 40 | from acts.test_utils.tel.tel_test_utils import abort_all_tests |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 41 | from acts.test_utils.tel.tel_test_utils import ensure_phones_default_state |
Betty Zhou | 7f45f55 | 2017-03-15 19:12:52 -0700 | [diff] [blame] | 42 | from acts.test_utils.tel.tel_test_utils import ensure_phone_subscription |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 43 | from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 44 | from acts.test_utils.tel.tel_test_utils import get_operator_name |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 45 | from acts.test_utils.tel.tel_test_utils import setup_droid_properties |
| 46 | from acts.test_utils.tel.tel_test_utils import set_phone_screen_on |
| 47 | from acts.test_utils.tel.tel_test_utils import set_phone_silent_mode |
| 48 | from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 49 | from acts.test_utils.tel.tel_test_utils import verify_http_connection |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 50 | from acts.test_utils.tel.tel_test_utils import wait_for_voice_attach_for_subscription |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 51 | from acts.test_utils.tel.tel_test_utils import wait_for_wifi_data_connection |
Betty Zhou | f987b8f | 2017-03-09 16:34:00 -0800 | [diff] [blame] | 52 | from acts.test_utils.tel.tel_test_utils import wifi_toggle_state |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 53 | from acts.test_utils.tel.tel_voice_utils import phone_setup_volte |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 54 | from acts.asserts import abort_all |
Betty Zhou | ec8378f | 2016-12-21 17:28:48 -0800 | [diff] [blame] | 55 | from acts.asserts import fail |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 56 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 57 | |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 58 | class TelLivePreflightTest(TelephonyBaseTest): |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 59 | def __init__(self, controllers): |
| 60 | TelephonyBaseTest.__init__(self, controllers) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 61 | |
Betty Zhou | 061ae08 | 2016-12-01 15:26:24 -0800 | [diff] [blame] | 62 | self.wifi_network_ssid = self.user_params.get( |
Betty Zhou | 158c333 | 2017-06-02 17:08:09 -0700 | [diff] [blame] | 63 | "wifi_network_ssid") or self.user_params.get("wifi_network_ssid_2g") |
Betty Zhou | 061ae08 | 2016-12-01 15:26:24 -0800 | [diff] [blame] | 64 | self.wifi_network_pass = self.user_params.get( |
Betty Zhou | 158c333 | 2017-06-02 17:08:09 -0700 | [diff] [blame] | 65 | "wifi_network_pass") or self.user_params.get("wifi_network_pass_2g") |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 66 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 67 | """ Tests Begin """ |
Nathan Harold | b1487af | 2016-07-19 16:05:37 -0700 | [diff] [blame] | 68 | |
Betty Zhou | 158c333 | 2017-06-02 17:08:09 -0700 | [diff] [blame] | 69 | @test_tracker_info(uuid="8390a2eb-a744-4cda-bade-f94a2cc83f02") |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 70 | @TelephonyBaseTest.tel_test_wrap |
| 71 | def test_check_environment(self): |
| 72 | ad = self.android_devices[0] |
| 73 | # Check WiFi environment. |
| 74 | # 1. Connect to WiFi. |
| 75 | # 2. Check WiFi have Internet access. |
Betty Zhou | 061ae08 | 2016-12-01 15:26:24 -0800 | [diff] [blame] | 76 | toggle_airplane_mode(self.log, ad, False, strict_checking=False) |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 77 | try: |
| 78 | if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid, |
| 79 | self.wifi_network_pass): |
Betty Zhou | 5534e67 | 2017-03-07 13:47:10 -0800 | [diff] [blame] | 80 | abort_all_tests(ad.log, "WiFi connect fail") |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 81 | if (not wait_for_wifi_data_connection(self.log, ad, True) or |
| 82 | not verify_http_connection(self.log, ad)): |
Betty Zhou | 5534e67 | 2017-03-07 13:47:10 -0800 | [diff] [blame] | 83 | abort_all_tests(ad.log, "Data not available on WiFi") |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 84 | finally: |
Betty Zhou | f987b8f | 2017-03-09 16:34:00 -0800 | [diff] [blame] | 85 | wifi_toggle_state(self.log, ad, False) |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 86 | # TODO: add more environment check here. |
| 87 | return True |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 88 | |
Betty Zhou | 158c333 | 2017-06-02 17:08:09 -0700 | [diff] [blame] | 89 | @test_tracker_info(uuid="7bb23ac7-6b7b-4d5e-b8d6-9dd10032b9ad") |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 90 | @TelephonyBaseTest.tel_test_wrap |
| 91 | def test_pre_flight_check(self): |
Nathan Harold | b1487af | 2016-07-19 16:05:37 -0700 | [diff] [blame] | 92 | for ad in self.android_devices: |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 93 | #check for sim and service |
Betty Zhou | 7f45f55 | 2017-03-15 19:12:52 -0700 | [diff] [blame] | 94 | if not ensure_phone_subscription(self.log, ad): |
| 95 | abort_all_tests(ad.log, "Unable to find a valid subscription!") |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 96 | return True |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 97 | |
Betty Zhou | 158c333 | 2017-06-02 17:08:09 -0700 | [diff] [blame] | 98 | @test_tracker_info(uuid="1070b160-902b-43bf-92a0-92cc2d05bb13") |
Betty Zhou | ec8378f | 2016-12-21 17:28:48 -0800 | [diff] [blame] | 99 | @TelephonyBaseTest.tel_test_wrap |
| 100 | def test_check_crash(self): |
| 101 | for ad in self.android_devices: |
Betty Zhou | 71dd30f | 2017-06-26 18:00:52 -0700 | [diff] [blame^] | 102 | ad.crash_report_preflight = ad.check_crash_report( |
| 103 | self.test_id, None, True) |
Betty Zhou | 7f45f55 | 2017-03-15 19:12:52 -0700 | [diff] [blame] | 104 | if ad.crash_report_preflight: |
| 105 | msg = "Find crash reports %s before test starts" % ( |
| 106 | ad.crash_report_preflight) |
| 107 | ad.log.warn(msg) |
Betty Zhou | bf8f9d5 | 2016-12-30 09:46:51 -0800 | [diff] [blame] | 108 | return True |