Пример #1
0
def step(context, view_name, entry_number):
    if not context.userData:
        context.userData = {}

    natural_number = entry_number - 1
    ui_item = None
    caller_prefix = qml.phone_contactView_prefix
    button_prefix = qml.phone_contactView_button_prefix
    name_prefix = qml.phone_contactView_caller_prefix
    if view_name == 'favorites':
        ui_item = names.favorites_phoneView_ContactsView
    elif view_name == 'contacts':
        ui_item = names.contacts_phoneView_ContactsView
    else:
        app.fail("from this view you cannot call directly: '"
                 + view_name + "'!!")
    # switch to app
    app.switch_to_app('phone')
    caller_view = squish.waitForObject(ui_item)

    if caller_view is not None:
        search_contact_name = caller_prefix + str(natural_number)
        caller_pointer = find_object_name_recursively(caller_view,
                                                      search_contact_name, 4)
        if caller_pointer is not None:
            search_contact_button_name = button_prefix + str(natural_number)
            button_pointer = find_object_name_recursively(caller_pointer,
                                                    search_contact_button_name,
                                                    4)
            if button_pointer is not None:
                # now store the name for comparison
                store_name = name_prefix + str(natural_number)
                name_obj = find_object_name_recursively(caller_pointer,
                                                        store_name,
                                                        4)
                if name_obj is not None:
                    full_name = str(name_obj.text)
                    context.userData['calling'] = full_name
                    # and finally hit 'call'
                    squish.tapObject(button_pointer)
                else:
                    app.fail("name for contact '"
                             + button_prefix
                             + str(natural_number)
                             + "' could not be found")
            else:
                app.fail("button for contact '"
                         + button_prefix
                         + str(natural_number)
                         + "' could not be found")
        else:
            app.fail("stackview item for '"
                     + view_name + str(natural_number)
                     + "' could not be found")
    else:
        app.fail("should not happen here!!!")

    # switch to main before new command
    app.switch_to_main_app()
    squish.snooze(0.2)
Пример #2
0
def step(context, number_sequence):
    button_sequence = []

    for i in range(len(number_sequence)):
        my_char = number_sequence[i]
        resolved_name = my_char if my_char >= '0' and my_char <= '9' else(
                    "asterisk" if my_char == "*" else (
                    "hash" if my_char == "#" else "error"))
        if resolved_name != "error":
            keypad_name = qml.phone_numpad_prefix + resolved_name
            button_sequence.append(keypad_name)
        else:
            app.fail("The character '" + my_char + "' cannot be dialed")
            return

    # switch to app
    app.switch_to_app('phone')
    squish.snooze(0.25)

    for elem in button_sequence:
        button_obj = {"container": names.container_phone, "objectName": elem,
                      "type": "KeypadButton", "visible": True}
        squish.waitForObject(button_obj)
        squish.snooze(0.1)
        squish.tapObject(button_obj)

    app.switch_to_main_app()
Пример #3
0
def step(context, views):
    if not context.userData:
        context.userData = {}
    calling_name = context.userData['calling']

    # use a natural numbering, so +1 since entry 0 is entry 1
    squish.snooze(0.25)
    # switch and wait a little
    app.switch_to_app('phone')
    squish.snooze(0.25)

    caller_name_obj = squish.waitForObject(names.phoneCallerLabel)

    caller_name = None
    if caller_name_obj is not None:
        caller_name = str(caller_name_obj.text)
    # end call before comparing
    end_call_button = squish.waitForObject(names.phoneCallerEndButton)
    squish.tapObject(end_call_button)

    app.compare(calling_name, caller_name, "calling the right name")

    # switch to main before new command
    app.switch_to_main_app()
    squish.snooze(0.2)
