Beispiel #1
0
    def runTest(self):
        if not self.tests:
            return

        args = ["%s/anaconda.py" % os.environ.get("top_srcdir", ""), "-G"]
        for drive in self._drivePaths.values():
            args += ["--image", drive]
        args += testconfig.config.get("anacondaArgs", "").strip('"')

        # Save a reference to the running anaconda process so we can later kill
        # it if necessary.  For now, the only reason we'd want to kill it is
        # an expired timer.
        self._proc = subprocess.Popen(args)  # starts anaconda
        doDelay(10)  # wait for anaconda to initialize

        try:
            self.test_result = unittest.TextTestRunner(verbosity=2,
                                                       failfast=True).run(
                                                           self.suite)
            if not self.test_result.wasSuccessful():
                raise AssertionError('Dogtail tests failed')
        except TimedOutException:
            self.die(True)
            self.collect_logs()
            self.cleanup()
            raise
        finally:
            self.die()
Beispiel #2
0
def keyCombo(comboString):
    """
    Generates the appropriate keyboard events to simulate a user pressing the
    specified key combination.

    comboString is the representation of the key combo to be generated.
    e.g. '<Control><Alt>p' or '<Control><Shift>PageUp' or '<Control>q'
    """
    strings = []
    for s in comboString.split('<'):
        if s:
            for S in s.split('>'):
                if S:
                    S = keyNameAliases.get(S.lower(), S)
                    strings.append(S)
    for s in strings:
        if not hasattr(Gdk, s):
            if not hasattr(Gdk, 'KEY_' + s):
                raise ValueError("Cannot find key %s" % s)
    modifiers = strings[:-1]
    finalKey = strings[-1]
    for modifier in modifiers:
        code = keyNameToKeyCode(modifier)
        registry.generateKeyboardEvent(code, None, KEY_PRESS)
    code = keyNameToKeyCode(finalKey)
    registry.generateKeyboardEvent(code, None, KEY_PRESSRELEASE)
    for modifier in modifiers:
        code = keyNameToKeyCode(modifier)
        registry.generateKeyboardEvent(code, None, KEY_RELEASE)
    doDelay()
Beispiel #3
0
    def check_enter_password(self, spoke):
        # The warning bar starts off telling us there's no password set.
        self.check_warning_bar("The password is empty", node=spoke)

        entry = self.find("Password", "password text", node=spoke)
        self.assertIsNotNone(entry, msg="Password entry should be displayed")
        entry.grabFocus()
        entry.text = "asdfasdf"

        # That wasn't a very good password and we haven't confirmed it, so the
        # bar is still displayed at the bottom.
        doDelay(1)
        self.check_warning_bar("The password you have provided is weak.",
                               node=spoke)

        # Let's confirm that terrible password.
        entry = self.find("Confirm Password", "password text", node=spoke)
        self.assertIsNotNone(entry, msg="Confirm password should be displayed")
        entry.grabFocus()
        entry.text = "asdfasdf"

        # But of course it's still a terrible password, so the bar is still
        # displayed at the bottom.
        doDelay(1)
        self.check_warning_bar("The password you have provided is weak.",
                               node=spoke)
Beispiel #4
0
 def deselectAll(self):
     """
     Deselects all selected children.
     """
     result = self.querySelection().clearSelection()
     doDelay()
     return result
Beispiel #5
0
def keyCombo(comboString):
    """
    Generates the appropriate keyboard events to simulate a user pressing the
    specified key combination.

    comboString is the representation of the key combo to be generated.
    e.g. '<Control><Alt>p' or '<Control><Shift>PageUp' or '<Control>q'
    """
    strings = []
    for s in comboString.split('<'):
        if s:
            for S in s.split('>'):
                if S:
                    S = keyNameAliases.get(S.lower(), S)
                    strings.append(S)
    for s in strings:
        if not hasattr(Gdk, s):
            if not hasattr(Gdk, 'KEY_' + s):
                raise ValueError("Cannot find key %s" % s)
    modifiers = strings[:-1]
    finalKey = strings[-1]
    for modifier in modifiers:
        code = keyNameToKeyCode(modifier)
        registry.generateKeyboardEvent(code, None, KEY_PRESS)
    code = keyNameToKeyCode(finalKey)
    registry.generateKeyboardEvent(code, None, KEY_PRESSRELEASE)
    for modifier in modifiers:
        code = keyNameToKeyCode(modifier)
        registry.generateKeyboardEvent(code, None, KEY_RELEASE)
    doDelay()
