Ejemplo n.º 1
0
 def test_x86_emulator_creation(self):
     """ Change to the Devices mode and click on the add new emulator button """
     kbd = Keyboard.create("X11")
     kbd.press_and_release('Ctrl+9')
     devices_quickview = self.ide.wait_select_single(
         'QQuickView',
         source='file:///usr/share/qtcreator/ubuntu/qml/devicespage.qml')
     add_emulator_button = devices_quickview.select_single(
         'Button', text='Add Emulator')
     add_emulator_button.visible.wait_for(True)
     """ The simple click_object() moves the pointer to the center of the button, but in some environment the responsive area of the button is smaller """
     self.pointing_device.move(
         add_emulator_button.globalRect.x + add_emulator_button.width - 1,
         add_emulator_button.globalRect.y + add_emulator_button.height - 1)
     self.pointing_device.click()
     config_emulator_dialog = devices_quickview.wait_select_single(
         'Dialog', title='Create emulator')
     emulatorname_textfield = config_emulator_dialog.wait_select_single(
         'TextField', placeholderText='Emulator name')
     self.pointing_device.click_object(emulatorname_textfield)
     kbd = Keyboard.create("X11")
     kbd.type("TestX86Emulator", delay=0.1)
     create_button = config_emulator_dialog.wait_select_single(
         'Button', text='Create')
     self.pointing_device.click_object(create_button)
     """ Wait the emulator creation to finish """
     devices_ubuntulistview = devices_quickview.wait_select_single(
         'UbuntuListView', objectName='devicesList')
     while True:
         if (devices_ubuntulistview.visible): break
         sleep(1)
     emulator_listitem = devices_ubuntulistview.wait_select_single(
         'Standard', text='TestX86Emulator')
Ejemplo n.º 2
0
    def test_input_backends_default_order(self, pick_backend):
        k = Keyboard()
        k.create()

        backends = list(pick_backend.call_args[0][0].items())
        self.assertTrue(backends[0][0] == 'X11')
        self.assertTrue(backends[1][0] == 'OSK')
        self.assertTrue(backends[2][0] == 'UInput')
Ejemplo 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()
Ejemplo 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()
Ejemplo n.º 5
0
    def test_text_typing(self):
        """Typing text must produce the correct characters in the target
        app.

        """
        app_proxy = self.start_mock_app()
        text_edit = app_proxy.select_single('QTextEdit')

        # make sure the text edit has keyboard focus:
        self.mouse.click_object(text_edit)
        self.assertThat(text_edit.focus, Eventually(Equals(True)))

        # even though we ensured the textedit has focus, it occasionally
        # does not yet accept keyboard input, causing this test to fail
        # intermittently.  to remedy this, we just add a sleep.
        sleep(2)

        # create keyboard and type the text.
        keyboard = Keyboard.create(self.backend)
        keyboard.type(self.input, 0.01)

        self.assertThat(text_edit.plainText,
                        Eventually(Equals(self.input)),
                        "app shows: " + text_edit.plainText
                        )
Ejemplo n.º 6
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')
Ejemplo n.º 7
0
 def test_wrong_password(self):
     test_id = '2015.com.canonical.certification::autopilot/sudo-right'
     self.start_and_select_tests('2015.com.canonical.certification::sudo',
                                 [test_id])
     keyboard = Keyboard.create()
     password_box = self.app.wait_select_single(objectName='passwordBox')
     with keyboard.focused_type(password_box) as kb:
         kb.type("wrong")
     ok_btn = self.app.wait_select_single(objectName='okButton')
     self.pointing_device.click_object(ok_btn)
     results = {'passed': '1', 'failed': '1', 'skipped': '0'}
     self.check_results(results)
Ejemplo n.º 8
0
    def test_keyboard_keys_are_released(self):
        """Typing characters must not leave keys pressed."""
        app_proxy = self.start_mock_app()
        text_edit = app_proxy.select_single('QTextEdit')

        # make sure the text edit has keyboard focus:
        self.mouse.click_object(text_edit)
        keyboard = Keyboard.create(self.backend)

        for character in self.input:
            self.assertThat(self._get_pressed_keys_list(), Equals([]))
            keyboard.type(character, 0.01)
            self.assertThat(self._get_pressed_keys_list(), Equals([]))
Ejemplo n.º 9
0
    def test_inline_backspace_works(self):
        app_proxy = self.start_mock_app()
        text_edit = app_proxy.select_single('QTextEdit')

        self.mouse.click_object(text_edit)

        keyboard = Keyboard.create(self.backend)
        keyboard.type("Hello1\b")

        self.assertThat(text_edit.plainText,
                        Eventually(Equals("Hello")),
                        "app shows: " + text_edit.plainText
                        )
