Exemple #1
0
def out_key(keyName, n=1, postdelay=0):
    """
    Press the key n times.
    """
    for i in range(n):
        rawinput.pressKey(keyName)
        time.sleep(postdelay)
    def __init__(self,
                 appName,
                 desktopFileName=None,
                 shortcut='<Control><Q>',
                 a11yAppName=None,
                 forceKill=True,
                 parameters='',
                 recordVideo=False):
        """
        Initialize object App
        appName     command to run the app
        shortcut    default quit shortcut
        a11yAppName app's a11y name is different than binary
        forceKill   is the app supposed to be kill before/after test?
        parameters  has the app any params needed to start? (only for startViaCommand)
        recordVideo start gnome-shell recording while running the app
        """
        self.appCommand = appName
        self.shortcut = shortcut
        self.forceKill = forceKill
        self.parameters = parameters
        self.internCommand = self.appCommand.lower()
        self.a11yAppName = a11yAppName
        self.recordVideo = recordVideo
        self.pid = None
        if desktopFileName is None:
            desktopFileName = self.appCommand
        self.desktopFileName = desktopFileName
        # a way of overcoming overview autospawn when mouse in 1,1 from start
        pressKey('Esc')
        absoluteMotion(100, 100, 2)

        # attempt to make a recording of the test
        if self.recordVideo:
            keyCombo('<Control><Alt><Shift>R')
Exemple #3
0
def outKey(keyName, n=1, postdelay=0):
    '''
    Press the key n times.
    '''
    for i in range(n):
        rawinput.pressKey(keyName)
        time.sleep(postdelay)
    def __init__(self,
                 appName,
                 shortcut='<Control><Q>',
                 a11yAppName=None,
                 forceKill=True,
                 parameters='',
                 recordVideo=False):
        """
        Initialize object App
        appName     command to run the app
        shortcut    default quit shortcut
        a11yAppName app's a11y name is different than binary
        forceKill   is the app supposed to be kill before/after test?
        parameters  has the app any params needed to start? (only for startViaCommand)
        recordVideo start gnome-shell recording while running the app
        """
        self.appCommand = appName
        self.shortcut = shortcut
        self.forceKill = forceKill
        self.parameters = parameters
        self.internCommand = self.appCommand.lower()
        self.a11yAppName = a11yAppName
        self.recordVideo = recordVideo
        self.pid = None

        # a way of overcoming overview autospawn when mouse in 1,1 from start
        pressKey('Esc')
        absoluteMotion(100, 100, 2)

        # attempt to make a recording of the test
        if self.recordVideo:
            keyCombo('<Control><Alt><Shift>R')
Exemple #5
0
def hit_keycombo(context, keycombo):
    sleep(0.2)
    if keycombo == "Enter":
        pressKey("Enter")
    else:
        keyCombo('%s' % keycombo)

    sleep(0.2)
Exemple #6
0
def hit_keycombo(context, keycombo):
    sleep(0.2)
    if keycombo == "Enter":
        pressKey("Enter")
    else:
        keyCombo('%s'%keycombo)

    sleep(0.2)
def insert_example_data(context, component):
    if component in ['Writer', 'Calc']:
        typeText('Example text')
        pressKey('Enter')
    elif component == 'Impress':
        context.execute_steps(u'''* Set current slide title to "Example"''')
    elif component == 'Draw':
        context.execute_steps(u'''* Select "Insert -> Fields -> File Name" menu''')
Exemple #8
0
def insert_example_data(context, component):
    if component in ['Writer', 'Calc']:
        typeText('Example text')
        pressKey('Enter')
    elif component == 'Impress':
        context.execute_steps(u'''* Set current slide title to "Example"''')
    elif component == 'Draw':
        context.execute_steps(u'''* Select "Insert -> Fields -> File Name" menu''')
Exemple #9
0
def start_app_component_via_command(context, app, component, type):
    context.app.parameters = '--' + component.lower()
    context.app.desktopFileName = 'libreoffice-' + component.lower()

    if type == 'command':
        context.app.startViaCommand()
    if type == 'menu':
        context.app.startViaMenu()
        pressKey('enter')