Beispiel #6
0
    def runTest(self):
        if not self.tests:
            return

        args = ["%s/anaconda.py" % os.environ.get("top_srcdir", ""), "-G"]
        for drive in self._drivePaths.values():
            args += ["--image", drive]
        args += testconfig.config.get("anacondaArgs", "").strip('"')

        # Save a reference to the running anaconda process so we can later kill
        # it if necessary.  For now, the only reason we'd want to kill it is
        # an expired timer.
        self._proc = subprocess.Popen(args) # starts anaconda
        doDelay(10) # wait for anaconda to initialize

        try:
            self.test_result = unittest.TextTestRunner(verbosity=2, failfast=True).run(self.suite)
            if not self.test_result.wasSuccessful():
                raise AssertionError('Dogtail tests failed')
        except TimedOutException:
            self.die(True)
            self.collect_logs()
            self.cleanup()
            raise
        finally:
            self.die()
Beispiel #7
0
 def selectAll(self):
     """
     Selects all children.
     """
     result = self.querySelection().selectAll()
     doDelay()
     return result
Beispiel #8
0
def click_gmenu(context, name):
    logging.debug("context = %s", context)
    gmenu = get_gmenu(context)
    logging.debug("gmenu = %s", gmenu)
    menu_item = gmenu.childLabelled(name)
    logging.debug("menu_item = %s", menu_item)
    menu_item.click()
    doDelay(2)
Beispiel #9
0
def release(x, y, button=1, check=True):
    """
    Synthesize a mouse button release at (x,y)
    """
    if check:
        checkCoordinates(x, y)
    logger.log("Mouse button %s release at (%s,%s)" % (button, x, y))
    registry.generateMouseEvent(x, y, name='b%sr' % button)
    doDelay()
Beispiel #10
0
def doubleClick(x, y, button=1, check=True):
    """
    Synthesize a mouse button double-click at (x,y)
    """
    if check:
        checkCoordinates(x, y)
    logger.log("Mouse button %s doubleclick at (%s,%s)" % (button, x, y))
    registry.generateMouseEvent(x, y, name='b%sd' % button)
    doDelay()
Beispiel #11
0
def release(x, y, button=1, check=True):
    """
    Synthesize a mouse button release at (x,y)
    """
    if check:
        checkCoordinates(x, y)
    logger.log("Mouse button %s release at (%s,%s)" % (button, x, y))
    registry.generateMouseEvent(x, y, name='b%sr' % button)
    doDelay()
Beispiel #12
0
def click(x, y, button=1, check=True):
    """
    Synthesize a mouse button click at (x,y)
    """
    if check:
        checkCoordinates(x, y)
    logger.log("Mouse button %s click at (%s,%s)" % (button, x, y))
    registry.generateMouseEvent(x, y, name='b%sc' % button)
    doDelay(config.actionDelay)
Beispiel #13
0
def click(x, y, button=1, check=True):
    """
    Synthesize a mouse button click at (x,y)
    """
    if check:
        checkCoordinates(x, y)
    logger.log("Mouse button %s click at (%s,%s)" % (button, x, y))
    registry.generateMouseEvent(x, y, name='b%sc' % button)
    doDelay(config.actionDelay)
Beispiel #14
0
def doubleClick(x, y, button=1, check=True):
    """
    Synthesize a mouse button double-click at (x,y)
    """
    if check:
        checkCoordinates(x, y)
    logger.log("Mouse button %s doubleclick at (%s,%s)" % (button, x, y))
    registry.generateMouseEvent(x, y, name='b%sd' % button)
    doDelay()
Beispiel #15
0
    def _run(self):
        w = self._common_run()

        # Clicking the Done button should bring up the installation options dialog
        # indicating there's never going to be enough space to install.  There's nothing
        # to do now but quit.
        self.click_button("_Done", node=w)
        doDelay(5)
        optionsDlg = self.check_dialog_displayed("No Space")
        self.click_button("Quit installer", node=optionsDlg)
Beispiel #16
0
def select_file_in_dialog(context, name):
    location_button = context.app.dialog.child('Enter Location')
    if pyatspi.STATE_ARMED not in location_button.getState().getStates():
        location_button.click()

    location_text = context.app.dialog.child(roleName='text')
    location_text.set_text_contents(name)
    doDelay(0.2)
    location_text.grab_focus()
    keyCombo('<Enter>')
