def test_app_started(context, app):
    # Dogtail seems to cache applications list
    # So we should wait for exception here
    try:
        root.application(app.lower()).child(roleName='frame')
    except SearchError:
        raise RuntimeError("App '%s' is not running" % app)
def test_app_started(context, app):
    # Dogtail seems to cache applications list
    # So we should wait for exception here
    try:
        root.application(app.lower()).child(roleName='frame')
    except SearchError:
        raise RuntimeError("App '%s' is not running" % app)
Exemple #3
0
def test_app_started(context, app):  # pylint: disable=W0613
    logging.debug('app = {}'.format(context.app.a11yAppName))
    for i in range(0, 10):
        try:
            root.application(context.app.a11yAppName).child(roleName='frame')
            break
        except SearchError:
            raise RuntimeError("App '%s' is not running" % context.app.a11yAppName)
        except GLib.GError:
            continue
Exemple #4
0
def test_app_started(context, app):  # pylint: disable=W0613
    logging.debug('app = {}'.format(context.app.a11yAppName))
    for i in range(0, 10):
        try:
            root.application(context.app.a11yAppName).child(roleName='frame')
            break
        except SearchError:
            raise RuntimeError("App '%s' is not running" %
                               context.app.a11yAppName)
        except GLib.GError:
            continue
Exemple #5
0
def startViaKDEMenu(context, app):
    """ Will run the app through the standard application launcher """
    corner_distance = 10
    height = Gdk.Display.get_default().get_default_screen().get_root_window().get_height()
    click(corner_distance, height - corner_distance)
    plasma = root.application('plasma-desktop')
    plasma.child(name='Search:', roleName='label').parent.child(roleName='text').text = context.app.appCommand
    sleep(0.5)
    pressKey('enter')
    assert wait_until(lambda x: isKDEAppRunning(x), context.app, timeout=30),\
        "Application failed to start"
    context.app.instance = root.application(context.app.a11yAppName)
Exemple #6
0
def handle_authentication_window(context, password='******'):
    # Get a list of applications
    app_names = []
    for attempt in range(0, 15):
        try:
            app_names = map(lambda x: x.name, root.applications())
            break
        except GLib.GError:
            sleep(1)
            continue
    if 'gcr-prompter' in app_names:
        # Non gnome shell stuf
        passprompt = root.application('gcr-prompter')
        continue_button = passprompt.findChild(
            GenericPredicate(name='Continue'),
            retry=False,
            requireResult=False)
        if continue_button:
            passprompt.findChildren(
                GenericPredicate(roleName='password text'))[-1].grab_focus()
            sleep(0.5)
            typeText(password)
            # Don't save passwords to keyring
            keyCombo('<Tab>')
            # Click Continue
            keyCombo('<Tab>')
            keyCombo('<Tab>')
            keyCombo('<Enter>')
    elif 'gnome-shell' in app_names:
        shell = root.application('gnome-shell')
        # if wait_until(lambda x: x.findChildren(
        #         lambda x: x.roleName == 'password text' and x.showing) != [], shell):
        #     pswrd = shell.child(roleName='password text')
        #     pswrd.text = password
        #     st = shell.child('Add this password to your keyring')
        #     if not st.parent.parent.checked:
        #         st.click()
        #     continue_button = shell.button('Continue')
        #     shell.button('Continue').click()
        #     sleep(3)
        if wait_until(
                lambda x: x.findChildren(lambda x: x.roleName ==
                                         'password text' and x.showing) != [],
                shell):
            st = shell.child('Add this password to your keyring')
            if not st.parent.parent.checked:
                st.click()
            pswrd = shell.child(roleName='password text')
            pswrd.click()
            typeText(password)
            keyCombo('<Enter>')
            wait_until(st.dead)
            sleep(1)
Exemple #7
0
def then_app_is_dead(context, app):  # pylint: disable=W0613
    isRunning = True
    for i in range(0, 10):
        try:
            root.application(context.app.a11yAppName).child(roleName='frame')
            sleep(1)
        except SearchError:
            isRunning = False
            break
        except GLib.GError:
            continue
    if isRunning:
        raise RuntimeError("App '%s' is running" % context.app.a11yAppName)
Exemple #8
0
def then_app_is_dead(context, app):  # pylint: disable=W0613
    isRunning = True
    for i in range(0, 10):
        try:
            root.application(context.app.a11yAppName).child(roleName='frame')
            sleep(1)
        except SearchError:
            isRunning = False
            break
        except GLib.GError:
            continue
    if isRunning:
        raise RuntimeError("App '%s' is running" % context.app.a11yAppName)