Exemple #10
0
def focus_window(context, window):
    if window == 'main':
        context.app.findChildren(lambda x: x.name == 'New' and x.showing and x.sensitive)[0].grabFocus()
    else:
        core = find_window(context, window)
        button = core.findChildren(lambda x: x.roleName == 'toggle button' and x.showing)[1]
        button.grabFocus()
        sleep(0.5)
        pressKey('Tab')
        sleep(0.5)
Exemple #11
0
def rename_vm(context, machine, name, way):
    if way == 'button':
        context.app.child(machine, roleName='push button').click()
        sleep(0.5)
    if way == 'label':
        context.app.child('General').child('Name').parent.child(roleName='text').click()
        keyCombo('<Ctrl><a>')
    typeText(name)
    pressKey('Enter')
    sleep(0.5)
Exemple #12
0
def add_value_to_cell(context, string_to_add, table_cell_name):
    # reuse of array so has to be empty!

    context.frame = context.app.get_current_window().child(roleName='document spreadsheet')
    try:
        cell = context.frame.child(roleName='table')[CELL_TRANSLATION[table_cell_name]]
        type_text_to_cell(string_to_add, cell)
        pressKey("enter")
        context.CELLS_INDEX_TEXT[CELL_TRANSLATION[table_cell_name]] = cell.text
    except KeyError:
        assert False, "%s is not supported character for this test!" % table_cell_name
Exemple #13
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)
Exemple #14
0
def rename_vm(context, machine, name, way):
    if way == 'button':
        context.app.child(machine, roleName='push button').click()
        sleep(0.5)
    if way == 'label':
        context.app.child('General').child('Name').parent.child(
            roleName='text').click()
        keyCombo('<Ctrl><a>')
    typeText(name)
    pressKey('Enter')
    sleep(0.5)
Exemple #15
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)
Exemple #16
0
def add_value_to_cell(context, string_to_add, table_cell_name):
    # reuse of array so has to be empty!

    context.frame = context.app.get_current_window().child(roleName='document spreadsheet')
    try:
        cell = context.frame.child(roleName='table')[CELL_TRANSLATION[table_cell_name]]
        type_text_to_cell(string_to_add, cell)
        pressKey("enter")
        context.CELLS_INDEX_TEXT[CELL_TRANSLATION[table_cell_name]] = cell.text
    except KeyError:
        assert False, "%s is not supported character for this test!" % table_cell_name
Exemple #17
0
def focus_window(context, window):
    if window == 'main':
        context.app.findChildren(lambda x: x.name == 'New' and x.showing and x.
                                 sensitive)[0].grabFocus()
    else:
        core = find_window(context, window)
        button = core.findChildren(
            lambda x: x.roleName == 'toggle button' and x.showing)[1]
        button.grabFocus()
        sleep(0.5)
        pressKey('Tab')
        sleep(0.5)
Exemple #18
0
def correct_sum_under_values(context):
    context.frame.child(roleName='table')[0].grabFocus()

    for i in range(0, len(VALUES)):
        pressKey('enter')

    text_input = context.app.get_current_window().child(
        roleName='document spreadsheet').parent.parent.findChildren(
        lambda x: x.roleName == 'tool bar' and x.name == 'Formula Tool Bar', recursive=False)[0]
    tx = text_input.child(roleName="paragraph").text
    assert context.sum_string == tx, \
        "Incorrect panel name, expected '%s' but was '%s'" % (context.sum_string, tx)
Exemple #19
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 #20
0
def revert_snapshot(context, vm_name, snap_name):
    context.execute_steps("""
        * Launch "Properties" for "%s" box
        * Press "Snapshots"
        """ % vm_name)

    name = context.app.findChildren(lambda x: x.name == snap_name and x.showing)[0]
    name.parent.child('Menu').click()
    revert = context.app.findChildren(lambda x: x.name == "Revert to this state" and x.showing)[0]
    revert.click()

    pressKey('Esc')
