コード例 #1
0
    def run_test(self):
        """
        Execute the test
        """

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

        # Set screen always on and unlock phone (Since LLP , DUT need to be unlocked to be visible)
        self._phone_system_api.set_phone_screen_lock_on("on")
        self._phone_system_api.set_phone_lock(0)

        if self._dis_mode in ("on", "1"):
            self._bt_api.\
                set_bt_discoverable('both', 0)
        elif self._dis_mode in ("off", "0"):
            self._bt_api.\
                set_bt_discoverable('none', 0)
        else:
            msg = "Set wrong dis_mode. could only be on(1) or off(0)"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Remove pairing from DEVICE_BT_ADDRESS
        time.sleep(self._wait_btwn_cmd)
        if (self._dis_mode in ("on", "1")
                and not self._bt_api2.bt_find_device(self._phone1_addr)) or \
            (self._dis_mode in ("off", "0")
             and self._bt_api2.bt_find_device(self._phone1_addr)):
            msg = "phone in wrong discoverable mode"
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        return Global.SUCCESS, "No errors"
コード例 #2
0
    def tear_down(self):
        """
        End and dispose the test
        """
        UseCaseBase.tear_down(self)

        # Handle LOng LAsting test
        if self._lola_test:
            self.__disconnect()

        # Disable BT tethering
        self._nap_api.set_bt_tethering_power("0")

        # Bluetooth unpairing
        self._logger.info("Unpair both devices")
        self._bt_api.unpair_bt_device(self._phone2_addr)
        self._bt_api2.unpair_bt_device(self._phone1_addr)

        # 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)

        return Global.SUCCESS, "No errors"
コード例 #3
0
    def tear_down(self):
        """
        End and dispose the test
        """

        # to have a log "We enter into the tear_down"
        UseCaseBase.tear_down(self)

        # Clean the notification list
        if self._receiver_api is not None:
            self._receiver_api.bt_opp_clean_notification_list()
        if self._sender_api is not None:
            self._sender_api.bt_opp_clean_notification_list()

        self._file_cleanup()

        # lock screen and set display OFF
        self._sender_phonesys_api.set_phone_lock(1)
        self._sender_phonesys_api.display_off()

        # Process the bidirectional transfer
        if self._is_bidirectional:
            self._receiver_phonesys_api.set_phone_lock(1)
            self._receiver_phonesys_api.display_off()

        # Switch OFF BT at the end
        LiveDualPhoneBTBase.tear_down(self)

        return Global.SUCCESS, "No errors"
コード例 #4
0
    def run_test(self):
        """
        Execute the test
        """
        LiveDualPhoneBTBase.run_test(self)

        # If necessary, remove the file on the destination device
        self._receiver_api.bt_opp_init(self._filename)

        # Clean the notification list
        self._receiver_api.bt_opp_clean_notification_list()
        self._sender_api.bt_opp_clean_notification_list()

        # Request for the First transfer to be registered
        self._logger.info("Start sending file %s" % self._fullpath_filename)
        self._sender_api.bt_opp_send_file(self._fullpath_filename,
                                          self._receiver_add)

        # Wait for the transfer First to started
        self._wait_for_transfer("downloading", self._receiver_api,
                                self._sender_add, self.TIME_OUT)

        # Cancel the transfer
        self._logger.info("Cancel file transfer")
        self._sender_api.bt_opp_cancel_send()

        # Wait for the transfer state to be cancelled
        self._wait_for_transfer("cancelled", self._receiver_api,
                                self._sender_add, self.TIME_OUT)

        # Send the file again
        self._logger.info("Start sending file %s again" %
                          self._fullpath_filename)
        self._sender_api.bt_opp_send_file(self._fullpath_filename,
                                          self._receiver_add)

        # Wait for the transfer to be complete
        self._wait_for_transfer("downloaded", self._receiver_api,
                                self._sender_add, self._timeout)

        # bt_opp_get_files_checksum wants a list, but there's only one file
        # so put it into a list
        file_list = [self._filename]

        source_path = self._multimedia_path1 if self._direction.upper() == "UL" \
        else self._multimedia_path2

        source_files = self._sender_api.bt_opp_get_files_checksum(
            source_path, file_list)
        dest_files = self._receiver_api.bt_opp_get_files_checksum(
            None, file_list)

        # Check the file matches on the RX phone
        self._logger.info("Compare file checksum on sender and receiver")
        if not source_files == dest_files:
            msg = "The file hasn't been received or it doesn't match the sent one"
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        return Global.SUCCESS, "No errors"
コード例 #5
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        LiveDualPhoneBTBase.__init__(self, tc_name, global_config)

        # Get the phone system apis
        self._phonesystem_api = self._device.get_uecmd("PhoneSystem")
        self._phonesystem2_api = self._phone2.get_uecmd("PhoneSystem")

        # Get TC Parameters
        self._direction = str(self._tc_parameters.get_param_value("DIRECTION"))
        self._filename = str(self._tc_parameters.get_param_value("FILENAME"))

        # Initialize sender/receiver pointers
        self._sender_api = None
        self._sender_add = None
        self._sender_device = None
        self._sender_phonesys_api = None
        self._receiver_api = None
        self._receiver_add = None
        self._receiver_device = None
        self._receiver_phonesys_api = None

        # Get the Multimedia folder name
        self._multimedia_path1 = self._device.multimedia_path
        self._multimedia_path2 = DeviceManager().get_device(
            "PHONE2").multimedia_path
        self._fullpath_filename = ""

        self._timeout = 0
        self._filesize = 0