Exemple #9
0
def startViaKDEMenu(context, app):
    """ Will run the app through the standard application launcher """
    corner_distance = 10
    height = Gdk.Display.get_default().get_default_screen().get_root_window(
    ).get_height()
    click(corner_distance, height - corner_distance)
    plasma = root.application('plasma-desktop')
    plasma.child(name='Search:', roleName='label').parent.child(
        roleName='text').text = context.app.appCommand
    sleep(0.5)
    pressKey('enter')
    assert wait_until(lambda x: isKDEAppRunning(x), context.app, timeout=30),\
        "Application failed to start"
    context.app.instance = root.application(context.app.a11yAppName)
def handle_authentication_window(context, password='******'):
    # Get a list of applications
    app_names = []
    for attempt in range(0, 15):
        try:
            app_names = map(lambda x: x.name, root.applications())
            break
        except GLib.GError:
            sleep(1)
            continue
    if 'gcr-prompter' in app_names:
        # Non gnome shell stuf
        passprompt = root.application('gcr-prompter')
        continue_button = passprompt.findChild(
            GenericPredicate(name='Continue'),
            retry=False, requireResult=False)
        if continue_button:
            passprompt.findChildren(GenericPredicate(roleName='password text'))[-1].grab_focus()
            sleep(0.5)
            typeText(password)
            # Don't save passwords to keyring
            keyCombo('<Tab>')
            # Click Continue
            keyCombo('<Tab>')
            keyCombo('<Tab>')
            keyCombo('<Enter>')
    elif 'gnome-shell' in app_names:
        shell = root.application('gnome-shell')
        # if wait_until(lambda x: x.findChildren(
        #         lambda x: x.roleName == 'password text' and x.showing) != [], shell):
        #     pswrd = shell.child(roleName='password text')
        #     pswrd.text = password
        #     st = shell.child('Add this password to your keyring')
        #     if not st.parent.parent.checked:
        #         st.click()
        #     continue_button = shell.button('Continue')
        #     shell.button('Continue').click()
        #     sleep(3)
        if wait_until(lambda x: x.findChildren(
                lambda x: x.roleName == 'password text' and x.showing) != [], shell):
            st = shell.child('Add this password to your keyring')
            if not st.parent.parent.checked:
                st.click()
            pswrd = shell.child(roleName='password text')
            pswrd.click()
            typeText(password)
            keyCombo('<Enter>')
            wait_until(st.dead)
            sleep(1)
Exemple #11
0
    def startViaMenu(self, throughCategories=False):  # pylint: disable=W0613
        """
        Start the app via Gnome Shell menu
        """
        desktopConfig = self.parseDesktopFile()

        if self.forceKill and self.isRunning():
            self.kill()
            assert wait_until(lambda x: not x.isRunning(), self, timeout=30),\
                "Application cannot be stopped"

        # panel button Activities
        gnomeShell = root.application('gnome-shell')
        os.system("dbus-send --session --type=method_call " +
                  "--dest='org.gnome.Shell' " +
                  "'/org/gnome/Shell' " +
                  "org.gnome.Shell.FocusSearch")
        textEntry = gnomeShell.textentry('')
        assert wait_until(lambda x: x.showing, textEntry), \
            "Can't find gnome shell search textbar"

        typeText(self.desktopFileName)
        keyCombo('<Enter>')

        assert wait_until(lambda x: x.isRunning(), self, timeout=30),\
            "Application failed to start"
