Esempio n. 1
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)
def step(context, button_name):
    if not context.userData:
        context.userData = {}

    if button_name not in top_buttons_calendar_ui.keys():
        app.fail("in calendar, the button '"
                 + button_name
                 + "' is not known!")
        return
    button = top_buttons_calendar_ui[button_name]
    month_delta = 1 if (top_buttons_calendar_ui.keys()[0]
                     == button_name) else -1

    app.switch_to_app('calendar')
    squish.snooze(0.25)

    squish.tapObject(button)

    squish.snooze(0.5)
    grid_for_info = squish.waitForObject(names.topCalendarGrid)

    month_now = __builtin__.int(str(grid_for_info.month))
    month_before = context.userData['month']

    month_change = (month_before + month_delta) % 12
    app.compare(str(month_change + 1), str(month_now + 1), " month changes")
Esempio n. 3
0
def step(context, number_sequence):
    # 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)
    app.compare(number_sequence, found_number, "numbers should be equal")
Esempio n. 4
0
def step(context, view_name):
    if view_name not in possible_view_buttons.keys():
        app.fail("in music view, list view '" + view_name + "' is not known!")
        return

    app.switch_to_app('music')
    squish.snooze(0.25)
    info_ui = squish.waitForObject(names.musicToolsColumn)

    currentView = str(info_ui.currentText)
    app.compare(currentView, view_name,
                "view stored is not what is changed to")
def step(context, view_name):
    if view_name not in possible_ui_elements.keys():
        app.fail("in downloads app, view '"
                 + view_name
                 + "' is not known!")
        return

    #app.switch_to_app('downloads')
    squish.snooze(0.25)
    info_ui = squish.waitForObject(names.downloadsToolsColumn)

    currentView = str(info_ui.currentTool)
    app.compare(currentView, view_name,
                "view stored is not what is changed to")
def step(context, distance_index):
    if not context.userData:
        context.userData = {}

    old_index = context.userData['index']
    count = context.userData['count']

    # switch context
    app.switch_to_app('music')
    ui_info_element = squish.waitForObject(names.musicPlayer)

    play_current_index = ui_info_element.currentIndex
    app.compare((old_index + distance_index) % count, play_current_index,
                "index should be according song skipping")
Esempio n. 7
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()
Esempio n. 8
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)
def step(context, command):
    possible_options = ['install', 'deinstall']
    if command not in possible_options:
        app.fail("in downloads, the command '"
                  + command + "' is not known!")
        return
    # what to do
    install = (command == possible_options[0])

    #app.switch_to_app('downloads')
    squish.snooze(0.25)
    app_list = squish.waitForObject(names.downloadAppList_DownloadAppList)
    number_of_app_in_view = app_list.count

    # store installable apps here
    just_changed_installation_apps = []

    for i in range(number_of_app_in_view):
        # this is a little bit old school without objectName
        # actually objectName is used to achieve
        # app information aka model.id
        # here we use index to find the item
        download_app_struct = {
                        "container": names.downloadAppList_DownloadAppList,
                        "index": i,
                        "type": "ListItemProgress",
                        "visible": True}
        model_ToolButton_ui = {"container": download_app_struct,
                                "type": "ToolButton",
                                "visible": True}
        test.log("download app index " + str(i)
                 + " was found! Trying ...")
        download_app = squish.waitForObject(download_app_struct)
        app_objectName = str(download_app.objectName)

        model_text = str(download_app.text)

        # delete prefix, if this works, string must be different
        model_name = app_objectName.replace(qml.app_downloads_prefix, "")
        if model_name != model_text:
            installed = download_app.isInstalled

            if install is not installed:
                test.log("Found: (" + str(i) + ") " + model_text + " as '"
                         + model_name + "' "
                         + ("installed" if installed
                                       else "not installed")
                         + "!")
                install_button = squish.waitForObject(model_ToolButton_ui)
                squish.tapObject(install_button)

                # wait a little and hope it installs during that time
                just_changed_installation_apps.append(model_name)
                squish.snooze(2)
            else:
                test.log("app '" + model_name + "' is already "
                        + ("installed" if not install else "not installed")
                        + "!")
        else:
            test.fail("in download test, a problem with model.id occurred.")

    # wait for last toast message to disappear
    squish.snooze(0.5)
    # now check in grid if just installed apps exist
    grid_view = squish.waitForObject(
                              names.neptune_UI_Center_Console_grid_GridView)
    launcher_bar = squish.waitForObject(
                    names.neptune_3_UI_Center_Console_gridButton_ToolButton)
    squish.tapObject(launcher_bar)

    if len(just_changed_installation_apps) == 0:
        test.passes("good, no apps to " +
                     ("install" if install else "uninstall")
                     + "!")
    else:
        for el in just_changed_installation_apps:
            object_name = qml.grid_delegate + el
            app_pointer = find_object_name_recursively(grid_view,
                                                       object_name,
                                                       3)
            # python .......
            found = (app_pointer is not None)
            app.compare(found, install,
                        ("app '" + str(el) + "' exists"))
    # tap again to close
    squish.tapObject(launcher_bar)
    # wait for toast message to disappear
    squish.snooze(0.5)