From 9b49c8da7725a9ec53bb594674f304f2b4681a6a Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 11 Jul 2022 23:17:26 -0700 Subject: start decoupling editor tests from App --- drawing_tests.lua | 48 ++++++++--------- text_tests.lua | 152 +++++++++++++++++++++++++++--------------------------- 2 files changed, 100 insertions(+), 100 deletions(-) diff --git a/drawing_tests.lua b/drawing_tests.lua index 4ec9690..c170caa 100644 --- a/drawing_tests.lua +++ b/drawing_tests.lua @@ -7,7 +7,7 @@ function test_creating_drawing_saves() App.screen.init{width=120, height=60} Filename = 'foo' Lines = load_array{} - App.draw() + edit.draw() -- click on button to create drawing App.run_after_mouse_click(8,Margin_top+8, 1) -- file not immediately saved @@ -27,7 +27,7 @@ function test_draw_line() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() check_eq(#Lines, 2, 'F - test_draw_line/baseline/#lines') check_eq(Lines[1].mode, 'drawing', 'F - test_draw_line/baseline/mode') check_eq(Lines[1].y, Margin_top+Drawing_padding_top, 'F - test_draw_line/baseline/y') @@ -70,7 +70,7 @@ function test_draw_horizontal_line() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'manhattan' - App.draw() + edit.draw() check_eq(#Lines, 2, 'F - test_draw_horizontal_line/baseline/#lines') check_eq(Lines[1].mode, 'drawing', 'F - test_draw_horizontal_line/baseline/mode') check_eq(Lines[1].y, Margin_top+Drawing_padding_top, 'F - test_draw_horizontal_line/baseline/y') @@ -97,7 +97,7 @@ function test_draw_circle() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() check_eq(#Lines, 2, 'F - test_draw_circle/baseline/#lines') check_eq(Lines[1].mode, 'drawing', 'F - test_draw_circle/baseline/mode') check_eq(Lines[1].y, Margin_top+Drawing_padding_top, 'F - test_draw_circle/baseline/y') @@ -125,7 +125,7 @@ function test_cancel_stroke() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() check_eq(#Lines, 2, 'F - test_cancel_stroke/baseline/#lines') check_eq(Lines[1].mode, 'drawing', 'F - test_cancel_stroke/baseline/mode') check_eq(Lines[1].y, Margin_top+Drawing_padding_top, 'F - test_cancel_stroke/baseline/y') @@ -146,7 +146,7 @@ function test_keys_do_not_affect_shape_when_mouse_up() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() -- hover over drawing and press 'o' without holding mouse App.mouse_move(Margin_left+4, Margin_top+Drawing_padding_top+4) -- hover on drawing App.run_after_keychord('o') @@ -161,7 +161,7 @@ function test_draw_circle_mid_stroke() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() check_eq(#Lines, 2, 'F - test_draw_circle_mid_stroke/baseline/#lines') check_eq(Lines[1].mode, 'drawing', 'F - test_draw_circle_mid_stroke/baseline/mode') check_eq(Lines[1].y, Margin_top+Drawing_padding_top, 'F - test_draw_circle_mid_stroke/baseline/y') @@ -188,7 +188,7 @@ function test_draw_arc() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'circle' - App.draw() + edit.draw() check_eq(#Lines, 2, 'F - test_draw_arc/baseline/#lines') check_eq(Lines[1].mode, 'drawing', 'F - test_draw_arc/baseline/mode') check_eq(Lines[1].y, Margin_top+Drawing_padding_top, 'F - test_draw_arc/baseline/y') @@ -217,7 +217,7 @@ function test_draw_polygon() -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} - App.draw() + edit.draw() check_eq(Current_drawing_mode, 'line', 'F - test_draw_polygon/baseline/drawing_mode') check_eq(#Lines, 2, 'F - test_draw_polygon/baseline/#lines') check_eq(Lines[1].mode, 'drawing', 'F - test_draw_polygon/baseline/mode') @@ -254,7 +254,7 @@ function test_draw_rectangle() -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} - App.draw() + edit.draw() check_eq(Current_drawing_mode, 'line', 'F - test_draw_rectangle/baseline/drawing_mode') check_eq(#Lines, 2, 'F - test_draw_rectangle/baseline/#lines') check_eq(Lines[1].mode, 'drawing', 'F - test_draw_rectangle/baseline/mode') @@ -297,7 +297,7 @@ function test_draw_rectangle_intermediate() -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} - App.draw() + edit.draw() check_eq(Current_drawing_mode, 'line', 'F - test_draw_rectangle_intermediate/baseline/drawing_mode') check_eq(#Lines, 2, 'F - test_draw_rectangle_intermediate/baseline/#lines') check_eq(Lines[1].mode, 'drawing', 'F - test_draw_rectangle_intermediate/baseline/mode') @@ -332,7 +332,7 @@ function test_draw_square() -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} - App.draw() + edit.draw() check_eq(Current_drawing_mode, 'line', 'F - test_draw_square/baseline/drawing_mode') check_eq(#Lines, 2, 'F - test_draw_square/baseline/#lines') check_eq(Lines[1].mode, 'drawing', 'F - test_draw_square/baseline/mode') @@ -376,7 +376,7 @@ function test_name_point() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() -- draw a line App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_release(Margin_left+35, Margin_top+Drawing_padding_top+36, 1) @@ -418,7 +418,7 @@ function test_move_point() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_release(Margin_left+35, Margin_top+Drawing_padding_top+36, 1) local drawing = Lines[1] @@ -440,7 +440,7 @@ function test_move_point() local p2 = Lines[1].points[drawing.shapes[1].p2] check_eq(p2.x, 35, 'F - test_move_point/save/x') check_eq(p2.y, 36, 'F - test_move_point/save/y') - App.draw() + edit.draw() -- enter 'move' mode without moving the mouse App.run_after_keychord('C-u') check_eq(Current_drawing_mode, 'move', 'F - test_move_point/mode:1') @@ -474,14 +474,14 @@ function test_move_point_on_manhattan_line() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'manhattan' - App.draw() + edit.draw() App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_release(Margin_left+35, Margin_top+Drawing_padding_top+46, 1) local drawing = Lines[1] check_eq(#drawing.shapes, 1, 'F - test_move_point_on_manhattan_line/baseline/#shapes') check_eq(#drawing.points, 2, 'F - test_move_point_on_manhattan_line/baseline/#points') check_eq(drawing.shapes[1].mode, 'manhattan', 'F - test_move_point_on_manhattan_line/baseline/shape:1') - App.draw() + edit.draw() -- enter 'move' mode App.run_after_keychord('C-u') check_eq(Current_drawing_mode, 'move', 'F - test_move_point_on_manhattan_line/mode:1') @@ -499,7 +499,7 @@ function test_delete_lines_at_point() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_release(Margin_left+35, Margin_top+Drawing_padding_top+36, 1) App.run_after_mouse_press(Margin_left+35, Margin_top+Drawing_padding_top+36, 1) @@ -527,7 +527,7 @@ function test_delete_line_under_mouse_pointer() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_release(Margin_left+35, Margin_top+Drawing_padding_top+36, 1) App.run_after_mouse_press(Margin_left+35, Margin_top+Drawing_padding_top+36, 1) @@ -550,7 +550,7 @@ function test_delete_point_from_polygon() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() -- first point App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_keychord('g') -- polygon mode @@ -580,7 +580,7 @@ function test_delete_point_from_polygon() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() -- first point App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_keychord('g') -- polygon mode @@ -607,7 +607,7 @@ function test_undo_name_point() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() -- draw a line App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_release(Margin_left+35, Margin_top+Drawing_padding_top+36, 1) @@ -652,7 +652,7 @@ function test_undo_move_point() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_release(Margin_left+35, Margin_top+Drawing_padding_top+36, 1) local drawing = Lines[1] @@ -701,7 +701,7 @@ function test_undo_delete_point() App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' - App.draw() + edit.draw() App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_release(Margin_left+35, Margin_top+Drawing_padding_top+36, 1) App.run_after_mouse_press(Margin_left+35, Margin_top+Drawing_padding_top+36, 1) diff --git a/text_tests.lua b/text_tests.lua index 49c737d..be6d0d9 100644 --- a/text_tests.lua +++ b/text_tests.lua @@ -5,7 +5,7 @@ function test_initial_state() App.screen.init{width=120, height=60} Lines = load_array{} Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() check_eq(#Lines, 1, 'F - test_initial_state/#lines') check_eq(Cursor1.line, 1, 'F - test_initial_state/cursor:line') check_eq(Cursor1.pos, 1, 'F - test_initial_state/cursor:pos') @@ -18,7 +18,7 @@ function test_click_to_create_drawing() App.screen.init{width=120, height=60} Lines = load_array{} Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_mouse_click(8,Margin_top+8, 1) -- cursor skips drawing to always remain on text check_eq(#Lines, 2, 'F - test_click_to_create_drawing/#lines') @@ -44,7 +44,7 @@ function test_insert_first_character() App.screen.init{width=120, height=60} Lines = load_array{} Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_textinput('a') local y = Margin_top App.screen.check(y, 'a', 'F - test_insert_first_character/screen:1') @@ -68,7 +68,7 @@ function test_move_left() Lines = load_array{'a'} Cursor1 = {line=1, pos=2} Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('left') check_eq(Cursor1.pos, 1, 'F - test_move_left') end @@ -79,7 +79,7 @@ function test_move_right() Lines = load_array{'a'} Cursor1 = {line=1, pos=1} Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('right') check_eq(Cursor1.pos, 2, 'F - test_move_right') end @@ -90,7 +90,7 @@ function test_move_left_to_previous_line() Lines = load_array{'abc', 'def'} Cursor1 = {line=2, pos=1} Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('left') check_eq(Cursor1.line, 1, 'F - test_move_left_to_previous_line/line') check_eq(Cursor1.pos, 4, 'F - test_move_left_to_previous_line/pos') -- past end of line @@ -102,7 +102,7 @@ function test_move_right_to_next_line() Lines = load_array{'abc', 'def'} Cursor1 = {line=1, pos=4} -- past end of line Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('right') check_eq(Cursor1.line, 2, 'F - test_move_right_to_next_line/line') check_eq(Cursor1.pos, 1, 'F - test_move_right_to_next_line/pos') @@ -114,7 +114,7 @@ function test_move_to_start_of_word() Lines = load_array{'abc'} Cursor1 = {line=1, pos=3} Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('M-left') check_eq(Cursor1.pos, 1, 'F - test_move_to_start_of_word') end @@ -125,7 +125,7 @@ function test_move_to_start_of_previous_word() Lines = load_array{'abc def'} Cursor1 = {line=1, pos=4} -- at the space between words Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('M-left') check_eq(Cursor1.pos, 1, 'F - test_move_to_start_of_previous_word') end @@ -136,7 +136,7 @@ function test_skip_to_previous_word() Lines = load_array{'abc def'} Cursor1 = {line=1, pos=5} -- at the start of second word Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('M-left') check_eq(Cursor1.pos, 1, 'F - test_skip_to_previous_word') end @@ -147,7 +147,7 @@ function test_skip_past_tab_to_previous_word() Lines = load_array{'abc def\tghi'} Cursor1 = {line=1, pos=10} -- within third word Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('M-left') check_eq(Cursor1.pos, 9, 'F - test_skip_past_tab_to_previous_word') end @@ -158,7 +158,7 @@ function test_skip_multiple_spaces_to_previous_word() Lines = load_array{'abc def'} Cursor1 = {line=1, pos=6} -- at the start of second word Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('M-left') check_eq(Cursor1.pos, 1, 'F - test_skip_multiple_spaces_to_previous_word') end @@ -169,7 +169,7 @@ function test_move_to_start_of_word_on_previous_line() Lines = load_array{'abc def', 'ghi'} Cursor1 = {line=2, pos=1} Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('M-left') check_eq(Cursor1.line, 1, 'F - test_move_to_start_of_word_on_previous_line/line') check_eq(Cursor1.pos, 5, 'F - test_move_to_start_of_word_on_previous_line/pos') @@ -181,7 +181,7 @@ function test_move_past_end_of_word() Lines = load_array{'abc def'} Cursor1 = {line=1, pos=1} Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('M-right') check_eq(Cursor1.pos, 4, 'F - test_move_past_end_of_word') end @@ -192,7 +192,7 @@ function test_skip_to_next_word() Lines = load_array{'abc def'} Cursor1 = {line=1, pos=4} -- at the space between words Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('M-right') check_eq(Cursor1.pos, 8, 'F - test_skip_to_next_word') end @@ -203,7 +203,7 @@ function test_skip_past_tab_to_next_word() Lines = load_array{'abc\tdef'} Cursor1 = {line=1, pos=1} -- at the space between words Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('M-right') check_eq(Cursor1.pos, 4, 'F - test_skip_past_tab_to_next_word') end @@ -214,7 +214,7 @@ function test_skip_multiple_spaces_to_next_word() Lines = load_array{'abc def'} Cursor1 = {line=1, pos=4} -- at the start of second word Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('M-right') check_eq(Cursor1.pos, 9, 'F - test_skip_multiple_spaces_to_next_word') end @@ -225,7 +225,7 @@ function test_move_past_end_of_word_on_next_line() Lines = load_array{'abc def', 'ghi'} Cursor1 = {line=1, pos=8} Margin_right = 0; Margin_width = Margin_left - App.draw() + edit.draw() App.run_after_keychord('M-right') check_eq(Cursor1.line, 2, 'F - test_move_past_end_of_word_on_next_line/line') check_eq(Cursor1.pos, 4, 'F - test_move_past_end_of_word_on_next_line/pos') @@ -241,7 +241,7 @@ function test_click_with_mouse() Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} -- click on the other line - App.draw() + edit.draw() App.run_after_mouse_click(Margin_left+8,Margin_top+5, 1) -- cursor moves check_eq(Cursor1.line, 1, 'F - test_click_with_mouse/cursor') @@ -258,7 +258,7 @@ function test_click_with_mouse_on_empty_line() Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} -- click on the empty line - App.draw() + edit.draw() App.run_after_mouse_click(Margin_left+8,Margin_top+5, 1) -- cursor moves check_eq(Cursor1.line, 1, 'F - test_click_with_mouse_on_empty_line/cursor') @@ -272,7 +272,7 @@ function test_draw_text() Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_draw_text/screen:1') y = y + Line_height @@ -289,7 +289,7 @@ function test_draw_wrapping_text() Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_draw_wrapping_text/screen:1') y = y + Line_height @@ -306,7 +306,7 @@ function test_draw_word_wrapping_text() Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc ', 'F - test_draw_word_wrapping_text/screen:1') y = y + Line_height @@ -324,7 +324,7 @@ function test_draw_text_wrapping_within_word() Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abcd ', 'F - test_draw_text_wrapping_within_word/screen:1') y = y + Line_height @@ -342,7 +342,7 @@ function test_draw_wrapping_text_containing_non_ascii() Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'mada', 'F - test_draw_wrapping_text_containing_non_ascii/screen:1') y = y + Line_height @@ -361,7 +361,7 @@ function test_click_on_wrapping_line() Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'madam ', 'F - test_click_on_wrapping_line/baseline/screen:1') y = y + Line_height @@ -384,7 +384,7 @@ function test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen() Cursor1 = {line=1, pos=8} Screen_top1 = {line=1, pos=7} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, "I'm ada", 'F - test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen/baseline/screen:2') y = y + Line_height @@ -405,7 +405,7 @@ function test_click_past_end_of_wrapping_line() Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'madam ', 'F - test_click_past_end_of_wrapping_line/baseline/screen:1') y = y + Line_height @@ -429,7 +429,7 @@ function test_click_on_wrapping_line_containing_non_ascii() Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'madam ', 'F - test_click_on_wrapping_line_containing_non_ascii/baseline/screen:1') y = y + Line_height @@ -454,7 +454,7 @@ function test_click_past_end_of_word_wrapping_line() Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'the quick brown fox ', 'F - test_click_past_end_of_word_wrapping_line/baseline/screen:1') y = y + Line_height @@ -473,7 +473,7 @@ function test_select_text() Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() -- select a letter App.fake_key_press('lshift') App.run_after_keychord('S-right') @@ -496,7 +496,7 @@ function test_cursor_movement_without_shift_resets_selection() Selection1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() -- press an arrow key without shift App.run_after_keychord('right') -- no change to data, selection is reset @@ -514,7 +514,7 @@ function test_edit_deletes_selection() Selection1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() -- press a key App.run_after_textinput('x') -- selected text is deleted and replaced with the key @@ -531,7 +531,7 @@ function test_edit_with_shift_key_deletes_selection() Selection1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() -- mimic precise keypresses for a capital letter App.fake_key_press('lshift') App.keypressed('d') @@ -553,7 +553,7 @@ function test_copy_does_not_reset_selection() Selection1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() -- copy selection App.run_after_keychord('C-c') check_eq(App.clipboard, 'a', 'F - test_copy_does_not_reset_selection/clipboard') @@ -571,7 +571,7 @@ function test_cut() Selection1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() -- press a key App.run_after_keychord('C-x') check_eq(App.clipboard, 'a', 'F - test_cut/clipboard') @@ -589,7 +589,7 @@ function test_paste_replaces_selection() Selection1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() -- set clipboard App.clipboard = 'xyz' -- paste selection @@ -608,7 +608,7 @@ function test_deleting_selection_may_scroll() Cursor1 = {line=3, pos=2} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'def', 'F - test_deleting_selection_may_scroll/baseline/screen:1') y = y + Line_height @@ -632,7 +632,7 @@ function test_edit_wrapping_text() Cursor1 = {line=2, pos=4} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() App.run_after_textinput('g') App.run_after_textinput('h') App.run_after_textinput('i') @@ -654,7 +654,7 @@ function test_insert_newline() Cursor1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_insert_newline/baseline/screen:1') y = y + Line_height @@ -700,7 +700,7 @@ function test_insert_from_clipboard() Cursor1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_insert_from_clipboard/baseline/screen:1') y = y + Line_height @@ -730,7 +730,7 @@ function test_move_cursor_using_mouse() Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} Selection1 = {} - App.draw() -- populate line.y for each line in Lines + edit.draw() -- populate line.y for each line in Lines App.run_after_mouse_release(Margin_left+8,Margin_top+5, 1) check_eq(Cursor1.line, 1, 'F - test_move_cursor_using_mouse/cursor:line') check_eq(Cursor1.pos, 2, 'F - test_move_cursor_using_mouse/cursor:pos') @@ -747,7 +747,7 @@ function test_select_text_using_mouse() Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} Selection1 = {} - App.draw() -- populate line.y for each line in Lines + edit.draw() -- populate line.y for each line in Lines -- press and hold on first location App.run_after_mouse_press(Margin_left+8,Margin_top+5, 1) -- drag and release somewhere else @@ -767,7 +767,7 @@ function test_select_text_using_mouse_and_shift() Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} Selection1 = {} - App.draw() -- populate line.y for each line in Lines + edit.draw() -- populate line.y for each line in Lines -- click on first location App.run_after_mouse_press(Margin_left+8,Margin_top+5, 1) App.run_after_mouse_release(Margin_left+8,Margin_top+5, 1) @@ -791,7 +791,7 @@ function test_select_text_repeatedly_using_mouse_and_shift() Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} Selection1 = {} - App.draw() -- populate line.y for each line in Lines + edit.draw() -- populate line.y for each line in Lines -- click on first location App.run_after_mouse_press(Margin_left+8,Margin_top+5, 1) App.run_after_mouse_release(Margin_left+8,Margin_top+5, 1) @@ -821,7 +821,7 @@ function test_cut_without_selection() Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} Selection1 = {} - App.draw() + edit.draw() -- try to cut without selecting text App.run_after_keychord('C-x') -- no crash @@ -837,7 +837,7 @@ function test_pagedown() Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} -- initially the first two lines are displayed - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_pagedown/baseline/screen:1') y = y + Line_height @@ -869,7 +869,7 @@ function test_pagedown_skips_drawings() local drawing_height = Drawing_padding_height + drawing_width/2 -- default -- initially the screen displays the first line and the drawing -- 15px margin + 15px line1 + 10px margin + 25px drawing + 10px margin = 75px < screen height 80px - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_pagedown_skips_drawings/baseline/screen:1') -- after pagedown the screen draws the drawing up top @@ -890,7 +890,7 @@ function test_pagedown_often_shows_start_of_wrapping_line() Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_pagedown_often_shows_start_of_wrapping_line/baseline/screen:1') y = y + Line_height @@ -920,7 +920,7 @@ function test_pagedown_can_start_from_middle_of_long_wrapping_line() Cursor1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc ', 'F - test_pagedown_can_start_from_middle_of_long_wrapping_line/baseline/screen:1') y = y + Line_height @@ -948,7 +948,7 @@ function test_down_arrow_moves_cursor() Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} -- initially the first three lines are displayed - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_down_arrow_moves_cursor/baseline/screen:1') y = y + Line_height @@ -977,7 +977,7 @@ function test_down_arrow_scrolls_down_by_one_line() Cursor1 = {line=3, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_down_arrow_scrolls_down_by_one_line/baseline/screen:1') y = y + Line_height @@ -1005,7 +1005,7 @@ function test_down_arrow_scrolls_down_by_one_screen_line() Cursor1 = {line=3, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_down_arrow_scrolls_down_by_one_screen_line/baseline/screen:1') y = y + Line_height @@ -1034,7 +1034,7 @@ function test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_ Cursor1 = {line=3, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/baseline/screen:1') y = y + Line_height @@ -1062,7 +1062,7 @@ function test_page_down_followed_by_down_arrow_does_not_scroll_screen_up() Cursor1 = {line=3, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:1') y = y + Line_height @@ -1096,7 +1096,7 @@ function test_up_arrow_moves_cursor() Cursor1 = {line=3, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_up_arrow_moves_cursor/baseline/screen:1') y = y + Line_height @@ -1125,7 +1125,7 @@ function test_up_arrow_scrolls_up_by_one_line() Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'def', 'F - test_up_arrow_scrolls_up_by_one_line/baseline/screen:1') y = y + Line_height @@ -1153,7 +1153,7 @@ function test_up_arrow_scrolls_up_by_one_screen_line() Cursor1 = {line=3, pos=6} Screen_top1 = {line=3, pos=5} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'jkl', 'F - test_up_arrow_scrolls_up_by_one_screen_line/baseline/screen:1') y = y + Line_height @@ -1181,7 +1181,7 @@ function test_up_arrow_scrolls_up_to_final_screen_line() Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'ghi', 'F - test_up_arrow_scrolls_up_to_final_screen_line/baseline/screen:1') y = y + Line_height @@ -1211,7 +1211,7 @@ function test_up_arrow_scrolls_up_to_empty_line() Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_up_arrow_scrolls_up_to_empty_line/baseline/screen:1') y = y + Line_height @@ -1239,7 +1239,7 @@ function test_pageup() Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} -- initially the last two lines are displayed - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'def', 'F - test_pageup/baseline/screen:1') y = y + Line_height @@ -1263,7 +1263,7 @@ function test_pageup_scrolls_up_by_screen_line() Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'ghi', 'F - test_pageup_scrolls_up_by_screen_line/baseline/screen:1') y = y + Line_height @@ -1292,7 +1292,7 @@ function test_pageup_scrolls_up_from_middle_screen_line() Cursor1 = {line=2, pos=5} Screen_top1 = {line=2, pos=5} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'jkl', 'F - test_pageup_scrolls_up_from_middle_screen_line/baseline/screen:2') y = y + Line_height @@ -1319,7 +1319,7 @@ function test_enter_on_bottom_line_scrolls_down() Cursor1 = {line=3, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_enter_on_bottom_line_scrolls_down/baseline/screen:1') y = y + Line_height @@ -1348,7 +1348,7 @@ function test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom() Cursor1 = {line=4, pos=2} Screen_top1 = {line=4, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'jkl', 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/baseline/screen:1') -- after hitting the enter key the screen does not scroll down @@ -1371,7 +1371,7 @@ function test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bot Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() -- after hitting the inserting_text key the screen does not scroll down App.run_after_textinput('a') check_eq(Screen_top1.line, 2, 'F - test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bottom/screen_top') @@ -1390,7 +1390,7 @@ function test_typing_on_bottom_line_scrolls_down() Cursor1 = {line=3, pos=4} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_typing_on_bottom_line_scrolls_down/baseline/screen:1') y = y + Line_height @@ -1422,7 +1422,7 @@ function test_left_arrow_scrolls_up_in_wrapped_line() Screen_bottom1 = {} -- cursor is at top of screen Cursor1 = {line=3, pos=5} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'jkl', 'F - test_left_arrow_scrolls_up_in_wrapped_line/baseline/screen:1') y = y + Line_height @@ -1451,7 +1451,7 @@ function test_right_arrow_scrolls_down_in_wrapped_line() Screen_bottom1 = {} -- cursor is at bottom right of screen Cursor1 = {line=3, pos=5} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_right_arrow_scrolls_down_in_wrapped_line/baseline/screen:1') y = y + Line_height @@ -1481,7 +1481,7 @@ function test_home_scrolls_up_in_wrapped_line() Screen_bottom1 = {} -- cursor is at top of screen Cursor1 = {line=3, pos=5} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'jkl', 'F - test_home_scrolls_up_in_wrapped_line/baseline/screen:1') y = y + Line_height @@ -1510,7 +1510,7 @@ function test_end_scrolls_down_in_wrapped_line() Screen_bottom1 = {} -- cursor is at bottom right of screen Cursor1 = {line=3, pos=5} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc', 'F - test_end_scrolls_down_in_wrapped_line/baseline/screen:1') y = y + Line_height @@ -1539,7 +1539,7 @@ function test_position_cursor_on_recently_edited_wrapping_line() Cursor1 = {line=1, pos=25} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'abc def ghi ', 'F - test_position_cursor_on_recently_edited_wrapping_line/baseline1/screen:1') y = y + Line_height @@ -1573,7 +1573,7 @@ function test_backspace_can_scroll_up() Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'def', 'F - test_backspace_can_scroll_up/baseline/screen:1') y = y + Line_height @@ -1601,7 +1601,7 @@ function test_backspace_can_scroll_up_screen_line() Cursor1 = {line=3, pos=5} Screen_top1 = {line=3, pos=5} Screen_bottom1 = {} - App.draw() + edit.draw() local y = Margin_top App.screen.check(y, 'jkl', 'F - test_backspace_can_scroll_up_screen_line/baseline/screen:1') y = y + Line_height @@ -1737,7 +1737,7 @@ function test_undo_insert_text() Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} -- insert a character - App.draw() + edit.draw() App.run_after_textinput('g') check_eq(Cursor1.line, 2, 'F - test_undo_insert_text/baseline/cursor:line') check_eq(Cursor1.pos, 5, 'F - test_undo_insert_text/baseline/cursor:pos') @@ -1810,7 +1810,7 @@ function test_undo_restores_selection() Selection1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} - App.draw() + edit.draw() -- delete selected text App.run_after_textinput('x') check_eq(Lines[1].data, 'xbc', 'F - test_undo_restores_selection/baseline') -- cgit 1.4.1-2-gfad0