Exemple #12
0
    def testDockTerminal(self):
        try:
            iconterminal = self.ddedockobject.child(self.terminaliconname)
        except:
            self.assertTrue(False, "Can't find the terminal icon on the Dock")

        iconterminal.click(3)

        try:
            dockmenuapp = root.application('deepin-menu',
                                           '/usr/lib/deepin-menu')
            dockmenu = dockmenuapp.child(utils.dock.dockmenuname)
        except:
            self.assertTrue(False, "Can't find dockmenu")

        self.assertTrue(dockmenu.position[0] > 1)
        self.assertTrue(dockmenu.position[1] > 1)
        self.assertTrue(dockmenu.size[0] > 1)
        self.assertTrue(dockmenu.size[1] > 1)

        utils.keySingle(utils.k.down_key)
        utils.keySingle(utils.k.down_key)
        utils.keySingle(utils.k.down_key)
        utils.keySingle(utils.k.down_key)
        utils.keySingle(utils.k.down_key)
        utils.keySingle(utils.k.down_key)
        utils.keySingle(utils.k.enter_key)
    def startViaMenu(self, throughCategories=False):  # pylint: disable=W0613
        """
        Start the app via Gnome Shell menu
        """
        desktopConfig = self.parseDesktopFile()

        if self.forceKill and self.isRunning():
            self.kill()
            assert wait_until(lambda x: not x.isRunning(), self, timeout=30),\
                "Application cannot be stopped"

        # panel button Activities
        gnomeShell = root.application('gnome-shell')
        os.system("dbus-send --session --type=method_call " +
                  "--dest='org.gnome.Shell' " + "'/org/gnome/Shell' " +
                  "org.gnome.Shell.FocusSearch")
        textEntry = gnomeShell.textentry('')
        assert wait_until(lambda x: x.showing, textEntry), \
            "Can't find gnome shell search textbar"

        app_name = self.getName(desktopConfig)
        typeText(app_name)
        sleep(1)
        icons = gnomeShell.findChildren(
            GenericPredicate(roleName='label', name=app_name))
        visible_icons = [x for x in icons if x.showing]
        assert wait_until(lambda x: len(x) > 0, visible_icons), \
            "Can't find gnome shell icon for '%s'" % app_name
        visible_icons[0].click()

        assert wait_until(lambda x: x.isRunning(), self, timeout=30),\
            "Application failed to start"
def appointment_reminders_window_pops_up(context, num):
    alarm_notify = root.application('evolution-alarm-notify')
    assert wait_until(
        lambda x: x.findChildren(GenericPredicate(name='Appointments')) != [],
        element=alarm_notify, timeout=60 * int(num)),\
        "Appointments window didn't appear"
    context.app.alarm_notify = alarm_notify.child(name='Appointments')
    def startViaMenu(self, throughCategories=False):  # pylint: disable=W0613
        """
        Start the app via Gnome Shell menu
        """
        desktopConfig = self.parseDesktopFile()

        if self.forceKill and self.isRunning():
            self.kill()
            assert wait_until(lambda x: not x.isRunning(), self, timeout=30),\
                "Application cannot be stopped"

        # panel button Activities
        gnomeShell = root.application('gnome-shell')
        os.system("dbus-send --session --type=method_call " +
                  "--dest='org.gnome.Shell' " +
                  "'/org/gnome/Shell' " +
                  "org.gnome.Shell.FocusSearch")
        textEntry = gnomeShell.textentry('')
        assert wait_until(lambda x: x.showing, textEntry), \
            "Can't find gnome shell search textbar"

        app_name = self.getName(desktopConfig)
        typeText(app_name)
        sleep(1)
        icons = gnomeShell.findChildren(GenericPredicate(roleName='label',
                                                         name=app_name))
        visible_icons = [x for x in icons if x.showing]
        assert wait_until(lambda x: len(x) > 0, visible_icons), \
            "Can't find gnome shell icon for '%s'" % app_name
        visible_icons[0].click()

        assert wait_until(lambda x: x.isRunning(), self, timeout=30),\
            "Application failed to start"
Exemple #16
0
def getDashIconPosition(name):
    """Get a position of icon on Overview dash"""
    over = root.application('gnome-shell').child(name='Overview')
    button = over[2].child(name=name)
    (x, y) = button.position
    (a, b) = button.size
    return (x + a / 2, y + b / 2)
 def getDashIconPosition(name):
     """Get a position of miniature on Overview"""
     over = root.application('gnome-shell').child(name='Overview')
     button = over[2].child(name=name)
     (x, y) = button.position
     (a, b) = button.size
     return (x + a / 2, y + b / 2)
Exemple #18
0
 def start(self):
     if self.is_running:
         self.stop()
     self.proc = Popen(self.exec.split(), stdout=PIPE, stderr=STDOUT)
     sleep(1)
     self.instance = root.application(self.a11y_app_name)
     self.main_window_name = self.instance.child(roleName='frame').name
def setup_function(module):
    config.searchCutoffCount = 2
    config.defaultDelay = 1.5
    config.blinkOnActions = True
    config.fatalErrors = True
    module.pidgin_pid = run('pidgin -c ./base_purple')
    module.pidgin = root.application('Pidgin')
