about summary refs log tree commit diff stats
path: root/drawing_tests.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-17 22:52:34 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-17 22:53:05 -0700
commit26995dd62e72b5d8075429c29b311125dbef5920 (patch)
treea17ccf09c18cbc5febf78462a7c85e6cec827187 /drawing_tests.lua
parent1ecc3f43e5949596ccb1bf9e2c9ad143d779deb1 (diff)
downloadtext.love-26995dd62e72b5d8075429c29b311125dbef5920.tar.gz
correct commit f3abc2cbf2
I can't be trusted to do anything without a test.

This should fix #5. Please reopen if it doesn't.
Diffstat (limited to 'drawing_tests.lua')
-rw-r--r--drawing_tests.lua27
1 files changed, 26 insertions, 1 deletions
diff --git a/drawing_tests.lua b/drawing_tests.lua
index faf94ce..e17b0bd 100644
--- a/drawing_tests.lua
+++ b/drawing_tests.lua
@@ -421,7 +421,6 @@ function test_move_point()
   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')
   -- wait until save
   App.wait_fake_time(3.1)
   App.update(0)
@@ -458,6 +457,32 @@ function test_move_point()
   check_eq(p2.y, 44, 'F - test_move_point/save/y')
 end
 
+function test_move_point_on_manhattan_line()
+  io.write('\ntest_move_point_on_manhattan_line')
+  -- create a drawing with a manhattan line
+  Filename = 'foo'
+  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 = 'manhattan'
+  App.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()
+  -- enter 'move' mode
+  App.run_after_keychord('C-u')
+  check_eq(Current_drawing_mode, 'move', 'F - test_move_point_on_manhattan_line/mode:1')
+  -- move point
+  App.mouse_move(Margin_left+26, Margin_top+Drawing_padding_top+44)
+  App.update(0.05)
+  -- line is no longer manhattan
+  check_eq(drawing.shapes[1].mode, 'line', 'F - test_move_point_on_manhattan_line/baseline/shape:1')
+end
+
 function test_delete_lines_at_point()
   io.write('\ntest_delete_lines_at_point')
   -- create a drawing with two lines connected at a point