Exemple #21
0
def correct_sum_under_values(context):
    context.frame.child(roleName='table')[0].grabFocus()

    for i in range(0, len(VALUES)):
        pressKey('enter')

    text_input = context.app.get_current_window().child(
        roleName='document spreadsheet').parent.parent.findChildren(
        lambda x: x.roleName == 'tool bar' and x.name == 'Formula Tool Bar', recursive=False)[0]
    tx = text_input.child(roleName="paragraph").text
    assert context.sum_string == tx, \
        "Incorrect panel name, expected '%s' but was '%s'" % (context.sum_string, tx)
Exemple #22
0
def add_sheet_in_spreadsheet(context, sheet_name):
    menu_item_insert = context.app.get_current_window().child(roleName='menu bar')[3]
    menu_item_insert.click()
    menu_item_insert.child(name='Sheet...').click()
    context.dialog = context.app.get_current_window()
    assert context.dialog.name == "Insert Sheet", "Name of dialog is: %s, should be %s" % (
        context.dialog.name, "Insert Sheet")

    context.dialog.child(roleName='text', name='Name:').grabFocus()
    keyCombo("<CTRL>a")
    pressKey("del")
    typeText(sheet_name)
    context.dialog.child(name='OK', roleName='push button').click()
Exemple #23
0
def add_sheet_in_spreadsheet(context, sheet_name):
    menu_item_insert = context.app.get_current_window().child(roleName='menu bar')[3]
    menu_item_insert.click()
    menu_item_insert.child(name='Sheet...').click()
    context.dialog = context.app.get_current_window()
    assert context.dialog.name == "Insert Sheet", "Name of dialog is: %s, should be %s" % (
        context.dialog.name, "Insert Sheet")

    context.dialog.child(roleName='text', name='Name:').grabFocus()
    keyCombo("<CTRL>a")
    pressKey("del")
    typeText(sheet_name)
    context.dialog.child(name='OK', roleName='push button').click()
Exemple #24
0
def revert_snapshot(context, vm_name, snap_name):
    context.execute_steps("""
        * Launch "Properties" for "%s" box
        * Press "Snapshots"
        """ % vm_name)

    name = context.app.findChildren(
        lambda x: x.name == snap_name and x.showing)[0]
    name.parent.child('Menu').click()
    revert = context.app.findChildren(
        lambda x: x.name == "Revert to this state" and x.showing)[0]
    revert.click()

    pressKey('Esc')
    def __init__(self,
                 appName,
                 shortcut='<Control><Q>',
                 desktopFileName=None,
                 timeout=5,
                 a11yAppName=None,
                 forceKill=True,
                 parameters='',
                 recordVideo=False,
                 recordVideoName=None):
        """
        Initialize object App
        appName     command to run the app
        shortcut    default quit shortcut
        a11yAppName app's a11y name is different than binary
        timeout     timeout for starting and shuting down the app
        forceKill   is the app supposed to be kill before/after test?
        parameters  has the app any params needed to start? (only for
                    startViaCommand)
        recordVideo start gnome-shell recording while running the app
        recordVideoName filename template for renaming the screencast video
        desktopFileName = name of the desktop file if other than
                          appName (without .desktop extension)
        """
        self.appCommand = appName
        self.shortcut = shortcut
        self.timeout = timeout
        self.forceKill = forceKill
        self.parameters = parameters
        self.internCommand = self.appCommand.lower()
        self.a11yAppName = a11yAppName
        self.recordVideo = recordVideo
        self.recordVideoName = recordVideoName
        self.pid = None

        # a way of overcoming overview autospawn when mouse in 1,1 from start
        pressKey('Esc')
        absoluteMotion(100, 100, 2)

        # set correct desktop file name
        if desktopFileName is None:
            desktopFileName = self.appCommand
        self.desktopFileName = desktopFileName

        # attempt to make a recording of the test
        if self.recordVideo:
            # Screencasts stop after 30 secs by default, see https://bugzilla.redhat.com/show_bug.cgi?id=1163186#c1
            cmd = "gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length 600"
            Popen(cmd, shell=True, stdout=PIPE).wait()
            keyCombo('<Control><Alt><Shift>R')