def action_to_run_specified_program(context, action):
    alarm_notify = root.application('evolution-alarm-notify')
    dialog = alarm_notify.dialog('Warning')
    if action == 'Agree':
        dialog.button('Yes').click()
    else:
        dialog.button('No').click()
    def testSelectMenuNewWindow(self):
        try:
            iconfilemanager = self.ddedockobject.child(
                self.filemanagericonname)
        except:
            self.assertTrue(False,
                            "Can't find the file manager icon on the Dock")

        iconfilemanager.click(3)

        try:
            dockmenuapp = root.application('deepin-menu',
                                           '/usr/lib/deepin-menu')
            dockmenu = dockmenuapp.child(utils.dock.dockmenuname)
        except:
            self.assertTrue(False, "Can't find dockmenu")

        self.assertTrue(dockmenu.position[0] > 1)
        self.assertTrue(dockmenu.position[1] > 1)
        self.assertTrue(dockmenu.size[0] > 1)
        self.assertTrue(dockmenu.size[1] > 1)

        utils.keySingle(utils.k.down_key)
        utils.keySingle(utils.k.down_key)
        utils.keySingle(utils.k.enter_key)
Exemple #22
0
 def quit_application(self):
     try:  # Quiting the application via gnome-shell menu
         shell = root.application('gnome-shell')
         shell.child(self.app).click()
         shell.child('Quit').click()
         return True
     except:
         return False
Exemple #23
0
def presentation_window_state(context, window_state):
    soffice = root.application('soffice')
    all_frames = [x.name for x in soffice.findChildren(lambda x: x.roleName == 'frame')]

    if window_state == 'open':
        assert '' in all_frames
    elif window_state == 'closed':
        assert '' not in all_frames
Exemple #24
0
    def setUp(self):
        # Force the locale/language to English.
        # Otherwise we won't be able to grab the right widgets.
        os.environ["LC_ALL"] = 'C'
        # Try to speed up UI interaction a little.
        # Do not change "typingDelay" from its default (0.075 secs);
        # Setting it too low makes dogtail type characters in random order!
        from dogtail.config import config
        config.load({'actionDelay': 0.1,
                     'runTimeout': 1,
                     'searchCutoffCount': 5,
                     'defaultDelay': 0.1})
        from dogtail.utils import run
        from dogtail.tree import root
        # Setting appName is critically important here.
        # Otherwise it will try to look for "bin/pitivi" through AT-SPI and fail,
        # making the tests take ages to start up.
        self.pid = run('bin/pitivi', dumb=False, appName="pitivi")
        # Apparently, if we start inspecting "too fast"... we slow down startup.
        # With GNOME 3.6, startup would be delayed to the point where the "Esc"
        # keypress to dismiss the welcome dialog would happen too soon.
        sleep(1)

        self.pitivi = root.application('pitivi')
        timer_start = time()
        # This is a performance hack to very quickly get the widgets we want,
        # by using their known position instead of searching.
        # Reuse those variables throughout your scripts for efficient access.
        # FIXME: this will probably break with detached tabs.
        mainwindow = self.pitivi.children[0].children[0]  # this is a vbox
        mainwindow_upper = mainwindow.children[2].child(name="upper half", recursive=False)
        timeline_area = mainwindow.children[2].child(name="timeline area", recursive=False)
        primary_tabs = mainwindow_upper.children[0].child(name="primary tabs", recursive=False)
        secondary_tabs = mainwindow_upper.children[0].child(name="secondary tabs", recursive=False)
        # These are the "shortcut" variables you can use for better perfs:
        self.menubar = mainwindow.child(roleName='menu bar')
        self.medialibrary = primary_tabs.children[0]
        self.effectslibrary = primary_tabs.children[1]
        self.clipproperties = secondary_tabs.children[0]
        self.transitions = secondary_tabs.children[0]
        self.titles = secondary_tabs.children[0]
        self.viewer = mainwindow_upper.child(name="viewer", recursive=False)
        self.zoom_best_fit_button = timeline_area.child(name="Zoom", recursive=True)
        self.timeline = timeline_area.child(name="timeline canvas", recursive=False)
        self.timeline_toolbar = timeline_area.child(name="timeline toolbar", recursive=False)
        # Used to speed up helper_functions in particular:
        self.import_button = self.medialibrary.child(name="media_import_button")
        self.insert_button = self.medialibrary.child(name="media_insert_button")
        start_time = time() - timer_start
        if start_time > 0.1:
            # When we were simply searching the toplevel for the menu bar,
            # startup time was 0.0043 seconds. Anything significantly longer
            # means there are optimizations to be done, avoid recursive searches
            print "\nWARNING: setUp in test_base took", start_time, "seconds, that's too slow.\n"
        try:
            self.unlink
        except AttributeError:
            self.unlink = []
