Esempio n. 1
0
    def run_test(self):
        """
        Execute the test
        """

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

        time.sleep(self._wait_btwn_cmd)

        # begin bluetooth turn on off sequence
        self._logger.info("bluetooth turn on off sequence is :" +
                          self._turn_bluetooth_sequence)
        time.sleep(self._wait_btwn_cmd)

        seqlist = self._turn_bluetooth_sequence.strip().split()
        for switch in seqlist:
            if switch.lower() in ("on", "1", 1):
                self._logger.info("try to turn on bluetooth")
                self._bt_api.set_bt_power("1")
                time.sleep(self._wait_btwn_cmd)
            elif switch.lower() in ("off", "0", 0):
                self._logger.info("try to turn off bluetooth ")
                self._bt_api.set_bt_power("0")
                time.sleep(self._wait_btwn_cmd)
            else:
                self._error.Code = Global.FAILURE
                self._error.Msg = \
                    "input wrong sequence , failed ." \
                    + "alter your sequence in test case xml file"

        return self._error.Code, self._error.Msg
Esempio n. 2
0
    def set_up(self):
        """
        Initialize the test
        """
        LabWifiIperf.set_up(self)
        LiveBTBase.set_up(self)

        # Check values
        if self._bt_play_music is not None and self._bt_play_music not in [
                "on", "off"
        ]:
            msg = "Bad value for BT_PLAY_MUSIC : %s" % self._bt_play_music
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Setup DUT for KPI TC
        LabWifiKPIBase.set_up(self)

        if self._bt_play_music == "on":
            LiveBTBase.set_up(self)
            # Configure Headset and launch audio
            self._bt_headset = self._em.get_bluetooth_headset("BT_HEADSET")
            self._bt_headset_addr = self._bt_headset.get_bdaddress()
            a2dp_pair_connect_to_headset(self._bt_api, self._bt_headset)
            a2dp_switch_music_state(self._bt_api, self._bt_headset,
                                    BtAudioCmd.PLAY)

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

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

        start = time.time()
        while (start + self._duration) > time.time():
            self._bt_api.set_bt_power(1)
            time.sleep(self._wait_btwn_cmd)
            self._check_bt_wifi_state(str(BT_STATE.STATE_ON), 0)

            self._networking_api.set_wifi_power(1)
            time.sleep(self._wait_btwn_cmd)
            self._check_bt_wifi_state(str(BT_STATE.STATE_ON), 1)

            self._bt_api.set_bt_power(0)
            time.sleep(self._wait_btwn_cmd)
            self._check_bt_wifi_state(str(BT_STATE.STATE_OFF), 1)

            self._networking_api.set_wifi_power(0)
            time.sleep(self._wait_btwn_cmd)
            self._check_bt_wifi_state(str(BT_STATE.STATE_OFF), 0)

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

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

        # Switch flight mode
        self._networking_api.set_flight_mode(1)
        time.sleep(
            LabBTAndWiFiReconnectionAfterFlightMode.WAIT_TIME_IN_FLIGHT_MODE)
        self._networking_api.set_flight_mode(0)
        time.sleep(LabBTAndWiFiReconnectionAfterFlightMode.
                   WAIT_BT_WIFI_AUTO_RECONNECTION)

        # Check BT connection
        bt_state = self._bt_api.get_bt_connection_state(
            self._bt_headset.get_bdaddress(), BtProfile.A2DP)
        if bt_state != BtConState.d[BtConState.CONNECTED]:
            msg = "Error BT reconnection - State %s" % str(bt_state)
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # Check WiFi connection
        packet_loss = self._networking_api.ping(self._wifi_ip, 16, 16)
        if packet_loss.value > LabBTAndWiFiReconnectionAfterFlightMode.MAX_PING_PACKET_LOST:
            msg = "Error WiFi reconnection - Ping %s fail with %s lost" % self._wifi_ip % packet_loss
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

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

        LiveBTBase.__init__(self, tc_name, global_config)

        # Get PHONE2
        self._phone2 = DeviceManager().get_device(self.STR_PHONE_2)

        # Check if we have the second phone available
        if self._phone2 is not None:
            if not self._phone2.is_available():
                DeviceManager().boot_device(self.STR_PHONE_2)
            self._bt_api2 = self._phone2.get_uecmd("LocalConnectivity")

            # Get PHONE2 networking interface
            self._networking_api2 = self._phone2.get_uecmd("Networking")

            # Get BT device parameters
            self._dut2_config = DeviceManager().get_device_config(self.STR_PHONE_2)

        self._phone_system_api = self._device.get_uecmd("PhoneSystem")

        # Initialize phones address
        self._phone1_addr = ""
        self._phone2_addr = ""

        self._original_flight_mode2 = 0
    def set_up(self):
        """
        Initialize the test
        """
        LiveBTBase.set_up(self)

        if self._phone2 is None:
            msg = "PHONE2 is not specified in the bench configuration"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, msg)

        # Get original phone mode
        self._original_flight_mode2 = self._networking_api2.get_flight_mode()
        # Flight mode
        if self._use_flightmode != self._original_flight_mode2:
            self._networking_api2.set_flight_mode(self._use_flightmode)

        self._logger.info("Reset phone Bluetooth adapter")
        self._bt_api2.bt_reset_device()

        # Get phones address
        self._phone1_addr = self._bt_api.get_bt_adapter_address()
        self._phone2_addr = self._bt_api2.get_bt_adapter_address()

        return Global.SUCCESS, "No errors"