コード例 #6
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveDualPhoneBTBase.set_up(self)

        # Check TC Parameters
        self.__check_tc_parameters()

        # 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
        else:
            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

        # Handle External connection (WIFI or CELLULAR)
        if self._connection_to_share == "WIFI":
            self._wifi_api.set_wifi_power("on")
            time.sleep(self._wait_btwn_cmd)
            self.__wifi_connect()
        else:
            if self._use_flightmode == 1:
                msg = "Cannot run the test with flight mode ON "
                msg += "while using CELLULAR shared connection"
                self._logger.error(msg)
                raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

            # Enable cellular data connection
            self._wifi_api.activate_pdp_context()

        # Deactivate DATA on PAN User device
        self._panu_net_api.deactivate_pdp_context()

        # Establish bluetooth pairing
        self._establish_bt_pairing(self._pairing_initiator)

        # Set NAP back to discoverable and connectable
        # as _establish_bt_pairing might have set it to "noscan"
        # breaking the test
        self._nap_api.set_bt_discoverable("both", 0)

        # Enable BT tethering
        self._nap_api.set_bt_tethering_power("1")

        # Handle LOng LAsting test
        if self._lola_test:
            connect_to_nap(self._panu_api, self._nap_api,
                           self._nap_addr, self._who_restarts_bt, self._wait_btwn_cmd)

        return Global.SUCCESS, "No errors"
コード例 #7
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LiveBTBase init function
        LiveDualPhoneBTBase.__init__(self, tc_name, global_config)
        UECmdTestTool.__init__(self, self.get_name(),
                               self._logger, self._device)

        self._fcts2test = list()
コード例 #8
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

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

        # Read DIS_MODE from test case xml file
        self._dis_mode = \
            str(self._tc_parameters.get_param_value("DIS_MODE")).lower()
コード例 #9
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

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

        # Read DISCOV_MODE from test case xml file
        self._discov_mode = \
            self._tc_parameters.get_param_value("DISCOV_MODE")

        # Read DISCOV_TIMEOUT from test case xml file
        self._discov_timeout = \
            self._tc_parameters.get_param_value("DISCOV_TIMEOUT")
コード例 #10
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveDualPhoneBTBase.set_up(self)

        # Check TC Parameters
        self.__check_tc_parameters()

        # 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
        else:
            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

        # Connection Wifi LAB Access Point
        LabWifiBase.set_up_without_flightmode(self, self._wifi_api)

        # Deactivate DATA on PAN User device
        self._panu_net_api.deactivate_pdp_context()

        # Establish bluetooth pairing
        self._establish_bt_pairing(self._pairing_initiator)

        # Set NAP back to discoverable and connectable
        # as _establish_bt_pairing might have set it to "noscan"
        # breaking the test
        self._nap_api.set_bt_discoverable("both", 0)

        # Enable BT tethering
        self._nap_api.set_bt_tethering_power("1")

        # Handle LOng LAsting test
        if self._lola_test:
            connect_to_nap(self._panu_api, self._nap_api,
                           self._nap_addr, self._who_restarts_bt, self._wait_btwn_cmd)

        return Global.SUCCESS, "No errors"
コード例 #11
0
    def set_up(self):
        """
        Initialize the test
        """

        LiveDualPhoneBTBase.set_up(self)

        if self._direction not in [self.STR_SEND, self.STR_RECEIVE]:
            msg = "wrong value of parameter DIRECTION"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Set PHONE2 Discoverable by PHONE1
        self._bt_api2.set_bt_discoverable("both", 0)

        return Global.SUCCESS, "No errors"