def wait_for_evolution_to_appear(context):
    # Waiting for a window to appear
    try:
        context.app.instance = root.application('evolution')
        context.app.instance.child(roleName='frame')
    except (GLib.GError, SearchError):
        os.system("python cleanup.py")
        os.system("evolution --force-shutdown 2&> /dev/null")
        raise RuntimeError("Evolution cannot be started")
Exemple #26
0
def help_is_displayed(context, name):
    try:
        context.yelp = root.application('yelp')
        frame = context.yelp.child(roleName='frame')
        wait_until(lambda x: x.showing, frame)
        sleep(1)
        context.assertion.assertEquals(name, frame.name)
    finally:
        os.system("killall yelp")
Exemple #27
0
def help_is_displayed(context, name):
    try:
        context.yelp = root.application('yelp')
        frame = context.yelp.child(roleName='frame')
        wait_until(lambda x: x.showing, frame)
        sleep(1)
        context.assertion.assertEquals(name, frame.name)
    finally:
        os.system("killall yelp")
Exemple #28
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")
Exemple #29
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")
Exemple #30
0
def translateAllStrings(appName):
    """
    Test of the translation functions.

    Take all user-visible strings in an app that's running in the default locale
    and try translating them all into the locale that this script is running in.
    """
    for string in root.application(appName).getUserVisibleStrings():
        print(("User-visible string: %s" % string))
        print(("Translation is:%s" % dogtail.i18n.translate(string)))
Exemple #31
0
def translateAllStrings(appName):
    """
    Test of the translation functions.

    Take all user-visible strings in an app that's running in the default locale
    and try translating them all into the locale that this script is running in.
    """
    for string in root.application(appName).getUserVisibleStrings():
        print "User-visible string: %s"%string
        print "Translation is:%s"%dogtail.i18n.translate(string)
def close_appointments_window(context):
    if filter(lambda x: x.name == 'evolution-alarm-notify', root.applications()):
        alarm_notify = root.application('evolution-alarm-notify')
        dialog = alarm_notify.findChild(
            GenericPredicate(name='Appointments'),
            retry=False, requireResult=False)
        if dialog:
            dialog.button('Dismiss All').click()
            assert wait_until(lambda x: x.dead and not x.showing, dialog),\
                "Appointments window didn't disappear"
Exemple #33
0
 def getGnomePanelQuit(self):
     """
     Return object of Quit button in gnome-panel menu
     It's the only way how to find out the gnome-panel menu...
     """
     try:
         return root.application('gnome-shell').child('Quit')
     except:
         raise Exception("Quit menu item at gnome-panel menu" +
                         " could not be found!")
Exemple #34
0
 def getGnomePanelMenu(self):
     """
     Return object of gnome-panel menu of the app
     """
     try:
         app = root.application('gnome-shell')
         menu = app.child(roleName='menu')
         return menu.child(self.getName(), roleName='label')
     except:
         raise Exception("Gnome-panel menu of the app could not be found!")
Exemple #35
0
def evo_account_assistant_receiving_email_dialog_from_table(
        context, sending_or_receiving):
    window = context.app.child(roleName='frame')
    for row in context.table:
        label = str(row['Field'])
        value = str(row['Value'])
        filler = window.child(roleName='filler',
                              name='%s Email' % sending_or_receiving)
        widgets = filler.findChildren(lambda x: x.showing)
        visible_widgets = [
            x for x in widgets if x.labeller and x.labeller.name == label
        ]
        if len(visible_widgets) == 0:
            raise RuntimeError("Cannot find visible widget labelled '%s'" %
                               label)
        widget = visible_widgets[0]
        if widget.roleName == 'combo box':
            if label != 'Port:':
                widget.click()
                widget.menuItem(value).click()
            else:
                # Port is a combobox, but you can type your port there
                widget.textentry('').text = value
                widget.textentry('').grab_focus()
                widget.textentry('').keyCombo("<Enter>")
        if widget.roleName == 'text':
            widget.text = value

    # Check for password here and accept self-generated certificate (if appears)
    btns = window.findChildren(lambda x: x.name == 'Check for Supported Types')
    visible_btns = [w for w in btns if w.showing]
    if visible_btns == []:
        click_next(window)
        return
    visible_btns[0].click()

    # Confirm all certificates by clicking 'Accept Permanently' until dialog is visible
    apps = [x.name for x in root.applications()]
    if 'evolution-user-prompter' in apps:
        prompter = root.application('evolution-user-prompter')
        dialog = prompter.child(roleName='dialog')
        while dialog.showing:
            if prompter.findChild(lambda x: x.name == 'Accept Permanently',
                                  retry=False,
                                  requireResult=False):
                prompter.button('Accept Permanently').click()
            else:
                sleep(0.1)

    # Wait until Cancel button disappears
    cancel = filler.findChildren(lambda x: x.name == 'Cancel')[0]
    while cancel.showing:
        sleep(0.1)
    check_for_errors(context)
    click_next(window)
