Beispiel #1
0
    def run_test(self):
        """
        As of right now, at the beginning of the RUN part, we have connected the 2 phones in
        a PAN-NAP way and we are also connected to the internet.
        """
        LiveDualPhoneBTBase.run_test(self)

        wifi_router = self.__global_config.benchConfig.get_parameters(self._wifi_access_point)
        server_to_ping = wifi_router.get_param_value("IP")
        #ping the AP
        packet_loss = self._panu_net_api.ping(server_to_ping,
                                          self._packet_size,
                                          self._packet_count)

        msg = "Measured Packet Loss: {0} {1} (Target: {2} {3})".format(packet_loss.value, packet_loss.units,
               self._target_packet_loss_rate, packet_loss.units)
        self._logger.info(msg)

        if packet_loss.value > self._target_packet_loss_rate:
            msg = "Ping packet loss is not acceptable [%s]" \
                % str(packet_loss.value)
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        return (Global.SUCCESS,
                "BT Tethering ping %s OK" % str(server_to_ping))
Beispiel #2
0
    def run_test(self):
        """
        Execute the test
        """
        # Call UseCase base run_test function
        LiveDualPhoneBTBase.run_test(self)

        time.sleep(self._wait_btwn_cmd)

        # start to browse device
        self._logger.info("Service Browsing")
        (result, remote) = self._initiator_api.bt_service_browsing(
            self._responder_addr)

        if self._class_list is "":
            if not result:
                msg = "Service browsing failed"
                self._logger.error(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        else:
            classlist = self._class_list.strip().split(";")

            for curr_class in classlist:
                # Remove leading and trailing whitespace
                curr_class = curr_class.strip()
                # Search service class in the list
                if BtServiceClass.BT_SERVICE_CLASS[
                        curr_class] not in remote.uuids:
                    msg = "Service %s is not found" % curr_class
                    self._logger.error(msg)
                    raise DeviceException(DeviceException.OPERATION_FAILED,
                                          msg)

        return Global.SUCCESS, "No errors"
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        LiveDualPhoneBTBase.__init__(self, tc_name, global_config)

        #Get TC parameters
        #wifi activity is set to WIFI_WEB_BROWSING for all PAN/NAP/PANU tests
        self._wifi_activity = str(self._tc_parameters.get_param_value("WIFI_ACTIVITY")).upper()
        if self._wifi_activity == "WIFI_WEB_BROWSING":
            self._wifi_url = str(self._tc_parameters.get_param_value("URL_TO_BROWSE"))
        self._thread_wifi_activity = None

        self._wifi_access_point = str(self._tc_parameters.get_param_value("WIFI_ACCESS_POINT", ""))

        # Read DUT_STATE from test case xml file: server or client
        self._dut_state = str(self._tc_parameters.get_param_value("DUT_STATE")).upper()
        # Read OPP_LOCAL_FILE from test case xml file
        self._opp_local_file = str(self._tc_parameters.get_param_value("OPP_LOCAL_FILE"))

        self._nap_or_pan_test = str(self._tc_parameters.get_param_value("NAP_OR_PAN_TEST")).upper()
        self._connection_to_share = str(self._tc_parameters.get_param_value("CONNECTION_TO_SHARE")).upper()
        self._pairing_initiator = str(self._tc_parameters.get_param_value("PAIRING_INITIATOR")).upper()
        self._bt_tethering_deactivation_test = \
            str(self._tc_parameters.get_param_value("ENABLE_BT_TETHERING_DEACTIVATION_TEST", default_value=False))
        self._who_disconnect = str(self._tc_parameters.get_param_value("WHO_DISCONNECT", default_value="NAP")).upper()
        self._fail_if = self._tc_parameters.get_param_value("PAIRING_CHECK_FAIL_IF", default_value="disconnected")

        self._interleave_search = self._tc_parameters.get_param_value("IS_INTERLEAVE_SEARCH", default_value=False)

        self._browse_retries = 2

        # Initialize data
        self._thread_opp_transfer = None
        self._thread_scan_bt = None
        self._thread_scan_wifi = None
        self._thread_connect_to_nap = None

        self._nap_api = None
        self._panu_api = None
        self._nap_addr = None
        self._panu_addr = None
        self._wifi_api = None
        self._panu_net_api = None
        self._paired_api = None
        self._pair_requester_api = None

        self._queue = Queue.Queue()
        self.__global_config = global_config
        self._wait_btwn_cmd = 5.0
        self._duration = 60
        self._replyval = True
        self._accept_connection = True
        self._must_find = True
        self._status = None
        self._sleep_time = self._SLEEP_TIME_SECS
        self._start_time = None
        self._timeout = self._DEFAULT_TIMEOUT_SECS

        self._bluetooth_connectivity_obj = BluetoothConnectivity(self._device, self._wait_btwn_cmd)
Beispiel #4
0
    def set_up(self):
        """
        Initialize the test
        """

        LiveDualPhoneBTBase.set_up(self)

        if self._initiator.strip().lower() in "phone1":
            self._initiator_api = self._bt_api
            self._responder_addr = self._phone2_addr
            self._responder_config = self._dut2_config
        elif self._initiator.strip().lower() in "phone2":
            self._initiator_api = self._bt_api2
            self._responder_addr = self._phone1_addr
            self._responder_config = self._dut_config
        else:
            msg = "Initiator value <%s> is not valid" % self._initiator
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        if self._class_list.upper().strip() == "__USE_DEVICE_SERVICE_LIST__":
            # Get default supported service list from device catalog file
            # Take value of responder device
            self._class_list = str(
                self._responder_config.get("SupportedServiceList"))

        # Start a first BT scan on initiator to list visible remote
        self._initiator_api.bt_scan_devices()

        return Global.SUCCESS, "No errors"
Beispiel #5
0
    def tear_down(self):

        #disconnect tethering
        self._bluetooth_connectivity_obj.disconnect_bt_tethering_and_pan(self._bt_tethering_deactivation_test, self._nap_api, self._who_disconnect, self._panu_api, self._nap_addr, self._panu_addr)
        # Bluetooth unpairing
        self._logger.info("Unpair both devices")
        paired = False
        list_paired_devices = self._panu_api.list_paired_device()
        for element in list_paired_devices:
            if str(element.address).upper() == str(self._phone2_addr).upper():
                paired = True
        if paired:
            self._bt_api.unpair_bt_device(self._phone2_addr)
            self._bt_api2.unpair_bt_device(self._phone1_addr)
        else:
            pass
        # Disconnect and clear WiFi networks
        if self._connection_to_share == "WIFI":
            self._wifi_api.wifi_remove_config("all")
            self._wifi_api.set_wifi_power("off")

        LiveDualPhoneBTBase.tear_down(self)

        result, output = Global.SUCCESS, ""
        return result, output
    def run_test(self):
        """
        Execute the test
        """

        # Call UseCase base run_test function
        LiveDualPhoneBTBase.run_test(self)

        # Configure BT OPP Transfer thread
        # Files used are big, use bigger timeout than default
        opp_timeout = 300 + self._duration
        if self._dut_state == "DUT_CLIENT":
            self._thread_opp_transfer = ThreadOPPTransferFile(
                self._queue, self._device, self._phone2, self._opp_local_file,
                self._device.multimedia_path, 1, 0, opp_timeout)
        else:
            self._thread_opp_transfer = ThreadOPPTransferFile(
                self._queue, self._phone2, self._device, self._opp_local_file,
                self._phone2.multimedia_path, 1, 0, opp_timeout)

        # Configure Pair/Unpair activity thread
        self._thread_headset_activity = ThreadPairConnectA2DPHeadset(
            self._queue, self._duration, self._bt_api,
            self._em.get_bluetooth_headset("BT_HEADSET"))

        # Launch threads
        self._thread_opp_transfer.start()
        time.sleep(LabDualPhoneBTOppWithA2DPConnect.WAIT_A2DP_ACTIVITY)
        self._thread_headset_activity.start()
        time.sleep(self._wait_btwn_cmd)
        self._exception_reader(
            self._queue,
            [self._thread_opp_transfer, self._thread_headset_activity])

        return Global.SUCCESS, "No errors"
Beispiel #7
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveDualPhoneBTBase.set_up(self)

        opp_init_configure(self._device, self._phone2)
        time.sleep(self._wait_btwn_cmd)

        if self._component_use not in [
                "USE_WIFI", "USE_BT", "USE_BT_AND_WIFI"
        ]:
            msg = "COMPONENT_USE parameter unknown - must be USE_WIFI, USE_BT or USE_BT_AND_WIFI"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        if self._dut_state not in ["DUT_CLIENT", "DUT_SERVER"]:
            msg = "DUT state configuration unknown - DUT should be client or server"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # WiFi configure if needed
        if self._component_use in ["USE_WIFI", "USE_BT_AND_WIFI"]:
            if self._ssid in (None, ""):
                msg = str(self._ssid) + ": WiFi SSID is missing"
                self._logger.error(msg)
                raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                         msg)
            self._networking_api.set_wifi_power(1)

        return Global.SUCCESS, "No errors"
    def run_test(self):
        """
        As of right now, at the beginning of the RUN part, we have connected the 2 phones in
        a PAN-NAP way and we are also connected to the internet.
        """
        LiveDualPhoneBTBase.run_test(self)

         # Configure Wifi Browse threads
        if self._wifi_activity == "WIFI_WEB_BROWSING":
            self._thread_wifi_activity = ThreadBrowseWifiChrome(self._queue, self._panu_net_api, self._duration, self._browse_retries, self._wifi_url)
        else:
            msg = "Unknown WIFI_ACTIVITY : %s" % self._wifi_activity
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Configure BT OPP Transfer
        if self._dut_state == "DUT_SERVER":
            self._thread_opp_transfer = ThreadOPPTransferFile(self._queue, self._device, self._phone2,
                                                              self._opp_local_file, self._device.multimedia_path, initialize=True)
        elif self._dut_state == "DUT_CLIENT":
            self._thread_opp_transfer = ThreadOPPTransferFile(self._queue, self._phone2, self._device,
                                                              self._opp_local_file, self._phone2.multimedia_path)

        self._thread_opp_transfer.start()
        time.sleep(20)
        self._thread_wifi_activity.start()
        time.sleep(self._wait_btwn_cmd)
        self._thread_opp_transfer.join()
        # This function waits all threads are dead or timeout is over before finish
        self._exception_reader(self._queue, [self._thread_wifi_activity, self._thread_opp_transfer])

        result, output = Global.SUCCESS, ""
        return result, output