Esempio n. 7
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

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

        # Get TestCase parameters
        # Read TURN_APM_SEQUENCE from test case xml file
        self._turn_apm_sequence = \
            str(self._tc_parameters.get_param_value("TURN_APM_SEQUENCE"))

        # Read BT_INIT_MODE from test case xml file
        self._bt_mode = \
            str(self._tc_parameters.get_param_value("BT_INIT_MODE"))
        if self._bt_mode is None:
            self._bt_mode = "on"

        # Read BT_GETMODE_TIMEOUT from test case xml file
        self._bt_getmode_timeout = \
            self._tc_parameters.get_param_value("BT_GETMODE_TIMEOUT")
        if self._bt_getmode_timeout is None \
           or not str(self._bt_getmode_timeout).isdigit():
            self._bt_getmode_timeout = int(self._device._uecmd_default_timeout)  # pylint: disable=W0212
        else:
            self._bt_getmode_timeout = int(self._bt_getmode_timeout)

        # get original bt mode
        self._original_bt_mode = self._bt_api.get_bt_power_status_eot()

        # local variable: BT power state when Airplane mode is disabled
        self._initial_bt_state = self._original_bt_mode
Esempio n. 8
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LiveBTBase init function
        LiveBTBase.__init__(self, tc_name, global_config)
        LiveWifiBase.__init__(self, tc_name, global_config)

        self._audio_file = str(self._tc_parameters.get_param_value("AUDIO_FILE"))
        self._duration = str(self._tc_parameters.get_param_value("DURATION"))
        self._a2dp_activity = str(self._tc_parameters.get_param_value("A2DP_ACTIVITY")).upper()
        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"))
        elif self._wifi_activity == "WIFI_FTP_DOWNLOAD":
            self._ftp_remote_file = str(self._tc_parameters.get_param_value("FTP_REMOTE_FILE"))
            self._timeout = 300

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

        self._thread_wifi_activity = None
        self._thread_a2dp_activity = None
        self._queue = Queue.Queue()
    def set_up(self):
        """
        Initialize the test
        """
        LiveBTBase.set_up(self)

        self._bt_headset_addr = self._bt_headset.get_bdaddress()

        if self._ref_bt_addr.lower() in ["none", ""] and self._bench_config is not None:
            self._ref_bt_addr = str(self._bench_config.get_param_value("MacAddress"), "")

        if self._ref_bt_addr.lower() in ["none", "", "00:00:00:00:00:00"]:
            msg = "No BD address found in the TC and/or in bench_config"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, msg)

        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)

        # Configure 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"