Exemple #36
0
 def start(self, slideshow=None):
     """ start imagination, returns its root dogtail object """
     app = os.environ.get(
         "IMAGINATION",
         str(Path(__file__).parent.parent / "src" / "imagination"))
     cmd = app
     if slideshow:
         cmd += " " + str(slideshow)
     print("launching", cmd)
     run(cmd, timeout=4)
     self.imagination = root.application("imagination")
Exemple #37
0
def startViaKRunner(context, app):
    """ Simulates running app through Run command interface (alt-F2...)"""
    os.system('krunner')
    assert wait_until(lambda x: x.application('krunner'), root),\
        "KRunner didn't start"
    typeText(context.app.appCommand)
    sleep(1)
    pressKey('enter')
    assert wait_until(lambda x: isKDEAppRunning(x), context.app, timeout=30),\
        "Application failed to start"
    context.app.instance = root.application(context.app.a11yAppName)
def wait_for_app_to_appear(context, app):
    # Waiting for a window to appear
    for attempt in xrange(0, 10):
        try:
            context.app.instance = root.application(app.lower())
            context.app.instance.child(roleName='frame')
            break
        except (GLib.GError, SearchError):
            sleep(1)
            continue
    context.execute_steps("Then %s should start" % app)
Exemple #39
0
def wait_for_app_to_appear(context, app, timeout):
    # Waiting for a window to appear
    for i in range(0, timeout):
        try:
            context.app.instance = root.application(context.app.a11yAppName)
            context.app.instance.child(roleName='frame')
            break
        except (GLib.GError, SearchError):
            sleep(1)
            continue
    context.execute_steps(u"Then %s should start" % app)
Exemple #40
0
def wait_for_app_to_appear(context, app, timeout):
    # Waiting for a window to appear
    for i in range(0, timeout):
        try:
            context.app.instance = root.application(context.app.a11yAppName)
            context.app.instance.child(roleName='frame')
            break
        except (GLib.GError, SearchError):
            sleep(1)
            continue
    context.execute_steps(u"Then %s should start" % app)
Exemple #41
0
def startViaKRunner(context, app):
    """ Simulates running app through Run command interface (alt-F2...)"""
    os.system('krunner')
    assert wait_until(lambda x: x.application('krunner'), root),\
        "KRunner didn't start"
    typeText(context.app.appCommand)
    sleep(1)
    pressKey('enter')
    assert wait_until(lambda x: isKDEAppRunning(x), context.app, timeout=30),\
        "Application failed to start"
    context.app.instance = root.application(context.app.a11yAppName)
def wait_for_app_to_appear(context, app):
    # Waiting for a window to appear
    for attempt in xrange(0, 10):
        try:
            context.app.instance = root.application(app.lower())
            context.app.instance.child(roleName='frame')
            break
        except (GLib.GError, SearchError):
            sleep(1)
            continue
    context.execute_steps("Then %s should start" % app)
Exemple #43
0
    def get_current_window(self, dialog=False):
        """
        Returns current window (actually last opened one)
        """
        if dialog:
            role = 'dialog'
        else:
            role = 'frame'

        soffice = root.application('soffice')
        # all_frames = [x for x in soffice.findChildren(lambda x: x.roleName == role, recursive=False)]
        all_frames = [x for x in soffice.findChildren(lambda x: True, recursive=False)]
        return all_frames[-1]
Exemple #44
0
    def startViaCommand(self):
        """
        Start the app via command
        """
        if self.forceKill and self.isRunning():
            self.kill()
            assert not self.isRunning(), "Application cannot be stopped"

        command = "%s %s" % (self.appCommand, self.parameters)
        self.pid = run(command, timeout=1)

        assert self.isRunning(), "Application failed to start"
        return root.application(self.a11yAppName)