Beispiel #17
0
def select_file_in_dialog(context, name):
    location_button = context.app.dialog.child('Enter Location')
    if pyatspi.STATE_ARMED not in location_button.getState().getStates():
        location_button.click()

    location_text = context.app.dialog.child(roleName='text')
    location_text.set_text_contents(name)
    doDelay(0.2)
    location_text.grab_focus()
    keyCombo('<Enter>')
Beispiel #18
0
    def check_help_button(self, node=None):
        self.click_button("Help!", node=node)

        try:
            yelp = root.application("yelp")
        except SearchError:
            self.fail("Help view is not displayed.")

        doDelay(2)
        yelp.keyCombo("<Alt>F4")
Beispiel #19
0
    def check_help_button(self, node=None):
        self.click_button("Help!", node=node)

        try:
            yelp = root.application("yelp")
        except SearchError:
            self.fail("Help view is not displayed.")

        doDelay(2)
        yelp.keyCombo("<Alt>F4")
Beispiel #20
0
    def _run(self):
        w = self._common_run()

        # Clicking the Done button should bring up the installation options dialog
        # indicating there's never going to be enough space to install.  There's nothing
        # to do now but quit.
        self.click_button("_Done", node=w)
        doDelay(5)
        optionsDlg = self.check_dialog_displayed("No Space")
        self.click_button("Quit installer", node=optionsDlg)
Beispiel #21
0
    def _run(self):
        # Before doing anything, verify we are on the right screen.
        doDelay(5)
        w = self.check_window_displayed("INSTALLATION SUMMARY")

        # And now we can check everything else on the screen.
        self.check_help_button(w)
        self.check_quit_button(w)
        self.check_begin_installation_button(w)
        self.check_shown_spoke_selectors(w)
        self.check_warning_bar(node=w)
Beispiel #22
0
def relativeMotion(x, y, mouseDelay=None):
    """
    Synthetize a relative motion from actual position.
    Note: Does not check if the end coordinates are positive.
    """
    logger.log("Mouse relative motion of (%s,%s)" % (x, y))
    registry.generateMouseEvent(x, y, name='rel')
    if mouseDelay:
        doDelay(mouseDelay)
    else:
        doDelay()
Beispiel #23
0
 def exit_spoke(self, hubName="INSTALLATION SUMMARY", node=None):
     """Leave a spoke by clicking the Done button in the upper left corner,
        then verify we have returned to the proper hub.  Since most spokes
        are off the summary hub, that's the default.  If we are not back
        on the hub, the current test case will be failed.
     """
     button = self.find("_Done", "push button", node=node)
     self.assertIsNotNone(button, msg="Done button not found")
     button.click()
     doDelay(5)
     self.check_window_displayed(hubName)
Beispiel #24
0
def relativeMotion(x, y, mouseDelay=None):
    """
    Synthetize a relative motion from actual position.
    Note: Does not check if the end coordinates are positive.
    """
    logger.log("Mouse relative motion of (%s,%s)" % (x, y))
    registry.generateMouseEvent(x, y, name='rel')
    if mouseDelay:
        doDelay(mouseDelay)
    else:
        doDelay()
Beispiel #25
0
 def exit_spoke(self, hubName="INSTALLATION SUMMARY", node=None):
     """Leave a spoke by clicking the Done button in the upper left corner,
        then verify we have returned to the proper hub.  Since most spokes
        are off the summary hub, that's the default.  If we are not back
        on the hub, the current test case will be failed.
     """
     button = self.find("_Done", "push button", node=node)
     self.assertIsNotNone(button, msg="Done button not found")
     button.click()
     doDelay(5)
     self.check_window_displayed(hubName)
Beispiel #26
0
    def _run(self):
        # Before doing anything, verify we are on the right screen.
        doDelay(5)
        w = self.check_window_displayed("INSTALLATION SUMMARY")

        # And now we can check everything else on the screen.
        self.check_help_button(w)
        self.check_quit_button(w)
        self.check_begin_installation_button(w)
        self.check_shown_spoke_selectors(w)
        self.check_warning_bar(node=w)
Beispiel #27
0
 def deselect(self):
     """
     Deselects the Accessible.
     """
     try:
         parent = self.parent
     except AttributeError:
         raise NotImplementedError
     result = parent.querySelection().deselectChild(self.indexInParent)
     doDelay()
     return result
