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 |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 38 | from acts.test_utils.tel.tel_test_utils import WifiUtils |
Betty Zhou | 5534e67 | 2017-03-07 13:47:10 -0800 | [diff] [blame^] | 39 | from acts.test_utils.tel.tel_test_utils import abort_all_tests |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 40 | from acts.test_utils.tel.tel_test_utils import ensure_phones_default_state |
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 |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 50 | from acts.test_utils.tel.tel_voice_utils import phone_setup_volte |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 51 | from acts.asserts import abort_all |
Betty Zhou | ec8378f | 2016-12-21 17:28:48 -0800 | [diff] [blame] | 52 | from acts.asserts import fail |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 53 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 54 | |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 55 | class TelLivePreflightTest(TelephonyBaseTest): |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 56 | def __init__(self, controllers): |
| 57 | TelephonyBaseTest.__init__(self, controllers) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 58 | |
Betty Zhou | 061ae08 | 2016-12-01 15:26:24 -0800 | [diff] [blame] | 59 | self.wifi_network_ssid = self.user_params.get( |
Betty Zhou | 5534e67 | 2017-03-07 13:47:10 -0800 | [diff] [blame^] | 60 | "wifi_network_ssid") or self.user_params.get( |
| 61 | "wifi_network_ssid_2g") |
Betty Zhou | 061ae08 | 2016-12-01 15:26:24 -0800 | [diff] [blame] | 62 | self.wifi_network_pass = self.user_params.get( |
Betty Zhou | 5534e67 | 2017-03-07 13:47:10 -0800 | [diff] [blame^] | 63 | "wifi_network_pass") or self.user_params.get( |
| 64 | "wifi_network_pass_2g") |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 65 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 66 | """ Tests Begin """ |
Nathan Harold | b1487af | 2016-07-19 16:05:37 -0700 | [diff] [blame] | 67 | |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 68 | @TelephonyBaseTest.tel_test_wrap |
| 69 | def test_check_environment(self): |
| 70 | ad = self.android_devices[0] |
| 71 | # Check WiFi environment. |
| 72 | # 1. Connect to WiFi. |
| 73 | # 2. Check WiFi have Internet access. |
Betty Zhou | 061ae08 | 2016-12-01 15:26:24 -0800 | [diff] [blame] | 74 | toggle_airplane_mode(self.log, ad, False, strict_checking=False) |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 75 | try: |
| 76 | if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid, |
| 77 | self.wifi_network_pass): |
Betty Zhou | 5534e67 | 2017-03-07 13:47:10 -0800 | [diff] [blame^] | 78 | abort_all_tests(ad.log, "WiFi connect fail") |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 79 | if (not wait_for_wifi_data_connection(self.log, ad, True) or |
| 80 | not verify_http_connection(self.log, ad)): |
Betty Zhou | 5534e67 | 2017-03-07 13:47:10 -0800 | [diff] [blame^] | 81 | abort_all_tests(ad.log, "Data not available on WiFi") |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 82 | finally: |
| 83 | WifiUtils.wifi_toggle_state(self.log, ad, False) |
| 84 | # TODO: add more environment check here. |
| 85 | return True |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 86 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 87 | @TelephonyBaseTest.tel_test_wrap |
| 88 | def test_pre_flight_check(self): |
Nathan Harold | b1487af | 2016-07-19 16:05:37 -0700 | [diff] [blame] | 89 | for ad in self.android_devices: |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 90 | #check for sim and service |
| 91 | subInfo = ad.droid.subscriptionGetAllSubInfoList() |
| 92 | if not subInfo or len(subInfo) < 1: |
Betty Zhou | 5534e67 | 2017-03-07 13:47:10 -0800 | [diff] [blame^] | 93 | abort_all_tests(ad.log, "Unable to find A valid subscription!") |
Nathan Harold | 05a6c27 | 2016-10-17 13:55:53 -0700 | [diff] [blame] | 94 | if ad.droid.subscriptionGetDefaultDataSubId() <= INVALID_SUB_ID: |
Betty Zhou | 5534e67 | 2017-03-07 13:47:10 -0800 | [diff] [blame^] | 95 | abort_all_tests(ad.log, "No Default Data Sub ID") |
Nathan Harold | 05a6c27 | 2016-10-17 13:55:53 -0700 | [diff] [blame] | 96 | elif ad.droid.subscriptionGetDefaultVoiceSubId() <= INVALID_SUB_ID: |
Betty Zhou | 5534e67 | 2017-03-07 13:47:10 -0800 | [diff] [blame^] | 97 | abort_all_tests(ad.log, "No Valid Voice Sub ID") |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 98 | sub_id = ad.droid.subscriptionGetDefaultVoiceSubId() |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 99 | if not wait_for_voice_attach_for_subscription( |
Nathan Harold | b1487af | 2016-07-19 16:05:37 -0700 | [diff] [blame] | 100 | self.log, ad, sub_id, MAX_WAIT_TIME_NW_SELECTION): |
Betty Zhou | 5534e67 | 2017-03-07 13:47:10 -0800 | [diff] [blame^] | 101 | abort_all_tests(ad.log, "Did Not Attach For Voice Services") |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 102 | return True |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 103 | |
Betty Zhou | ec8378f | 2016-12-21 17:28:48 -0800 | [diff] [blame] | 104 | @TelephonyBaseTest.tel_test_wrap |
| 105 | def test_check_crash(self): |
| 106 | for ad in self.android_devices: |
| 107 | ad.crash_report = ad.check_crash_report() |
| 108 | if ad.crash_report: |
| 109 | msg = "Find crash reports %s" % (ad.crash_report) |
| 110 | ad.log.error(msg) |
| 111 | fail(msg) |
Betty Zhou | bf8f9d5 | 2016-12-30 09:46:51 -0800 | [diff] [blame] | 112 | return True |