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