Exemple #26
0
def select_cell(context, text, column_name, row_name):

    keyCombo('<F5>')
    sleep(1)
    context.dialog = context.app.get_current_window()
    assert "Navigator" == context.dialog.name, "Name of dialog is: %s, should be: %s"\
                                               % (context.dialog.name, "Navigator")

    column_field = context.dialog.child(name='Column', roleName='text')
    row_field = context.dialog.child(name='Row', roleName='text')
    column_field.text = column_name
    row_field.text = row_name
    pressKey("enter")
    typeText(text)
Exemple #27
0
def select_cell(context, text, column_name, row_name):

    keyCombo('<F5>')
    sleep(1)
    context.dialog = context.app.get_current_window()
    assert "Navigator" == context.dialog.name, "Name of dialog is: %s, should be: %s"\
                                               % (context.dialog.name, "Navigator")

    column_field = context.dialog.child(name='Column', roleName='text')
    row_field = context.dialog.child(name='Row', roleName='text')
    column_field.text = column_name
    row_field.text = row_name
    pressKey("enter")
    typeText(text)
Exemple #28
0
def table_created(context, type_of_records, tbname, dbname):
    button = context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'tree item' and x.text == tbname)[0]
    button.doubleClick()

    if button.showing:
        button.doubleClick()

    w = context.app.get_current_window()
    table = w.findChildren(
        lambda x: x.roleName == 'table' and x.name == 'Table' and x.showing)[0]
    i = 1

    tab_rec = []
    if type_of_records == "non-english":
        tab_rec = TABLE_RECORDS_NON_ENGLISH
    if type_of_records == "english":
        tab_rec = TABLE_RECORDS

    for record in tab_rec:

        assert table[i].text == record['id'],\
            "Incorrect text in column " + "id" + " and row " + str(i) + ", expected '%s' but was '%s'" % (
            record['id'], table[i].text)
        assert table[i + 1].text == record['name'],\
            "Incorrect text in column " + "name" + " and row " + str(i) + ", expected '%s' but was '%s'" % (
            record['name'], table[i + 1].text)
        assert table[i + 2].text == record['address'],\
            "Incorrect text in column " + "address" + " and row " + str(i) + ", expected '%s' but was '%s'" % (
            record['address'], table[i + 2].text)
        # there is commented assert for last column in table because thrue the accessibility its imposible to reach it
        # assert table[i+3].text == record['phone'], "Incorrect text in paragraph,\
        #  expected '%s' but was '%s'" % (record['phone'], table[i+3].text)
        i += len(record)

    j = 1
    for record in tab_rec:
        table[j].grabFocus()
        for i in range(0, len(tab_rec[0]) - 1):
            pressKey('\t')
        keyCombo('<Control>c')
        table[j + 1].grabFocus()
        keyCombo('<Control>a')
        keyCombo('<Control>v')
        keyCombo('<Enter>')
        assert table[j + 1].text == record[
            'phone'], "Incorrect text in paragraph, expected '%s' but was '%s'" % (
                record['phone'], table[j + 1].text)

        j += len(tab_rec[0])
Exemple #29
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 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"
Exemple #31
0
def select_menu_action(context, action):
    keyCombo("<Super_L><F10>")
    if action == 'About':
        pressKey('Down')
    if action == 'Quit':
        pressKey('Down')
        pressKey('Down')
    pressKey('Enter')
Exemple #32
0
def insert_values_and_create_sum(context):
    context.frame = context.app.get_current_window().child(roleName='document spreadsheet')
    context.frame.child(roleName='table')[0].grabFocus()
    for value in VALUES:
        typeText(value)
        pressKey('enter')
    context.sum_string = '='
    for i in range(1, len(VALUES) + 1):
        if i == len(VALUES):
            context.sum_string = context.sum_string + 'A' + str(i)
        else:
            context.sum_string = context.sum_string + 'A' + str(i) + '+'

    typeText(context.sum_string)
    pressKey('enter')
 def startViaKRunner(self):
     """ Simulates running app through Run command interface (alt-F2...)"""
     try:
         sleep(self.splashscreen_delay) #
         os.system('krunner')
         sleep(1.5)
         typeText('%s' % self.command)
         sleep(2)
         pressKey('enter')
         sleep(5)
     except:
         printException()
         return False
     self.__PID = self.getHighestPid()
     return self.checkRunning('Running %s via menu Run Command Interface' % self.appname)
