Home | History | Annotate | Download | only in live
      1 #!/usr/bin/env python3.4
      2 #
      3 #   Copyright 2016 - Google
      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
     21 from queue import Empty
     22 from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
     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
     30 from acts.test_utils.tel.tel_defines import INVALID_SUB_ID
     31 from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_NW_SELECTION
     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
     36 from acts.test_utils.tel.tel_lookup_tables import device_capabilities
     37 from acts.test_utils.tel.tel_lookup_tables import operator_capabilities
     38 from acts.test_utils.tel.tel_test_utils import abort_all_tests
     39 from acts.test_utils.tel.tel_test_utils import ensure_phones_default_state
     40 from acts.test_utils.tel.tel_test_utils import ensure_phone_subscription
     41 from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected
     42 from acts.test_utils.tel.tel_test_utils import get_operator_name
     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
     47 from acts.test_utils.tel.tel_test_utils import verify_http_connection
     48 from acts.test_utils.tel.tel_test_utils import wait_for_voice_attach_for_subscription
     49 from acts.test_utils.tel.tel_test_utils import wait_for_wifi_data_connection
     50 from acts.test_utils.tel.tel_test_utils import wifi_toggle_state
     51 from acts.test_utils.tel.tel_voice_utils import phone_setup_volte
     52 from acts.asserts import abort_all
     53 from acts.asserts import fail
     54 
     55 
     56 class TelLivePreflightTest(TelephonyBaseTest):
     57     def __init__(self, controllers):
     58         TelephonyBaseTest.__init__(self, controllers)
     59 
     60         self.wifi_network_ssid = self.user_params.get(
     61             "wifi_network_ssid") or self.user_params.get(
     62                 "wifi_network_ssid_2g")
     63         self.wifi_network_pass = self.user_params.get(
     64             "wifi_network_pass") or self.user_params.get(
     65                 "wifi_network_pass_2g")
     66 
     67     """ Tests Begin """
     68 
     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.
     75         toggle_airplane_mode(self.log, ad, False, strict_checking=False)
     76         try:
     77             if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid,
     78                                          self.wifi_network_pass):
     79                 abort_all_tests(ad.log, "WiFi connect fail")
     80             if (not wait_for_wifi_data_connection(self.log, ad, True) or
     81                     not verify_http_connection(self.log, ad)):
     82                 abort_all_tests(ad.log, "Data not available on WiFi")
     83         finally:
     84             wifi_toggle_state(self.log, ad, False)
     85         # TODO: add more environment check here.
     86         return True
     87 
     88     @TelephonyBaseTest.tel_test_wrap
     89     def test_pre_flight_check(self):
     90         for ad in self.android_devices:
     91             #check for sim and service
     92             if not ensure_phone_subscription(self.log, ad):
     93                 abort_all_tests(ad.log, "Unable to find a valid subscription!")
     94         return True
     95 
     96     @TelephonyBaseTest.tel_test_wrap
     97     def test_check_crash(self):
     98         for ad in self.android_devices:
     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)
    104         return True
    105