Home | History | Annotate | Download | only in live
      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 """
     17 Sanity tests for connectivity tests in telephony
     18 """
     19 
     20 import time
     21 from queue import Empty
     22 
     23 from acts.controllers.anritsu_lib.md8475a import BtsNumber
     24 from acts.controllers.anritsu_lib.md8475a import BtsTechnology
     25 from acts.controllers.anritsu_lib.md8475a import MD8475A
     26 from acts.test_utils.tel import tel_test_utils
     27 from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
     28 
     29 
     30 class TelephonyDataSanityTest(TelephonyBaseTest):
     31     def __init__(self, controllers):
     32         TelephonyBaseTest.__init__(self, controllers)
     33         self.anritsu = MD8475A(tel_test_utils.MD8475A_IP_ADDRESS)
     34 
     35     def setup_test(self):
     36         self.lte_bts, self.wcdma_bts = tel_test_utils.set_system_model(
     37             self.anritsu, "LTE_WCDMA")
     38         tel_test_utils.init_phone(self.droid, self.ed)
     39         self.droid.telephonyStartTrackingServiceStateChange()
     40         self.droid.telephonyStartTrackingDataConnectionStateChange()
     41         self.log.info("Starting Simulation")
     42         self.anritsu.start_simulation()
     43         return True
     44 
     45     def teardown_test(self):
     46         self.droid.telephonyStopTrackingServiceStateChange()
     47         self.droid.telephonyStopTrackingDataConnectionStateChange()
     48         self.log.info("Stopping Simulation")
     49         self.anritsu.stop_simulation()
     50         # turn off modem
     51         tel_test_utils.turn_off_modem(self.droid)
     52 
     53     def teardown_class(self):
     54         self.anritsu.disconnect()
     55 
     56     def _wait_for_bts_state(self, btsnumber, state, timeout=30):
     57         ''' Wait till BTS state changes. state value are "IN" and "OUT" '''
     58         sleep_interval = 2
     59         status = "failed"
     60 
     61         wait_time = timeout
     62         while (wait_time > 0):
     63             if state == btsnumber.service_state:
     64                 print(btsnumber.service_state)
     65                 status = "passed"
     66                 break
     67             else:
     68                 time.sleep(sleep_interval)
     69                 waiting_time = waiting_time - sleep_interval
     70 
     71         if status == "failed":
     72             self.log.info("Timeout: Expected state is not received.")
     73 
     74     """ Tests Begin """
     75 
     76     @TelephonyBaseTest.tel_test_wrap
     77     def test_data_conn_state_when_access_enabled(self):
     78         '''
     79         Check data conenction state after boot up
     80 
     81         Steps
     82         -----
     83         1. Get the device is IN_SERVICE state
     84         2. check the data conenction status
     85         '''
     86         test_status = "failed"
     87         # turn on modem to start registration
     88         tel_test_utils.turn_on_modem(self.droid)
     89         self.log.info("Waiting for Network registration")
     90         test_status, event = tel_test_utils.wait_for_network_registration(
     91             self.ed, self.anritsu, self.log)
     92 
     93         # proceed with next step only if previous step is success
     94         if test_status == "passed":
     95             self.log.info("Waiting for data state: DATA_CONNECTED")
     96             test_status, event = tel_test_utils.wait_for_data_state(
     97                 self.ed, self.log, "DATA_CONNECTED", 120)
     98 
     99         if test_status == "passed":
    100             self.log.info("Data connection state(access enabled) "
    101                           "verification: Passed")
    102             return True
    103         else:
    104             self.log.info("Data connection state(access enabled) "
    105                           "verification: Failed")
    106             return False
    107 
    108     @TelephonyBaseTest.tel_test_wrap
    109     def test_data_conn_state_when_access_disabled(self):
    110         '''
    111         Check data conenction state after disabling data access
    112 
    113         Steps
    114         -----
    115         1. Get the device is IN_SERVICE state
    116         2. check the data conenction status ( data access enabled)
    117         3. disable the data access
    118         4. check the data conenction status ( data access enabled)
    119         '''
    120         test_status = "failed"
    121         # turn on modem to start registration
    122         tel_test_utils.turn_on_modem(self.droid)
    123         self.log.info("Waiting for Network registration")
    124         test_status, event = tel_test_utils.wait_for_network_registration(
    125             self.ed, self.anritsu, self.log)
    126 
    127         # proceed with next step only if previous step is success
    128         if test_status == "passed":
    129             self.log.info("Waiting for data state: DATA_CONNECTED")
    130             test_status, event = tel_test_utils.wait_for_data_state(
    131                 self.ed, self.log, "DATA_CONNECTED", 120)
    132 
    133         if test_status == "passed":
    134             time.sleep(20)
    135             self.log.info("Disabling data access")
    136             self.droid.telephonyToggleDataConnection(False)
    137             self.log.info("Waiting for data state: DATA_DISCONNECTED")
    138             test_status, event = tel_test_utils.wait_for_data_state(
    139                 self.ed, self.log, "DATA_DISCONNECTED", 120)
    140 
    141         if test_status == "passed":
    142             self.log.info("Data connection state(access disabled) "
    143                           "verification: Passed")
    144             return True
    145         else:
    146             self.log.info("Data connection state(access disabled) "
    147                           "verification: Failed")
    148             return False
    149 
    150     """ Tests End """
    151