Exemple #34
0
def select_menu_action(context, action):
    keyCombo("<Super_L><F10>")
    if action == 'About':
        pressKey('Down')
    if action == 'Quit':
        pressKey('Down')
        pressKey('Down')
    pressKey('Enter')
Exemple #35
0
def insert_values_and_create_sum(context):
    context.frame = context.app.get_current_window().child(roleName='document spreadsheet')
    context.frame.child(roleName='table')[0].grabFocus()
    for value in VALUES:
        typeText(value)
        pressKey('enter')
    context.sum_string = '='
    for i in range(1, len(VALUES) + 1):
        if i == len(VALUES):
            context.sum_string = context.sum_string + 'A' + str(i)
        else:
            context.sum_string = context.sum_string + 'A' + str(i) + '+'

    typeText(context.sum_string)
    pressKey('enter')
Exemple #36
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"
Exemple #38
0
def table_created(context, type_of_records, tbname, dbname):
    button = context.app.get_current_window().findChildren(lambda x: x.roleName == 'tree item' and x.text == tbname)[0]
    button.doubleClick()

    if button.showing:
        button.doubleClick()

    w = context.app.get_current_window()
    table = w.findChildren(lambda x: x.roleName == 'table' and x.name == 'Table' and x.showing)[0]
    i = 1

    tab_rec = []
    if type_of_records == "non-english":
        tab_rec = TABLE_RECORDS_NON_ENGLISH
    if type_of_records == "english":
        tab_rec = TABLE_RECORDS

    for record in tab_rec:

        assert table[i].text == record['id'],\
            "Incorrect text in column " + "id" + " and row " + str(i) + ", expected '%s' but was '%s'" % (
            record['id'], table[i].text)
        assert table[i + 1].text == record['name'],\
            "Incorrect text in column " + "name" + " and row " + str(i) + ", expected '%s' but was '%s'" % (
            record['name'], table[i + 1].text)
        assert table[i + 2].text == record['address'],\
            "Incorrect text in column " + "address" + " and row " + str(i) + ", expected '%s' but was '%s'" % (
            record['address'], table[i + 2].text)
        # there is commented assert for last column in table because thrue the accessibility its imposible to reach it
        # assert table[i+3].text == record['phone'], "Incorrect text in paragraph,\
        #  expected '%s' but was '%s'" % (record['phone'], table[i+3].text)
        i += len(record)

    j = 1
    for record in tab_rec:
        table[j].grabFocus()
        for i in range(0, len(tab_rec[0])-1):
            pressKey('\t')
        keyCombo('<Control>c')
        table[j+1].grabFocus()
        keyCombo('<Control>a')
        keyCombo('<Control>v')
        keyCombo('<Enter>')
        assert table[j+1].text == record['phone'], "Incorrect text in paragraph, expected '%s' but was '%s'" % (
            record['phone'], table[j+1].text)

        j += len(tab_rec[0])
Exemple #39
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"
Exemple #40
0
def selec_values_from_and_to_in_random_number_dialog_and_confirm(context, from_number, to_number):
    parameters_section = context.dialog_random.child(name="Random Number Generator")

    minimum_text_field = parameters_section.child(roleName="text", name="Minimum")
    minimum_text_field.grabFocus()
    keyCombo("<CTRL>a")
    pressKey("del")
    minimum_text_field.typeText(from_number)

    maximum_text_field = parameters_section.child(roleName="text", name="Maximum")
    maximum_text_field.grabFocus()
    keyCombo("<CTRL>a")
    pressKey("del")
    maximum_text_field.typeText(to_number)

    context.dialog_random.child(name="Apply").click()
    context.dialog_random.child(name="OK").click()