Beispiel #28
0
def absoluteMotion(x, y, mouseDelay=None, check=True):
    """
    Synthesize mouse absolute motion to (x,y)
    """
    if check:
        checkCoordinates(x, y)
    logger.log("Mouse absolute motion to (%s,%s)" % (x, y))
    registry.generateMouseEvent(x, y, name='abs')
    if mouseDelay:
        doDelay(mouseDelay)
    else:
        doDelay()
Beispiel #29
0
 def point(self, mouseDelay=None):
     """
     Move mouse cursor to the center of the widget.
     """
     pointX = self.position[0] + self.size[0] / 2
     pointY = self.position[1] + self.size[1] / 2
     logger.log("Pointing on %s %s at (%s,%s)" % (self.name, self.getLogString(), str(pointX), str(pointY)))
     rawinput.registry.generateMouseEvent(pointX, pointY, "abs")
     if mouseDelay:
         doDelay(mouseDelay)
     else:
         doDelay()
Beispiel #30
0
def absoluteMotion(x, y, mouseDelay=None, check=True):
    """
    Synthesize mouse absolute motion to (x,y)
    """
    if check:
        checkCoordinates(x, y)
    logger.log("Mouse absolute motion to (%s,%s)" % (x, y))
    registry.generateMouseEvent(x, y, name='abs')
    if mouseDelay:
        doDelay(mouseDelay)
    else:
        doDelay()
Beispiel #31
0
def get_gmenu(context):
    gs = tree.root.application('gnome-shell')
    logging.debug("gs = %s", gs)
    quit_element = gs.child(roleName='menu', label='Quit')
    logging.debug("quit_element = %s", quit_element)
    if not quit_element.showing:
        gnome_menu = gs.child(roleName='menu')
        logging.debug("gnome_menu = %s", gnome_menu)
        gnome_menu.click()
        doDelay(2)
    return gs.child(roleName='menu', label='Quit').parent.parent.parent.\
        parent.parent
Beispiel #32
0
def start():
    builddir = os.environ.get('G_TEST_BUILDDIR', None)
    if builddir and not 'TESTUTIL_DONT_START' in os.environ:
        subprocess.Popen([os.path.join(builddir, '..', 'src', APPLICATION_ID)],
                         cwd=os.path.join(builddir, '..'))
    else:
        _do_bus_call("Activate", GLib.Variant('(a{sv})', ([],)))
    utils.doDelay(3)

    app = tree.root.application(APPLICATION_ID)
    focus.application(APPLICATION_ID)

    return app
Beispiel #33
0
 def point(self, mouseDelay=None):
     """
     Move mouse cursor to the center of the widget.
     """
     pointX = self.position[0] + self.size[0] / 2
     pointY = self.position[1] + self.size[1] / 2
     logger.log(str("Pointing on %s %s at (%s,%s)") %
                (str(self.name), self.getLogString(), str(pointX), str(pointY)))
     rawinput.registry.generateMouseEvent(pointX, pointY, 'abs')
     if mouseDelay:
         doDelay(mouseDelay)
     else:
         doDelay()
Beispiel #34
0
def start():
    builddir = os.environ.get('G_TEST_BUILDDIR', None)
    if builddir and not 'TESTUTIL_DONT_START' in os.environ:
        subprocess.Popen([os.path.join(builddir, '..', 'src', APPLICATION_ID)],
                         cwd=os.path.join(builddir, '..'))
    else:
        _do_bus_call("Activate", GLib.Variant('(a{sv})', ([],)))
    utils.doDelay(3)

    app = tree.root.application(APPLICATION_ID)
    focus.application(APPLICATION_ID)

    return app
def add_windows_live_account(context, user, password):
    dialog = context.app.instance.dialog('Windows Live account')

    # Input credentials
#    assert wait_until(
#        lambda x: x.findChildren(
    #        GenericPredicate(roleName='entry')) != [], dialog,
    #    timeout=90), "Windows Live auth window didn't appear"
    entry = dialog.child(roleName='entry', description="Email or phone")
    if entry.text != user:
        entry.click()
        typeText(user)
        pressKey('Tab')
        typeText(password)
    doDelay(2)

    dialog.button('Sign in').click()
    doDelay(5)

    # Wait for GNOME icon to appear
    third_party_icon_pred = GenericPredicate(roleName='document web',
                                             name='Let this app access your info?')
    for attempts in range(0, 10):  # pylint: disable=W0612
        if dialog.findChild(third_party_icon_pred,
                            retry=False,
                            requireResult=False) is not None:
            break
        else:
            doDelay(2)

    doDelay(1)
    allow_button = dialog.child("Yes", roleName='push button')
    if not allow_button.showing:
        # Scroll to confirmation button
        scrolls = dialog.findChildren(
            GenericPredicate(roleName='scroll bar'))
        scrolls[-1].value = scrolls[-1].maxValue
        pressKey('space')
        pressKey('space')

    # Wait for button to become enabled
    for attempts in range(0, 10):
        if pyatspi.STATE_SENSITIVE in \
                allow_button.getState().getStates():
            break
        else:
            doDelay(1)
    allow_button.click()
    assert wait_until(lambda x: x.dead, dialog), \
        "Dialog was not closed"