Ejemplo n.º 10
0
 def test_x86_emulator_start(self):
     """ Change to the Devices mode, select the TestX86Emulator and deploy it """
     kbd = Keyboard.create("X11")
     kbd.press_and_release('Ctrl+9')
     devices_quickview = self.ide.wait_select_single(
         'QQuickView',
         source='file:///usr/share/qtcreator/ubuntu/qml/devicespage.qml')
     devices_ubuntulistview = devices_quickview.wait_select_single(
         'UbuntuListView', objectName='devicesList')
     while True:
         if (devices_ubuntulistview.visible): break
         sleep(1)
     emulator_listitem = devices_ubuntulistview.wait_select_single(
         'Standard', text='TestX86Emulator')
     self.pointing_device.click_object(emulator_listitem)
Ejemplo n.º 11
0
    def test_can_type_string(self):
        """Typing text must produce the expected characters in the input
        field.

        """

        text_area = self.launch_test_input_area()
        keyboard = Keyboard.create('OSK')
        pointer = Pointer(Touch.create())
        pointer.click_object(text_area)
        keyboard._keyboard.wait_for_keyboard_ready()

        keyboard.type(self.input)

        self.assertThat(text_area.text, Eventually(Equals(self.input)))
Ejemplo n.º 12
0
    def test_typing_with_contextmanager(self):
        """Typing text must produce the correct characters in the target
        app.

        """
        app_proxy = self.start_mock_app()
        text_edit = app_proxy.select_single('QTextEdit')

        keyboard = Keyboard.create(self.backend)
        with keyboard.focused_type(text_edit) as kb:
            kb.type(self.input, 0.01)

            self.assertThat(
                text_edit.plainText,
                Eventually(Equals(self.input)),
                "app shows: " + text_edit.plainText
            )
Ejemplo n.º 13
0
    def test_focused_typing_contextmanager(self):
        """Typing text using the 'focused_typing' context manager must not only
        produce the expected characters in the input field but also cleanup the
        OSK afterwards too.

        """
        text_area = self.launch_test_input_area()
        keyboard = Keyboard.create('OSK')
        with keyboard.focused_type(text_area) as kb:
            kb.type(self.input)
            self.assertThat(
                text_area.text,
                Eventually(Equals(self.input))
            )
        self.assertThat(
            keyboard._keyboard.is_available,
            Eventually(Equals(False))
        )
Ejemplo n.º 14
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
Ejemplo n.º 15
0
    def skip_test(self, selectable_object_name=None):
        """Skip current test using header action.

        :param selectable_object_name:
             the objectName of component that has to be visible and selecable
             before the action is clicked.
        """
        if selectable_object_name is not None:
            self.app.wait_select_single(
                objectName=selectable_object_name, visible=True)
        self._click_action_button('trailingActionBar', 'skip')
        dialog = self.app.wait_select_single(objectName='dialog')
        yes_btn = dialog.select_single(objectName='yesButton')
        self.pointing_device.click_object(yes_btn)
        keyboard = Keyboard.create()
        comment_text = self.app.select_single(objectName='commentText')
        with keyboard.focused_type(comment_text) as kb:
            kb.type("Skipped by autopilot!")
        done_btn = self.app.select_single(objectName='doneButton')
        self.pointing_device.click_object(done_btn)
Ejemplo n.º 16
0
 def __init__(self, *args):
     super(GtkBox, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
     self.kbd = Keyboard.create()
Ejemplo n.º 17
0
Archivo: main.py Proyecto: 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):
Ejemplo n.º 18
0
 def _keyboard(self):
     return Keyboard.create()
 def __init__(self, *args):
     super(GtkFileChooserDialog, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
     self.kbd = Keyboard.create()
Ejemplo n.º 20
0
 def __init__(self, *args, **kwargs):
     super(DashController, self).__init__(*args, **kwargs)
     self.keyboard = Keyboard.create()
     self.mouse = Mouse.create()
Ejemplo n.º 21
0
 def __init__(self, *args, **kwargs):
     super(HudController, self).__init__(*args, **kwargs)
     self.keyboard = Keyboard.create()
 def __init__(self, *args):
     super(TestAppWindow, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
     self.kbd = Keyboard.create()
Ejemplo n.º 23
0
 def test_press_key(self):
     kb = Keyboard.create('UInput')
     kb.press('Shift')
Ejemplo n.º 24
0
 def __init__(self, *args):
     super(GtkFileChooserEntry, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
     self.kbd = Keyboard.create()
Ejemplo n.º 25
0
    def preview_key(self):
        Mouse.create().move_to_object(self)

        k = Keyboard.create()
        k.press_and_release('Menu')
Ejemplo n.º 26
0
 def __init__(self, *args):
     super(GtkTextView, self).__init__(*args)
     self.pointing_device = Pointer(Mouse.create())
     self.kbd = Keyboard.create()
Ejemplo n.º 27
0
 def test_can_create_backend(self):
     keyboard = Keyboard.create(self.backend)
     self.assertThat(keyboard, IsInstance(Keyboard))
Ejemplo n.º 28
0
 def __init__(self, *args):
     super(MainView, self).__init__(*args)
     self.pointing_device = toolkit_emulators.get_pointing_device()
     self.keyboard = Keyboard.create()
     self.logger = logging.getLogger(__name__)
Ejemplo n.º 29
0
 def __init__(self, *args, **kwargs):
     super(HudController, self).__init__(*args, **kwargs)
     self.keyboard = Keyboard.create()