Exemplo n.º 1
0
def move_mouse_to_screen(screen_number):
    """Move the mouse to the center of the specified screen."""
    geo = Display.create().get_screen_geometry(screen_number)
    x = geo[0] + (geo[2] / 2)
    y = geo[1] + (geo[3] / 2)
    # dont animate this or it might not get there due to barriers
    Mouse.create().move(x, y, False)
Exemplo n.º 2
0
    def setUp(self):
        super(DejaDupTestCase, self).setUp()
        self.pointer = Pointer(Mouse.create())

        self.rootdir = os.environ['DEJA_DUP_TEST_ROOT']
        self.sourcedir = os.path.join(self.rootdir, 'source')
        self.copydir = os.path.join(self.rootdir, 'source.copy')
        self.backupdir = os.path.join(self.rootdir, 'backup')
        self.addCleanup(self.safe_rmtree, self.sourcedir)
        self.addCleanup(self.safe_rmtree, self.copydir)
        self.addCleanup(self.safe_rmtree, self.backupdir)
        self.addCleanup(self.safe_rmtree, os.path.join(self.rootdir, 'cache'))
        try:
            os.makedirs(self.sourcedir)
        except OSError:
            pass

        self.set_config("root-prompt", False)
        self.set_config("location-mode",
                        "filename-entry",
                        schema="org.gtk.Settings.FileChooser",
                        path="/org/gtk/settings/file-chooser/")

        # And a catch-all for the other settings that get set as part of a
        # deja-dup run, like last-backup or such.
        self.addCleanup(os.system,
                        "gsettings reset-recursively org.gnome.DejaDup")
Exemplo n.º 3
0
def drag_window_to_screen(window, screen):
    """Drags *window* to *screen*

    :param autopilot.process.Window window: The window to drag
    :param integer screen: The screen to drag the *window* to
    :raises: **TypeError** if *window* is not a autopilot.process.Window

    """
    if not isinstance(window, Window):
        raise TypeError("Window must be a autopilot.process.Window")

    if window.monitor == screen:
        logger.debug("Window %r is already on screen %d." % (window.x_id, screen))
        return

    assert(not window.is_maximized)
    (win_x, win_y, win_w, win_h) = window.geometry
    (mx, my, mw, mh) = Display.create().get_screen_geometry(screen)

    logger.debug("Dragging window %r to screen %d." % (window.x_id, screen))

    mouse = Mouse.create()
    keyboard = Keyboard.create()
    mouse.move(win_x + win_w/2, win_y + win_h/2)
    keyboard.press("Alt")
    mouse.press()
    keyboard.release("Alt")

    # We do the movements in two steps, to reduce the risk of being
    # blocked by the pointer barrier
    target_x = mx + mw/2
    target_y = my + mh/2
    mouse.move(win_x, target_y, rate=20, time_between_events=0.005)
    mouse.move(target_x, target_y, rate=20, time_between_events=0.005)
    mouse.release()
Exemplo n.º 4
0
def drag_window_to_screen(window, screen):
    """Drags *window* to *screen*

    :param autopilot.process.Window window: The window to drag
    :param integer screen: The screen to drag the *window* to
    :raises: **TypeError** if *window* is not a autopilot.process.Window

    """
    if not isinstance(window, Window):
        raise TypeError("Window must be a autopilot.process.Window")

    if window.monitor == screen:
        logger.debug("Window %r is already on screen %d." % (window.x_id, screen))
        return

    assert(not window.is_maximized)
    (win_x, win_y, win_w, win_h) = window.geometry
    (mx, my, mw, mh) = Display.create().get_screen_geometry(screen)

    logger.debug("Dragging window %r to screen %d." % (window.x_id, screen))

    mouse = Mouse.create()
    keyboard = Keyboard.create()
    mouse.move(win_x + win_w/2, win_y + win_h/2)
    keyboard.press("Alt")
    mouse.press()
    keyboard.release("Alt")

    # We do the movements in two steps, to reduce the risk of being
    # blocked by the pointer barrier
    target_x = mx + mw/2
    target_y = my + mh/2
    mouse.move(win_x, target_y, rate=20, time_between_events=0.005)
    mouse.move(target_x, target_y, rate=20, time_between_events=0.005)
    mouse.release()
