about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-09 15:09:32 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-09 15:09:32 -0700
commit173d3a3de0a99769e0378436c4375f8bd39aef5c (patch)
tree2f5e75306dcc93274c10ff12dfa5479c74bdf8b4
parentfe170fc579cc084061f6dce70aa9b4e966148ca7 (diff)
downloadtext.love-173d3a3de0a99769e0378436c4375f8bd39aef5c.tar.gz
test both ways of selecting text with mouse
-rw-r--r--text_tests.lua29
1 files changed, 25 insertions, 4 deletions
diff --git a/text_tests.lua b/text_tests.lua
index 4a6203f..097f487 100644
--- a/text_tests.lua
+++ b/text_tests.lua
@@ -189,6 +189,27 @@ function test_select_text_using_mouse()
   Selection1 = {}
   App.draw()  -- populate line.y for each line in Lines
   local screen_left_margin = 25  -- pixels
+  -- press and hold on first location
+  App.run_after_mousepress(screen_left_margin+8,Margin_top+5, '1')
+  -- drag and release somewhere else
+  App.run_after_mouserelease(screen_left_margin+20,Margin_top+Line_height+5, '1')
+  check_eq(Cursor1.line, 2, 'F - test_select_text_using_mouse/cursor:line')
+  check_eq(Cursor1.pos, 4, 'F - test_select_text_using_mouse/cursor:pos')
+  check_eq(Selection1.line, 1, 'F - test_select_text_using_mouse/selection:line')
+  check_eq(Selection1.pos, 2, 'F - test_select_text_using_mouse/selection:pos')
+end
+
+function test_select_text_using_mouse_and_shift()
+  io.write('\ntest_select_text_using_mouse_and_shift')
+  App.screen.init{width=50, height=60}
+  Lines = load_array{'abc', 'def', 'xyz'}
+  Line_width = App.screen.width
+  Cursor1 = {line=1, pos=1}
+  Screen_top1 = {line=1, pos=1}
+  Screen_bottom1 = {}
+  Selection1 = {}
+  App.draw()  -- populate line.y for each line in Lines
+  local screen_left_margin = 25  -- pixels
   -- click on first location
   App.run_after_mousepress(screen_left_margin+8,Margin_top+5, '1')
   App.run_after_mouserelease(screen_left_margin+8,Margin_top+5, '1')
@@ -197,10 +218,10 @@ function test_select_text_using_mouse()
   App.run_after_mousepress(screen_left_margin+20,Margin_top+5, '1')
   App.run_after_mouserelease(screen_left_margin+20,Margin_top+Line_height+5, '1')
   App.keyrelease('lshift')
-  check_eq(Cursor1.line, 2, 'F - test_select_text_using_mouse/cursor:line')
-  check_eq(Cursor1.pos, 4, 'F - test_select_text_using_mouse/cursor:pos')
-  check_eq(Selection1.line, 1, 'F - test_select_text_using_mouse/selection:line')
-  check_eq(Selection1.pos, 2, 'F - test_select_text_using_mouse/selection:pos')
+  check_eq(Cursor1.line, 2, 'F - test_select_text_using_mouse_and_shift/cursor:line')
+  check_eq(Cursor1.pos, 4, 'F - test_select_text_using_mouse_and_shift/cursor:pos')
+  check_eq(Selection1.line, 1, 'F - test_select_text_using_mouse_and_shift/selection:line')
+  check_eq(Selection1.pos, 2, 'F - test_select_text_using_mouse_and_shift/selection:pos')
 end
 
 function test_pagedown()