Beispiel #9
0
    def set_up(self):
        """
        Initialize the test
        """

        LiveDualPhoneBTBase.set_up(self)

        # defines NAP / PAN-User roles
        if self._nap_or_pan_test == "NAP":
            self._nap_api = self._bt_api
            self._nap_addr = self._phone1_addr
            self._panu_api = self._bt_api2
            self._panu_addr = self._phone2_addr
            self._wifi_api = self._networking_api
            self._panu_net_api = self._networking_api2
        elif self._nap_or_pan_test == "PAN":
            self._nap_api = self._bt_api2
            self._nap_addr = self._phone2_addr
            self._panu_api = self._bt_api
            self._panu_addr = self._phone1_addr
            self._wifi_api = self._networking_api2
            self._panu_net_api = self._networking_api
        else:
            raise AcsConfigException(AcsConfigException.INVALID_TEST_CASE_FILE, "You did not provide a valid value for the NAP_OR_PAN_TEST parameter. It must pe NAP or PAN.")

        # Handle External connection (WIFI or CELLULAR)
        self._bluetooth_connectivity_obj.handle_external_connection(self._connection_to_share, self._wifi_api, self.__global_config, self._wifi_access_point)
        time.sleep(self._wait_btwn_cmd)

        #initialize phone for PAN
        if self._interleave_search is False:
            self._bluetooth_connectivity_obj.search_for_device_until_found(self._panu_api, self._nap_api, self._nap_addr, self._must_find)
        elif self._interleave_search is True:
            self._bluetooth_connectivity_obj.search_for_device_interleave(self._panu_api, self._nap_api, self._nap_addr, self._must_find)

         # Pair the DUT with the device
        self._bluetooth_connectivity_obj.try_until_paired(self._panu_api, self._nap_api, self._panu_addr, self._nap_addr, self._replyval, self._accept_connection)
        # # 4) Set tethering power to on, PAN connect
        # PAN connect the devices
        # Enable BT tethering
        #check devices are truly paired
        self._bluetooth_connectivity_obj.check_paired(self._panu_api, self._nap_addr)
        self._nap_api.set_bt_tethering_power("on")
        time.sleep(self._wait_btwn_cmd)
        #connect PAN way
        self._panu_api.connect_bt_device(self._nap_addr, BtProfile.PAN)
        #check profiles are connected
        keep_going = True
        self._start_time = time.time()
        while keep_going:
            self._status = self._panu_api.get_bt_connection_state(self._nap_addr, BtProfile.PAN)
            keep_going = self._bluetooth_connectivity_obj._keep_going(self._status, self._start_time, self._timeout)
        self._bluetooth_connectivity_obj._raise_error_if_fail_when_profiles_not_connected(self._status, self._fail_if)

        result, output = Global.SUCCESS, ""
        return result, output