Beispiel #36
0
def add_windows_live_account(context, user, password):
    dialog = context.app.instance.dialog('Windows Live account')

    # Input credentials
    #    assert wait_until(
    #        lambda x: x.findChildren(
    #        GenericPredicate(roleName='entry')) != [], dialog,
    #    timeout=90), "Windows Live auth window didn't appear"
    entry = dialog.child(roleName='entry', description="Email or phone")
    if entry.text != user:
        entry.click()
        typeText(user)
        pressKey('Tab')
        typeText(password)
    doDelay(2)

    dialog.button('Sign in').click()
    doDelay(5)

    # Wait for GNOME icon to appear
    third_party_icon_pred = GenericPredicate(
        roleName='document web', name='Let this app access your info?')
    for attempts in range(0, 10):  # pylint: disable=W0612
        if dialog.findChild(third_party_icon_pred,
                            retry=False,
                            requireResult=False) is not None:
            break
        else:
            doDelay(2)

    doDelay(1)
    allow_button = dialog.child("Yes", roleName='push button')
    if not allow_button.showing:
        # Scroll to confirmation button
        scrolls = dialog.findChildren(GenericPredicate(roleName='scroll bar'))
        scrolls[-1].value = scrolls[-1].maxValue
        pressKey('space')
        pressKey('space')

    # Wait for button to become enabled
    for attempts in range(0, 10):
        if pyatspi.STATE_SENSITIVE in \
                allow_button.getState().getStates():
            break
        else:
            doDelay(1)
    allow_button.click()
    assert wait_until(lambda x: x.dead, dialog), \
        "Dialog was not closed"
def add_google_account(context, user, password):
    dialog = get_showing_node_name('Google account', context.app.instance)
    #idialog = context.app.instance.dialog('Google account')


    # Input credentials
    entry = get_showing_node_name('Enter your email', dialog)
    if entry.text != user:
        entry.click()
        typeText(user)
    if dialog.findChildren(lambda x: x.roleName == 'password text') == []:
        dialog.child('Next').click()
    get_showing_node_name('Password', dialog).click()
    typeText(password)
    keyCombo('<Enter>')
    #get_showing_node_name('Sign in', dialog).click()

    # Wait for Allow to appear
    third_party_icon_pred = GenericPredicate(roleName='push button',
                                             name='Allow')
    for attempts in range(0, 40):  # pylint: disable=W0612
        if dialog.findChild(third_party_icon_pred,
                            retry=False,
                            requireResult=False) is not None:
            break
        else:
            doDelay(0.5)

    allow_button = dialog.child("Allow", roleName='push button')
    if not allow_button.showing:
        # Scroll to confirmation button
        scrolls = dialog.findChildren(
            GenericPredicate(roleName='scroll bar'))
        scrolls[-1].value = scrolls[-1].maxValue
        pressKey('space')
        pressKey('space')

    # Wait for button to become enabled
    for attempts in range(0, 10):
        if pyatspi.STATE_SENSITIVE in \
                allow_button.getState().getStates():
            break
        else:
            doDelay(0.5)

    sleep(1)
    allow_button.click()
    assert wait_until(lambda x: x.dead, dialog), \
        "Dialog was not closed"
Beispiel #38
0
def drag(fromXY, toXY, button=1, check=True):
    """
    Synthesize a mouse press, drag, and release on the screen.
    """
    logger.log("Mouse button %s drag from %s to %s" % (button, fromXY, toXY))

    (x, y) = fromXY
    press(x, y, button, check)

    (x, y) = toXY
    absoluteMotion(x, y, check=check)
    doDelay()

    release(x, y, button, check)
    doDelay()