Exemple #45
0
    def startViaCommand(self):
        """
        Start the app via command
        """
        if self.forceKill and self.isRunning():
            self.kill()
            assert not self.isRunning(), "Application cannot be stopped"

        self.process = Popen(self.appCommand.split() + self.parameters.split(), stdout=PIPE, stderr=PIPE, bufsize=0)
        self.pid = self.process.pid

        assert self.isRunning(), "Application failed to start"
        return root.application(self.a11yAppName)
    def startViaCommand(self):
        """
        Start the app via command
        """
        if self.forceKill and self.isRunning():
            self.kill()
            assert not self.isRunning(), "Application cannot be stopped"

        command = "%s %s" % (self.appCommand, self.parameters)
        self.pid = run(command, timeout=10)

        assert self.isRunning(), "Application failed to start"
        return root.application(self.a11yAppName)
    def startViaMenu(self, throughCategories = False):
        self.parseDesktopFile()
        if self.forceKill and self.isRunning():
            self.kill()
            sleep(2)
            assert not self.isRunning(), "Application cannot be stopped"
        try:
            gnomeShell = root.application('gnome-shell')
            pressKey('Super_L')
            sleep(6)
            if throughCategories:
                # menu Applications
                x, y = getDashIconPosition('Show Applications')
                absoluteMotion(x, y)
                time.sleep(1)
                click(x, y)
                time.sleep(4) # time for all the oversized app icons to appear

                # submenu that contains the app
                submenu = gnomeShell.child(
                    name=self.getMenuGroups(), roleName='list item')
                submenu.click()
                time.sleep(4)

                # the app itself
                app = gnomeShell.child(
                    name=self.getName(), roleName='label')
                app.click()
            else:
                typeText(self.getName())
                sleep(2)
                pressKey('Enter')

            assert self.isRunning(), "Application failed to start"
        except SearchError:
            print("!!! Lookup error while passing the path")
        
        return root.application(self.a11yAppName)
Exemple #48
0
def select_menuitem(context, menu):
    menu_item = menu.split(' -> ')
    # First level menu
    context.app.instance = root.application('soffice')
    current = context.app.instance.menu(menu_item[0])
    current.click()
    if len(menu_item) == 1:
        return
    # Intermediate menus
    for item in menu_item[1:-1]:
        current = context.app.instance.menu(item)
        current.click()
    # Last level menu item
    current.menuItem(menu_item[-1]).doActionNamed('click')
Exemple #49
0
def select_menuitem(context, menu):
    menu_item = menu.split(' -> ')
    # First level menu
    context.app.instance = root.application('soffice')
    current = context.app.instance.menu(menu_item[0])
    current.click()
    if len(menu_item) == 1:
        return
    # Intermediate menus
    for item in menu_item[1:-1]:
        current = context.app.instance.menu(item)
        current.click()
    # Last level menu item
    current.menuItem(menu_item[-1]).doActionNamed('click')
def evo_account_assistant_receiving_email_dialog_from_table(context, sending_or_receiving):
    window = context.app.instance.child('Evolution Account Assistant')
    for row in context.table:
        label = str(row['Field'])
        value = str(row['Value'])
        filler = window.child(roleName='filler', name='%s Email' % sending_or_receiving)
        widgets = filler.findChildren(GenericPredicate(label=label))
        visible_widgets = [w for w in widgets if w.showing]
        if len(visible_widgets) == 0:
            raise RuntimeError("Cannot find visible widget labelled '%s'" % label)
        widget = visible_widgets[0]
        if widget.roleName == 'combo box':
            if label != 'Port:':
                widget.click()
                widget.menuItem(value).click()
            else:
                # Port is a combobox, but you can type your port there
                widget.textentry('').text = value
                widget.textentry('').grab_focus()
                widget.textentry('').keyCombo("<Enter>")
        if widget.roleName == 'text':
            widget.text = value

    # Check for password here and accept self-generated certificate (if appears)
    btns = window.findChildren(GenericPredicate(name='Check for Supported Types'))
    visible_btns = [w for w in btns if w.showing]
    if visible_btns == []:
        click_continue(window)
        return
    visible_btns[0].click()

    # Confirm all certificates by clicking 'Accept Permanently' until dialog is visible
    apps = [x.name for x in root.applications()]
    if 'evolution-user-prompter' in apps:
        prompter = root.application('evolution-user-prompter')
        dialog = prompter.findChild(GenericPredicate(roleName='dialog'))
        while dialog.showing:
            if prompter.findChild(
                    GenericPredicate(name='Accept Permanently'),
                    retry=False, requireResult=False):
                prompter.button('Accept Permanently').click()
            else:
                sleep(0.1)

    # Wait until Cancel button disappears
    cancel = filler.findChildren(GenericPredicate(name='Cancel'))[0]
    while cancel.showing:
        sleep(0.1)
    check_for_errors(context)
    click_continue(window)
    def startViaMenu(self, throughCategories=False):
        self.parseDesktopFile()
        if self.forceKill and self.isRunning():
            self.kill()
            sleep(2)
            assert not self.isRunning(), "Application cannot be stopped"
        try:
            gnomeShell = root.application('gnome-shell')
            pressKey('Super_L')
            sleep(6)
            if throughCategories:
                # menu Applications
                x, y = getDashIconPosition('Show Applications')
                absoluteMotion(x, y)
                time.sleep(1)
                click(x, y)
                time.sleep(4)  # time for all the oversized app icons to appear

                # submenu that contains the app
                submenu = gnomeShell.child(name=self.getMenuGroups(),
                                           roleName='list item')
                submenu.click()
                time.sleep(4)

                # the app itself
                app = gnomeShell.child(name=self.getName(), roleName='label')
                app.click()
            else:
                typeText(self.getName())
                sleep(2)
                pressKey('Enter')

            assert self.isRunning(), "Application failed to start"
        except SearchError:
            print("!!! Lookup error while passing the path")

        return root.application(self.a11yAppName)