Exemplo n.º 5
0
 def setUp(self):
     self.setup_base_path()
     self.pointer = Pointer(Mouse.create())
     self.app = self.launch_test_application(self.BROWSER_QML_APP_LAUNCHER, self.get_browser_container_path())
     self.webviewContainer = self.get_webviewContainer()
     self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)')
     super(UbuntuHTML5TestCaseBase, self).setUp()
Exemplo n.º 6
0
 def test_mouse_move_must_log_final_position_at_debug_level(self):
     self.root_logger.setLevel(logging.DEBUG)
     mouse = Mouse.create()
     mouse.move(10, 10)
     self.assertLogLevelContains(
         'DEBUG',
         "The mouse is now at position 10,10."
     )
Exemplo n.º 7
0
 def activate(self, double_click=True):
     tx = self.x + (self.width / 2)
     ty = self.y + (self.height / 2)
     m = Mouse.create()
     m.move(tx, ty)
     m.click(1)
     if double_click:
         m.click(1)
Exemplo n.º 8
0
    def preview_key(self):
        tx = self.x + (self.width / 2)
        ty = self.y + (self.height / 2)
        m = Mouse.create()
        m.move(tx, ty)

        k = Keyboard.create()
        k.press_and_release('Menu')
    def setUp(self):
        super(EmulatorTest, self).setUp()

        self.app = self.launch_test_application(FULL_PATH,
                                                app_type='gtk',
                                                emulator_base=AutopilotGtkEmulatorBase)
        self.pointing_device = Pointer(Mouse.create())
        self.assertThat(self.main_window.visible, Eventually(Equals(1)))
        self.status_label = self.app.select_single(BuilderName='statuslabel')
Exemplo n.º 10
0
 def ensure_expanded(self):
     """Expand the filter expander label, if it's not already"""
     if not self.expanded:
         tx = self.x + self.width / 2
         ty = self.y + self.height / 2
         m = Mouse.create()
         m.move(tx, ty)
         m.click()
         self.expanded.wait_for(True)
Exemplo n.º 11
0
 def setUp(self):
     self.setup_base_path()
     self.pointer = Pointer(Mouse.create())
     self.app = self.launch_test_application(
         self.BROWSER_QML_APP_LAUNCHER, self.get_browser_container_path())
     self.webviewContainer = self.get_webviewContainer()
     self.watcher = self.webviewContainer.watch_signal(
         'resultUpdated(QString)')
     super(UbuntuHTML5TestCaseBase, self).setUp()
Exemplo n.º 12
0
 def setUp(self):
     self.pointing_device = Pointer(Mouse.create())
     #        sdk_test_mode = os.environ['SDK_TEST_MODE']
     sdk_test_mode = os.environ.get('SDK_TEST_MODE', 'auto')
     if sdk_test_mode != 'manual':
         self._set_temporary_home_directory()
         self._set_click_chroot_suffix()
     super(QtCreatorTestCase, self).setUp()
     self.launch_qt_creator()
Exemplo n.º 13
0
 def execute_action_by_id(self, action_id):
     """Executes an action given by the id."""
     action = self.get_action_by_id(action_id)
     if action:
         tx = action.x + (action.width / 2)
         ty = action.y + (action.height / 2)
         m = Mouse.create()
         m.move(tx, ty)
         m.click()
Exemplo n.º 14
0
 def ensure_collapsed(self):
     """Collapse the filter expander label, if it's not already"""
     if self.expanded:
         tx = self.x + self.width / 2
         ty = self.y + self.height / 2
         m = Mouse.create()
         m.move(tx, ty)
         m.click()
         self.expanded.wait_for(False)
Exemplo n.º 15
0
    def test_mouse_creation_on_device_raises_useful_error(self):
        """Trying to create a mouse device on the phablet devices must raise an
        explicit exception.

        """
        expected_exception = RuntimeError(
            "Cannot create a Mouse on devices where X11 is not available."
        )
        self.assertThat(lambda: Mouse.create(),
                        raises(expected_exception))
Exemplo n.º 16
0
    def __init__(self, *args, **kwargs):
        super(Launcher, self).__init__(*args, **kwargs)

        self.show_timeout = 1
        self.hide_timeout = 1
        self.in_keynav_mode = False
        self.in_switcher_mode = False

        self._mouse = Mouse.create()
        self._display = Display.create()