Exemple #41
0
def selec_values_from_and_to_in_random_number_dialog_and_confirm(context, from_number, to_number):
    parameters_section = context.dialog_random.child(name="Random Number Generator")

    minimum_text_field = parameters_section.child(roleName="text", name="Minimum")
    minimum_text_field.grabFocus()
    keyCombo("<CTRL>a")
    pressKey("del")
    minimum_text_field.typeText(from_number)

    maximum_text_field = parameters_section.child(roleName="text", name="Maximum")
    maximum_text_field.grabFocus()
    keyCombo("<CTRL>a")
    pressKey("del")
    maximum_text_field.typeText(to_number)

    context.dialog_random.child(name="Apply").click()
    context.dialog_random.child(name="OK").click()
 def startViaMenu(self):
     """ Will run the app through the standard application launcher """
     try:
         sleep(self.splashscreen_delay) # time before kwin starts up and the splash screen disappears
         height = Gdk.Display.get_default().get_default_screen().get_root_window().get_height()
         click(self.corner_distance,height - self.corner_distance)
         plasma = root.application('plasma-desktop')
         plasma.child(name='Search:', roleName='label').click()
         typeText(self.command)
         sleep(1)
         pressKey('enter')
         sleep(5)
     except:
         printException()
         return False
     self.__PID = self.getHighestPid()
     return self.checkRunning('Running %s via menu search' % self.appname)
    def __init__(self, appName, shortcut='<Control><Q>', desktopFileName=None,
                 timeout=5, a11yAppName=None, forceKill=True, parameters='',
                 recordVideo=False, recordVideoName=None):
        """
        Initialize object App
        appName     command to run the app
        shortcut    default quit shortcut
        a11yAppName app's a11y name is different than binary
        timeout     timeout for starting and shuting down the app
        forceKill   is the app supposed to be kill before/after test?
        parameters  has the app any params needed to start? (only for
                    startViaCommand)
        recordVideo start gnome-shell recording while running the app
        recordVideoName filename template for renaming the screencast video
        desktopFileName = name of the desktop file if other than
                          appName (without .desktop extension)
        """
        self.appCommand = appName
        self.shortcut = shortcut
        self.timeout = timeout
        self.forceKill = forceKill
        self.parameters = parameters
        self.internCommand = self.appCommand.lower()
        self.a11yAppName = a11yAppName
        self.recordVideo = recordVideo
        self.recordVideoName = recordVideoName
        self.pid = None

        # a way of overcoming overview autospawn when mouse in 1,1 from start
        pressKey('Esc')
        absoluteMotion(100, 100, 2)

        # set correct desktop file name
        if desktopFileName is None:
            desktopFileName = self.appCommand
        self.desktopFileName = desktopFileName

        # attempt to make a recording of the test
        if self.recordVideo:
            # Screencasts stop after 30 secs by default, see https://bugzilla.redhat.com/show_bug.cgi?id=1163186#c1
            cmd = "gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length 600"
            Popen(cmd, shell=True, stdout=PIPE).wait()
            keyCombo('<Control><Alt><Shift>R')
    def __init__(
        self, appName, critical=None, shortcut='<Control><Q>', desktopFileName=None, a11yAppName=None, quitButton=None, timeout=5,
            forceKill=True, parameters='', polkit=False, recordVideo=True):
        """
        Initialize object App
        appName     command to run the app
        critical    what's the function we check? {start,quit}
        shortcut    default quit shortcut
        timeout     timeout for starting and shuting down the app
        forceKill   is the app supposed to be kill before/after test?
        parameters  has the app any params needed to start? (only for startViaCommand)
        desktopFileName = name of the desktop file if other than appName (without .desktop extension)
        """
        self.appCommand = appName
        self.shortcut = shortcut
        self.timeout = timeout
        self.forceKill = forceKill
        self.critical = critical
        self.quitButton = quitButton
        # the result remains false until the correct result is verified
        self.result = False
        self.updateCorePattern()
        self.parameters = parameters
        self.internCommand = self.appCommand.lower()
        self.polkit = polkit
        self.polkitPass = '******'
        self.a11yAppName = a11yAppName
        self.recordVideo = recordVideo

        if desktopFileName is None:
            desktopFileName = self.appCommand
        self.desktopFileName = desktopFileName

        # a way of overcoming overview autospawn when mouse in 1,1 from start
        pressKey('Esc')
        absoluteMotion(100, 100, 2)
        # attempt to make a recording of the test
        if self.recordVideo:
            keyCombo('<Control><Alt><Shift>R')