Пример #4
0
def step(context):
    if not context.userData:
        context.userData = {}

    was_24h_format = context.userData['isDateFormat24h']
    squish.snooze(0.5)
    app.switch_to_main_app()
    squish.snooze(0.5)
    date_object = squish.waitForObject(names.dateAndTime)
    test_text = str(date_object.text)
    squish.snooze(0.5)
    app.switch_to_app('settings')
    squish.snooze(0.5)

    # search for 'm' is a cheap test, and
    # should be replaced. 'm' because 'am' and
    # 'pm' both contain 'm'
    is_now_24h_format = not ("m" in test_text)
    test.log("'" + test_text + "' is " +
             ("24h" if is_now_24h_format else "am/pm"))

    test.compare(was_24h_format, not is_now_24h_format, "date format")

    # switch back
    app.switch_to_main_app()
Пример #5
0
def step(context, language_abbr):
    squish.snooze(0.5)
    app.switch_to_main_app()
    squish.snooze(0.5)
    centerc_object = squish.waitForObject(names.neptune_UI_Center_Console)
    current_lang_abbr = str(centerc_object.store.uiSettings.language)
    test.compare(language_abbr, current_lang_abbr,
                 "current and wanted language abbreviation")
Пример #6
0
def step(context):
    # get current theme
    theme_panel = squish.waitForObject(names.themesPanel_ThemesPanel)
    current_theme = theme_panel.currentTheme
    old_theme = context.userData['old_theme']
    test.compare(old_theme, (current_theme - 1) % NR_THEMES,
                 "should be the previous theme")
    # switch back to main context
    app.switch_to_main_app()
Пример #7
0
def step(context):
    # switch to app
    app.switch_to_app('phone')
    squish.snooze(0.25)

    number_textobj = squish.waitForObject(names.callNumber_TextEdit)
    found_number = str(number_textobj.text)

    # clear field by tapping del length(text) times
    for _i in range(len(found_number)):
        del_button = squish.waitForObject(names.delLastCallDigitButton)
        squish.snooze(0.05)
        squish.tapObject(del_button)
    app.switch_to_main_app()
Пример #8
0
def step(context, app_name):
    # update context, because map is now if not before loaded
    squish.snooze(1)
    app.update_all_contexts()

    # must switch to main_app
    app.switch_to_main_app()

    found, result = find_homeWidgetGrid_app(app_name)
    if found:
        grid_entry, app_idname = result
        close_name = qml.app_widget_close + app_idname
        close_obj = find_object_name_recursively(grid_entry, close_name, 3)

        if close_obj is not None and close_obj.visible:
            tapObject(close_obj)
Пример #9
0
def step(context, firstname, lastname):
    if not context.userData:
        context.userData = {}

    app.switch_to_app('phone')

    # concat names
    name = firstname + " " + lastname

    start_search = squish.waitForObject(
        names.phonefavoritesView_FavoritesWidgetView)
    short_list = find_same_prefix_list(start_search,
                                       qml.phone_shortcall_prefix, 4)
    success = False
    if short_list is not None:
        for item in short_list:
            name_obj = find_object_name_recursively(item,
                                                    qml.phone_shortcall_name,
                                                    5)
            if name_obj is not None:
                full_name = str(name_obj.text)
                if full_name == name:
                    # after name has matched, search the button
                    # and call
                    call_button = find_object_name_recursively(
                        item, qml.phone_shortcall_button, 5)
                    if call_button is not None:
                        squish.tapObject(call_button)
                        success = True
                        context.userData['calling'] = name
                        break
                    else:
                        test.fail("name '" + name +
                                  "' found but not the button")
            else:
                test.fail("listitem's descendant must contain '" +
                          qml.phone_shortcall_name + "'!")
    else:
        test.fail("should not happen: '" + qml.phone_shortcall_prefix +
                  "' list in phone not found!")
    # check if a correct item was found
    app.compare(
        success, True,
        "name " + name + (" was found!" if success else " was not found!"))
    # back to main
    app.switch_to_main_app()