Beispiel #10
0
    def run_test(self):
        """
        Execute the test
        """
        # pylint: disable=E1101

        # Call UseCase base run_test function
        LiveDualPhoneBTBase.run_test(self)

        # Configure BT OPP Transfer
        if self._dut_state == "DUT_CLIENT":
            self._thread_opp_transfer = ThreadOPPTransferFile(
                self._queue, self._device, self._phone2, self._opp_local_file,
                self._device.multimedia_path)
            self._thread_opp_transfer_retry = ThreadOPPTransferFile(
                self._queue, self._device, self._phone2, self._opp_local_file,
                self._device.multimedia_path)
        else:
            self._thread_opp_transfer = ThreadOPPTransferFile(
                self._queue, self._phone2, self._device, self._opp_local_file,
                self._phone2.multimedia_path)
            self._thread_opp_transfer_retry = ThreadOPPTransferFile(
                self._queue, self._phone2, self._device, self._opp_local_file,
                self._phone2.multimedia_path)

        self._thread_opp_transfer.start()
        time.sleep(LiveDualPhoneBTTransferSwitchBT.WAIT_BETWEEN_BT_SWITCH)

        # Switch On/Off Bluetooth
        self._bt_api.set_bt_power(str(BT_STATE.STATE_OFF))
        time.sleep(LiveDualPhoneBTTransferSwitchBT.WAIT_BETWEEN_BT_SWITCH)
        if self._bt_api.get_bt_power_status() != str(BT_STATE.STATE_OFF):
            msg = "error switch off Bluetooth adapter"
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        self._bt_api.set_bt_power(str(BT_STATE.STATE_ON))
        time.sleep(LiveDualPhoneBTTransferSwitchBT.WAIT_BETWEEN_BT_SWITCH)

        self._thread_opp_transfer.join()
        try:
            current_exception = self._queue.get(True, 3)

        except Queue.Empty:
            current_exception = None

        if current_exception is None:
            msg = "no error return after switch on/off BT during transfer"
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        self._thread_opp_transfer_retry.start()
        time.sleep(self._wait_btwn_cmd)
        self._exception_reader(self._queue, [self._thread_opp_transfer_retry])

        return Global.SUCCESS, "No errors"
Beispiel #11
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveDualPhoneBTBase.set_up(self)

        # Split to create a list of Initiator in case of multiple pairing
        self._ini_list = self._initiator_list.strip().split(",")
        # Split to create a list of phone_1 pairing request reply
        self._reply_list1 = self._reply1_list.strip().split(",")
        # Split to create a list of phone_2 pairing request reply
        self._reply_list2 = self._reply2_list.strip().split(",")

        # Check lists have the same number of iteration
        if (not (range(len(self._ini_list)) == range(len(self._reply_list1)) ==
                 range(len(self._reply_list2)))):
            msg = "INITIATOR_LIST, REPLY_LIST_1 and REPLY_LIST_2"\
                  + " shall have same size"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Change scan mode on both devices
        if self._discov_mode1.upper() == "NOT_DISCOV":
            self._bt_api.set_bt_discoverable("none", 0)
        elif self._discov_mode1.upper() == "DISCOV_PAIR":
            self._bt_api.set_bt_discoverable("connectable", 0)
        elif self._discov_mode1.upper() == "DISCOV_ALL":
            self._bt_api.set_bt_discoverable("both", 0)
        else:
            msg = "Wrong value of DISCOVERY_MODE_1"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        if self._discov_mode2.upper() == "NOT_DISCOV":
            self._bt_api2.set_bt_discoverable("none", 0)
        elif self._discov_mode2.upper() == "DISCOV_PAIR":
            self._bt_api2.set_bt_discoverable("connectable", 0)
        elif self._discov_mode2.upper() == "DISCOV_ALL":
            self._bt_api2.set_bt_discoverable("both", 0)
        else:
            msg = "Wrong value of DISCOVERY_MODE_2"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Start a first BT scan on both devices to list visible remote
        self._bt_api.bt_scan_devices()
        self._bt_api2.bt_scan_devices()

        return Global.SUCCESS, "No errors"
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LiveBTBase init function
        LiveDualPhoneBTBase.__init__(self, tc_name, global_config)

        self._dut_state = str(self._tc_parameters.get_param_value("DUT_STATE"))
        self._opp_local_file = str(
            self._tc_parameters.get_param_value("OPP_LOCAL_FILE"))
        self._duration = str(self._tc_parameters.get_param_value("DURATION"))

        self._thread_opp_transfer = None
        self._thread_headset_activity = None
        self._queue = Queue.Queue()