Esempio n. 10
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LiveBTBase init function
        LiveBTBase.__init__(self, tc_name, global_config)

        # Read CONNECT_INITIATOR from test case xml file
        self._connector = \
            str(self._tc_parameters.get_param_value("CONNECT_INITIATOR"))
        # Read MUSIC_CONTROL_SEQUENCE from test case xml file
        audiocmd_list = \
            str(self._tc_parameters.get_param_value("MUSIC_CONTROL_SEQUENCE"))
        # Read DURATION from test case xml file
        self._duration = \
            int(self._tc_parameters.get_param_value("DURATION"))

        # Name of the MP3 file to play
        self._file_name = str(
            self._tc_parameters.get_param_value("FILE_TO_PLAY"))

        # Split to create a list of audio command
        self._audiocmd_list = audiocmd_list.strip().split(",")

        # BT headset
        self._bt_headset = None

        # BD address of Headset
        self._hsaddr = ""
Esempio n. 11
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

        LiveBTBase.__init__(self, tc_name, global_config)

        # Get TC Parameters

        # Read DEVICE_BT_ADDRESS from test case xml file or BenchConfig
        self._device_to_search = \
            str(self._tc_parameters.get_param_value("DEVICE_TO_SEARCH"))
        if self._device_to_search.lower() in ["none", ""]:
            # Then search for the BT MAC address into the BenchConfig
            bench_bt_device = global_config.benchConfig\
                .get_parameters("BT_DEVICE")
            if bench_bt_device is not None:
                if str(bench_bt_device.get_param_value("MacAddress")).lower()\
                        not in ["none", "", "00:00:00:00:00:00"]:
                    self._device_to_search = str(
                        bench_bt_device.get_param_value("MacAddress"))
                else:
                    msg = "No BD addr defined in the TC and/or in bench_config"
                    self._logger.error(msg)
                    raise AcsConfigException(
                        AcsConfigException.INVALID_PARAMETER, msg)
            else:
                msg = "No BD address defined in the TC and/or in bench_config"
                self._logger.error(msg)
                raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                         msg)