コード例 #12
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LiveDualPhoneBTBase base run_test function
        LiveDualPhoneBTBase.run_test(self)

        # Check every EUCmd
        for fct2test in self._fcts2test:
            self._check_uecmd(fct2test)
            time.sleep(self._wait_btwn_cmd)

        # Raise an Exception in case of all tests do not pass
        self._compute_general_verdict()

        return Global.SUCCESS, "All UECmds OK"
コード例 #13
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

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

        # Read TC parameters
        self._nap_or_pan_test = \
            str(self._tc_parameters.get_param_value("NAP_OR_PAN_TEST")).upper()
        self._pairing_initiator = \
            str(self._tc_parameters.get_param_value("PAIRING_INITIATOR")).upper()
        self._who_disconnect = \
            str(self._tc_parameters.get_param_value("WHO_DISCONNECT")).upper()
        self._who_restarts_bt = \
            str(self._tc_parameters.get_param_value("WHO_RESTARTS_BT_BEFORE_TEST")).upper()
        self._connection_to_share = \
            str(self._tc_parameters.get_param_value("CONNECTION_TO_SHARE")).upper()
        self._wifi_access_point = \
            str(self._tc_parameters.get_param_value("WIFI_ACCESS_POINT", ""))
        self._bt_tethering_deactivation_test = \
            str(self._tc_parameters.get_param_value("ENABLE_BT_TETHERING_DEACTIVATION_TEST", ""))
        self._lola_test = \
            str(self._tc_parameters.get_param_value("ENABLE_LOLA_TEST", ""))
        self._server_to_ping = \
            str(self._tc_parameters.get_param_value("SERVER_TO_PING", ""))
        self._packet_count = \
            str(self._tc_parameters.get_param_value("PACKET_COUNT"))
        self._packet_size = \
            str(self._tc_parameters.get_param_value("PACKET_SIZE"))
        self._target_packet_loss_rate = \
            str(self._tc_parameters.get_param_value("TARGET_PACKET_LOSS_RATE"))

        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.__global_config = global_config
コード例 #14
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LiveDualPhoneBTBase and LabWifiBase init functions
        LiveDualPhoneBTBase.__init__(self, tc_name, global_config)
        LabWifiBase.__init__(self, tc_name, global_config)

        # Reset unused parameter:
        self._wrong_passphrase = None
        self._key_exchange_should_fail = False

        # Read TC parameters
        self._nap_or_pan_test = \
            str(self._tc_parameters.get_param_value("NAP_OR_PAN_TEST")).upper()
        self._pairing_initiator = \
            str(self._tc_parameters.get_param_value("PAIRING_INITIATOR")).upper()
        self._who_disconnect = \
            str(self._tc_parameters.get_param_value("WHO_DISCONNECT")).upper()
        self._who_restarts_bt = \
            str(self._tc_parameters.get_param_value("WHO_RESTARTS_BT_BEFORE_TEST")).upper()
        self._bt_tethering_deactivation_test = \
            str(self._tc_parameters.get_param_value("ENABLE_BT_TETHERING_DEACTIVATION_TEST", ""))
        self._lola_test = \
            str(self._tc_parameters.get_param_value("ENABLE_LOLA_TEST", ""))
        self._packet_count = \
            str(self._tc_parameters.get_param_value("PACKET_COUNT"))
        self._packet_size = \
            str(self._tc_parameters.get_param_value("PACKET_SIZE"))
        self._target_packet_loss_rate = \
            str(self._tc_parameters.get_param_value("TARGET_PACKET_LOSS_RATE"))

        # Server to ping
        self._server_to_ping = self._wifirouter_ip

        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
コード例 #15
0
    def set_up(self):
        """
        Initialize the test
        """
        # Call LiveBTBase set_up function
        LiveDualPhoneBTBase.set_up(self)

        # Format _discov_mode
        self._discov_mode = str(self._discov_mode).lower()

        # Format _discov_timeout
        self._discov_timeout = int(self._discov_timeout)

        if self._discov_mode not in ("on", "1", "off", "0"):
            msg = "Set wrong discov_mode. could only be on(1) or off(0)"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        return Global.SUCCESS, "No errors"