Beispiel #13
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveDualPhoneBTBase.set_up(self)

        if self._dut_state not in ["DUT_CLIENT", "DUT_SERVER"]:
            msg = "DUT state configuration unknown - DUT should be client or server"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        opp_init_configure(self._device, self._phone2)
        time.sleep(self._wait_btwn_cmd)

        return Global.SUCCESS, "No errors"
Beispiel #14
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LiveBTBase init function
        LiveDualPhoneBTBase.__init__(self, tc_name, global_config)

        # Read DUT_STATE from test case xml file
        self._dut_state = str(self._tc_parameters.get_param_value("DUT_STATE"))
        # Read OPP_LOCAL_FILE from test case xml file
        self._opp_local_file = str(
            self._tc_parameters.get_param_value("OPP_LOCAL_FILE"))

        # Initialize data
        self._thread_opp_transfer = None

        self._queue = Queue.Queue()
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LiveBTBase init function
        LiveDualPhoneBTBase.__init__(self, tc_name, global_config)
        LiveWifiBase.__init__(self, tc_name, global_config)

        self._duration = str(self._tc_parameters.get_param_value("DURATION"))
        self._dut_state = str(self._tc_parameters.get_param_value("DUT_STATE"))
        self._opp_local_file = str(self._tc_parameters.get_param_value("OPP_LOCAL_FILE"))
        self._wifi_activity = str(self._tc_parameters.get_param_value("WIFI_ACTIVITY"))
        if self._wifi_activity == "WIFI_FTP_DOWNLOAD":
            self._ftp_remote_file = str(self._tc_parameters.get_param_value("FTP_REMOTE_FILE"))

        self._bt_headset = None
        self._bt_headset_addr = None
    def run_test(self):
        """
        Execute the test
        """

        # Call UseCase base run_test function
        LiveDualPhoneBTBase.run_test(self)

        queue = Queue.Queue()

        # Configure BT OPP Transfer
        opp_timeout = LabDualPhoneBTOppA2DPWithWiFiActivities.OFFSET_TIMEOUT + self._duration
        if self._dut_state == "DUT_CLIENT":
            thread_opp_transfer = ThreadOPPTransferFile(queue, self._device, self._phone2,
                                                        self._opp_local_file, self._device.multimedia_path, 1, 0, opp_timeout)
        else:
            thread_opp_transfer = ThreadOPPTransferFile(queue, self._phone2, self._device,
                                                        self._opp_local_file, self._phone2.multimedia_path, 1, 0, opp_timeout)

        # Configure WiFi Activity
        if self._wifi_activity == "WIFI_FTP_DOWNLOAD":
            thread_wifi_activity = ThreadDownloadFileFromFTP(queue, self._networking_api,
                                                             self._server_ip_address, self._username,
                                                             self._password, self._ftp_remote_file, self._ftp_path,
                                                             str(self._device.get_ftpdir_path()),
                                                             LabDualPhoneBTOppA2DPWithWiFiActivities.OFFSET_TIMEOUT + self._duration)
        else:
            thread_wifi_activity = ThreadWiFiSwitchPowerScanAndConnect(queue, self._networking_api,
                                                                       self._duration, self._ssid,
                                                                       self._passphrase, self._security)

        # Configure A2DP Activity
        thread_a2dp_activity = ThreadA2DPCheckMusic(queue, BtAudioState.PLAYING, self._duration,
                                                    self._bt_api, self._bt_headset_addr)

        # Launch threads
        thread_opp_transfer.start()
        time.sleep(LabDualPhoneBTOppA2DPWithWiFiActivities.WAIT_OPP_ACTIVITY_START)
        thread_a2dp_activity.start()
        thread_wifi_activity.start()
        time.sleep(self._wait_btwn_cmd)
        self._exception_reader(queue, [thread_a2dp_activity,
                                       thread_opp_transfer, thread_wifi_activity])

        return Global.SUCCESS, "No errors"
    def tear_down(self):
        """
        Finish the test and clear environment
        """

        # Call UseCase base tear_down function
        LiveDualPhoneBTBase.tear_down(self)

        # Clear OPP transfer
        opp_terminate(self._device, self._phone2)

        # Delete sent file
        if self._dut_state == "DUT_CLIENT":
            self._bt_api2.bt_opp_init(self._opp_local_file)
        else:
            self._bt_api.bt_opp_init(self._opp_local_file)

        return Global.SUCCESS, "No errors"