Beispiel #39
0
    def check_reclaim(self, optionsDlg):
        self.click_button("Reclaim space", node=optionsDlg)

        # Verify we are on the reclaim dialog.
        reclaimDlg = self.check_dialog_displayed("Reclaim")
        self.check_reclaim_buttons_before(reclaimDlg)

        # Click the Delete all button to free up enough space.
        self.click_button("Delete all", node=reclaimDlg)
        self.check_reclaim_buttons_after(reclaimDlg)

        # Click on Reclaim space, which should take us all the way back to the hub.
        self.click_button("Reclaim space", node=reclaimDlg)
        doDelay(5)
        self.check_window_displayed("INSTALLATION SUMMARY")
Beispiel #40
0
def drag(fromXY, toXY, button=1, check=True):
    """
    Synthesize a mouse press, drag, and release on the screen.
    """
    logger.log("Mouse button %s drag from %s to %s" % (button, fromXY, toXY))

    (x, y) = fromXY
    press(x, y, button, check)

    (x, y) = toXY
    absoluteMotion(x, y, check=check)
    doDelay()

    release(x, y, button, check)
    doDelay()
Beispiel #41
0
    def check_reclaim(self, optionsDlg):
        self.click_button("Reclaim space", node=optionsDlg)

        # Verify we are on the reclaim dialog.
        reclaimDlg = self.check_dialog_displayed("Reclaim")
        self.check_reclaim_buttons_before(reclaimDlg)

        # Click the Delete all button to free up enough space.
        self.click_button("Delete all", node=reclaimDlg)
        self.check_reclaim_buttons_after(reclaimDlg)

        # Click on Reclaim space, which should take us all the way back to the hub.
        self.click_button("Reclaim space", node=reclaimDlg)
        doDelay(5)
        self.check_window_displayed("INSTALLATION SUMMARY")
Beispiel #42
0
def dragWithTrajectory(fromXY, toXY, button=1, check=True):
    """
    Synthetize a mouse press, drag (including move events), and release on the screen
    """
    logger.log("Mouse button %s drag with trajectory from %s to %s" % (button, fromXY, toXY))

    (x, y) = fromXY
    press(x, y, button, check)

    (x, y) = toXY
    absoluteMotionWithTrajectory(fromXY[0], fromXY[1], x, y, check=check)
    doDelay()

    release(x, y, button, check)
    doDelay()
Beispiel #43
0
 def do(self):
     """
     Performs the given tree.Action, with appropriate delays and logging.
     """
     logger.log(str("%s on %s") % (str(self.name), self.node.getLogString()))
     if not self.node.sensitive:
         if config.ensureSensitivity:
             raise NotSensitiveError(self)
         else:
             nSE = NotSensitiveError(self)
             logger.log("Warning: " + str(nSE))
     if config.blinkOnActions:
         self.node.blink()
     result = self.__action.doAction(self.__index)
     doDelay(config.actionDelay)
     return result
Beispiel #44
0
def add_facebook_account(context, user, password):
    dialog = context.app.instance.dialog('Facebook account')
    # Input credentials
    assert wait_until(lambda x: x.findChildren(
        GenericPredicate(roleName='entry')) != [],
        dialog, timeout=90), \
        "Facebook auth window didn't appear"
    entry = dialog.child(roleName='entry')
    if entry.text != user:
        entry.text = user
    dialog.child(roleName='password text').text = password
    doDelay(1)
    dialog.child(roleName='password text').grabFocus()
    pressKey('Enter')
    assert wait_until(lambda x: x.dead, dialog), \
        "Dialog was not closed"
def add_facebook_account(context, user, password):
    dialog = context.app.instance.dialog('Facebook account')
    # Input credentials
    assert wait_until(lambda x: x.findChildren(
        GenericPredicate(roleName='entry')) != [],
        dialog, timeout=90), \
        "Facebook auth window didn't appear"
    entry = dialog.child(roleName='entry')
    if entry.text != user:
        entry.text = user
    dialog.child(roleName='password text').text = password
    doDelay(1)
    dialog.child(roleName='password text').grabFocus()
    pressKey('Enter')
    assert wait_until(lambda x: x.dead, dialog), \
        "Dialog was not closed"
Beispiel #46
0
def dragWithTrajectory(fromXY, toXY, button=1, check=True):
    """
    Synthetize a mouse press, drag (including move events), and release on the screen
    """
    logger.log("Mouse button %s drag with trajectory from %s to %s" %
               (button, fromXY, toXY))

    (x, y) = fromXY
    press(x, y, button, check)

    (x, y) = toXY
    absoluteMotionWithTrajectory(fromXY[0], fromXY[1], x, y, check=check)
    doDelay()

    release(x, y, button, check)
    doDelay()
