Пример #1
0
def check_axis(arguments):
    global VERDICT
    global OUTPUT
    x_max, x_min, y_max, y_min = touch_util.retrieve_resolution_geteven()

    events_structure = touch_util.poll_touchscreen(events=1, timeout=20)
    if not events_structure:
        VERDICT = FAILURE
        OUTPUT = "Failure. No touch events are retrieved"
        return

    x_middle = (x_min + x_max) / 2
    y_middle = (y_min + y_max) / 2
    if abs(events_structure.x[0][0] -
           x_middle) < 50 and abs(events_structure.y[0][0] - y_middle) < 50:
        print_to_console_and_logcat("Success")
        VERDICT = SUCCESS
        OUTPUT = "Success"
    else:
        print_to_console_and_logcat(
            "Middle of the touchscreen is located at coordinate [{} {}].".
            format(x_middle, y_middle))
        print_to_console_and_logcat(
            "Touch event was found at coordinate [{} {}]".format(
                events_structure.x[0][0], events_structure.y[0][0]))
        print_to_console_and_logcat(
            "Failure. Touch event should be near the middle of the touchscreen"
        )
        VERDICT = FAILURE
        OUTPUT = "Failure. Coordinates don't match middle of the screen. Expected: " + str(x_middle) + " " + str(y_middle) +\
                 " Received: " + str(events_structure.x[0][0]) + " " +str(events_structure.y[0][0])
Пример #2
0
def check_pressure(arguments):
    global VERDICT
    global OUTPUT

    events_structure = touch_util.poll_touchscreen(events=1000,
                                                   timeout=10,
                                                   stop_finger_up=True)
    if not events_structure:
        VERDICT = FAILURE
        OUTPUT = "Failure. No touch events are retrieved"
        return

    pressure_values = []
    for index, fingers_nr in enumerate(events_structure.fingers_number):
        for finger in range(0, fingers_nr):
            if len(pressure_values) <= finger:
                pressure_values.append([])
            pressure_values[finger].append(
                events_structure.pressure[index][finger])
    if MULTIPLE_FINGERS == "False":
        if not 0 in pressure_values[0]:
            print_to_console_and_logcat("Success")
            VERDICT = SUCCESS
            OUTPUT = "Success"
        else:
            fail_message = "Failure. Found a value of zero for pressure for the finger. " \
                           "Pressure values should be non-zero."
            print_to_console_and_logcat(fail_message)
            VERDICT = FAILURE
            OUTPUT = fail_message
    else:
        fingers_nr = len(pressure_values)
        if fingers_nr < 5:
            print_to_console_and_logcat(
                "Failure. Touch should be pressed with at least 5 fingers")
            print_to_console_and_logcat("Failure. It were recorded only " + str(fingers_nr) + \
                                        " fingers")
            VERDICT = FAILURE
            OUTPUT = "Failure. Only " + str(fingers_nr) + " fingers detected"
        else:
            passed = True
            for finger in range(0, fingers_nr):
                if 0 in pressure_values[finger]:
                    passed = False
                    fail_message = "Failure. Found a value of zero for pressure for one of the fingers. " \
                                   "Pressure values should be non-zero."
                    print_to_console_and_logcat(fail_message)
                    VERDICT = FAILURE
                    OUTPUT = fail_message
                    break
            if passed:
                print_to_console_and_logcat("Success")
                VERDICT = SUCCESS
                OUTPUT = "Success"
Пример #3
0
def check_size(arguments):
    global VERDICT
    global OUTPUT

    events_structure = touch_util.poll_touchscreen(events=1000,
                                                   timeout=10,
                                                   stop_finger_up=True)
    if not events_structure:
        VERDICT = FAILURE
        OUTPUT = "Failure. No touch events are retrieved"
        return

    size_values = []
    for index, fingers_nr in enumerate(events_structure.fingers_number):
        for finger in range(0, fingers_nr):
            if len(size_values) <= finger:
                size_values.append([])
            size_values[finger].append(events_structure.size[index][finger])
    if MULTIPLE_FINGERS == "False":
        if are_values_ordered(size_values[0]):
            print_to_console_and_logcat("Success")
            VERDICT = SUCCESS
            OUTPUT = "Success"
        else:
            print_to_console_and_logcat(
                "Failure. Finger size should increase.")
            VERDICT = FAILURE
            OUTPUT = "Failure. Finger size didn't increase."
    else:
        fingers_nr = len(size_values)
        if fingers_nr < 5:
            print_to_console_and_logcat(
                "Failure. Touch should be pressed with at least 5 fingers")
            print_to_console_and_logcat("Failure. There were recorded only " + str(fingers_nr) + \
                                        " fingers")
            VERDICT = FAILURE
            OUTPUT = "Failure. There were recorded only " + str(fingers_nr) + \
                                        " fingers"
        else:
            passed = True
            for finger in range(0, fingers_nr):
                if not are_values_ordered(size_values[finger]):
                    passed = False
                    print_to_console_and_logcat(
                        "Failure. Fingers size should increase")
                    VERDICT = FAILURE
                    OUTPUT = "Failure. Finger size didn't increase."
                    break
            if passed:
                print_to_console_and_logcat("Success")
                VERDICT = SUCCESS
                OUTPUT = "Success"