Beispiel #18
0
    def run_test(self):
        """
        Execute the test
        """

        # Call UseCase base run_test function
        LiveDualPhoneBTBase.run_test(self)

        # Wifi configure if needed
        if self._component_use in ["USE_WIFI", "USE_BT_AND_WIFI"]:
            self._thread_scan_wifi = ThreadScanWiFi(self._queue,
                                                    self._networking_api,
                                                    self._ssid)
        # Configure BT if needed
        if self._component_use in ["USE_BT", "USE_BT_AND_WIFI"]:
            self._thread_scan_bt = ThreadScanBT(self._queue, self._bt_api,
                                                self._bt_api2)

        # Configure BT OPP Transfer
        if self._dut_state == "DUT_CLIENT":
            self._thread_opp_transfer = ThreadOPPTransferFile(
                self._queue, self._device, self._phone2, self._opp_local_file,
                self._device.multimedia_path)
        else:
            self._thread_opp_transfer = ThreadOPPTransferFile(
                self._queue, self._phone2, self._device, self._opp_local_file,
                self._phone2.multimedia_path)

        # Launch threads
        self._thread_opp_transfer.start()
        time.sleep(LiveDualPhoneBTTransferWithScan.SCANNING_WAIT_TIME)

        if self._thread_scan_wifi is not None:
            self._thread_scan_wifi.start()

        if self._thread_scan_bt is not None:
            self._thread_scan_bt.start()

        self._exception_reader(self._queue, [
            self._thread_scan_wifi, self._thread_scan_bt,
            self._thread_opp_transfer
        ])

        return Global.SUCCESS, "No errors"
Beispiel #19
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LiveBTBase init function
        LiveDualPhoneBTBase.__init__(self, tc_name, global_config)

        # Read INITIATOR_LIST from test case xml file
        self._initiator_list = \
            str(self._tc_parameters.get_param_value("INITIATOR_LIST"))
        # Read REPLY_LIST_1 from test case xml file
        self._reply1_list = \
            str(self._tc_parameters.get_param_value("REPLY_LIST_1"))
        # Read REPLY_LIST_2 from test case xml file
        self._reply2_list = \
            str(self._tc_parameters.get_param_value("REPLY_LIST_2"))

        # Read DISCOVERY_MODE_1 from test case xml file
        self._discov_mode1 = \
            str(self._tc_parameters.get_param_value("DISCOVERY_MODE_1"))
        # Read CODEPIN_1 from test case xml file
        self._pin1 = \
            str(self._tc_parameters.get_param_value("CODEPIN_1"))
        # Read PASSKEY_1 from test case xml file
        self._passkey1 = \
            str(self._tc_parameters.get_param_value("PASSKEY_1"))

        # Read DISCOVERY_MODE_2 from test case xml file
        self._discov_mode2 = \
            str(self._tc_parameters.get_param_value("DISCOVERY_MODE_2"))
        # Read CODEPIN_2 from test case xml file
        self._pin2 = \
            str(self._tc_parameters.get_param_value("CODEPIN_2"))
        # Read PASSKEY_2 from test case xml file
        self._passkey2 = \
            str(self._tc_parameters.get_param_value("PASSKEY_2"))

        # Read DURATION from test case xml file
        self._duration = \
            int(self._tc_parameters.get_param_value("DURATION"))

        self._ini_list = []
        self._reply_list1 = []
        self._reply_list2 = []
Beispiel #20
0
    def tear_down(self):
        """
        Execute the test
        """

        # Call UseCase base tear_down function
        LiveDualPhoneBTBase.tear_down(self)

        # Clear OPP transfer
        opp_terminate(self._device, self._phone2)

        # Delete sent file
        if self._dut_state == "DUT_CLIENT":
            self._bt_api2.bt_opp_init(self._opp_local_file)
        else:
            self._bt_api.bt_opp_init(self._opp_local_file)

        # Disable WiFi
        self._networking_api.set_wifi_power(0)

        return Global.SUCCESS, "No errors"
Beispiel #21
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

        # Call LiveBTBase init function
        LiveDualPhoneBTBase.__init__(self, tc_name, global_config)

        # Get device_config
        self._dut2_config = DeviceManager().get_device_config("PHONE2")

        # Get TC Parameters
        self._class_list = \
            self._tc_parameters.get_param_value("CLASS_LIST")

        self._initiator = \
            self._tc_parameters.get_param_value("INITIATOR")

        self._initiator_api = None
        self._responder_addr = None
        self._responder_config = None
    def set_up(self):
        """
        Initialize the test
        """
        LiveDualPhoneBTBase.set_up(self)

        self._bt_headset = self._em.get_bluetooth_headset("BT_HEADSET")
        self._bt_headset_addr = self._bt_headset.get_bdaddress()

        if self._wifi_activity == "WIFI_FTP_DOWNLOAD":
            LiveWifiBase.set_up(self)
        else:
            self._networking_api.set_wifi_power(0)

        if not str(self._duration).isdigit():
            msg = "Bad value on duration parameter : %s" % self._duration
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        self._duration = int(self._duration)

        if self._dut_state not in ["DUT_CLIENT", "DUT_SERVER"]:
            msg = "DUT state configuration unknown - DUT should be client or server"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        if self._wifi_activity not in ["WIFI_FTP_DOWNLOAD", "WIFI_SWITCH_SCAN_CONNECT"]:
            msg = "Unknown WiFi activity : %s" % self._wifi_activity
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Configure OPP transfer
        opp_init_configure(self._device, self._phone2)

        # Connect to BT Headset
        a2dp_pair_connect_to_headset(self._bt_api, self._bt_headset)

        # Launch audio
        a2dp_switch_music_state(self._bt_api, self._bt_headset, BtAudioCmd.PLAY)

        return Global.SUCCESS, "No errors"