Esempio n. 12
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.
        """
        LiveBTBase.run_test(self)

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

        #turn airplane mode ON
        self._networking_api.set_flight_mode(1)
        time.sleep(BluetoothPanAirplane.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._bt_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._bt_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._networking_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 airplane mode OFF
        self._networking_api.set_flight_mode(0)
        time.sleep(BluetoothPanAirplane.WAIT_TIME_IN_FLIGHT_MODE)

        #check BT, BT Tethering and Wifi are reactivated
        #check BT status is ON
        time.sleep(self._wait_btwn_cmd)
         #locally initialize phone for PAN - turn tethering ON
        self._bt_api.set_bt_tethering_power("on")

        bt_power_air_off = self._bt_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._bt_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._networking_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)

        return Global.SUCCESS, "Usecase successful"
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LiveBTBase init function
        LiveBTBase.__init__(self, tc_name, global_config)
        LiveWifiBase.__init__(self, tc_name, global_config)

        self._wifi_ip = self._wifirouter.get_param_value("IP")
        self._bt_headset = self._em.get_bluetooth_headset("BT_HEADSET")
Esempio n. 14
0
    def run_test(self):
        """
        Execute the test
        """

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

        # Configure threads
        if self._wifi_activity == "WIFI_WEB_BROWSING":
            self._thread_wifi_activity = ThreadWebBrowsing(self._queue,
                                                           self._networking_api,
                                                           self._duration,
                                                           self._wifi_url)
        elif self._wifi_activity == "WIFI_FTP_DOWNLOAD":
            self._thread_wifi_activity = ThreadDownloadFileFromFTP(self._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()), self._timeout)
        else:
            msg = "Unknown WIFI_ACTIVITY : %s" % self._wifi_activity
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        if self._a2dp_activity == "A2DP_CHECK_AUDIO":
            self._thread_a2dp_activity = ThreadA2DPCheckMusic(self._queue,
                                                              BtAudioState.PLAYING, self._duration,
                                                              self._bt_api, self._bt_headset_addr)
        elif self._a2dp_activity == "A2DP_SWITCH_VOLUME":
            self._thread_a2dp_activity = ThreadA2DPSwitchVolume(self._queue,
                                                                self._duration,
                                                                self._bt_api, self._bt_headset)
        elif self._a2dp_activity == "A2DP_SWITCH_SONG":
            self._thread_a2dp_activity = ThreadA2DPSwitchSong(self._queue,
                                                              self._duration,
                                                              self._bt_api, self._bt_headset)
        elif self._a2dp_activity == "A2DP_SWITCH_PLAYING":
            self._thread_a2dp_activity = ThreadA2DPSwitchPlaying(self._queue, BtAudioState.PLAYING,
                                                                 self._duration, 1.0,
                                                                 self._bt_api, self._bt_headset)
        else:
            msg = "Unknown A2DP_ACTIVITY : %s" % self._a2dp_activity
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Launch threads
        self._thread_wifi_activity.start()
        self._thread_a2dp_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, self._thread_a2dp_activity])

        return Global.SUCCESS, "No errors"
Esempio n. 15
0
    def set_up(self):
        """
        Initialize the test
        """

        LiveBTBase.set_up(self)

        #locally initialize phone for PAN - turn tethering ON
        self._bt_api.set_bt_tethering_power("on")
        result, output = Global.SUCCESS, ""
        return result, output
Esempio n. 16
0
    def tear_down(self):

        # Disconnect and clear WiFi networks
        if self._connection_to_share == "WIFI":
            self._networking_api.wifi_remove_config("all")
            self._networking_api.set_wifi_power("off")

        LiveBTBase.tear_down(self)

        result, output = Global.SUCCESS, ""
        return result, output
Esempio n. 17
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

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

        # Read TURN_BLUETOOTH_SEQUENCE from test case xml file
        self._turn_bluetooth_sequence = \
            str(self._tc_parameters.get_param_value("TURN_BLUETOOTH_SEQUENCE"))
    def set_up(self):
        """
        Initialize the test
        """
        LiveBTBase.set_up(self)
        LiveWifiBase.set_up(self)

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

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

        self._duration = str(self._tc_parameters.get_param_value("DURATION"))

        self._thread_bt_switch = None
        self._thread_wifi_switch = None
        self._queue = Queue.Queue()
    def tear_down(self):
        """
        Finish the test and clear environment
        """

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

        # Disable WiFi
        self._networking_api.set_wifi_power(0)

        return Global.SUCCESS, "No errors"
Esempio n. 21
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        LiveBTBase.__init__(self, tc_name, global_config)

        #Get TC parameters
        self._wifi_access_point = str(self._tc_parameters.get_param_value("WIFI_ACCESS_POINT", ""))
        self._connection_to_share = "WIFI"
        self.__global_config = global_config
        # Initialize data
        self._wait_btwn_cmd = 5.0
        self._bluetooth_connectivity_obj = BluetoothConnectivity(self._device, self._wait_btwn_cmd)
Esempio n. 22
0
    def tear_down(self):
        """
        End and dispose the test
        """
        self._bt_api.unpair_bt_device(self._hsaddr)

        LiveBTBase.tear_down(self)

        time.sleep(self._wait_btwn_cmd)

        # Power off headset
        self._bt_headset.set_power(False)

        return Global.SUCCESS, "No errors"
Esempio n. 23
0
    def run_test(self):
        """
        Execute the test
        """

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

        time.sleep(self._wait_btwn_cmd)

        # begin APM turn on off sequence
        self._logger.info("Airplane mode sequence is :" +
                          self._turn_apm_sequence)
        time.sleep(self._wait_btwn_cmd)

        self._turn_apm_sequence = self._turn_apm_sequence.lower()
        seqlist = self._turn_apm_sequence.strip().split()
        # pylint: disable=E1101
        for switch in seqlist:
            if switch.lower() in ("flight", "on", "1"):
                self._logger.info("try to set airplane mode to flight mode")
                self._networking_api.set_flight_mode(1)
                # CHeck BT is switched off
                if not self._bt_api.bt_power_state_reached(
                        str(BT_STATE.STATE_OFF), self._bt_getmode_timeout):
                    msg = "set BT OFF failure"
                    self._logger.error(msg)
                    raise DeviceException(DeviceException.OPERATION_FAILED,
                                          msg)

            elif switch.lower() in ("normal", "off", "0"):
                self._logger.info("try to set airplane mode to normal mode")
                self._networking_api.set_flight_mode(0)
                # CHeck BT is coming back to power state before flight mode
                if not self._bt_api.bt_power_state_reached(
                        self._initial_bt_state, self._bt_getmode_timeout):
                    msg = "switch BT back to previous state failure"
                    self._logger.error(msg)
                    raise DeviceException(DeviceException.OPERATION_FAILED,
                                          msg)

            else:
                msg = "input wrong sequence, failed. " \
                    + "Alter your sequence in test case xml file"
                self._logger.error(msg)
                raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                         msg)

        return Global.SUCCESS, "No errors"
Esempio n. 24
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

        LabWifiIperf.__init__(self, tc_name, global_config)
        LiveBTBase.__init__(self, tc_name, global_config)
        LabWifiKPIBase.__init__(self, tc_name, global_config)

        self._bt_play_music = self._tc_parameters.get_param_value(
            "BT_PLAY_MUSIC")
        self._bt_headset = None
        self._bt_headset_addr = None
        self._thread_headset_check_music = None
        self._queue = Queue.Queue()
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LiveBTBase init function
        LiveBTBase.__init__(self, tc_name, global_config)

        self._ref_bt_addr = str(self._tc_parameters.get_param_value("REF_BT_ADDR"))
        self._duration = str(self._tc_parameters.get_param_value("DURATION"))

        self._bench_config = global_config.benchConfig.get_parameters("BT_DEVICE")
        self._bt_headset = self._em.get_bluetooth_headset("BT_HEADSET")
        self._bt_headset_addr = None
        self._thread_bt_scan = None
        self._thread_headset_check_music = None
        self._queue = Queue.Queue()
    def set_up(self):
        """
        Initialize the test
        """
        LiveBTBase.set_up(self)

        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)

        self._networking_api.set_wifi_power(0)
        self._bt_api.set_bt_power(0)

        return Global.SUCCESS, "No errors"
Esempio n. 27
0
    def tear_down(self):
        """
        End and dispose the test
        """
        LiveBTBase.tear_down(self)

        time.sleep(self._wait_btwn_cmd)

        self._logger.info("Set original BT mode: " +
                          str(self._original_bt_mode))
        self._bt_api.set_bt_power(self._original_bt_mode)
        if self._original_bt_mode != self._bt_api.get_bt_power_status_eot():
            msg = "Set BT original mode failure"
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        return Global.SUCCESS, "No errors"
Esempio n. 28
0
    def set_up(self):
        """
        Initialize the test
        """

        LiveBTBase.set_up(self)

        # set flight mode
        self._logger.info("set Device to normal mode")
        if self._networking_api.get_flight_mode():
            self._networking_api.set_flight_mode(0)
            time.sleep(self._wait_btwn_cmd)
            if self._networking_api.get_flight_mode():
                msg = "set to normal mode failure"
                self._logger.error(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # pylint: disable=E1101
        # set BT mode
        if self._bt_mode.strip().lower() in ("on", "1"):
            # Already Powered On in LiveBTBase
            # Store BT power state
            self._initial_bt_state = self._bt_api.get_bt_power_status_eot()
            if self._initial_bt_state != str(BT_STATE.STATE_ON):
                msg = "set BT ON failure"
                self._logger.error(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        elif self._bt_mode.strip().lower() in ("off", "0"):
            self._logger.info("set BT mode to OFF")
            self._bt_api.set_bt_power("0")
            # Store BT power state
            self._initial_bt_state = self._bt_api.get_bt_power_status_eot()
            if self._initial_bt_state != str(BT_STATE.STATE_OFF):
                msg = "set BT OFF failure"
                self._logger.error(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        else:
            self._logger.info("Set wrong BT init mode")
            msg = "set wrong BT init mode, failed . alter bt_init_mode in "\
                + "test case xml file"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        return Global.SUCCESS, "No errors"
    def tear_down(self):
        """
        End and dispose the test
        """
        LiveBTBase.tear_down(self)

        time.sleep(self._wait_btwn_cmd)

        # Recover to initial flight mode
        self._logger.info("Set PHONE2 to original flight mode")
        self._networking_api2.set_flight_mode(self._original_flight_mode2)
        time.sleep(self._wait_btwn_cmd)

        self._logger.info("Close phone 2 adapter devices")
        self._bt_api2.set_bt_power("off")
        time.sleep(self._wait_btwn_cmd)

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

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

        self._connect_profile()
        self._raise_error_if_already_playing()
        self._start_media_player()

        try:
            self._do_run_test()
        finally:
            self._bt_api.stop_a2dp_media_player()
            self._disconnect_profile()

        return Global.SUCCESS, "No errors"