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