Пример #4
0
def check_axis(arguments):
    global VERDICT
    global OUTPUT

    events_structure = touch_util.poll_touchscreen(events=1, timeout=20)
    if not events_structure:
        VERDICT = FAILURE
        OUTPUT = "Failure. No touch events are retrieved"
        return

    if touch_util.is_coord_in_corner(events_structure.x[0][0], events_structure.y[0][0], CORNER):
        print_to_console_and_logcat("Success")
        VERDICT = SUCCESS
        OUTPUT = "Success"
    else:
        fail_message = "Failure. Touch event should be near the {} corner of the touchscreen"\
            .format(CORNER)
        print_to_console_and_logcat(fail_message)
        VERDICT = FAILURE
        OUTPUT = fail_message
Пример #5
0
def check_edge(arguments):
    global VERDICT
    global OUTPUT

    events_structure = touch_util.poll_touchscreen(events=1000,
                                                   timeout=10,
                                                   stop_finger_up=True)
    if not events_structure:
        VERDICT = FAILURE
        OUTPUT = "Failure. No touch events are retrieved"
        return

    x_coords = []
    y_coords = []
    for x_event in events_structure.x:
        x_coords.append(x_event[0])
    for y_event in events_structure.y:
        y_coords.append(y_event[0])

    if are_values_correct(x_coords, y_coords):
        if EDGE == "non_touch":
            print_to_console_and_logcat("Success")
            VERDICT = SUCCESS
            OUTPUT = "Success"
        elif are_values_on_the_edge(x_coords, y_coords):
            print_to_console_and_logcat("Success")
            VERDICT = SUCCESS
            OUTPUT = "Success"
        else:
            fail_message = "Failure. Events coordinates were not appropriate for the " + EDGE + " edge."
            print_to_console_and_logcat(fail_message)
            VERDICT = FAILURE
            OUTPUT = fail_message
    else:
        VERDICT = FAILURE
        OUTPUT = "Failure. X and y values are not correct " + str(
            x_coords) + str(y_coords)
Пример #6
0
def check_multiple_swipe(arguments):
    global VERDICT
    global OUTPUT

    events_structure = touch_util.poll_touchscreen(events=1000,
                                                   timeout=10,
                                                   stop_finger_up=True)
    if not events_structure:
        VERDICT = FAILURE
        OUTPUT = "Failure. No touch events are retrieved"
        return

    x_coords = []
    y_coords = []
    for index, fingers_nr in enumerate(events_structure.fingers_number):
        # when at least one finger is lifted we won't take into consideration other events
        if events_structure.action[index] == "pointer up":
            break
        for finger in range(0, fingers_nr):
            if len(x_coords) <= finger:
                x_coords.append([])
            x_coords[finger].append(events_structure.x[index][finger])
            if len(y_coords) <= finger:
                y_coords.append([])
            y_coords[finger].append(events_structure.y[index][finger])

    # x_coords and y_coords are the same length
    fingers_nr = len(x_coords)
    if fingers_nr < 5:
        print_to_console_and_logcat(
            "Failure. Touch should be pressed with at least 5 fingers")
        print_to_console_and_logcat("Failure. There were recorded only " +
                                    str(fingers_nr) + " fingers")
        VERDICT = FAILURE
        OUTPUT = "Failure. Only " + str(fingers_nr) + " fingers detected"

    else:
        passed = True
        for finger in range(0, fingers_nr):
            if swipe_direction == "down":
                constant = "x coords"
                ordered = "y coords"
                order = 1
            elif swipe_direction == "up":
                constant = "x coords"
                ordered = "y coords"
                order = -1
            elif swipe_direction == "right":
                constant = "y coords"
                ordered = "x coords"
                order = 1
            elif swipe_direction == "left":
                constant = "y coords"
                ordered = "x coords"
                order = -1

            if constant == "x coords":
                constant_vals = x_coords[finger]
            else:
                constant_vals = y_coords[finger]

            if ordered == "x coords":
                ordered_vals = x_coords[finger]
            else:
                ordered_vals = y_coords[finger]

            if not are_values_ordered(ordered_vals, order, 0.99):
                passed = False
                fail_message = "Failure. For at least one finger, values for {} did not increase " \
                               "as they should.".format(ordered)
                print_to_console_and_logcat(fail_message)
                VERDICT = FAILURE
                OUTPUT = fail_message
                break
            elif not are_values_constant(constant_vals, 0.2):
                passed = False
                fail_message = "Failure. For at least one finger, values for {} are not relative constant " \
                               "as they should be.".format(finger+1, constant)
                print_to_console_and_logcat(fail_message)
                VERDICT = FAILURE
                OUTPUT = fail_message
                break
        if passed:
            print_to_console_and_logcat("Success")
            VERDICT = SUCCESS
            OUTPUT = "Success"