Exemple #45
0
    def set_transition_type(self, category: str, index: int):
        """ Set the transition type of the current slide.

        Index is the 0-based number of the row in the category submenu
        """
        combo = self.imagination.child("Slide Settings").child(
            description="Transition type")
        combo.click()
        menu = combo.menu(category)
        menu.click()
        rawinput.pressKey("Right")
        rawinput.pressKey("Home")
        for _ in range(index):
            rawinput.pressKey("Down")
        rawinput.pressKey("Return")
    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 #47
0
def add_text_to_sheet_in_spreadsheet_to_cell(context, text_to_add, cell_name, sheet_name):
    # click on right sheet
    page_tab_list = context.app.get_current_window().child(roleName='document spreadsheet').parent[-1].child(
        roleName='page tab list')
    try:
        sheet = page_tab_list.child(name=sheet_name)
        sheet.click()
    except KeyError:
        assert False, "Sheet with name %s is missing" % sheet_name
    # find right cell
    context.frame = context.app.get_current_window().child(roleName='document spreadsheet')
    try:
        cell = context.frame.child(roleName='table')[CELL_TRANSLATION[cell_name]]
        cell.grabFocus()
        # type text    
        typeText(text_to_add)
        pressKey("enter")

        DATA.append(sheet_name)
        DATA.append(-1)
        DATA.append(text_to_add)
    except KeyError:
        assert False, "Missing implementation for cell name %s " % cell_name
Exemple #48
0
def add_text_to_sheet_in_spreadsheet_to_cell(context, text_to_add, cell_name, sheet_name):
    # click on right sheet
    page_tab_list = context.app.get_current_window().child(roleName='document spreadsheet').parent[-1].child(
        roleName='page tab list')
    try:
        sheet = page_tab_list.child(name=sheet_name)
        sheet.click()
    except KeyError:
        assert False, "Sheet with name %s is missing" % sheet_name
    # find right cell
    context.frame = context.app.get_current_window().child(roleName='document spreadsheet')
    try:
        cell = context.frame.child(roleName='table')[CELL_TRANSLATION[cell_name]]
        cell.grabFocus()
        # type text
        typeText(text_to_add)
        pressKey("enter")

        DATA.append(sheet_name)
        DATA.append(-1)
        DATA.append(text_to_add)
    except KeyError:
        assert False, "Missing implementation for cell name %s " % cell_name
    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 #50
0
    def test_scale_moved(self):
        scale = self.app.findChild(
            predicate.GenericPredicate(roleName='slider'))
        scale.grabFocus()
        rawinput.pressKey('Right')
        rawinput.pressKey('Right')
        rawinput.pressKey('Right')

        self.assertDump('scale_moved', self.app)
Exemple #51
0
def enter_records_to_table(context):
    table = context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'table' and x.name == 'Table' and x.showing)[0]
    table[1].grabFocus()
    for record in TABLE_RECORDS:
        typeText(record['id'])
        pressKey('\t')
        typeText(record['name'])
        pressKey('\t')
        typeText(record['address'])
        pressKey('\t')
        typeText(record['phone'])
        pressKey('\t')
    context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'push button' and x.name == 'Save current record' and x.showing)[0].click()
    # close edit table window
    keyCombo('<Control>w')