Пример #10
0
def step(context):
    if not context.userData:
        context.userData = {}

    squish.snooze(0.25)
    app.switch_to_main_app()
    date_object = squish.waitForObject(names.dateAndTime)
    test_text = str(date_object.text)
    # cheap comparison, only text and searching for 'm'
    # whether 'am' or 'pm'
    is_24h_format = not ('m' in test_text)
    context.userData['isDateFormat24h'] = is_24h_format

    test.log("'" + test_text + "' was " +
             ("24h" if is_24h_format else "am/pm"))

    app.switch_to_app('settings')
    squish.snooze(0.25)
    switch = squish.waitForObject(names.dateTimeSwitch_SwitchDelegate)
    squish.tapObject(switch)
Пример #11
0
def step(context, view_name):
    if view_name not in qml.viewPhoneButtons:
        app.fail("in phone the view '" + view_name
                 + "' is not known!!")
    # recents and favorites so far not
    has_2_views = [qml.viewPhoneButtons[2:]]

    view_obj_name = None
    if view_name == 'contacts':
        view_obj_name = names.contacts_phoneView_ContactsView
    elif view_name == 'recents':
        view_obj_name = names.recents_phoneView_RecentCallsView
    elif view_name == 'favorites':
        view_obj_name = names.favorites_phoneView_ContactsView
    elif view_name == 'keypad':
        view_obj_name = names.keypad_phoneView_KeypadViewPanel
    else:
        app.fail("this should not happen, this view '"
                 + view_name + "'" is not known)

    view_found = squish.waitForObject(view_obj_name)
    # first test (since it is not the last no "app.compare()"
    test.compare(view_found is not None, True, "view '"
                + view_name + "' found!!")

    if view_name in has_2_views:
        if view_name == 'favorites':
            second_ui_item = names.phonefavoritesView_FavoritesWidgetView
        elif view_name == 'keypad':
            second_ui_item = names.phoneCallView_CallWidgetView
        else:
            app.fail("this should not happen here with '"
                     + view_name + "'!!")
        test_ui = squish.waitForObject(second_ui_item)
        app.compare(test_ui.visible, True, "2nd view item should be visible")

    # switch to main before new command
    app.switch_to_main_app()
    squish.snooze(0.2)
Пример #12
0
def step(context, wait_sec, app_name):
    if not context.userData:
        context.userData = {}

    # MUST switch to main app
    app.switch_to_main_app()

    # wait a small while to let it open
    snooze(wait_sec)

    found, app_idname = app.get_app_id(app_name)

    if found:
        object_name = qml.current_inFrame_Application + app_idname
        active_app_slot = waitForObject(
            names.neptune_3_UI_Center_Console_activeApplicationSlot_Item)

        # 1st: look for "inFrameApplication"
        app_pointer = find_object_name_recursively(active_app_slot,
                                                   object_name, 3)
        if app_pointer is not None:
            my_numnber = app_pointer.children.count
            test.log("-_" + str(my_numnber))
            test.compare(True, app_pointer.visible, "should be visible!")
        else:
            #  2nd try: look for "application_widget"
            test.log("'" + app_idname + "' as inFrameApp not found," +
                     " trying as applicationWidget")
            object_name = qml.application_widget + app_idname
            app_pointer = find_object_name_recursively(active_app_slot,
                                                       object_name, 3)
            if app_pointer is not None:
                test.compare(True, app_pointer.visible, " should be visible!")
            else:
                test.fail("'" + app_name + "' app is not known!!")
    else:
        test.fail("'" + app_name + "' app is not known!!")
Пример #13
0
def step(context, button_name):
    selected_button = map_button(button_name)
    test.compare(selected_button.checked, True, "some climate button")
    squish.snooze(1)
    app.switch_to_main_app()