Exemple #52
0
def start_galicaster():

    global galicaster
    global root, predicate

    import gi
    gi.require_version('Atspi', '2.0')
    gi.require_version('Wnck', '3.0')
    from dogtail.tree import root, predicate

    pid = is_running('run_galicaster')
    if pid:
        execute(['kill', str(pid)])
    run('python run_galicaster.py')
    galicaster = root.application('run_galicaster.py')
def start_galicaster():

    global galicaster
    global root, predicate

    import gi
    gi.require_version('Atspi', '2.0')
    gi.require_version('Wnck', '3.0')
    from dogtail.tree import root, predicate

    pid = is_running('run_galicaster')
    if pid:
        execute(['kill',str(pid)])
    run('python run_galicaster.py')
    galicaster = root.application('run_galicaster.py')
Exemple #54
0
    def startViaCommand(self):
        """
        Start the app via command
        """
        if self.forceKill and self.isRunning():
            self.kill()
            assert not self.isRunning(), "Application cannot be stopped"

        self.process = Popen(self.appCommand.split() + self.parameters.split(),
                             stdout=PIPE,
                             stderr=PIPE,
                             bufsize=0)
        self.pid = self.process.pid

        assert self.isRunning(), "Application failed to start"
        return root.application(self.a11yAppName)
Exemple #55
0
def getMiniaturesPosition(name):
    """Get a position of miniature on Overview"""
    miniatures = []

    over = root.application('gnome-shell').child(name='Overview')
    mini = over.parent.children[-1]
    if mini == over:
        #print "Overview is not active"
        return miniatures
    widgets = mini.findChildren(GenericPredicate(name=name, roleName='label'))

    for widget in widgets:
        (x, y) = widget.position
        (a, b) = widget.size
        miniatures.append((x + a / 2, y + b / 2 - 100))
    return miniatures
    def testSetDock(self):
        utils.keySingle(utils.k.windows_l_key)
        try:
            launcherwin = utils.findWindow("dde-launcher")
        except:
            self.assertTrue(False, "Can't open dde-launcher")

        utils.keyTypeString(self.filemanagerlauncher)

        app = launcher.getAppObj(self.filemanagericonname)
        app.click(3)

        try:
            dockmenuapp = root.application('deepin-menu',
                                           '/usr/lib/deepin-menu')
            dockmenu = dockmenuapp.child(utils.desktop.desktopmenuname)
        except:
            self.assertTrue(False, "Can't find desktopmenu")

        utils.keySingle('c')
Exemple #57
0
def do_polkit_agent(pw='deepin', action='Confirm'):
    app_name = 'Deepin Polkit Agent'
    polkit_agent = window.WindowState(app_name)
    win_polkit_agent = polkit_agent.getWindow()

    if None == win_polkit_agent:
        print("Window: %s does not exist." % app_name)
    else:
        dogtail_agent = root.application(
            'dde-polkit-agent', '/usr/lib/polkit-1-dde/dde-polkit-agent')
        PasswordInput = dogtail_agent.child('PasswordInput')
        PasswordInput.click()
        utils.keyTypeString(pw)

        if action == 'Confirm':
            Comfirm = dogtail_agent.child('Confirm')
            Comfirm.click()
        else:
            Cancel = dogtail_agent.child('Cancel')
            Cancel.click()