Exemple #52
0
def enter_records_to_table(context):
    table = context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'table' and x.name == 'Table' and x.showing)[0]
    table[1].grabFocus()
    for record in TABLE_RECORDS:
        typeText(record['id'])
        pressKey('\t')
        typeText(record['name'])
        pressKey('\t')
        typeText(record['address'])
        pressKey('\t')
        typeText(record['phone'])
        pressKey('\t')
    context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'push button' and x.name ==
        'Save current record' and x.showing)[0].click()
    # close edit table window
    keyCombo('<Control>w')
Exemple #53
0
    def test_scale_fixed(self):
        fixButton = self.app.childNamed('Fix Values')
        fixButton.click()

        scale = self.app.findChild(
            predicate.GenericPredicate(roleName='slider'))
        scale.grabFocus()
        rawinput.pressKey('Right')
        rawinput.pressKey('Right')
        rawinput.pressKey('Right')

        self.assertDump('scale_fixed', self.app)
Exemple #54
0
def customize_vm(context, mem):
    context.app.child('Customize…').click()
    pressKey('Tab')
    pressKey('Tab')
    memory_label = context.app.findChildren(lambda x: x.name == 'Memory: ' and x.showing)[0]
    mem = mem+" MiB"
    counter = 0
    while not memory_label.parent.findChildren(lambda x: x.name == mem and x.showing):
        pressKey('Left')
        counter += 1
        if counter == 100:
            break
    context.app.findChildren(lambda x: x.name == 'Back' and x.showing)[0].click()
Exemple #55
0
def enter_records_to_table(context):
    table = context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'table' and x.name == 'Table' and x.showing)[0]
    table[1].grabFocus()
    for record in TABLE_RECORDS_NON_ENGLISH:
        #Converting strings to unicode,to work with F23
        typeText(record['id'].decode('utf-8'))
        pressKey('\t')
        typeText(record['name'].decode('utf-8'))
        pressKey('\t')
        typeText(record['address'].decode('utf-8'))
        pressKey('\t')
        typeText(record['phone'].decode('utf-8'))
        pressKey('\t')
    sleep(10)
    context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'push button' and x.name ==
        'Save current record' and x.showing)[0].click()
    # close edit table window
    keyCombo('<Control>w')
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"
Exemple #57
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"
Exemple #58
0
def customize_vm(context, mem):
    context.app.child('Customize…').click()
    sleep(0.5)
    pressKey('Tab')
    pressKey('Tab')
    memory_label = context.app.findChildren(
        lambda x: x.name == 'Memory: ' and x.showing)[0]
    mem = mem + " MiB"
    counter = 0
    while not memory_label.parent.findChildren(
            lambda x: x.name == mem and x.showing):
        pressKey('Left')
        counter += 1
        if counter == 100:
            break
    context.app.findChildren(
        lambda x: x.name == 'Back' and x.showing)[0].click()
    sleep(0.5)
Exemple #59
0
def delete_snapshot(context, vm_name, snap_name):
    context.execute_steps("""
        * Launch "Properties" for "%s" box
        * Press "Snapshots"
        """ % vm_name)

    name = context.app.findChildren(
        lambda x: x.name == snap_name and x.showing)[0]
    name.parent.child('Menu').click()
    delete = context.app.findChildren(
        lambda x: x.name == "Delete" and x.showing)[0]
    delete.click()

    context.app.findChildren(
        lambda x: x.name == 'Undo' and x.showing)[0].grabFocus()
    pressKey('Tab')
    pressKey('Enter')
    sleep(2)

    pressKey('Esc')
Exemple #60
0
def presentation_from_template(context, presentation_title):
    current_window = context.app.get_current_window()

    # step one
    template_rb = current_window.child(name='From template', roleName='radio button')
    template_rb.click()
    # workaround for the radio button not being checked:
    if not template_rb.checked:
        pressKey('Tab')
        pressKey('Tab')
        pressKey('Down')

    current_window.button('Next').click()

    # step two and three
    current_window.button('Next').click()
    current_window.button('Next').click()

    # step four
    current_window.childLabelled('What is the subject of your presentation?').click()
    typeText(presentation_title)
    current_window.button('Create').click()