def key_pressed_cb (controller, keyval, keycode, state): global expected_change global loop
if verbose:
print(f'got key press: {keyval}, state {state}') assert expected_change != None, 'Unexpected key press' assert expected_change['type'] == 'press', 'Key press event expected' assert keyval == expected_change['keyval'], 'Unexpected keyval in key press event' assert state == expected_change['state'], 'Unexpected state in key press event'
expected_change = None
loop.quit()
def key_released_cb (controller, keyval, keycode, state): global expected_change global loop
if verbose:
print(f'got key release: {keyval}, state {state}') assert expected_change != None, 'Unexpected key release' assert expected_change['type'] == 'release', 'Key release event expected' assert keyval == expected_change['keyval'], 'Unexpected keyval in key release event' assert state == expected_change['state'], 'Unexpected state in key release event'
expected_change = None
loop.quit()
def motion_cb (controller, x, y): global expected_change global loop
if verbose:
print(f'got motion: {x}, {y}') if expected_change != None: assert expected_change['type'] == 'motion', 'Motion event expected' assert x == expected_change['x'], 'Unexpected x coord in motion event' assert y == expected_change['y'], 'Unexpected y coord in motion event'
expected_change = None
loop.quit()
def enter_cb (controller, x, y): global expected_change global loop
if verbose:
print(f'got enter: {x}, {y}') assert expected_change != None, 'Unexpected enter' assert expected_change['type'] == 'enter', 'Enter event expected' assert x == expected_change['x'], 'Unexpected x coord in enter event' assert y == expected_change['y'], 'Unexpected y coord in enter event'
expected_change = None
loop.quit()
def pressed_cb(controller, n, x, y): global expected_change global loop
if verbose:
print(f'got pressed') assert expected_change != None, 'Unexpected event' assert expected_change['type'] == 'press', 'Button press expected' assert expected_change['button'] == controller.get_current_button(), 'Unexpected button pressed' assert x == expected_change['x'], 'Unexpected x coord in motion event' assert y == expected_change['y'], 'Unexpected y coord in motion event'
expected_change = None
loop.quit()
def released_cb(controller, n, x, y): global expected_change global loop
assert dt_window.is_active(), 'drop target not active' assert dt_window.get_width() == 1024, 'Window not maximized' assert dt_window.get_height() == 768, 'Window not maximized'
# we need to wait out the map animation, or pointer coords will be off
wait(1000)
def stop_drop_target(): global dt_window
dt_window.destroy()
dt_window = None
def expect_drag(timeout): global expected_change
expected_change = { 'type' : 'drag',
}
wait(timeout) assert expected_change == None, 'DND operation not started'
def expect_drop(value, timeout): global expected_change
expected_change = { 'type' : 'drop', 'value' : value
}
wait(timeout) assert expected_change == None, 'Drop has not happened'
def dnd_tests(): try: if verbose:
print('Starting dnd tests')
pointer_move(-100, -100)
launch_drag_source('abc')
wait(100);
pointer_move(100, 100)
wait(100);
button_press(1)
expect_button_press(button=1, x=100, y=100, timeout=300) # need to wait out the MIN_TIME_TO_DND
wait(150)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.