Beispiel #23
0
    def tear_down(self):
        """
        Execute the test
        """

        # Call UseCase base tear_down function
        LiveDualPhoneBTBase.tear_down(self)

        # Clear OPP transfer
        opp_terminate(self._device, self._phone2)

        # WiFi configure if needed
        if self._component_use == "USE_WIFI" or self._component_use == "USE_BT_AND_WIFI":
            self._networking_api.set_wifi_power(0)

        # Delete sent file
        if self._dut_state == "DUT_CLIENT":
            self._bt_api2.bt_opp_init(self._opp_local_file)
        else:
            self._bt_api.bt_opp_init(self._opp_local_file)

        return Global.SUCCESS, "No errors"
    def set_up(self):
        """
        Initialize the test
        """
        LiveDualPhoneBTBase.set_up(self)

        # Configure iterations
        if not str(self._duration).isdigit() or int(self._duration) < 1:
            msg = "DURATION parameter error - must be >= 1 but is %s" % self._duration
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        self._duration = int(self._duration)

        if self._dut_state not in ["DUT_CLIENT", "DUT_SERVER"]:
            msg = "DUT state configuration unknown - DUT should be client or server"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Configure OPP Transfer
        opp_init_configure(self._device, self._phone2)

        return Global.SUCCESS, "No errors"
Beispiel #25
0
    def run_test(self):
        """
        Execute the test
        """

        # Call UseCase base run_test function
        LiveDualPhoneBTBase.run_test(self)

        # Configure BT OPP Transfer
        if self._dut_state == "DUT_CLIENT":
            self._thread_opp_transfer = ThreadOPPTransferFile(
                self._queue, self._device, self._phone2, self._opp_local_file,
                self._device.multimedia_path)
        else:
            self._thread_opp_transfer = ThreadOPPTransferFile(
                self._queue, self._phone2, self._device, self._opp_local_file,
                self._phone2.multimedia_path)

        self._thread_opp_transfer.start()
        time.sleep(LiveDualPhoneBTTransferSwitchWifi.WAIT_BETWEEN_WIFI_SWITCH)

        # Switch On/Off WiFi
        self._networking_api.set_wifi_power(0)
        time.sleep(self._wait_btwn_cmd)

        if self._networking_api.get_wifi_power_status() == 1:
            msg = "DUT switch WiFi error"
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        self._networking_api.set_wifi_power(1)
        time.sleep(self._wait_btwn_cmd)

        if self._networking_api.get_wifi_power_status() == 0:
            msg = "DUT switch WiFi error"
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        self._exception_reader(self._queue, [self._thread_opp_transfer])

        return Global.SUCCESS, "No errors"
