def network_switch_test(self, carrier): tasks = [(self.operator_network_switch, [ad, carrier]) for ad in self.android_devices] if not multithread_func(self.log, tasks): abort_all_tests(self.log, "Unable to switch to network %s" % carrier) return True
def __init__(self, controllers): BaseTestClass.__init__(self, controllers) self.logger_sessions = [] for ad in self.android_devices: if getattr(ad, "qxdm_always_on", False): #this is only supported on 2017 devices ad.log.info("qxdm_always_on is set in config file") mask = getattr(ad, "qxdm_mask", "Radio-general.cfg") if not check_qxdm_logger_always_on(ad, mask): ad.log.info("qxdm always on is not set, turn it on") set_qxdm_logger_always_on(ad, mask) else: ad.log.info("qxdm always on is already set") #The puk and pin should be provided in testbed config file. #"AndroidDevice": [{"serial": "84B5T15A29018214", # "adb_logcat_param": "-b all", # "puk": "12345678", # "puk_pin": "1234"}] if hasattr(ad, 'puk'): if not hasattr(ad, 'puk_pin'): abort_all_tests(ad.log, "puk_pin is not provided") ad.log.info("Enter PUK code and pin") if not ad.droid.telephonySupplyPuk(ad.puk, ad.puk_pin): abort_all_tests( ad.log, "Puk and puk_pin provided in testbed config do NOT work" ) self.skip_reset_between_cases = self.user_params.get( "skip_reset_between_cases", True)
def setup_class(self): self.dut = self.android_devices[0] req_params = ['wifi_network', 'receiver_number', 'ping_count'] self.unpack_userparams(req_param_names=req_params) self.ssid_map = {} for network in self.wifi_network: SSID = network['SSID'].replace('-', '_') self.ssid_map[SSID] = network self.dut.droid.setMobileDataEnabled() if not tutils.verify_internet_connection( self.dut.log, self.dut, retries=3): tutils.abort_all_tests(self.dut.log, 'Internet connection Failed.')
def test_check_environment(self): ad = self.android_devices[0] # Check WiFi environment. # 1. Connect to WiFi. # 2. Check WiFi have Internet access. try: if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid, self.wifi_network_pass): abort_all_tests(ad.log, "WiFi connect fail") if (not wait_for_wifi_data_connection(self.log, ad, True) or not verify_internet_connection(self.log, ad)): abort_all_tests(ad.log, "Data not available on WiFi") finally: wifi_toggle_state(self.log, ad, False) # TODO: add more environment check here. return True
def test_project_fi_account_activation(self): """Test activate Fi account. Returns: True if success. False if failed. """ tasks = [(self._account_registration, [ad]) for ad in self.android_devices] try: if not multithread_func(self.log, tasks): abort_all_tests(self.log, "Unable to activate Fi account!") except Exception as e: self.log.error(e) abort_all_tests(self.log, "Unable to activate Fi account!") return True
def test_ota_upgrade(self): ota_package = self.user_params.get("ota_package") if isinstance(ota_package, list): ota_package = ota_package[0] if ota_package and "dev/null" not in ota_package: self.log.info("Upgrade with ota_package %s", ota_package) self.log.info("Before OTA upgrade: %s", get_info(self.android_devices)) else: raise signals.TestSkip("No ota_package is defined") ota_util = self.user_params.get("ota_util") if isinstance(ota_util, list): ota_util = ota_util[0] if ota_util: if "update_engine_client.zip" in ota_util: self.user_params["UpdateDeviceOtaTool"] = ota_util self.user_params["ota_tool"] = "UpdateDeviceOtaTool" else: self.user_params["AdbSideloadOtaTool"] = ota_util self.user_params["ota_tool"] = "AdbSideloadOtaTool" self.log.info("OTA upgrade with %s by %s", ota_package, self.user_params["ota_tool"]) ota_updater.initialize(self.user_params, self.android_devices) tasks = [(self._ota_upgrade, [ad]) for ad in self.android_devices] try: result = multithread_func(self.log, tasks) except Exception as err: abort_all_tests(self.log, "Unable to do ota upgrade: %s" % err) device_info = get_info(self.android_devices) self.log.info("After OTA upgrade: %s", device_info) self.results.add_controller_info("AndroidDevice", device_info) if len(self.android_devices) > 1: caller = self.android_devices[0] callee = self.android_devices[1] return call_setup_teardown( self.log, caller, callee, caller, self._get_call_verification_function(caller), self._get_call_verification_function(callee)) and result return result
def setup_test(self): if not unlock_sim(self.dut): abort_all_tests(self.dut.log, "unable to unlock SIM") self.expected_call_result = True
def test_pre_flight_check(self): for ad in self.android_devices: #check for sim and service if not ensure_phone_subscription(self.log, ad): abort_all_tests(ad.log, "Unable to find a valid subscription!") return True