コード例 #16
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

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

        # Read CODE_PIN from test case xml file
        self._code_pin = \
            str(self._tc_parameters.get_param_value("CODE_PIN"))
        # Read PASSPHRASE from test case xml file
        self._passphrase = \
            str(self._tc_parameters.get_param_value("PASSPHRASE"))
        # Read MESSAGE from test case xml file
        self._message = \
            str(self._tc_parameters.get_param_value("MESSAGE"))
        # Read DURATION from test case xml file
        self._direction = \
            str(self._tc_parameters.get_param_value("DIRECTION")).lower()
コード例 #17
0
    def tear_down(self):
        """
        End and dispose the test
        """

        # to have a log "We enter into the tear_down"
        UseCaseBase.tear_down(self)

        # Clean the notification list
        self._receiver_api.bt_opp_clean_notification_list()
        self._sender_api.bt_opp_clean_notification_list()

        self._receiver_api.bt_opp_init(self._filename)

        # lock screen and set display OFF
        self._sender_phonesys_api.set_phone_lock(1)
        self._sender_phonesys_api.display_off()

        # Switch OFF BT at the end
        LiveDualPhoneBTBase.tear_down(self)

        return Global.SUCCESS, "No errors"
コード例 #18
0
    def run_test(self):
        """
        Execute the test
        """
        # Call UseCase base run_test function
        LiveDualPhoneBTBase.run_test(self)

        # BT Tethering Connection
        if not self._lola_test:
            connect_to_nap(self._panu_api, self._nap_api,
                           self._nap_addr, self._who_restarts_bt, self._wait_btwn_cmd)
        else:
            self._logger.info("Sleeping 60 seconds")
            time.sleep(60)

        # Check connection with ping command
        packet_loss = self._panu_net_api.ping(self._server_to_ping,
                                              self._packet_size,
                                              self._packet_count)

        msg = "Measured Packet Loss: %.0f%s (Target: %.0f%s)" \
            % (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)

        # BT Tethering Disconnection
        if not self._lola_test:
            self.__disconnect()

        return (Global.SUCCESS,
                "BT Tethering ping %s OK" % self._server_to_ping)
コード例 #19
0
    def tear_down(self):
        """
        End and dispose the test
        """
        UseCaseBase.tear_down(self)

        # Handle LOng LAsting test
        if self._lola_test:
            self.__disconnect()

        # Disable BT tethering
        self._nap_api.set_bt_tethering_power("0")

        # Bluetooth unpairing
        self._logger.info("Unpair both devices")
        self._bt_api.unpair_bt_device(self._phone2_addr)
        self._bt_api2.unpair_bt_device(self._phone1_addr)

        # Disconnect and clear WiFi networks
        LabWifiBase.tear_down_without_flightmode(self, self._wifi_api)

        LiveDualPhoneBTBase.tear_down(self)

        return Global.SUCCESS, "No errors"
コード例 #20
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveDualPhoneBTBase.set_up(self)

        # Check BT addresses validity
        if not NetworkingUtil.is_valid_mac_address(self._phone1_addr):
            msg = "Wrong MAC address for PHONE1 [%s]" % self._phone1_addr
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if not NetworkingUtil.is_valid_mac_address(self._phone2_addr):
            msg = "Wrong MAC address for PHONE2 [%s]" % self._phone2_addr
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Set sender/receiver APIs and varialbes
        if self._direction.upper() == "UL":
            self._sender_api = self._bt_api
            self._sender_add = self._phone1_addr
            self._sender_device = self._device
            self._sender_phonesys_api = self._phonesystem_api
            self._receiver_api = self._bt_api2
            self._receiver_add = self._phone2_addr
            self._receiver_device = self._phone2
            self._receiver_phonesys_api = self._phonesystem2_api
            self._fullpath_filename = self._multimedia_path1 + "/" \
                + self._filename
            self._filesize = self._phonesystem_api.\
                get_file_size(self._fullpath_filename)
        elif self._direction.upper() == "DL":
            self._sender_api = self._bt_api2
            self._sender_add = self._phone2_addr
            self._sender_device = self._phone2
            self._sender_phonesys_api = self._phonesystem2_api
            self._receiver_api = self._bt_api
            self._receiver_add = self._phone1_addr
            self._receiver_device = self._device
            self._receiver_phonesys_api = self._phonesystem_api
            self._fullpath_filename = self._multimedia_path2 + "/" \
                + self._filename
            self._filesize = self._phonesystem2_api.\
                get_file_size(self._fullpath_filename)
        else:
            msg = "Invalid DIRECTION parameter [%s]" % self._direction
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Control the existence of the file to send and get the file size \
        # in order to determine the timeout duration
        if self._filesize < 0:
            msg = "Filesize is not accessible. " \
                + "File is probably missing on TX device"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.FEATURE_NOT_AVAILABLE,
                                     msg)

        self._timeout = int(
            self._filesize / self.BT_OPP_SPEED_FOR_TIMEOUT) + 20

        # Set receiver discoverable by sender
        self._receiver_api.set_bt_discoverable("connectable", 0)
        # First Scan devices around to speed-up run_test
        self._sender_api.bt_scan_devices()

        # unlock screen and set display ON
        # Mandatory prior to use bt_opp_send_file UECmd
        self._sender_phonesys_api.display_on()
        self._sender_phonesys_api.set_phone_lock(0)

        return Global.SUCCESS, "No errors"
