Exemple #1
0
    def create(preferred_backend=''):
        """Get an instance of the :py:class:`Touch` class.

        :param preferred_backend: A string containing a hint as to which
            backend you would like. If left blank, autopilot will pick a
            suitable backend for you. Specifying a backend will guarantee that
            either that backend is returned, or an exception is raised.

            possible backends are:

            * ``UInput`` - Use UInput kernel-level device driver.

        :raises: RuntimeError if autopilot cannot instantate any of the
            possible backends.
        :raises: RuntimeError if the preferred_backend is specified and is not
            one of the possible backends for this device class.
        :raises: :class:`~autopilot.BackendException` if the preferred_backend
            is set, but that backend could not be instantiated.

        """
        def get_uinput_touch():
            from autopilot.input._uinput import Touch
            return Touch()

        backends = OrderedDict()
        backends['UInput'] = get_uinput_touch
        return _pick_backend(backends, preferred_backend)
Exemple #2
0
    def create(preferred_backend=""):
        """Get an instance of the :py:class:`ProcessManager` class.

        For more infomration on picking specific backends, see
        :ref:`tut-picking-backends`

        :param preferred_backend: A string containing a hint as to which
            backend you would like. Possible backends are:

            * ``BAMF`` - Get process information using the BAMF Application
                Matching Framework.

        :raises: RuntimeError if autopilot cannot instantate any of the
            possible backends.
        :raises: RuntimeError if the preferred_backend is specified and is not
            one of the possible backends for this device class.
        :raises: :class:`~autopilot.BackendException` if the preferred_backend
            is set, but that backend could not be instantiated.

        """
        def get_bamf_pm():
            from autopilot.process._bamf import ProcessManager
            return ProcessManager()

        backends = OrderedDict()
        backends['BAMF'] = get_bamf_pm
        return _pick_backend(backends, preferred_backend)
Exemple #3
0
    def create(preferred_backend=''):
        """Get an instance of the :py:class:`Mouse` class.

        For more infomration on picking specific backends, see
        :ref:`tut-picking-backends`

        :param preferred_backend: A string containing a hint as to which
            backend you would like. Possible backends are:

            * ``X11`` - Generate mouse events using the X11 client libraries.

        :raises: RuntimeError if autopilot cannot instantate any of the
            possible backends.
        :raises: RuntimeError if the preferred_backend is specified and is not
            one of the possible backends for this device class.
        :raises: :class:`~autopilot.BackendException` if the preferred_backend
            is set, but that backend could not be instantiated.

        """
        def get_x11_mouse():
            from autopilot.input._X11 import Mouse
            return Mouse()

        def get_uinput_mouse():
            # Return the Touch device for now as Mouse under a Mir desktop
            # is a challenge for now.
            from autopilot.input._uinput import Touch
            return Touch()

        backends = OrderedDict()
        backends['X11'] = get_x11_mouse
        backends['UInput'] = get_uinput_mouse
        return _pick_backend(backends, preferred_backend)
Exemple #4
0
    def create(preferred_backend=''):
        """Get an instance of the Display class.

        For more infomration on picking specific backends, see
        :ref:`tut-picking-backends`

        :param preferred_backend: A string containing a hint as to which
            backend you would like.

            possible backends are:

            * ``X11`` - Get display information from X11.
            * ``UPA`` - Get display information from the ubuntu platform API.
        :raises: RuntimeError if autopilot cannot instantate any of the
            possible backends.
        :raises: RuntimeError if the preferred_backend is specified and is not
            one of the possible backends for this device class.
        :raises: :class:`~autopilot.BackendException` if the preferred_backend
            is set, but that backend could not be instantiated.
        :returns: Instance of Display with appropriate backend.

        """
        def get_x11_display():
            from autopilot.display._X11 import Display
            return Display()

        def get_upa_display():
            from autopilot.display._upa import Display
            return Display()

        backends = OrderedDict()
        backends['X11'] = get_x11_display
        backends['UPA'] = get_upa_display
        return _pick_backend(backends, preferred_backend)
Exemple #5
0
    def create(preferred_backend=''):
        """Get an instance of the :py:class:`Keyboard` class.

        For more infomration on picking specific backends, see
        :ref:`tut-picking-backends`

        For details regarding backend limitations please see:
        :ref:`Keyboard backend limitations<keyboard_backend_limitations>`

        .. warning:: The **OSK** (On Screen Keyboard) backend option does not
         implement either :py:meth:`press` or :py:meth:`release` methods due to
         technical implementation details and will raise a NotImplementedError
         exception if used.

        :param preferred_backend: A string containing a hint as to which
            backend you would like. Possible backends are:

            * ``X11`` - Generate keyboard events using the X11 client
                libraries.
            * ``UInput`` - Use UInput kernel-level device driver.
            * ``OSK`` - Use the graphical On Screen Keyboard as a backend.

        :raises: RuntimeError if autopilot cannot instantate any of the
            possible backends.
        :raises: RuntimeError if the preferred_backend is specified and is not
            one of the possible backends for this device class.
        :raises: :class:`~autopilot.BackendException` if the preferred_backend
            is set, but that backend could not be instantiated.

        """
        def get_x11_kb():
            from autopilot.input._X11 import Keyboard
            return Keyboard()

        def get_uinput_kb():
            from autopilot.input._uinput import Keyboard
            return Keyboard()

        def get_osk_kb():
            try:
                maliit = [
                    p for p in psutil.process_iter()
                    if p.name() == 'maliit-server'
                ]
                if maliit:
                    from autopilot.input._osk import Keyboard
                    return Keyboard()
                else:
                    raise RuntimeError('maliit-server is not running')
            except ImportError as e:
                e.args += ("Unable to import the OSK backend", )
                raise

        backends = OrderedDict()
        backends['X11'] = get_x11_kb
        backends['OSK'] = get_osk_kb
        backends['UInput'] = get_uinput_kb
        return _pick_backend(backends, preferred_backend)