Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 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 voice tests in telephony |
| 18 | """ |
Jaineel | 5eba0e9 | 2017-03-10 15:56:17 -0800 | [diff] [blame] | 19 | import time |
| 20 | |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 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 CBCHSetup |
| 24 | from acts.controllers.anritsu_lib.md8475a import CTCHSetup |
| 25 | from acts.test_utils.tel.anritsu_utils import ETWS_WARNING_EARTHQUAKETSUNAMI |
| 26 | from acts.test_utils.tel.anritsu_utils import ETWS_WARNING_OTHER_EMERGENCY |
| 27 | from acts.test_utils.tel.anritsu_utils import cb_serial_number |
| 28 | from acts.test_utils.tel.anritsu_utils import etws_receive_verify_message_lte_wcdma |
| 29 | from acts.test_utils.tel.anritsu_utils import set_system_model_gsm |
| 30 | from acts.test_utils.tel.anritsu_utils import set_system_model_lte |
| 31 | from acts.test_utils.tel.anritsu_utils import set_system_model_wcdma |
Patrick Chiang | 8324da7 | 2017-04-07 17:02:17 -0700 | [diff] [blame^] | 32 | from acts.test_utils.tel.anritsu_utils import set_usim_parameters |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 33 | from acts.test_utils.tel.tel_defines import NETWORK_MODE_CDMA |
| 34 | from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_ONLY |
| 35 | from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_UMTS |
| 36 | from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_GSM_WCDMA |
| 37 | from acts.test_utils.tel.tel_defines import RAT_1XRTT |
| 38 | from acts.test_utils.tel.tel_defines import RAT_GSM |
| 39 | from acts.test_utils.tel.tel_defines import RAT_LTE |
| 40 | from acts.test_utils.tel.tel_defines import RAT_WCDMA |
| 41 | from acts.test_utils.tel.tel_defines import RAT_FAMILY_CDMA2000 |
| 42 | from acts.test_utils.tel.tel_defines import RAT_FAMILY_GSM |
| 43 | from acts.test_utils.tel.tel_defines import RAT_FAMILY_LTE |
| 44 | from acts.test_utils.tel.tel_defines import RAT_FAMILY_UMTS |
| 45 | from acts.test_utils.tel.tel_test_utils import ensure_network_rat |
| 46 | from acts.test_utils.tel.tel_test_utils import ensure_phones_idle |
| 47 | from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode |
| 48 | from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest |
| 49 | |
Jaineel | 5eba0e9 | 2017-03-10 15:56:17 -0800 | [diff] [blame] | 50 | WAIT_TIME_BETWEEN_REG_AND_MSG = 15 # default 15 sec |
| 51 | |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 52 | |
| 53 | class TelLabEtwsTest(TelephonyBaseTest): |
| 54 | SERIAL_NO = cb_serial_number() |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 55 | |
| 56 | def __init__(self, controllers): |
| 57 | TelephonyBaseTest.__init__(self, controllers) |
| 58 | self.ad = self.android_devices[0] |
Patrick Chiang | 8324da7 | 2017-04-07 17:02:17 -0700 | [diff] [blame^] | 59 | self.ad.sim_card = getattr(self.ad, "sim_card", None) |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 60 | self.md8475a_ip_address = self.user_params[ |
| 61 | "anritsu_md8475a_ip_address"] |
Patrick Chiang | 2f7d8f9 | 2017-03-17 15:42:28 -0700 | [diff] [blame] | 62 | self.wlan_option = self.user_params.get("anritsu_wlan_option", False) |
Betty Zhou | b499fe1 | 2017-03-01 19:38:42 -0800 | [diff] [blame] | 63 | self.ad.adb.shell("settings put secure cmas_additional_broadcast_pkg " |
| 64 | "com.googlecode.android_scripting") |
Jaineel | 5eba0e9 | 2017-03-10 15:56:17 -0800 | [diff] [blame] | 65 | self.wait_time_between_reg_and_msg = self.user_params.get( |
| 66 | "wait_time_between_reg_and_msg", WAIT_TIME_BETWEEN_REG_AND_MSG) |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 67 | |
| 68 | def setup_class(self): |
| 69 | try: |
Patrick Chiang | 2f7d8f9 | 2017-03-17 15:42:28 -0700 | [diff] [blame] | 70 | self.anritsu = MD8475A(self.md8475a_ip_address, self.log, |
| 71 | self.wlan_option) |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 72 | except AnritsuError: |
| 73 | self.log.error("Error in connecting to Anritsu Simulator") |
| 74 | return False |
| 75 | return True |
| 76 | |
| 77 | def setup_test(self): |
| 78 | ensure_phones_idle(self.log, self.android_devices) |
| 79 | toggle_airplane_mode(self.log, self.ad, True) |
| 80 | return True |
| 81 | |
| 82 | def teardown_test(self): |
| 83 | self.log.info("Stopping Simulation") |
| 84 | self.anritsu.stop_simulation() |
| 85 | toggle_airplane_mode(self.log, self.ad, True) |
| 86 | |
| 87 | def teardown_class(self): |
| 88 | self.anritsu.disconnect() |
| 89 | return True |
| 90 | |
| 91 | def _send_receive_etws_message(self, set_simulation_func, rat, message_id, |
| 92 | warning_message): |
| 93 | try: |
Patrick Chiang | 8324da7 | 2017-04-07 17:02:17 -0700 | [diff] [blame^] | 94 | [self.bts1] = set_simulation_func(self.anritsu, self.user_params, |
| 95 | self.ad.sim_card) |
| 96 | set_usim_parameters(self.anritsu, self.ad.sim_card) |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 97 | self.anritsu.start_simulation() |
| 98 | |
| 99 | if rat == RAT_LTE: |
| 100 | preferred_network_setting = NETWORK_MODE_LTE_GSM_WCDMA |
| 101 | rat_family = RAT_FAMILY_LTE |
| 102 | elif rat == RAT_WCDMA: |
| 103 | self.bts1.wcdma_ctch = CTCHSetup.CTCH_ENABLE |
| 104 | self.ad.droid.telephonyToggleDataConnection(False) |
| 105 | preferred_network_setting = NETWORK_MODE_GSM_UMTS |
| 106 | rat_family = RAT_FAMILY_UMTS |
| 107 | elif rat == RAT_GSM: |
| 108 | self.bts1.gsm_cbch = CBCHSetup.CBCH_ENABLE |
| 109 | self.ad.droid.telephonyToggleDataConnection(False) |
| 110 | preferred_network_setting = NETWORK_MODE_GSM_ONLY |
| 111 | rat_family = RAT_FAMILY_GSM |
| 112 | elif rat == RAT_1XRTT: |
| 113 | preferred_network_setting = NETWORK_MODE_CDMA |
| 114 | rat_family = RAT_FAMILY_CDMA2000 |
| 115 | else: |
| 116 | self.log.error("No valid RAT provided for ETWS test.") |
| 117 | return False |
| 118 | |
Betty Zhou | b499fe1 | 2017-03-01 19:38:42 -0800 | [diff] [blame] | 119 | if not ensure_network_rat( |
| 120 | self.log, |
| 121 | self.ad, |
| 122 | preferred_network_setting, |
| 123 | rat_family, |
| 124 | toggle_apm_after_setting=True): |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 125 | self.log.error( |
| 126 | "Failed to set rat family {}, preferred network:{}".format( |
| 127 | rat_family, preferred_network_setting)) |
| 128 | return False |
| 129 | |
| 130 | self.anritsu.wait_for_registration_state() |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 131 | if not etws_receive_verify_message_lte_wcdma( |
| 132 | self.log, self.ad, self.anritsu, |
| 133 | next(TelLabEtwsTest.SERIAL_NO), message_id, |
| 134 | warning_message): |
| 135 | self.log.error("Phone {} Failed to receive ETWS message" |
| 136 | .format(self.ad.serial)) |
| 137 | return False |
| 138 | except AnritsuError as e: |
| 139 | self.log.error("Error in connection with Anritsu Simulator: " + |
| 140 | str(e)) |
| 141 | return False |
| 142 | except Exception as e: |
| 143 | self.log.error("Exception during ETWS send/receive: " + str(e)) |
| 144 | return False |
| 145 | return True |
| 146 | |
| 147 | """ Tests Begin """ |
| 148 | |
| 149 | @TelephonyBaseTest.tel_test_wrap |
| 150 | def test_etws_earthquake_tsunami_lte(self): |
| 151 | """ETWS Earthquake and Tsunami warning message reception on LTE |
| 152 | |
| 153 | Tests the capability of device to receive and inform the user |
| 154 | about the ETWS Earthquake and Tsunami warning message when camped on |
| 155 | LTE newtork |
| 156 | |
| 157 | Steps: |
| 158 | 1. Make Sure Phone is camped on LTE network |
| 159 | 2. Send ETWS Earthquake and Tsunami warning message from Anritsu |
| 160 | |
| 161 | Expected Result: |
| 162 | Phone receives ETWS Earthquake and Tsunami warning message |
| 163 | |
| 164 | Returns: |
| 165 | True if pass; False if fail |
| 166 | """ |
| 167 | return self._send_receive_etws_message(set_system_model_lte, RAT_LTE, |
| 168 | ETWS_WARNING_EARTHQUAKETSUNAMI, |
| 169 | "LTE Earthquake and Tsunami") |
| 170 | |
| 171 | @TelephonyBaseTest.tel_test_wrap |
| 172 | def test_etws_other_emergency_lte(self): |
| 173 | """ETWS Other emergency warning message reception on LTE |
| 174 | |
| 175 | Tests the capability of device to receive and inform the user |
| 176 | about the ETWS Other emergency warning message when camped on |
| 177 | LTE newtork |
| 178 | |
| 179 | Steps: |
| 180 | 1. Make Sure Phone is camped on LTE network |
| 181 | 2. Send ETWS Earthquake and Tsunami warning message from Anritsu |
| 182 | |
| 183 | Expected Result: |
| 184 | Phone receives ETWS Earthquake and Tsunami warning message |
| 185 | |
| 186 | Returns: |
| 187 | True if pass; False if fail |
| 188 | """ |
| 189 | return self._send_receive_etws_message(set_system_model_lte, RAT_LTE, |
| 190 | ETWS_WARNING_OTHER_EMERGENCY, |
| 191 | "LTE ETWS Other Emergency") |
| 192 | |
| 193 | @TelephonyBaseTest.tel_test_wrap |
| 194 | def test_etws_earthquake_tsunami_wcdma(self): |
| 195 | """ETWS Earthquake and Tsunami warning message reception on WCDMA |
| 196 | |
| 197 | Tests the capability of device to receive and inform the user |
| 198 | about the ETWS Earthquake and Tsunami warning message when camped on |
| 199 | WCDMA newtork |
| 200 | |
| 201 | Steps: |
| 202 | 1. Make Sure Phone is camped on WCDMA network |
| 203 | 2. Send ETWS Earthquake and Tsunami warning message from Anritsu |
| 204 | |
| 205 | Expected Result: |
| 206 | Phone receives ETWS Earthquake and Tsunami warning message |
| 207 | |
| 208 | Returns: |
| 209 | True if pass; False if fail |
| 210 | """ |
| 211 | return self._send_receive_etws_message( |
| 212 | set_system_model_wcdma, RAT_WCDMA, ETWS_WARNING_EARTHQUAKETSUNAMI, |
| 213 | "WCDMA Earthquake and Tsunami") |
| 214 | |
| 215 | @TelephonyBaseTest.tel_test_wrap |
| 216 | def test_etws_other_emergency_wcdma(self): |
| 217 | """ETWS Other emergency warning message reception on WCDMA |
| 218 | |
| 219 | Tests the capability of device to receive and inform the user |
| 220 | about the ETWS Other emergency warning message when camped on |
| 221 | WCDMA newtork |
| 222 | |
| 223 | Steps: |
| 224 | 1. Make Sure Phone is camped on WCDMA network |
| 225 | 2. Send ETWS Earthquake and Tsunami warning message from Anritsu |
| 226 | |
| 227 | Expected Result: |
| 228 | Phone receives ETWS Earthquake and Tsunami warning message |
| 229 | |
| 230 | Returns: |
| 231 | True if pass; False if fail |
| 232 | """ |
| 233 | return self._send_receive_etws_message( |
| 234 | set_system_model_wcdma, RAT_WCDMA, ETWS_WARNING_OTHER_EMERGENCY, |
| 235 | "WCDMA ETWS Other Emergency") |
| 236 | |
| 237 | @TelephonyBaseTest.tel_test_wrap |
| 238 | def test_etws_earthquake_tsunami_gsm(self): |
| 239 | """ETWS Earthquake and Tsunami warning message reception on GSM |
| 240 | |
| 241 | Tests the capability of device to receive and inform the user |
| 242 | about the ETWS Earthquake and Tsunami warning message when camped on |
| 243 | GSM newtork |
| 244 | |
| 245 | Steps: |
| 246 | 1. Make Sure Phone is camped on GSM network |
| 247 | 2. Send ETWS Earthquake and Tsunami warning message from Anritsu |
| 248 | |
| 249 | Expected Result: |
| 250 | Phone receives ETWS Earthquake and Tsunami warning message |
| 251 | |
| 252 | Returns: |
| 253 | True if pass; False if fail |
| 254 | """ |
| 255 | return self._send_receive_etws_message(set_system_model_gsm, RAT_GSM, |
| 256 | ETWS_WARNING_EARTHQUAKETSUNAMI, |
| 257 | "GSM Earthquake and Tsunami") |
| 258 | |
| 259 | @TelephonyBaseTest.tel_test_wrap |
| 260 | def test_etws_other_emergency_gsm(self): |
| 261 | """ETWS Other emergency warning message reception on GSM |
| 262 | |
| 263 | Tests the capability of device to receive and inform the user |
| 264 | about the ETWS Other emergency warning message when camped on |
| 265 | GSM newtork |
| 266 | |
| 267 | Steps: |
| 268 | 1. Make Sure Phone is camped on GSM network |
| 269 | 2. Send ETWS Earthquake and Tsunami warning message from Anritsu |
| 270 | |
| 271 | Expected Result: |
| 272 | Phone receives ETWS Earthquake and Tsunami warning message |
| 273 | |
| 274 | Returns: |
| 275 | True if pass; False if fail |
| 276 | """ |
| 277 | return self._send_receive_etws_message(set_system_model_gsm, RAT_GSM, |
| 278 | ETWS_WARNING_OTHER_EMERGENCY, |
| 279 | "GSM ETWS Other Emergency") |
| 280 | |
| 281 | """ Tests End """ |