Beispiel #47
0
def add_google_account(context, user, password):
    dialog = get_showing_node_name('Google account', context.app.instance)
    #idialog = context.app.instance.dialog('Google account')

    # Input credentials
    entry = get_showing_node_name('Enter your email', dialog)
    if entry.text != user:
        entry.click()
        typeText(user)
    if dialog.findChildren(lambda x: x.roleName == 'password text') == []:
        dialog.child('Next').click()
    get_showing_node_name('Password', dialog).click()
    typeText(password)
    keyCombo('<Enter>')
    #get_showing_node_name('Sign in', dialog).click()

    # Wait for Allow to appear
    third_party_icon_pred = GenericPredicate(roleName='push button',
                                             name='Allow')
    for attempts in range(0, 40):  # pylint: disable=W0612
        if dialog.findChild(third_party_icon_pred,
                            retry=False,
                            requireResult=False) is not None:
            break
        else:
            doDelay(0.5)

    allow_button = dialog.child("Allow", roleName='push button')
    if not allow_button.showing:
        # Scroll to confirmation button
        scrolls = dialog.findChildren(GenericPredicate(roleName='scroll bar'))
        scrolls[-1].value = scrolls[-1].maxValue
        pressKey('space')
        pressKey('space')

    # Wait for button to become enabled
    for attempts in range(0, 10):
        if pyatspi.STATE_SENSITIVE in \
                allow_button.getState().getStates():
            break
        else:
            doDelay(0.5)

    sleep(1)
    allow_button.click()
    assert wait_until(lambda x: x.dead, dialog), \
        "Dialog was not closed"
Beispiel #48
0
    def _run(self):
        # Before doing anything, verify we are still on the summary hub.
        w = self.check_window_displayed("INSTALLATION SUMMARY")

        # network or disk may be slow. wait for them
        self.wait_for_configuration_to_settle(w)

        # All spokes should have been visited and satisfied now.
        self.check_no_warning_bar(w)
        self.check_begin_installation_button(w)

        # Click the begin installation button, wait a moment, and now we should
        # be on the progress hub.
        self.click_button("Begin Installation", node=w)

        w = self.check_window_displayed("CONFIGURATION")
        self.check_shown_spoke_selectors(w)
        self.check_warning_bar(node=w)
        self.check_help_button(w)

        # Now we need to wait for installation to finish.  We're doing that two ways:
        # (1) Set a 30 minute timeout.  Should we hit that, anaconda's clearly not
        #     going to finish (or is hung or something) and we should fail.
        # (2) Poll the UI waiting for the "Complete!" message to pop up.  Once
        #     that happens, we know it's time to test the user settings stuff and
        #     the end of the UI.
        signal.signal(signal.SIGALRM, self._timer_expired)
        signal.alarm(30 * 60)

        while True:
            label = self.find("Complete!", node=w)
            if label:
                signal.alarm(0)
                break

            doDelay(20)

        # If we got here, installation completed successfully.  Since we've not
        # done a password or created a user yet, we still have to do that.  The
        # finish configuration button should still be insensitive.
        button = self.find("Finish configuration", "push button", node=w)
        self.assertIsNotNone(button,
                             msg="Finish configuration button not found")
        self.assertFalse(
            button.sensitive,
            msg="Finish Configuration button should not be sensitive")
Beispiel #49
0
    def wait_for_configuration_to_settle(self, spoke):
        """ Wait for some of the configuration to settle down
            before continuing further.
        """
        selectors = spoke.findChildren(GenericPredicate(roleName="spoke selector"))

        for wait_for in ["INSTALLATION SOURCE", "SOFTWARE SELECTION", "INSTALLATION DESTINATION"]:
            retry = 0
            while retry < 5:
                for selector in selectors:
                    if (selector.name == wait_for):
                        if not selector.sensitive:
                            retry += 1
                            doDelay(10)
                        else:
                            retry = 5 # break while
                            break
Beispiel #50
0
    def die(self, terminate=False):
        """Kill any running process previously started by this test."""
        if self._proc:
            if terminate:
                self._proc.terminate()

            # tests will click the Reboot or Quit button which will shutdown anaconda
            # we need to make sure /mnt/sysimage/* are unmounted and device mapper devices
            # are removed before starting the next test. ATM I have no idea if pyanaconda
            # provides an API for this so wait for a while instead!
            doDelay(30)

            self._proc.kill()
            self._proc = None
            try:
                os.remove('/var/run/anaconda.pid')
            except OSError:
                pass
