diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-12-12 23:18:42 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-12-12 23:18:42 -0800 |
commit | 39ffe7f411d75687b57232ae39e5b280dccfacc4 (patch) | |
tree | 96b0c7933f06afd11f54592e0ec0e74b32e348cc | |
parent | 92eccaea5ac39f4c362d216b8a74edf6aac3af4a (diff) | |
download | text.love-39ffe7f411d75687b57232ae39e5b280dccfacc4.tar.gz |
switch a bunch of tests to textinput events
textinput is strictly more realistic than keychord_pressed, which doesn't cause any textinput events. Use it wherever possible.
-rw-r--r-- | drawing_tests.lua | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/drawing_tests.lua b/drawing_tests.lua index 8bcaa43..36ad2e8 100644 --- a/drawing_tests.lua +++ b/drawing_tests.lua @@ -162,7 +162,7 @@ function test_keys_do_not_affect_shape_when_mouse_up() edit.draw(Editor_state) -- hover over drawing and press 'o' without holding mouse App.mouse_move(Editor_state.left+4, Editor_state.top+Drawing_padding_top+4) -- hover on drawing - edit.run_after_keychord(Editor_state, 'o') + edit.run_after_textinput(Editor_state, 'o') -- no change to drawing mode check_eq(Editor_state.current_drawing_mode, 'line', 'F - test_keys_do_not_affect_shape_when_mouse_up/drawing_mode') -- no change to text either because we didn't run the textinput event @@ -214,7 +214,7 @@ function test_draw_arc() -- draw an arc edit.run_after_mouse_press(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1) App.mouse_move(Editor_state.left+35+30, Editor_state.top+Drawing_padding_top+36) - edit.run_after_keychord(Editor_state, 'a') -- arc mode + edit.run_after_textinput(Editor_state, 'a') -- arc mode edit.run_after_mouse_release(Editor_state, Editor_state.left+35+50, Editor_state.top+Drawing_padding_top+36+50, 1) -- 45° local drawing = Editor_state.lines[1] check_eq(#drawing.shapes, 1, 'F - test_draw_arc/#shapes') @@ -245,10 +245,10 @@ function test_draw_polygon() check_eq(#Editor_state.lines[1].shapes, 0, 'F - test_draw_polygon/baseline/#shapes') -- first point edit.run_after_mouse_press(Editor_state, Editor_state.left+5, Editor_state.top+Drawing_padding_top+6, 1) - edit.run_after_keychord(Editor_state, 'g') -- polygon mode + edit.run_after_textinput(Editor_state, 'g') -- polygon mode -- second point App.mouse_move(Editor_state.left+65, Editor_state.top+Drawing_padding_top+36) - edit.run_after_keychord(Editor_state, 'p') -- add point + edit.run_after_textinput(Editor_state, 'p') -- add point -- final point edit.run_after_mouse_release(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+26, 1) local drawing = Editor_state.lines[1] @@ -284,13 +284,13 @@ function test_draw_rectangle() check_eq(#Editor_state.lines[1].shapes, 0, 'F - test_draw_rectangle/baseline/#shapes') -- first point edit.run_after_mouse_press(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1) - edit.run_after_keychord(Editor_state, 'r') -- rectangle mode + edit.run_after_textinput(Editor_state, 'r') -- rectangle mode -- second point/first edge App.mouse_move(Editor_state.left+42, Editor_state.top+Drawing_padding_top+45) - edit.run_after_keychord(Editor_state, 'p') + edit.run_after_textinput(Editor_state, 'p') -- override second point/first edge App.mouse_move(Editor_state.left+75, Editor_state.top+Drawing_padding_top+76) - edit.run_after_keychord(Editor_state, 'p') + edit.run_after_textinput(Editor_state, 'p') -- release (decides 'thickness' of rectangle perpendicular to first edge) edit.run_after_mouse_release(Editor_state, Editor_state.left+15, Editor_state.top+Drawing_padding_top+26, 1) local drawing = Editor_state.lines[1] @@ -329,13 +329,13 @@ function test_draw_rectangle_intermediate() check_eq(#Editor_state.lines[1].shapes, 0, 'F - test_draw_rectangle_intermediate/baseline/#shapes') -- first point edit.run_after_mouse_press(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1) - edit.run_after_keychord(Editor_state, 'r') -- rectangle mode + edit.run_after_textinput(Editor_state, 'r') -- rectangle mode -- second point/first edge App.mouse_move(Editor_state.left+42, Editor_state.top+Drawing_padding_top+45) - edit.run_after_keychord(Editor_state, 'p') + edit.run_after_textinput(Editor_state, 'p') -- override second point/first edge App.mouse_move(Editor_state.left+75, Editor_state.top+Drawing_padding_top+76) - edit.run_after_keychord(Editor_state, 'p') + edit.run_after_textinput(Editor_state, 'p') local drawing = Editor_state.lines[1] check_eq(#drawing.points, 3, 'F - test_draw_rectangle_intermediate/#points') -- currently includes every point added local pending = drawing.pending @@ -366,13 +366,13 @@ function test_draw_square() check_eq(#Editor_state.lines[1].shapes, 0, 'F - test_draw_square/baseline/#shapes') -- first point edit.run_after_mouse_press(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1) - edit.run_after_keychord(Editor_state, 's') -- square mode + edit.run_after_textinput(Editor_state, 's') -- square mode -- second point/first edge App.mouse_move(Editor_state.left+42, Editor_state.top+Drawing_padding_top+45) - edit.run_after_keychord(Editor_state, 'p') + edit.run_after_textinput(Editor_state, 'p') -- override second point/first edge App.mouse_move(Editor_state.left+65, Editor_state.top+Drawing_padding_top+66) - edit.run_after_keychord(Editor_state, 'p') + edit.run_after_textinput(Editor_state, 'p') -- release (decides which side of first edge to draw square on) edit.run_after_mouse_release(Editor_state, Editor_state.left+15, Editor_state.top+Drawing_padding_top+26, 1) local drawing = Editor_state.lines[1] @@ -594,13 +594,13 @@ function test_delete_point_from_polygon() edit.draw(Editor_state) -- first point edit.run_after_mouse_press(Editor_state, Editor_state.left+5, Editor_state.top+Drawing_padding_top+6, 1) - edit.run_after_keychord(Editor_state, 'g') -- polygon mode + edit.run_after_textinput(Editor_state, 'g') -- polygon mode -- second point App.mouse_move(Editor_state.left+65, Editor_state.top+Drawing_padding_top+36) - edit.run_after_keychord(Editor_state, 'p') -- add point + edit.run_after_textinput(Editor_state, 'p') -- add point -- third point App.mouse_move(Editor_state.left+35, Editor_state.top+Drawing_padding_top+26) - edit.run_after_keychord(Editor_state, 'p') -- add point + edit.run_after_textinput(Editor_state, 'p') -- add point -- fourth point edit.run_after_mouse_release(Editor_state, Editor_state.left+14, Editor_state.top+Drawing_padding_top+16, 1) local drawing = Editor_state.lines[1] @@ -626,10 +626,10 @@ function test_delete_point_from_polygon() edit.draw(Editor_state) -- first point edit.run_after_mouse_press(Editor_state, Editor_state.left+5, Editor_state.top+Drawing_padding_top+6, 1) - edit.run_after_keychord(Editor_state, 'g') -- polygon mode + edit.run_after_textinput(Editor_state, 'g') -- polygon mode -- second point App.mouse_move(Editor_state.left+65, Editor_state.top+Drawing_padding_top+36) - edit.run_after_keychord(Editor_state, 'p') -- add point + edit.run_after_textinput(Editor_state, 'p') -- add point -- third point edit.run_after_mouse_release(Editor_state, Editor_state.left+14, Editor_state.top+Drawing_padding_top+16, 1) local drawing = Editor_state.lines[1] |