Beispiel #26
0
    def run_test(self):
        """
        Execute the test
        """
        # pylint: disable=E1101

        # Call UseCase base run_test function
        LiveDualPhoneBTBase.run_test(self)

        # Loop on list of initiator
        for iteration in range(len(self._ini_list)):

            # Remove leading and trailing whitespace
            curr_ini = self._ini_list[iteration].strip().lower()

            # Set Initiator and responder of the pairing request
            if curr_ini in "phone1":
                initiator_name = "phone1"
                initiator_api = self._bt_api
                initiator_addr = self._phone1_addr
                initiator_rep = int(self._reply_list1[iteration].strip())
                initiator_pin = self._pin1
                initiator_pass = self._passkey1
                responder_name = "phone2"
                responder_api = self._bt_api2
                responder_addr = self._phone2_addr
                responder_rep = int(self._reply_list2[iteration].strip())
                responder_pin = self._pin2
                responder_pass = self._passkey2

            elif curr_ini in "phone2":
                initiator_name = "phone2"
                initiator_api = self._bt_api2
                initiator_addr = self._phone2_addr
                initiator_rep = int(self._reply_list2[iteration].strip())
                initiator_pin = self._pin2
                initiator_pass = self._passkey2
                responder_name = "phone1"
                responder_api = self._bt_api
                responder_addr = self._phone1_addr
                responder_rep = int(self._reply_list1[iteration].strip())
                responder_pin = self._pin1
                responder_pass = self._passkey1
            else:
                msg = "Initiator value <%s> is not valid" % curr_ini
                self._logger.error(msg)
                raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                         msg)

            # Start pairing sequence
            responder_api.wait_for_pairing(initiator_addr, 1, responder_rep,
                                           responder_pin, responder_pass)
            time.sleep(self._wait_btwn_cmd)
            pair_result, pinvar = initiator_api.pair_to_device(
                responder_addr, 1, initiator_rep, initiator_pin,
                initiator_pass)

            if pair_result == BT_BOND_STATE.BOND_NONE:
                msg = "[PHONE1]%s is not paired with %s" \
                    % (initiator_name, responder_name)
                self._logger.info(msg)
            elif pair_result == BT_BOND_STATE.BOND_BONDED:
                msg = "[PHONE1]%s is paired with %s" \
                    % (initiator_name, responder_name)
                self._logger.info(msg)
            else:
                msg = "[PHONE1]Unexpected return value %s" % pair_result
                self._logger.info(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

            # In case of success pairing, wait for DURATION and
            # check devices are still paired
            if pair_result == BT_BOND_STATE.BOND_BONDED:
                for i in range(self._duration):
                    if not i % 10:
                        msg = "[PHONE1]Wait for %d seconds" % (self._duration -
                                                               i)
                        self._logger.info(msg)
                    time.sleep(1)

                # Retrieve list of paired devices
                pairedflag = False
                list_paired_devices = self._bt_api.list_paired_device()
                for element in list_paired_devices:
                    if str(element.address).upper() \
                            == str(self._phone2_addr).upper():
                        self._logger.info(
                            "Still paired with device %s after %s s" %
                            (self._phone2_addr, self._duration))
                        pairedflag = True
                        break

                if not pairedflag:
                    msg = "Pairing to device %s fail" % self._phone2_addr
                    self._logger.info(msg)
                    raise DeviceException(DeviceException.OPERATION_FAILED,
                                          msg)

            # analyze of pairing state for final verdict
            if not self._is_verdict_pass(pair_result, pinvar, iteration):
                msg = "[PHONE1]Unexpected pairing verdict %s" % pair_result
                self._logger.info(msg)
                self._display_param(pair_result, pinvar, iteration, "info")
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)
            else:
                msg = "[PHONE1]pairing Verdict is PASS"
                self._logger.info(msg)
                self._display_param(pair_result, pinvar, iteration, "debug")

            # If Responder is NOT discoverable
            # Stop "WaitForPair" activity on Responder
            self._stop_remaining_activity(iteration, responder_api)

        # after end of loop, Remove pairing
        time.sleep(self._wait_btwn_cmd)
        list_paired_devices = self._bt_api.list_paired_device()
        for element in list_paired_devices:
            if str(element.address).upper() == str(self._phone2_addr).upper():
                self._logger.info("Unpair both devices")
                self._bt_api.unpair_bt_device(self._phone2_addr)
                self._bt_api2.unpair_bt_device(self._phone1_addr)

        return Global.SUCCESS, "No errors"
    def run_test(self):
        """
        As of right now, at the beginning of the RUN part, we have connected the 2 phones in
        a PAN-NAP way and we are also connected to the internet.
        """
        LiveDualPhoneBTBase.run_test(self)

        # Configure Wifi Browse threads
        if self._wifi_activity == "WIFI_WEB_BROWSING":
            self._thread_wifi_activity = ThreadBrowseWifiChrome(
                self._queue, self._panu_net_api, self._duration,
                self._browse_retries, self._wifi_url)
        else:
            msg = "Unknown WIFI_ACTIVITY : %s" % self._wifi_activity
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # search for the interface on the device, must be present
        netcfg_cmd_up = "adb shell netcfg | grep bt-pan"
        ifconfig_cmd_up = "adb shell ifconfig | grep -A8 bt-pan"
        time.sleep(self._wait_btwn_cmd)
        result_up, output_up = self._device.run_cmd(netcfg_cmd_up,
                                                    self._wait_btwn_cmd)
        return_result = Global.SUCCESS
        return_output = "The bt-pan interface is in the correct state"
        if not output_up or "not found" in output_up:
            result_up, output_up = self._device.run_cmd(
                ifconfig_cmd_up, self._wait_btwn_cmd)
        if not output_up:
            # return_result = Global.SUCCESS
            msg = "The bt-pan interface is not present, it was not instantiated"
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        elif "UP" not in output_up:
            msg = "The bt-pan interface is present, but it is down. Output of grep command" \
                  " is: \n" + str(output_up)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        elif "0.0.0.0/0" in output_up:
            msg = "The bt-pan interface is present, but no IP was assigned. Output of grep command" \
                  " is: \n" + str(output_up)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        else:
            return_output = "The bt-pan interface is present and UP"

        #browse for a page
        self._thread_wifi_activity.start()
        time.sleep(self._wait_btwn_cmd)
        # This function waits all threads are dead or timeout is over before finish
        self._exception_reader(self._queue, [self._thread_wifi_activity])

        #turn off BT Tethering on the remote device
        self._bluetooth_connectivity_obj.disconnect_bt_tethering_and_pan(
            self._bt_tethering_deactivation_test, self._nap_api,
            self._who_disconnect, self._panu_api, self._nap_addr,
            self._panu_addr)

        # search for the interface on the device, must not be present
        netcfg_cmd_down = "adb shell netcfg | grep bt-pan"
        time.sleep(self._wait_btwn_cmd)
        self._device.run_cmd(netcfg_cmd_down, self._wait_btwn_cmd)
        result_down, output_down = self._device.run_cmd(
            netcfg_cmd_down, self._wait_btwn_cmd)
        return_result = Global.SUCCESS
        return_output = "The bt-pan interface is in the correct state"
        if not output_down or "not found" in output_down:
            result_down, output_down = self._device.run_cmd(
                ifconfig_cmd_up, self._wait_btwn_cmd)
        if output_down:
            msg = "The bt-pan interface is still present, it was wrongly instantiated"
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        else:
            return_output = "The bt-pan interface is no longer present, as expected."
        return Global.SUCCESS, return_output