Beispiel #51
0
    def die(self, terminate=False):
        """Kill any running process previously started by this test."""
        if self._proc:
            if terminate:
                self._proc.terminate()

            # tests will click the Reboot or Quit button which will shutdown anaconda
            # we need to make sure /mnt/sysimage/* are unmounted and device mapper devices
            # are removed before starting the next test. ATM I have no idea if pyanaconda
            # provides an API for this so wait for a while instead!
            doDelay(30)

            self._proc.kill()
            self._proc = None
            try:
                os.remove('/var/run/anaconda.pid')
            except OSError:
                pass
Beispiel #52
0
    def typeText(self, string):
        """
        Type the given text into the node, with appropriate delays and logging.
        """
        logger.log(str("Typing text into %s: '%s'") % (self.getLogString(), str(string)))

        if self.focusable:
            if not self.focused:
                try:
                    self.grabFocus()
                except Exception:
                    logger.log("Node is focusable but I can't grabFocus!")
            rawinput.typeText(string)
        else:
            logger.log("Node is not focusable; falling back to inserting text")
            et = self.queryEditableText()
            et.insertText(self.caretOffset, string, len(string))
            self.caretOffset += len(string)
            doDelay()
Beispiel #53
0
    def _run(self):
        # Before doing anything, verify we are still on the summary hub.
        w = self.check_window_displayed("INSTALLATION SUMMARY")

        # network or disk may be slow. wait for them
        self.wait_for_configuration_to_settle(w)

        # All spokes should have been visited and satisfied now.
        self.check_no_warning_bar(w)
        self.check_begin_installation_button(w)

        # Click the begin installation button, wait a moment, and now we should
        # be on the progress hub.
        self.click_button("Begin Installation", node=w)

        w = self.check_window_displayed("CONFIGURATION")
        self.check_shown_spoke_selectors(w)
        self.check_warning_bar(node=w)
        self.check_help_button(w)

        # Now we need to wait for installation to finish.  We're doing that two ways:
        # (1) Set a 30 minute timeout.  Should we hit that, anaconda's clearly not
        #     going to finish (or is hung or something) and we should fail.
        # (2) Poll the UI waiting for the "Complete!" message to pop up.  Once
        #     that happens, we know it's time to test the user settings stuff and
        #     the end of the UI.
        signal.signal(signal.SIGALRM, self._timer_expired)
        signal.alarm(30*60)

        while True:
            label = self.find("Complete!", node=w)
            if label:
                signal.alarm(0)
                break

            doDelay(20)

        # If we got here, installation completed successfully.  Since we've not
        # done a password or created a user yet, we still have to do that.  The
        # finish configuration button should still be insensitive.
        button = self.find("Finish configuration", "push button", node=w)
        self.assertIsNotNone(button, msg="Finish configuration button not found")
        self.assertFalse(button.sensitive, msg="Finish Configuration button should not be sensitive")
Beispiel #54
0
    def wait_for_configuration_to_settle(self, spoke):
        """ Wait for some of the configuration to settle down
            before continuing further.
        """
        selectors = spoke.findChildren(
            GenericPredicate(roleName="spoke selector"))

        for wait_for in [
                "INSTALLATION SOURCE", "SOFTWARE SELECTION",
                "INSTALLATION DESTINATION"
        ]:
            retry = 0
            while retry < 5:
                for selector in selectors:
                    if (selector.name == wait_for):
                        if not selector.sensitive:
                            retry += 1
                            doDelay(10)
                        else:
                            retry = 5  # break while
                            break
Beispiel #55
0
    def _run(self):
        # Before doing anything, verify we are still on the progress hub.
        w = self.check_window_displayed("CONFIGURATION")

        self.check_finish_config_button(w)
        # We've completed configuration, so the warning bar should be gone.
        self.check_no_warning_bar(node=w)

        # And now we wait for configuration to finish.  Then we check the
        # reboot button, but don't click it.  The end of the test case shuts
        # down the system for us.
        signal.signal(signal.SIGALRM, self._timer_expired)
        signal.alarm(5 * 60)

        while True:
            button = self.find("Reboot", "push button", node=w)
            if button and button.showing:
                signal.alarm(0)
                break

            doDelay(20)

        self.click_button("Reboot", node=w)