mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
More mouse interaction tests
This commit is contained in:
@@ -11,8 +11,8 @@ from kitty.fast_data_types import (
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
def send_mouse_event(window, button=-1, modifiers=0, is_release=False, x=0, y=0):
|
||||
send_mock_mouse_event_to_window(window, button, modifiers, is_release, x, y)
|
||||
def send_mouse_event(window, button=-1, modifiers=0, is_release=False, x=0, y=0, clear_click_queue=False):
|
||||
send_mock_mouse_event_to_window(window, button, modifiers, is_release, x, y, clear_click_queue)
|
||||
|
||||
|
||||
class TestMouse(BaseTest):
|
||||
@@ -23,7 +23,7 @@ class TestMouse(BaseTest):
|
||||
ev = partial(send_mouse_event, w)
|
||||
|
||||
def sel():
|
||||
return s.text_for_selection()[0]
|
||||
return ''.join(s.text_for_selection())
|
||||
|
||||
def init():
|
||||
s.reset()
|
||||
@@ -33,9 +33,43 @@ class TestMouse(BaseTest):
|
||||
s.draw('fghij')
|
||||
s.draw('klmno')
|
||||
|
||||
def press(x=0, y=0):
|
||||
ev(GLFW_MOUSE_BUTTON_LEFT, x=x, y=y)
|
||||
|
||||
def release(x=0, y=0):
|
||||
ev(GLFW_MOUSE_BUTTON_LEFT, x=x, y=y, is_release=True, clear_click_queue=True)
|
||||
|
||||
def move(x=0, y=0):
|
||||
ev(x=x, y=y)
|
||||
|
||||
def multi_click(x=0, y=0, count=2):
|
||||
while count > 0:
|
||||
count -= 1
|
||||
ev(GLFW_MOUSE_BUTTON_LEFT, x=x, y=y)
|
||||
|
||||
# Simple, click, move, release test
|
||||
init()
|
||||
ev(GLFW_MOUSE_BUTTON_LEFT)
|
||||
ev(x=3)
|
||||
press()
|
||||
move(x=3)
|
||||
self.ae(sel(), '1234')
|
||||
ev(GLFW_MOUSE_BUTTON_LEFT, x=3, is_release=True)
|
||||
release(x=3)
|
||||
self.ae(sel(), '1234')
|
||||
|
||||
# Multi-line click release
|
||||
init()
|
||||
press(1, 1), release(3, 2)
|
||||
self.ae(sel(), '7890abcd')
|
||||
press(3, 4), release(2, 2)
|
||||
self.ae(sel(), 'cdefghijklmn')
|
||||
|
||||
# Word select with drag
|
||||
s.reset()
|
||||
s.draw('ab cd')
|
||||
s.draw(' f gh')
|
||||
s.draw(' stuv')
|
||||
multi_click(x=1)
|
||||
self.ae(sel(), 'ab')
|
||||
move(3)
|
||||
self.ae(sel(), 'ab cd')
|
||||
release(3, 1)
|
||||
self.ae(sel(), 'ab cd f gh')
|
||||
|
||||
Reference in New Issue
Block a user