Exemplo n.º 17
0
    def __init__(self, *args, **kwargs):
        super(Launcher, self).__init__(*args, **kwargs)

        self.show_timeout = 1
        self.hide_timeout = 1
        self.in_keynav_mode = False
        self.in_switcher_mode = False

        self._mouse = Mouse.create()
        self._display = Display.create()
Exemplo n.º 18
0
 def ensure_collapsed(self):
     """Collapse the filter bar, if it's not already."""
     if self.expanded:
         searchbar = self._get_searchbar()
         tx = searchbar.filter_label_x + (searchbar.filter_label_width / 2)
         ty = searchbar.filter_label_y + (searchbar.filter_label_height / 2)
         m = Mouse.create()
         m.move(tx, ty)
         m.click()
         self.expanded.wait_for(False)
Exemplo n.º 19
0
    def navigate_right(self, count=1):
        """Navigate preview right"""
        m = Mouse.create()
        m.move_to_object(self.get_right_navigator().button_geo)

        old_preview_initiate_count = self.preview_initiate_count

        for i in range(count):
            self.navigate_right_enabled.wait_for(True)
            m.click()
            self.preview_initiate_count.wait_for(GreaterThan(old_preview_initiate_count))
            old_preview_initiate_count = self.preview_initiate_count
Exemplo n.º 20
0
    def test_move_to_nonint_point(self):
        """Test mouse does not get stuck when we move to a non-integer point.

        LP bug #1195499.

        """
        device = Mouse.create()
        screen_geometry = Display.create().get_screen_geometry(0)
        target_x = screen_geometry[0] + 10
        target_y = screen_geometry[1] + 10.6
        device.move(target_x, target_y)
        self.assertEqual(device.position(), (target_x, int(target_y)))
Exemplo n.º 21
0
    def navigate_right(self, count=1):
        """Navigate preview right"""
        navigator = self.get_right_navigator()

        tx = navigator.button_x + (navigator.button_width / 2)
        ty = navigator.button_y + (navigator.button_height / 2)
        m = Mouse.create()
        m.move(tx, ty)

        old_preview_initiate_count = self.preview_initiate_count

        for i in range(count):
            self.navigate_right_enabled.wait_for(True)
            m.click()
            self.preview_initiate_count.wait_for(GreaterThan(old_preview_initiate_count))
            old_preview_initiate_count = self.preview_initiate_count
Exemplo n.º 22
0
    def setUp(self):
        super(UbiquityAutopilotTestCase, self).setUp()
        self.app = self.launch_application()

        self.pointing_device = Pointer(Mouse.create())
        self.kbd = Keyboard.create()
        self.current_page_title = ''
        self.previous_page_title = ''
        self.current_step = ''
        self.step_before = ''
        self.english_install = False
        english_label_conf.generate_config()
        self.english_config = configparser.ConfigParser()
        self.english_config.read('/tmp/english_config.ini')
        #delete config at end of test
        self.addCleanup(os.remove, '/tmp/english_config.ini')
        # always starts with 1 row ('/dev/sda')
        self.part_table_rows = 1
        self.total_number_partitions = 0
