Example #1
0
    def run(self, context):
        """
        Display an image given in parameter on host screen using Tkinter
        """
        TestStepBase.run(self, context)

        host_screen = Util.str_to_bool(
            DeviceManager().get_device_config("PHONE1").get(
                "DisplayScreenAvailable", "False"))
        if host_screen is not None and host_screen:
            # On windows, Tk main window must be instanciated here, otherwise
            # an exception will be raise.
            if platform.system() == "Windows":
                self.__root = Tkinter.Tk()
                self.__root.attributes("-fullscreen", True)

            wthread = Thread(target=self.__start_tk_thread)
            wthread.start()

            wthread.join(0.2)
            while not self.__root.attributes("-fullscreen"):
                wthread.join(0.1)

            self._logger.debug("Tk main window loaded")
            wimgthread = Thread(target=self.__show_tk_img)
            wimgthread.start()

            context.set_info("DisplayImageOnHost_Event", self.__event)
        else:
            self._logger.info(
                "Host screen not available, nothing will be displayed")
Example #2
0
    def init(self):
        """
        Initializes the equipment. The equipment is ready to use.
            - Load equipment driver
            - Connection to the equipment is established
            - Show equipment informations
            - Reset equipment
        """
        self.get_logger().info("Initialization")
        # Loads the driver
        self.load_driver()

        serial_number = self.get_bench_params().get_param_value(
            "serialNumber", "")
        if serial_number not in [None, ""]:
            serial_number = int(
                self.get_bench_params().get_param_value("serialNumber"))

        # get if we use external power supply as charger
        self._use_ext_ps = self.get_bench_params().get_param_value(
            "ExtPowerSupplyAsCharger", False)
        if type(self._use_ext_ps) is str:
            self._use_ext_ps = Util.str_to_bool(self._use_ext_ps)

        # Tries to connect to equipment
        self.__device_index = W.Connect(self, serial_number)
        if self.__device_index == -1:
            raise TestEquipmentException(
                TestEquipmentException.CONNECTION_ERROR,
                "Failed to connect to %s" % self.get_name())
        W.ShowInfo(self)
        W.Reset(self)
        self.battery_connector(False, self.BAT_INVALID)
Example #3
0
    def convert_parameter_value(self,
                                tc_param_value,
                                tc_param_name,
                                default_cast_type=str):
        """
        convert value according to a cast type

        This function returns the value of a parameter.

        :type tc_param_value: string
        :param tc_param_value: value to convert

        :type default_cast_type: type object
        :param default_cast_type: type to cast (int, str, list ...)
        By default cast into str type.

        :rtype: depends on default_cast_type
        :return: test case parameter value
        """
        if default_cast_type == "str_to_bool":
            if Utils.is_bool(str(tc_param_value)):
                tc_param_value = Utils.str_to_bool(str(tc_param_value))
            else:
                self._logger.warning(
                    "%s='%s', invalid value in campaign for test %s" %
                    (tc_param_name, tc_param_value, self._name))
                tc_param_value = None
        elif default_cast_type is int or default_cast_type is float:
            if Utils.is_number(str(tc_param_value)):
                tc_param_value = default_cast_type(str(tc_param_value))
            else:
                tc_param_value = None
        else:
            tc_param_value = default_cast_type(tc_param_value)
        return tc_param_value
Example #4
0
    def run(self, context):
        """
        Close image Tkinter viewer
        """
        TestStepBase.run(self, context)

        host_screen = Util.str_to_bool(
            DeviceManager().get_device_config("PHONE1").get(
                "DisplayScreenAvailable", "False"))
        if host_screen is not None and host_screen:
            event = context.get_info("DisplayImageOnHost_Event")
            event.set()
        else:
            self._logger.info(
                "Host screen not available, nothing will be closed")
Example #5
0
    def run(self, context):
        """
        Generic method to run MediaPlayer test steps
        """
        TestStepBase.run(self, context)

        host_screen = Util.str_to_bool(
            DeviceManager().get_device_config("PHONE1").get(
                "DisplayScreenAvailable", "False"))
        if host_screen is not None and host_screen:
            from acs_test_scripts.Lib.EM.VideoPlayback import MediaPlayer as MediaPlayer

            self._media_player = context.get_info(self._pars.instance_name)
            if self._media_player is None:
                self._media_player = MediaPlayer()
                context.set_info(self._pars.instance_name, self._media_player)

            self._run()
        else:
            self._logger.info(
                "Host screen not available, nothing will be displayed")
Example #6
0
    def __is_stock_msg_app_running(self):
        """
        Checks id the stock messaging application is running.
        :rtype: boolean
        :return: True if the application is running False otherwise.
        """
        result_key = "isMessagingAppRunning"

        self._logger.info("Check if stock messaging is running.")

        function = "checkIfMmsStockAppIsRunning"

        output = self._internal_exec_v2(self._mms_module,
                                        function,
                                        is_system=True)

        if result_key not in output:
            raise AcsToolException(
                AcsToolException.INVALID_PARAMETER,
                "output key %s not found : %s" % (result_key, str(output)))
        # Convert result to bool.
        result = Util.str_to_bool(output[result_key])
        return result
Example #7
0
    def parse_action_node(self, action_node):
        """
        Returns a C{dictionnary} containing all relevant data from the
        given C{action_node} parameter.

        The returned dictionnary contains the following elements:
            - command
            - parameters
            - timeout
            - triglog
            - iteration

        :type action_node: NodeList
        :param action_node: the XML node

        :rtype: dictionnary
        :return: the data from the given XML node
        """
        action = {}
        # Get the action name
        action["command"] = None
        nodes_cmd = action_node.xpath("./CMD")
        if nodes_cmd:
            action_name = self.__get_text(nodes_cmd)
            action["command"] = str(action_name).strip()
        else:
            raise AcsConfigException(
                AcsConfigException.XML_PARSING_ERROR,
                "Did not find the CMD node of "
                "the action, check your script")

        # Get the action parameters
        action["parameters"] = None
        nodes_param = action_node.xpath("./PARAMETERS")
        if nodes_param:
            parameters = self.__get_text(nodes_param)
            action["parameters"] = parameters.split(';')

        # Get the timeout
        action["timeout"] = None
        nodes_timeout = action_node.xpath("./TIMEOUT")
        if nodes_timeout:
            timeout = self.__get_text(nodes_timeout)
            action["timeout"] = str(timeout).strip()

        # Get the trigger tag
        action["triglog"] = None
        nodes_triglog = action_node.xpath("./TRIG_LOG")
        if nodes_triglog:
            triglog = self.__get_text(nodes_triglog)
            action["triglog"] = str(triglog).strip()

        # Get the log tag
        action["log"] = None
        nodes_log = action_node.xpath("./LOG")
        if nodes_log:
            log = self.__get_text(nodes_log)
            action["log"] = str(log).strip()

        # Get the iteration count
        action["iteration"] = None
        nodes_iterations = action_node.xpath("./ITERATION")
        if nodes_iterations:
            iteration = self.__get_text(nodes_iterations)
            action["iteration"] = str(iteration).strip()

        # Get the stop iteration on success parameter
        action["stop_iteration_on_success"] = False
        nodes_stop_iter_on_1st_success = action_node.xpath("./STOP_ITER_ON_FIRST_SUCCESS")
        if nodes_stop_iter_on_1st_success:
            stop_iteration_on_success = self.__get_text(nodes_stop_iter_on_1st_success)
            action["stop_iteration_on_success"] = Utils.str_to_bool(str(stop_iteration_on_success).strip())

        return action