test: moving a point

[?]
Jun 15, 2022, 4:08 AM
L6XA5EY2FVDQFRGCBFSCOM6O4GYN74K3YTZKGFUOPXIUYA3YT5JQC

Dependencies

  • [2] 6LIPEQ5I more robust transitions to temporary modes
  • [3] 42LVB4DE test: naming a point
  • [4] BYG5CEMV support for naming points
  • [5] YCDYGEZU include drawing index in a few places
  • [6] SRVDX4I5 local var
  • [7] JAXPXLEB set current_drawing_index with current_drawing
  • [8] JFFUF5AL override mouse state lookups in tests
  • [9] BJ2C6F2B ignore 'name' mode in a few places
  • [10] SVJZZDC3 snapshot - no, that's all wrong
  • [11] 7SFHSB47 rename
  • [12] WTDKUACN rectangle and square shapes
  • [13] CPZGQT72 go through and fix similar issues
  • [14] FEEGTRGQ bugfix: duplicate character on enter
  • [15] UZVWYRTY missing temporary modes in a couple more places
  • [16] MGT5FTJ3 first stab at supporting wrapping in cursor up
  • [17] DSLD74DK lots more tests
  • [18] CRYGI3LR more drawing tests
  • [19] 2XLZCWZC bugfix: rectangles and squares are now saved
  • [20] SBJRWFSP one less manual test
  • [21] XNFTJHC4 split keyboard handling between Text and Drawing
  • [22] 6DE7RBZ6 move mouse_released events to Drawing
  • [23] DRFE3B3Z mouse buttons are integers, not strings
  • [24] BJ5X5O4A let's prevent the text cursor from ever getting on a drawing
  • [25] F63Q4OV7 several bugfixes
  • [*] K2X6G75Z start writing some tests for drawings
  • [*] BLWAYPKV extract a module

Change contents

  • edit in drawing_tests.lua at line 358
    [3.1770]
    [3.1770]
    end
    function test_move_point()
    io.write('\ntest_move_point')
    -- create a drawing with a line
    App.screen.init{width=Margin_left+300, height=300}
    Lines = load_array{'```lines', '```', ''}
    Line_width = 256 -- drawing coordinates 1:1 with pixels
    Current_drawing_mode = 'line'
    App.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)
    local drawing = Lines[1]
    check_eq(#drawing.shapes, 1, 'F - test_move_point/baseline/#shapes')
    check_eq(#drawing.points, 2, 'F - test_move_point/baseline/#points')
    check_eq(drawing.shapes[1].mode, 'line', 'F - test_move_point/baseline/shape:1')
    local p1 = drawing.points[drawing.shapes[1].p1]
    local p2 = drawing.points[drawing.shapes[1].p2]
    check_eq(p1.x, 5, 'F - test_move_point/baseline/p1:x')
    check_eq(p1.y, 6, 'F - test_move_point/baseline/p1:y')
    check_eq(p2.x, 35, 'F - test_move_point/baseline/p2:x')
    check_eq(p2.y, 36, 'F - test_move_point/baseline/p2:y')
    check_nil(p2.name, 'F - test_move_point/baseline/p2:name')
    -- 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')
    -- point is lifted
    check_eq(drawing.pending.mode, 'move', 'F - test_move_point/mode:2')
    check_eq(drawing.pending.target_point, p2, 'F - test_move_point/target')
    -- move point
    App.mouse_move(Margin_left+26, Margin_top+Drawing_padding_top+44)
    App.update(0.05)
    local p2 = drawing.points[drawing.shapes[1].p2]
    check_eq(p2.x, 26, 'F - test_move_point/x')
    check_eq(p2.y, 44, 'F - test_move_point/y')
    -- exit 'move' mode
    App.run_after_mouse_click(Margin_left+26, Margin_top+Drawing_padding_top+44, 1)
    check_eq(Current_drawing_mode, 'line', 'F - test_move_point/mode:3')
    check_eq(drawing.pending, {}, 'F - test_move_point/pending')
  • edit in drawing.lua at line 263
    [4.221]
    [4.226]
    if Lines.current_drawing then
    Lines.current_drawing.pending = {}
    Lines.current_drawing = nil
    end
  • edit in drawing.lua at line 343
    [4.3044][4.3719:3768](),[4.3768][4.82:101](),[4.82][4.82:101]()
    elseif drawing.pending.mode == 'move' then
    -- drop it
  • edit in drawing.lua at line 491
    [4.10365][4.2666:2715](),[4.2715][4.138:208](),[4.3891][4.138:208](),[4.10419][4.138:208](),[4.208][4.10475:10495](),[4.476][4.10475:10495](),[4.10475][4.10475:10495](),[4.10495][2.118:224](),[2.224][4.10546:10650](),[4.10546][4.10546:10650](),[4.10650][4.209:259](),[4.259][4.420:458](),[4.10650][4.420:458](),[4.458][4.1818:1826](),[4.1818][4.1818:1826]()
    elseif App.mouse_down(1) and chord == 'v' then
    local drawing_index,drawing,_,p = Drawing.select_point_at_mouse()
    if drawing then
    if Previous_drawing_mode == nil then
    Previous_drawing_mode = Current_drawing_mode
    end
    Current_drawing_mode = 'move'
    drawing.pending = {mode=Current_drawing_mode, target_point=p}
    Lines.current_drawing_index = drawing_index
    Lines.current_drawing = drawing
    end
  • edit in Manual_tests.md at line 15
    [4.3][4.3:11](),[4.43][4.61:90](),[4.61][4.61:90](),[4.1809][4.2:3]()
    drawing
    select a point and move it