Exemplo n.º 23
0
    def setUp(self):
        self.setup_base_path()
        if platform.model() == "Desktop":
            self.pointer = Pointer(Mouse.create())
        else:
            self.pointer = Pointer(Touch.create())

        params = [self.BROWSER_QML_APP_LAUNCHER,
                  self.get_browser_container_path()]
        if (platform.model() != 'Desktop'):
            params.append(
                '--desktop_file_hint=/usr/share/" \
                + "applications/unitywebappsqmllauncher.desktop')

        self.app = self.launch_test_application(
            *params,
            app_type='qt')

        self.webviewContainer = self.get_webviewContainer()
        self.watcher = self.webviewContainer.watch_signal(
            'resultUpdated(QString)')
        super(UbuntuHTML5TestCaseBase, self).setUp()
 def __init__(self, *args):
     super(GtkComboBoxText, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
Exemplo n.º 25
0
 def preview(self, button=1):
     tx = self.x + (self.width / 2)
     ty = self.y + (self.height / 2)
     m = Mouse.create()
     m.move(tx, ty)
     m.click(button)
Exemplo n.º 26
0
 def __init__(self, *args):
     super(GtkBox, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
     self.kbd = Keyboard.create()
Exemplo n.º 27
0
 def __init__(self, *args):
     super(GtkTextView, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
     self.kbd = Keyboard.create()
Exemplo n.º 28
0
 def setUp(self):
     super(DefaultInstallTests, self).setUp()
     self.app = self.launch_application()
     #properties = self.app.get_properties()
     #print(properties)
     self.pointing_device = Pointer(Mouse.create())
Exemplo n.º 29
0
 def __init__(self, *args, **kwargs):
     super(UnityPanel, self).__init__(*args, **kwargs)
     self._mouse = Mouse.create()
Exemplo n.º 30
0
 def __init__(self, *args):
     super(GtkComboBoxText, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
Exemplo n.º 31
0
Arquivo: main.py Projeto: jmcarcell/og
import time
import defs as og
import random as rd

from autopilot.input import Mouse
from autopilot.input import Keyboard
m = Mouse.create()
k = Keyboard.create()


max_position = (955, 430)
#max_position = (955, 412)
#max_position = (955, 392)
#max_position = (955, 372)
first_ok = (887, 474)
first_ok = (892, 452)
first_ok = (892, max_position[1] + 40)
overview = (138, 214)
fleet = (149, 289)
galaxy = (161, 314)
objective = "1:196:8"
second_ok = (897, 421)
third_ok = (884, 398)
attack_button = (737, 305)
first_field_fleet = (941, 252)

low_wait = 0.8
counter = 0

class Job:
    def __init__(self, reports_string, mouse, keyboard):
Exemplo n.º 32
0
 def __init__(self, *args, **kwargs):
     super(WindowButton, self).__init__(*args, **kwargs)
     self._mouse = Mouse.create()
Exemplo n.º 33
0
 def __init__(self, *args):
     super(GtkMessageDialog, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
Exemplo n.º 34
0
 def __init__(self, *args):
     super(GtkToggleButton, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
Exemplo n.º 35
0
 def setUp(self):
     super(LvmInstallTests, self).setUp()
     self.app = self.launch_application()
     
     self.pointing_device = Pointer(Mouse.create())
Exemplo n.º 36
0
 def move_mouse_to_right(self):
     """Moves the mouse outside the quicklist"""
     logger.debug("Moving mouse outside the quicklist %r", self)
     target_x = self.x + self.width + 10
     target_y = self.y + self.height / 2
     Mouse.create().move(target_x, target_y, animate=False)
Exemplo n.º 37
0
 def __init__(self, *args, **kwargs):
     super(QuicklistMenuItem, self).__init__(*args, **kwargs)
     self._mouse = Mouse.create()
Exemplo n.º 38
0
 def __init__(self, *args, **kwargs):
     super(WindowButton, self).__init__(*args, **kwargs)
     self._mouse = Mouse.create()
Exemplo n.º 39
0
 def __init__(self, *args, **kwargs):
     super(DashController, self).__init__(*args, **kwargs)
     self.keyboard = Keyboard.create()
     self.mouse = Mouse.create()
Exemplo n.º 40
0
 def __init__(self, *args, **kwargs):
     super(IndicatorEntry, self).__init__(*args, **kwargs)
     self._mouse = Mouse.create()
 def __init__(self, *args):
     super(GtkSwitch, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
Exemplo n.º 42
0
 def __init__(self, *args):
     super(GtkTreeView, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
Exemplo n.º 43
0
 def __init__(self, *args):
     super(GtkNoteBookPageAccessible, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
Exemplo n.º 44
0
 def __init__(self, *args):
     super(GtkSpinButton, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
Exemplo n.º 45
0
 def __init__(self, *args):
     super(GtkTreeViewAccessible, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
Exemplo n.º 46
0
 def __init__(self, *args):
     super(GtkFileChooserEntry, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
     self.kbd = Keyboard.create()
Exemplo n.º 47
0
 def __init__(self, *args):
     super(GtkContainers, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
Exemplo n.º 48
0
 def __init__(self, *args, **kwargs):
     super(IndicatorEntry, self).__init__(*args, **kwargs)
     self._mouse = Mouse.create()
 def __init__(self, *args):
     super(TestAppWindow, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
     self.kbd = Keyboard.create()
Exemplo n.º 50
0
 def __init__(self, *args, **kwargs):
     super(SwitcherController, self).__init__(*args, **kwargs)
     self._mouse = Mouse.create()
Exemplo n.º 51
0
 def __init__(self, *args, **kwargs):
     super(UnityPanel, self).__init__(*args, **kwargs)
     self._mouse = Mouse.create()