Пример #14
0
def start_neptune_ui_app_w_focus(window):
    """ Starting hook for all tests to be started. It can be started in 2 modes
    which selects which window of neptune should be focused (for a visible
    experience and double check the tests' effect)

    'console'   : console view focused
    'dashboard' : dashboard view focused
    """

    # check forced single process:
    # it can be used to start in single process though it would normally
    # start in multi-process, this is just passing through of an option
    # which is also defined in starting neptune3-ui executable
    force_single_process = (os.environ.get('SINGLE_PROCESS') == '1')

    # !!! Remember to use ignoredauts.txt feature
    # otherwise this will cause a lot of trouble,
    # with dbus and remotesettings-server !!!
    # Read the documentation:
    # https://doc.qt.io/Neptune3UI/neptune3ui-testing-squish.html#exclude-disruptive-sub-processes
    command_line_options = (
        "-r" + " --start-session-dbus" + " -c am-config-neptune.yaml" +
        " -c squish-appman-hook.yaml" +
        (" --force-single-process" if force_single_process else ""))

    # assemble the line
    command_line = settings.G_AUT_MAIN + " " + command_line_options

    test.log("command_line: " + command_line)

    try:
        # try to start application
        app_context = squish.startApplication(command_line)
    except Exception as e:
        test.fail("direct command line call didn't work:", str(e))
        return False

    test.log("Started applicationContext: '" + app_context.name + "' (" +
             str(app_context.pid) + ", #" + str(app_context.port) +
             ") is running!")

    # this snooze is really needed, VERY IMPORTANT
    squish.snooze(STARTUP_ARRANGE_TIME_SEC)

    # try to register all already connected AUTs
    # especially from appman
    nr_apps = app.update_all_contexts()

    # setting multi process according to how many apps
    # were found
    settings.G_MULTI_PROCESS = (nr_apps > 1)
    test.log("Using " + ("MULTI" if settings.G_MULTI_PROCESS else "SINGLE") +
             " PROCESS!!")

    # if it is multi process, change search container for
    # all according apps
    if settings.G_MULTI_PROCESS:
        # change for all known apps the search container
        for change_app in names.apps_change_collection:
            change_app(names.multi_process_container)

    # to be able to focus window we need the neptune main app
    app.switch_to_main_app()

    try:
        worked, window_obj = get_focus_window(window)

        if not worked:
            return False
    except Exception as e:
        test.fail("Window not found!! (" + str(e) + ")")
        return False

    # only for console so far
    test.log("Window size is   : " + str(window_obj.width) + "x" +
             str(window_obj.height))
    test.log("Window pos  is   : " + str(window_obj.x) + "," +
             str(window_obj.y))

    # look for center console
    try:
        console_obj = squish.waitForObject(
            names.neptune_3_UI_Center_Console_centerConsole_CenterConsole, 500)
    except Exception:
        test.fail("Could not find console window!!!")
    else:
        # look also into
        # https://doc.froglogic.com/squish/latest/rgs-squish.html#rgss-screen-object
        test.log("----------------------")
        settings.SCREEN_WIDTH = console_obj.width
        settings.SCREEN_HEIGHT = console_obj.height

        settings.SCREEN_LANDSCAPE = console_obj.store.centerConsole.isLandscape

        test.log("Landscape" if settings.SCREEN_LANDSCAPE else "No landscape")

        # I misuse it to distinguish between target and test development
        if settings.SCREEN_LANDSCAPE:
            settings.G_WAIT_SYSTEM_READY_SEC = 3

        test.log("Console size     : " + str(settings.SCREEN_WIDTH) + "x" +
                 str(settings.SCREEN_HEIGHT))
        test.log("Console offset is: " + str(console_obj.x) + "," +
                 str(console_obj.y))

        # from https://kb.froglogic.com/display/KB/Problem+-+Bringing+window+to+foreground+%28Qt%29
        window_obj.show()
        getattr(window_obj, "raise")()
Пример #15
0
def step(context):
    """ Is just a thin wrapper to access directly from test """
    app.switch_to_main_app()
Пример #16
0
def step(context):
    # this button exists only in main app
    app.switch_to_main_app()

    click_popup_close(context)