Beispiel #28
0
    def run_test(self):
        """
        As of right now, at the beginning of the RUN part, we have connected the 2 phones in
        a PAN-NAP way and we are also connected to the internet.
        """
        LiveDualPhoneBTBase.run_test(self)

          # Configure Wifi Browse threads
        if self._wifi_activity == "WIFI_WEB_BROWSING":
            self._thread_wifi_activity = ThreadBrowseWifiChrome(self._queue, self._panu_net_api, self._duration, self._browse_retries, self._wifi_url)
        else:
            msg = "Unknown WIFI_ACTIVITY : %s" % self._wifi_activity
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # search for the interface on the reference device, must be present
        netcfg_cmd_up = "adb shell netcfg | grep bt-pan"
        ifconfig_cmd_up = "adb shell ifconfig | grep -A8 bt-pan"
        time.sleep(self._wait_btwn_cmd)
        result_up, output_up = self._phone2.run_cmd(netcfg_cmd_up, self._wait_btwn_cmd)
        return_result = Global.SUCCESS
        return_output = "The bt-pan interface is in the correct state"
        if not output_up or "not found" in output_up:
            result_up, output_up = self._device.run_cmd(ifconfig_cmd_up, self._wait_btwn_cmd)
        if not output_up:
            msg = "The bt-pan interface is not present, it was not instantiated after first connection."
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        elif "UP" not in output_up:
            msg = "The bt-pan interface is present, but it is down after first connection.. Output of grep command" \
                  " is: \n" + str(output_up)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        elif "0.0.0.0/0" in output_up:
            msg = "The bt-pan interface is present, but no IP was assigned after first connection.. Output of grep command" \
                  " is: \n" + str(output_up)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        else:
            return_output = "The bt-pan interface is present and UP"

        #browse for a page
        self._thread_wifi_activity.start()
        time.sleep(self._wait_btwn_cmd)
         # This function waits all threads are dead or timeout is over before finish
        self._exception_reader(self._queue, [self._thread_wifi_activity])

        #turn airplane mode ON
        self._wifi_api.set_flight_mode(1)
        time.sleep(BluetoothPanNapAirplane.WAIT_TIME_IN_FLIGHT_MODE)

        #check BT, BT Tethering and Wifi are deactivated
        #check BT status is OFF
        time.sleep(self._wait_btwn_cmd)
        bt_power_air_on = self._nap_api.get_bt_power_status()
        if bt_power_air_on != str(BT_STATE.STATE_OFF):
            msg = "After setting Airplane mode to ON, Bluetooth is still ON. Expected state is OFF." \
                  "the actual state is: " + bt_power_air_on
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        #check BT tethering is turned off
        if self._nap_api.get_bt_tethering_power_status() != str(BT_STATE.STATE_OFF):
            msg = "After setting Airplane mode to ON, Bluetooth TETHERING is still ON. Expected state is OFF."
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        #check Wifi status is OFF
        if self._wifi_api.get_wifi_power_status == 1:
            msg = "After setting Airplane mode to ON, WIFI is still ON. Expected state is OFF."
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        #turn ON BT and Wifi on DUT
        self._nap_api.set_bt_power("on")
        self._wifi_api.set_wifi_power("on")

        self._nap_api.set_bt_tethering_power("on")

        #check BT, BT Tethering and Wifi are reactivated. BT Tethering should be automatically re-activated
        #check BT status is ON
        time.sleep(self._wait_btwn_cmd)
        bt_power_air_off = self._nap_api.get_bt_power_status()
        if bt_power_air_off != str(BT_STATE.STATE_ON):
            msg = "After setting Airplane mode to OFF, Bluetooth is still OFF. Expected state is ON." \
                  "the actual state is: " + bt_power_air_off
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        #check BT tethering is turned ON
        if self._nap_api.get_bt_tethering_power_status() != str(BT_STATE.STATE_ON):
            msg = "After setting Airplane mode to OFF, Bluetooth TETHERING is still OFF. Expected state is ON."
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        #check Wifi status is ON
        if self._wifi_api.get_wifi_power_status == 1:
            msg = "After setting Airplane mode to OFF, WIFI is still OFF. Expected state is ON."
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        #PAN-reconnect the devices
        self._panu_api.connect_bt_device(self._nap_addr, BtProfile.PAN)

        # search for the interface on the device, must not be present
        netcfg_cmd_up = "adb shell netcfg | grep bt-pan"
        ifconfig_cmd_up = "adb shell ifconfig | grep -A8 bt-pan"
        time.sleep(self._wait_btwn_cmd)
        result_up, output_up = self._phone2.run_cmd(netcfg_cmd_up, self._wait_btwn_cmd)
        return_result = Global.SUCCESS
        return_output = "The bt-pan interface is in the correct state"
        if not output_up or "not found" in output_up:
            result_up, output_up = self._device.run_cmd(ifconfig_cmd_up, self._wait_btwn_cmd)
        if not output_up:
            msg = "The bt-pan interface is not present, it was not instantiated after PAN-reconnecting. Message is: "+ str(output_up)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        elif "UP" not in output_up:
            msg = "The bt-pan interface is present, but it is down after PAN-reconnecting. Output of grep command" \
                  " is: \n" + str(output_up)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        elif "0.0.0.0/0" in output_up:
            msg = "The bt-pan interface is present, but no IP was assigned after PAN-reconnecting. Output of grep command" \
                  " is: \n" + str(output_up)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        else:
            return_output = "The bt-pan interface is present and UP"

        #turn airplane mode OFF
        self._wifi_api.set_flight_mode(0)
        time.sleep(BluetoothPanNapAirplane.WAIT_TIME_IN_FLIGHT_MODE)

        #check internet service was not stopped
        # search for the interface on the reference device, must be present
        netcfg_cmd_up = "adb shell netcfg | grep bt-pan"
        time.sleep(self._wait_btwn_cmd)
        result_up, output_up = self._phone2.run_cmd(netcfg_cmd_up, self._wait_btwn_cmd)
        return_result = Global.SUCCESS
        return_output = "The bt-pan interface is in the correct state"
        if not output_up or "not found" in output_up:
            result_up, output_up = self._device.run_cmd(ifconfig_cmd_up, self._wait_btwn_cmd)
        if not output_up:
            msg = "The bt-pan interface is not present, it was not instantiated after Airplane mode OFF"
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        elif "UP" not in output_up:
            msg = "The bt-pan interface is present, but it is down after Airplane mode OFF. Output of grep command" \
                  " is: \n" + str(output_up)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        elif "0.0.0.0/0" in output_up:
            msg = "The bt-pan interface is present, but no IP was assigned after Airplane mode OFF. Output of grep command" \
                  " is: \n" + str(output_up)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        else:
            return_output = "The bt-pan interface is present and UP after Airplane mode OFF, the usecase fully passed."

        return Global.SUCCESS, return_output