Exemplo n.º 1
0
def mouse_test(test, params, vm, wait_time, count=1):
    """
    Mouse test, include button test, scroll test and move test.

    :param test: kvm test object
    :param params: Dictionary with the test parameters
    :param vm: VM object
    :param wait_time: wait event received in listener event queue.
    :param count: wheel event counts, default count=1.
    """
    console = graphical_console.GraphicalConsole(vm)
    listener = input_event_proxy.EventListener(vm)
    mice_name = params.get("mice_name", "QEMU PS/2 Mouse")
    mice_info = query_mice_status(vm, mice_name)
    absolute = True if mice_info["absolute"] else False
    error_context.context("Check if %s device is working" % mice_name,
                          logging.info)
    if not mice_info["current"]:
        test.fail("%s does not worked currently" % mice_name)

    mouse_btn_test(test, params, console, listener, wait_time)
    mouse_scroll_test(test, params, console, listener, wait_time, count=count)
    if not params.get("target_pos", None):
        width, height = console.screen_size
        x_max, y_max = width - 1, height - 1
        target_pos = [(1, 0), (x_max, 0), (1, y_max), (x_max, y_max)]
    else:
        # suggest set target_pos if want to test one target position.
        target_pos = [tuple([int(i) for i in params.objects("target_pos")])]
    for end_pos in target_pos:
        mouse_move_test(test, params, console, listener, wait_time, end_pos,
                        absolute)
    listener.clear_events()
    listener.cleanup()
Exemplo n.º 2
0
def run(test, params, env):
    """
    Input mice test, include 2 type mices.
    virtio-mouse-pci device and virtio-table-pci device.

    1) Log into the guest.
    2) Check if the driver is installed and verified.
    3) Check if tested device is working.
    4) Start event listener in guest.
    5) Do mouse button test.
    6) Do mouse scroll test.
    7) Do mouse pointer move test.

    :param test: kvm test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    driver = params["driver_name"]

    if params["os_type"] == "windows":
        session = vm.wait_for_login()

        error_context.context("Check vioinput driver is running", logging.info)
        utils_test.qemu.windrv_verify_running(session, test, driver.split()[0])

        error_context.context("Enable all vioinput related driver verified",
                              logging.info)
        session = utils_test.qemu.setup_win_driver_verifier(session, driver, vm)

    mice_name = params.get("mice_name", "QEMU PS/2 Mouse")
    mice_info = query_mice_status(vm, mice_name)
    error_context.context("Check if %s device is working" % mice_name,
                          logging.info)
    if not mice_info["current"]:
        test.fail("%s does not worked currently" % mice_name)

    listener = input_event_proxy.EventListener(vm)
    console = graphical_console.GraphicalConsole(vm)
    wait_time = float(params.get("wait_time", 0.2))
    absolute = True if mice_info["absolute"] else False

    mouse_btn_test(test, params, console, listener, wait_time)
    mouse_scroll_test(test, params, console, listener, wait_time)

    if not params.get("target_pos", None):
        width, height = console.screen_size
        x_max, y_max = width-1, height-1
        target_pos = [(1, 0), (x_max, 0), (1, y_max), (x_max, y_max)]
    else:
        # suggest set target_pos if want to test one target position.
        target_pos = [tuple([int(i) for i in params.objects("target_pos")])]
    for end_pos in target_pos:
        mouse_move_test(test, params, console, listener, wait_time,
                        end_pos, absolute)

    listener.clear_events()
    listener.cleanup()
    session.close()
Exemplo n.º 3
0
def keyboard_test(test, params, vm, wait_time):
    """
    Keyboard tests, only include key_tap_test currently.

    :param test: kvm test object
    :param params: Dictionary with the test parameters
    :param vm: VM object
    :param wait_time: wait event received in listener event queue.
    """
    console = graphical_console.GraphicalConsole(vm)
    listener = input_event_proxy.EventListener(vm)
    key_tap_test(test, params, console, listener, wait_time)
    listener.clear_events()
    listener.cleanup()
Exemplo n.º 4
0
def key_tap_test(test, params, vm):
    """
    Keyboard test. Support single key and combination key tests.

    :param test: kvm test object
    :param params: dictionary with the test parameters
    :param vm: vm object
    """

    def key_check(key):
        """
        Check received key event match exepected key event.
        :param key: tested key name.
        """
        events_queue = listener.events

        if '-' in key:
            key_lst = [key_check_cfg[k] for k in key.split('-')]
        else:
            key_lst = [key_check_cfg[key]]
        key_num = len(key_lst)
        key_event_lst = list()

        while not events_queue.empty():
            events = events_queue.get()
            key_event_lst.append((events["keyCode"], events["type"]))

        if len(key_event_lst) < 2 * key_num:
            test.fail("Reveived key events %s were not enough" % key_event_lst)

        key_down_lst = list()
        for k, v in key_event_lst[:-key_num]:
            if v != 'KEYDOWN':
                test.fail("Received key {0} event type {1} was not KEYDOWN").format(k, v)
            key_down_lst.append(k)

        if len(key_down_lst) != key_num or set(key_down_lst) != set(key_lst):
            test.fail("Key down event keycode error, received:{0},"
                      "expect:{1}").format(key_down_lst, key_lst)

        key_up_lst = list()
        for k, v in key_event_lst[-key_num:]:
            if v != 'KEYUP':
                test.fail("Received key {0} event type {1} was not KEYUP").format(k, v)
            key_up_lst.append(k)

        if set(key_up_lst) != set(key_lst):
            test.fail("Key up event keycode error, received:{0},"
                      "expect:{1}").format(key_up_lst, key_lst)

    key_table_file = params.get('key_table_file')
    key_check_cfg = get_keycode_cfg(key_table_file)
    wait_time = float(params.get("wait_time", 0.2))

    error_context.context("Start event listener in guest", test.log.info)
    listener = input_event_proxy.EventListener(vm)

    console = graphical_console.GraphicalConsole(vm)
    for key in key_check_cfg.keys():
        error_context.context("Send %s key tap to guest" % key, test.log.info)
        console.key_tap(key)
        error_context.context("Check %s key tap event received"
                              "correct in guest" % key, test.log.info)
        time.sleep(wait_time)
        key_check(key)

    listener.clear_events()
    listener.cleanup()