Home | History | Annotate | Download | only in lab
      1 #/usr/bin/env python3.4
      2 #
      3 #   Copyright 2017 - 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 voice tests in telephony
     18 """
     19 import time
     20 
     21 from acts.controllers.anritsu_lib._anritsu_utils import AnritsuError
     22 from acts.controllers.anritsu_lib.md8475a import MD8475A
     23 from acts.controllers.anritsu_lib.md8475a import BtsServiceState
     24 from acts.controllers.anritsu_lib.md8475a import BtsPacketRate
     25 from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
     26 from acts.test_utils.tel.anritsu_utils import set_system_model_lte_wcdma
     27 from acts.test_utils.tel.anritsu_utils import set_usim_parameters
     28 from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_GSM_WCDMA
     29 from acts.test_utils.tel.tel_defines import RAT_FAMILY_LTE
     30 from acts.test_utils.tel.tel_test_utils import ensure_network_rat
     31 from acts.test_utils.tel.tel_test_utils import ensure_phones_idle
     32 from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode
     33 from acts.test_utils.tel.tel_test_utils import toggle_cell_data_roaming
     34 from acts.utils import adb_shell_ping
     35 
     36 PING_DURATION = 5  # Number of packets to ping
     37 PING_TARGET = "192.168.1.2"  # Set to Eth0 IP address of MD8475A
     38 TIME_TO_WAIT_BEFORE_PING = 10  # Time(sec) to wait before ping
     39 
     40 
     41 class TelLabDataRoamingTest(TelephonyBaseTest):
     42     def __init__(self, controllers):
     43         TelephonyBaseTest.__init__(self, controllers)
     44         self.ad = self.android_devices[0]
     45         self.ad.sim_card = getattr(self.ad, "sim_card", None)
     46         self.md8475a_ip_address = self.user_params[
     47             "anritsu_md8475a_ip_address"]
     48         self.wlan_option = self.user_params.get("anritsu_wlan_option", False)
     49 
     50     def setup_class(self):
     51         try:
     52             self.anritsu = MD8475A(self.md8475a_ip_address, self.log,
     53                                    self.wlan_option)
     54         except AnritsuError:
     55             self.log.error("Error in connecting to Anritsu Simulator")
     56             return False
     57         return True
     58 
     59     def setup_test(self):
     60         ensure_phones_idle(self.log, self.android_devices)
     61         toggle_airplane_mode(self.log, self.ad, True)
     62         self.ad.adb.shell("setprop net.lte.ims.volte.provisioned 1",
     63                           ignore_status=True)
     64         return True
     65 
     66     def teardown_test(self):
     67         self.log.info("Stopping Simulation")
     68         self.anritsu.stop_simulation()
     69         toggle_airplane_mode(self.log, self.ad, True)
     70         return True
     71 
     72     def teardown_class(self):
     73         self.anritsu.disconnect()
     74         return True
     75 
     76     def LTE_WCDMA_data_roaming(self, mcc, mnc):
     77         try:
     78             [self.bts1, self.bts2] = set_system_model_lte_wcdma(
     79                 self.anritsu, self.user_params, self.ad.sim_card)
     80             set_usim_parameters(self.anritsu, self.ad.sim_card)
     81             self.bts1.mcc = mcc
     82             self.bts1.mnc = mnc
     83             self.bts2.mcc = mcc
     84             self.bts2.mnc = mnc
     85             self.bts2.packet_rate = BtsPacketRate.WCDMA_DLHSAUTO_REL7_ULHSAUTO
     86             self.anritsu.start_simulation()
     87             self.bts2.service_state = BtsServiceState.SERVICE_STATE_OUT
     88             self.log.info("Toggle Mobile Data On")
     89             self.ad.droid.telephonyToggleDataConnection(True)
     90             if not ensure_network_rat(
     91                     self.log,
     92                     self.ad,
     93                     NETWORK_MODE_LTE_GSM_WCDMA,
     94                     RAT_FAMILY_LTE,
     95                     toggle_apm_after_setting=True):
     96                 self.log.error(
     97                     "Failed to set rat family {}, preferred network:{}".format(
     98                         RAT_FAMILY_LTE, NETWORK_MODE_LTE_GSM_WCDMA))
     99                 return False
    100             toggle_cell_data_roaming(self.ad, True)
    101             self.anritsu.wait_for_registration_state(1)  # for BTS1 LTE
    102 
    103             time.sleep(TIME_TO_WAIT_BEFORE_PING)
    104             if not adb_shell_ping(self.ad, PING_DURATION, PING_TARGET):
    105                 self.log.error(
    106                     "Test Fail: Phone {} can not ping {} with Data Roaming On"
    107                     .format(self.ad.serial, PING_TARGET))
    108                 return False
    109             toggle_cell_data_roaming(self.ad, False)
    110             time.sleep(TIME_TO_WAIT_BEFORE_PING)
    111             if adb_shell_ping(self.ad, PING_DURATION, PING_TARGET):
    112                 self.log.error(
    113                     "Test Fail: Phone {} can ping {} with Data Roaming Off"
    114                     .format(self.ad.serial, PING_TARGET))
    115                 return False
    116 
    117             toggle_airplane_mode(self.log, self.ad, True)
    118             time.sleep(2)
    119             self.bts2.service_state = BtsServiceState.SERVICE_STATE_IN
    120             self.bts1.service_state = BtsServiceState.SERVICE_STATE_OUT
    121 
    122             toggle_airplane_mode(self.log, self.ad, False)
    123             toggle_cell_data_roaming(self.ad, True)
    124             self.anritsu.wait_for_registration_state(2)  # for BTS2 WCDMA
    125 
    126             time.sleep(TIME_TO_WAIT_BEFORE_PING)
    127             if not adb_shell_ping(self.ad, PING_DURATION, PING_TARGET):
    128                 self.log.error(
    129                     "Test Fail: Phone {} can not ping {} with Data Roaming On"
    130                     .format(self.ad.serial, PING_TARGET))
    131                 return False
    132             toggle_cell_data_roaming(self.ad, False)
    133             time.sleep(TIME_TO_WAIT_BEFORE_PING)
    134             if adb_shell_ping(self.ad, PING_DURATION, PING_TARGET):
    135                 self.log.error(
    136                     "Test Fail: Phone {} can ping {} with Data Roaming Off"
    137                     .format(self.ad.serial, PING_TARGET))
    138                 return False
    139 
    140         except AnritsuError as e:
    141             self.log.error("Error in connection with Anritsu Simulator: " +
    142                            str(e))
    143             return False
    144         except Exception as e:
    145             self.log.error("Exception during data roaming: " + str(e))
    146             return False
    147         return True
    148 
    149     """ Tests Begin """
    150 
    151     @TelephonyBaseTest.tel_test_wrap
    152     def test_data_roaming_optus(self):
    153         """Data roaming test for Optus LTE and WCDMA networks
    154 
    155         Tests if data roaming enabled/disabled work correctly with
    156         Optus(Australia) LTE and WCDMA networks
    157 
    158         Steps:
    159         1. Setup Optus LTE network and make sure UE registers
    160         2. Turn on data roaming, and check if Ping succeeds
    161         3. Turn off data roaming, and check if Ping fails
    162         4. Turn Airplane Mode On in UE
    163         5. Setup Optus WCDMA network and make sure UE registers
    164         6. Turn on data roaming, and check if Ping succeeds
    165         7. Turn off data roaming, and check if Ping fails
    166 
    167         Expected Result:
    168         Ping succeeds when data roaming is turned on,
    169         and Ping fails when data roaming is turned off
    170 
    171         Returns:
    172             True if pass; False if fail
    173         """
    174         return self.LTE_WCDMA_data_roaming("505", "90F")
    175 
    176     @TelephonyBaseTest.tel_test_wrap
    177     def test_data_roaming_telus(self):
    178         """Data roaming test for Telus LTE and WCDMA networks
    179 
    180         Tests if data roaming enabled/disabled work correctly with
    181         Telus(Canada) LTE and WCDMA networks
    182 
    183         Steps:
    184         1. Setup Telus LTE network and make sure UE registers
    185         2. Turn on data roaming, and check if Ping succeeds
    186         3. Turn off data roaming, and check if Ping fails
    187         4. Turn Airplane Mode On in UE
    188         5. Setup Telus WCDMA network and make sure UE registers
    189         6. Turn on data roaming, and check if Ping succeeds
    190         7. Turn off data roaming, and check if Ping fails
    191 
    192         Expected Result:
    193         Ping succeeds when data roaming is turned on,
    194         and Ping fails when data roaming is turned off
    195 
    196         Returns:
    197             True if pass; False if fail
    198         """
    199         return self.LTE_WCDMA_data_roaming("302", "86F")
    200 
    201     @TelephonyBaseTest.tel_test_wrap
    202     def test_data_roaming_vodafone(self):
    203         """Data roaming test for Vodafone LTE and WCDMA networks
    204 
    205         Tests if data roaming enabled/disabled work correctly with
    206         Vodafone(UK) LTE and WCDMA networks
    207 
    208         Steps:
    209         1. Setup Vodafone LTE network and make sure UE registers
    210         2. Turn on data roaming, and check if Ping succeeds
    211         3. Turn off data roaming, and check if Ping fails
    212         4. Turn Airplane Mode On in UE
    213         5. Setup Vodafone WCDMA network and make sure UE registers
    214         6. Turn on data roaming, and check if Ping succeeds
    215         7. Turn off data roaming, and check if Ping fails
    216 
    217         Expected Result:
    218         Ping succeeds when data roaming is turned on,
    219         and Ping fails when data roaming is turned off
    220 
    221         Returns:
    222             True if pass; False if fail
    223         """
    224         return self.LTE_WCDMA_data_roaming("234", "15F")
    225 
    226     @TelephonyBaseTest.tel_test_wrap
    227     def test_data_roaming_o2(self):
    228         """Data roaming test for O2 LTE and WCDMA networks
    229 
    230         Tests if data roaming enabled/disabled work correctly with
    231         O2(UK) LTE and WCDMA networks
    232 
    233         Steps:
    234         1. Setup O2 LTE network and make sure UE registers
    235         2. Turn on data roaming, and check if Ping succeeds
    236         3. Turn off data roaming, and check if Ping fails
    237         4. Turn Airplane Mode On in UE
    238         5. Setup O2 WCDMA network and make sure UE registers
    239         6. Turn on data roaming, and check if Ping succeeds
    240         7. Turn off data roaming, and check if Ping fails
    241 
    242         Expected Result:
    243         Ping succeeds when data roaming is turned on,
    244         and Ping fails when data roaming is turned off
    245 
    246         Returns:
    247             True if pass; False if fail
    248         """
    249         return self.LTE_WCDMA_data_roaming("234", "02F")
    250 
    251     @TelephonyBaseTest.tel_test_wrap
    252     def test_data_roaming_orange(self):
    253         """Data roaming test for Orange LTE and WCDMA networks
    254 
    255         Tests if data roaming enabled/disabled work correctly with
    256         Orange(UK) LTE and WCDMA networks
    257 
    258         Steps:
    259         1. Setup Orange LTE network and make sure UE registers
    260         2. Turn on data roaming, and check if Ping succeeds
    261         3. Turn off data roaming, and check if Ping fails
    262         4. Turn Airplane Mode On in UE
    263         5. Setup Orange WCDMA network and make sure UE registers
    264         6. Turn on data roaming, and check if Ping succeeds
    265         7. Turn off data roaming, and check if Ping fails
    266 
    267         Expected Result:
    268         Ping succeeds when data roaming is turned on,
    269         and Ping fails when data roaming is turned off
    270 
    271         Returns:
    272             True if pass; False if fail
    273         """
    274         return self.LTE_WCDMA_data_roaming("234", "33F")
    275 
    276     @TelephonyBaseTest.tel_test_wrap
    277     def test_data_roaming_idea(self):
    278         """Data roaming test for Idea LTE and WCDMA networks
    279 
    280         Tests if data roaming enabled/disabled work correctly with
    281         Idea(India) LTE and WCDMA networks
    282 
    283         Steps:
    284         1. Setup Idea LTE network and make sure UE registers
    285         2. Turn on data roaming, and check if Ping succeeds
    286         3. Turn off data roaming, and check if Ping fails
    287         4. Turn Airplane Mode On in UE
    288         5. Setup Idea WCDMA network and make sure UE registers
    289         6. Turn on data roaming, and check if Ping succeeds
    290         7. Turn off data roaming, and check if Ping fails
    291 
    292         Expected Result:
    293         Ping succeeds when data roaming is turned on,
    294         and Ping fails when data roaming is turned off
    295 
    296         Returns:
    297             True if pass; False if fail
    298         """
    299         return self.LTE_WCDMA_data_roaming("404", "24F")
    300 
    301     """ Tests End """
    302