コード例 #21
0
    def run_test(self):
        """
        Execute the test
        """

        LiveDualPhoneBTBase.run_test(self)

        # Flush bt scanned devices list.
        # Doing so makes sure if the DUT is in the list is because it's been found now
        self._bt_api2.flush_bt_scanned_devices()

        if self._discov_mode in ("on", "1"):
            # step 1: Enable discoverable mode
            start_time = int(time.time())
            self._bt_api.set_bt_discoverable('both', self._discov_timeout)
            start_time2 = math.ceil(time.time())
            delta_time = 1

            if self._discov_timeout != 0:
                self._logger.info(
                    "Start waiting for the end of %d sec timeout" %
                    self._discov_timeout)
                # step 2: time < timeout, Check DUT is visible by 2nd phone
                while delta_time < self._discov_timeout:
                    time.sleep(1)
                    if not delta_time % 20:
                        self._logger.info(
                            "timeout in %d sec" %
                            int(self._discov_timeout - delta_time))

                    if ((not delta_time % 50)
                            and (delta_time < self._discov_timeout) and
                        (not self._bt_api2.bt_find_device(self._phone1_addr))):
                        msg = "DUT is not visible"
                        self._logger.error(msg)
                        raise DeviceException(DeviceException.OPERATION_FAILED,
                                              msg)
                    delta_time = math.ceil(time.time() - start_time)

                # step 3: time > timeout, Check DUT no more visible
                delta_time = int(time.time() - start_time2)
                while delta_time < self._discov_timeout:
                    time.sleep(1)

                    delta_time = math.ceil(time.time() - start_time2)

                # Before scanning again (and expecting not to find the device)
                # flush bt scanned devices list.
                # Doing so makes sure if the DUT is in the list is because it's been found now
                self._bt_api2.flush_bt_scanned_devices()

                if self._bt_api2.bt_find_device(self._phone1_addr):
                    msg = "DUT is still visible"
                    self._logger.error(msg)
                    raise DeviceException(DeviceException.OPERATION_FAILED,
                                          msg)
            else:
                # Set screen always on and unlock phone (Since LLP , DUT need to be unlocked to be visible)
                self._phone_system_api.set_phone_screen_lock_on("on")
                self._phone_system_api.set_phone_lock(0)

                max_time = 300
                self._logger.info("timeout is to never")
                self._logger.info("Start waiting for %d sec" % max_time)
                # timeout = 0  equals never timeout
                # step 2: time < 5min, Check DUT is visible by 2nd phone
                while int(delta_time) < max_time:
                    time.sleep(1)
                    delta_time = int(time.time() - start_time)
                    if not int(delta_time) % 20:
                        self._logger.info("end of wait = %d sec" %
                                          int(max_time - delta_time))
                    if ((not delta_time % 50) and
                        (not self._bt_api2.bt_find_device(self._phone1_addr))):
                        msg = "DUT is not visible"
                        self._logger.error(msg)
                        raise DeviceException(DeviceException.OPERATION_FAILED,
                                              msg)

                # Before scanning again (and expecting to find the device)
                # flush bt scanned devices list.
                # Doing so makes sure if the DUT is in the list is because it's been found now
                self._bt_api2.flush_bt_scanned_devices()

                # step 3: Check after 5minutes that DUT is still visible
                if not self._bt_api2.bt_find_device(self._phone1_addr):
                    msg = "DUT is not visible"
                    self._logger.error(msg)
                    raise DeviceException(DeviceException.OPERATION_FAILED,
                                          msg)

        elif self._discov_mode in ("off", "0"):
            self._bt_api.set_bt_discoverable('none', 0)

            time.sleep(self._wait_btwn_cmd)
            if self._bt_api2.bt_find_device(self._phone1_addr):
                msg = "phone in wrong discoverable mode"
                self._logger.error(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        return Global.SUCCESS, "No errors"
コード例 #22
0
    def run_test(self):
        """
        Execute the test
        """

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

        # pair two phones
        device_found = False

        # Prepare remote device to respond to pairing request
        self._bt_api2.wait_for_pairing(self._phone1_addr, 1, 1)
        time.sleep(self._wait_btwn_cmd)

        # pair two devices
        self._bt_api.pair_to_device(self._phone2_addr, 1)
        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():
                device_found = True

        if not device_found:
            msg = "Connect to device %s failed" % self._phone2_addr
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # connect and send message
        self._logger.info("Message to send is : " + self._message)
        time.sleep(self._wait_btwn_cmd)
        if self._direction == self.STR_SEND:
            self._logger.info("Start receiving msg")
            self._bt_api2.bt_receive_msg()
            time.sleep(self._wait_btwn_cmd)
            self._logger.info("Start sending msg")
            self._bt_api.bt_send_msg(self._phone2_addr, self._message)
        elif self._direction == self.STR_RECEIVE:
            self._logger.info("Start receiving msg")
            self._bt_api.bt_receive_msg()
            time.sleep(self._wait_btwn_cmd)
            self._logger.info("Start sending msg")
            self._bt_api2.bt_send_msg(self._phone1_addr, self._message)

        # check message
        time.sleep(self._wait_btwn_cmd)
        self._logger.info("Start checking msg")

        if self._direction == self.STR_SEND:
            self._bt_api2.bt_check_msg(self._message)
        else:
            self._bt_api.bt_check_msg(self._message)

        self._logger.info("Message received successfully")

        # Unpair both devices
        time.sleep(self._wait_btwn_cmd)
        self._logger.info("Unpair both devices")
        self._bt_api.unpair_bt_device(self._phone2_addr)
        self._bt_api2.unpair_bt_device(self._phone1_addr)
        time.sleep(self._wait_btwn_cmd)

        return (Global.SUCCESS,
                "Pairing to device %s success" % self._phone2_addr)
コード例 #23
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        LiveDualPhoneBTBase.__init__(self, tc_name, global_config)

        # Get device_config and phone system apis
        self._dut2_config = DeviceManager().get_device_config("PHONE2")
        self._phonesystem_api = self._device.get_uecmd("PhoneSystem")
        self._phonesystem2_api = self._phone2.get_uecmd("PhoneSystem")

        # Get mandatory TC Parameters
        self._direction = str(
            self._tc_parameters.get_param_value("DIRECTION")).upper()
        self._filename = str(self._tc_parameters.get_param_value("FILENAME"))

        # Get optional TC Parameters
        self._is_bidirectional = \
            str(self._tc_parameters.get_param_value("BOTH_DIRECTIONS", "")).lower()
        self._tp_enable = \
            str(self._tc_parameters.get_param_value("THROUGHPUT_ENABLE", "")).lower()
        self._tp_margin = \
            str(self._tc_parameters.get_param_value("ERROR_MARGIN", ""))

        # Will contain self._tp_margin value as an integer
        # If self._tp_margin is empty, by default _throughtput_margin will be 0.
        self._throughtput_margin = 0

        # Format _is_bidirectional to boolean
        self._is_bidirectional = str_to_bool_ex(self._is_bidirectional)
        if self._is_bidirectional is None:
            self._is_bidirectional = False

        # Format _tp_enable to boolean
        self._tp_enable = str_to_bool_ex(self._tp_enable)

        # Initialize sender/receiver pointers
        self._sender_api = None
        self._sender_add = None
        self._sender_device = None
        self._sender_phonesys_api = None
        self._receiver_api = None
        self._receiver_add = None
        self._receiver_device = None
        self._receiver_phonesys_api = None

        # Get the Multimedia folder name
        self._multimedia_path1 = self._device.multimedia_path
        self._multimedia_path2 = DeviceManager().get_device(
            "PHONE2").multimedia_path
        self._fullpath_filenames = ""
        self._fp_filename_other_dir = ""

        # Initialize other protected attributes
        self._timeout1 = 0
        self._timeout2 = 0

        # Split the file names and strip each of them
        self._file_list = [
            x.strip() for x in self._filename.split(self.FILE_NAME_SEPARATOR)
        ]

        # Initialize variables for average throughput calculation
        self._throughput_targets = None
        self._tp_meas = {}
        self._tp_meas_bidir = {}
コード例 #24
0
    def run_test(self):
        """
        Execute the test
        """
        LiveDualPhoneBTBase.run_test(self)

        # If necessary, remove the file on the destination device
        self._file_cleanup()

        # Clean the notification list
        self._receiver_api.bt_opp_clean_notification_list()
        self._sender_api.bt_opp_clean_notification_list()

        # Request for the First transfer to be registered
        self._sender_api.bt_opp_send_file(self._fullpath_filenames,
                                          self._receiver_add)

        # Process the bidirectional transfer
        if self._is_bidirectional:
            # Wait for the transfer start
            self._wait_for_transfer("downloading", self._receiver_api,
                                    self._sender_add, True, self._timeout1)

            # Request for the second transfer to be registered
            self._receiver_api.bt_opp_send_file(self._fp_filename_other_dir,
                                                self._sender_add)

        # Wait for the transfer First to complete
        self._wait_for_transfer("downloaded", self._receiver_api,
                                self._sender_add, False, self._timeout1)

        # Process the bidirectional transfer
        if self._is_bidirectional:
            # Wait for the second transfer to complete
            self._wait_for_transfer("downloaded", self._sender_api,
                                    self._receiver_add, False, self._timeout2)

        self._logger.info(
            "Compare files' checksum on RX phone with the sent ones")
        self._check_files_checksum(
            self._sender_api, self._multimedia_path1, self._receiver_api,
            "Received files on RX phone are different from Sent ones"
            " (or don't exist)")

        if self._is_bidirectional in ["1", "yes", "true"]:
            self._logger.info(
                "Compare files' checksum on TX phone with the sent ones")
            self._check_files_checksum(
                self._receiver_api, self._multimedia_path2, self._sender_api,
                "Received files on TX phone are different from Sent ones"
                " (or don't exist)")

        # Throughput measurement
        if self._tp_enable:
            # Compare average throughput with Threshold
            self._compare_tp_threshold()
            # Reset self._tp_meas value in case of multiple b2bIteration.
            self._reset_tp_meas(self._file_list, self._direction,
                                self._is_bidirectional)

        return Global.SUCCESS, "No errors"
コード例 #25
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveDualPhoneBTBase.set_up(self)

        # Check BT addresses validity
        if not NetworkingUtil.is_valid_mac_address(self._phone1_addr):
            msg = "Wrong MAC address for PHONE1 [%s]" % self._phone1_addr
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if not NetworkingUtil.is_valid_mac_address(self._phone2_addr):
            msg = "Wrong MAC address for PHONE2 [%s]" % self._phone2_addr
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Set sender/receiver APIs and variables
        if self._direction == self.UPLOAD:
            self._sender_api = self._bt_api
            self._sender_add = self._phone1_addr
            self._sender_device = self._device
            self._sender_phonesys_api = self._phonesystem_api
            self._receiver_api = self._bt_api2
            self._receiver_add = self._phone2_addr
            self._receiver_device = self._phone2
            self._receiver_phonesys_api = self._phonesystem2_api
            (self._fullpath_filenames, expected_size1) = self \
                ._process_files(self._multimedia_path1, self._file_list, False)

            (self._fp_filename_other_dir, expected_size2) = self \
                ._process_files(self._multimedia_path2, self._file_list, True)
        elif self._direction == self.DOWNLOAD:
            self._sender_api = self._bt_api2
            self._sender_add = self._phone2_addr
            self._sender_device = self._phone2
            self._sender_phonesys_api = self._phonesystem2_api
            self._receiver_api = self._bt_api
            self._receiver_add = self._phone1_addr
            self._receiver_device = self._device
            self._receiver_phonesys_api = self._phonesystem_api
            (self._fullpath_filenames, expected_size1) = self \
                ._process_files(self._multimedia_path2, self._file_list, False)

            (self._fp_filename_other_dir, expected_size2) = self \
                ._process_files(self._multimedia_path1, self._file_list, True)
        else:
            msg = "Invalid DIRECTION parameter [%s]" % self._direction
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        if expected_size1 != expected_size2:
            # same files, hence must have same size!!
            msg = "Files size are supposed to be the same!!"
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        self._timeout1 = int(
            expected_size1 / self.BT_OPP_SPEED_FOR_TIMEOUT) + 20
        self._timeout2 = int(
            expected_size2 / self.BT_OPP_SPEED_FOR_TIMEOUT) + 20

        # Set receiver discoverable by sender
        self._receiver_api.set_bt_discoverable("connectable", 0)
        # First Scan devices around to speed-up run_test
        self._sender_api.bt_scan_devices()

        # unlock screen and set display ON
        # Mandatory prior to use bt_opp_send_file UECmd
        self._sender_phonesys_api.display_on()
        self._sender_phonesys_api.set_phone_lock(0)

        # Process the bidirectional transfer
        if self._is_bidirectional:
            # Set sender discoverable by receiver
            self._sender_api.set_bt_discoverable("connectable", 0)
            self._receiver_api.bt_scan_devices()
            self._receiver_phonesys_api.display_on()
            self._receiver_phonesys_api.set_phone_lock(0)

        # Check throughput data validity
        if self._tp_enable:
            msg = "Throughput measurement is enabled"
            self._logger.info(msg)
            # Read the throughput targets
            self._throughput_targets = ConfigsParser("BT_Throughput_Targets").\
                parse_bt_targets(self._device.get_phone_model(), "OPP")

            # Verify validity of margin parameter
            if self._tp_margin.isdigit():
                self._throughtput_margin = int(self._tp_margin)
            else:
                msg = "ERROR_MARGIN parameter is not valid: <%s>" % self._tp_margin
                self._logger.error(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

            # Initialize Average tp measure
            self._reset_tp_meas(self._file_list, self._direction,
                                self._is_bidirectional)

        return Global.SUCCESS, "No errors"
コード例 #26
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveDualPhoneBTBase.set_up(self)
        UECmdTestTool.set_up(self, self.tc_order)

        """
        List of tests to perform. Each test is described as followed:
        [Label to print in the secondary report,
         UECmd to test,
         parameter(s) for the UECmd to test,
         Depends on the test names in the list]
        """
        bt_api = self._bt_api
        self._fcts2test = [
            {self._FCT: bt_api.get_bt_adapter_address},
            {self._FCT: bt_api.get_bt_power_status},
            {self._NAME: "set_bt_power OFF", self._FCT: bt_api.set_bt_power, self._PARMS: ["off"]},
            {self._NAME: "set_bt_power ON", self._FCT: bt_api.set_bt_power, self._PARMS: ["on"]},
            {self._FCT: bt_api.get_bt_scan_mode},
            {self._FCT: bt_api.bt_reset_device},
            {self._FCT: bt_api.bt_scan_devices},
            {self._NAME: "wait_for_pairing_canceled", self._FCT: self.__wait_for_pairing_canceled},
            {self._FCT: bt_api.set_bt_discoverable, self._PARMS: ["both", 120]},
            {self._NAME: "bt_find_device", self._FCT: self.__find_device},
            {self._NAME: "pair_to_device", self._FCT: self.__pair_device},
            {self._NAME: "bt_send_msg", self._FCT: self.__send_message, self._PARMS: [self.__MSG]},
            {self._NAME: "bt_receive_msg", self._FCT: self.__receive_message, self._PARMS: [self.__MSG]},
            {self._FCT: bt_api.bt_check_msg, self._PARMS: [self.__MSG]},
            {self._FCT: bt_api.bt_service_browsing, self._PARMS: [self._phone2_addr]},
            {self._NAME: "unpair_bt_device", self._FCT: self.__unpair_bt_device},
            {self._NAME: "wait_for_pairing", self._FCT: self.__wait_for_pairing},
            {self._FCT: bt_api.list_paired_device, self._DEP: ["wait_for_pairing"]},
            # {self._FCT: bt_api.bt_l2cap_ping, self._PARMS: [self._phone2_addr]},
            {self._FCT: bt_api.set_bt_tethering_power, self._PARMS: ["on"]},
            {self._FCT: bt_api.connect_bt_device, self._PARMS: [self._phone2_addr, BtProfile.PAN]},
            {self._FCT: bt_api.get_bt_connection_state, self._PARMS: [self._phone2_addr, BtProfile.HSP]},
            {self._FCT: bt_api.disconnect_bt_device, self._PARMS: [self._phone2_addr, BtProfile.PAN]},
            {self._NAME: "unpair_bt_device final", self._FCT: self.__unpair_bt_device}
        ]

        # UECmd to add later
        # ------------------
        # bt_opp_init
        # bt_opp_send_file
        # bt_opp_receive_file
        # connect_bt_hid_device
        # get_bt_audio_state

        # Not used EUCmd
        # --------------
        # set_agent_property
        # set_bt_authentication
        # set_bt_scanning
        # get_bt_autoconnect_status
        # set_bt_autoconnect
        # set_bt_pairable
        # get_bt_pairable_status
        # get_bt_pairable_timeout

        # set_bt_ctrl_event_mask
        # set_bt_ctrl_event_filter
        # activate_bt_test_mode
        # set_bt_default_link_policy

        return Global.SUCCESS, "No errors"