Пример #7
0
def check_axis(arguments):
    global VERDICT
    global OUTPUT

    events_structure = touch_util.poll_touchscreen(events=1000,
                                                   timeout=10,
                                                   stop_finger_up=True)
    if not events_structure:
        VERDICT = FAILURE
        OUTPUT = "Failure. No touch events are retrieved"
        return

    x_coords = []
    y_coords = []
    for x_event in events_structure.x:
        x_coords.append(x_event[0])
    for y_event in events_structure.y:
        y_coords.append(y_event[0])

    if DIAGONAL == "primary":
        if not (touch_util.is_coord_in_corner(x_coords[0], y_coords[0],
                                              "upper-left")
                and touch_util.is_coord_in_corner(x_coords[-1], y_coords[-1],
                                                  "bottom-right")):
            print_to_console_and_logcat(
                "Failure. Swipe should start from the top left corner "
                "and end in the bottom right corner")
            VERDICT = FAILURE
            OUTPUT = "Failure. Swipe start coordinate " + str(x_coords[0]) +" "+ str(y_coords[0]) + " and end cooridnates " + \
                     str(x_coords[-1]) +" "+ str(y_coords[-1]) + " don't match the intended swipe gesture"
            return

        for coords, coords_name, axis in zip([x_coords, y_coords],
                                             ["x_coords", "y_coords"],
                                             ["X", "Y"]):
            if not are_values_ordered(coords):
                print_to_console_and_logcat(
                    "Failure. Events coordinates should increase on {} axis.".
                    format(axis))
                VERDICT = FAILURE
                OUTPUT = "Failure. Events coordinates should increase on {} axis.".format(
                    axis)
                return

        print_to_console_and_logcat("Success")
        VERDICT = SUCCESS
        OUTPUT = "Success"

    if DIAGONAL == "secondary":
        if not (touch_util.is_coord_in_corner(x_coords[0], y_coords[0],
                                              "upper-right")
                and touch_util.is_coord_in_corner(x_coords[-1], y_coords[-1],
                                                  "bottom-left")):
            print_to_console_and_logcat(
                "Failure. Swipe should start from the top right corner "
                "and end in the bottom left corner")
            VERDICT = FAILURE
            OUTPUT = "Failure. Swipe start coordinate " + str(x_coords[0]) +" "+ str(y_coords[0]) + " and end cooridnates " + \
                     str(x_coords[-1]) +" "+ str(y_coords[-1]) + " don't match the intended swipe gesture"
            return
        if not are_values_ordered(x_coords, -1):
            print_to_console_and_logcat(
                "Failure. Events coordinates should decrease on X axis.")
            VERDICT = FAILURE
            OUTPUT = "Failure. Events along x axis are not in decrease order"
            return
        if not are_values_ordered(y_coords):
            print_to_console_and_logcat(
                "Failure. Events coordinates should increase on Y axis.")
            VERDICT = FAILURE
            OUTPUT = "Failure. Events along y axis are not in decrease order"
            return
        print_to_console_and_logcat("Success")
        VERDICT = SUCCESS
        OUTPUT = "Success"
Пример #8
0
def get_events(arguments):
    global events_structure
    events_structure = touch_util.poll_touchscreen(events=1000, timeout=10)