about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-17 22:24:46 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-17 22:24:46 -0700
commit1ecc3f43e5949596ccb1bf9e2c9ad143d779deb1 (patch)
treecb80ff8533010b32d27ebbd4c96c549ac8639a79
parentb8e8ac248178dba3c60e5c164a04054937aa6d29 (diff)
downloadview.love-1ecc3f43e5949596ccb1bf9e2c9ad143d779deb1.tar.gz
drop last couple of manual tests
-rw-r--r--Manual_tests.md12
-rw-r--r--main.lua4
-rw-r--r--main_tests.lua29
3 files changed, 32 insertions, 13 deletions
diff --git a/Manual_tests.md b/Manual_tests.md
index cadfbd7..715c50b 100644
--- a/Manual_tests.md
+++ b/Manual_tests.md
@@ -10,15 +10,3 @@ Lua is dynamically typed. Tests can't patch over lack of type-checking.
 * All strings are UTF-8. Bytes within them are not characters. I try to label
   byte offsets as _offset, and character positions as _pos. For example,
   string.sub should never use a _pos to substring, only an _offset.
-
-### Todo list
-
-* resize:
-  * Create a file containing a long line of characters without spaces. Try
-    resizing the window vertically and horizontally, as far as possible.
-
-* line-width button
-  * Create a file containing a single line with a reasonable number of
-    characters. Move the cursor towards the end of the line. Click on
-    line-width icon in the top margin, slide it left and right. Watch the line
-    of characters wrap and unwrap in response. Text should not be selected.
diff --git a/main.lua b/main.lua
index ffe6838..b5a3e6b 100644
--- a/main.lua
+++ b/main.lua
@@ -12,6 +12,8 @@ local geom = require 'geom'
 require 'help'
 require 'icons'
 
+require 'main_tests'
+
 -- run in both tests and a real run
 function App.initialize_globals()
 -- a line is either text or a drawing
@@ -167,7 +169,7 @@ function parse_geometry_spec(geometry_spec)
   return true
 end
 
-function love.resize(w, h)
+function App.resize(w, h)
 --?   print(("Window resized to width: %d and height: %d."):format(w, h))
   App.screen.width, App.screen.height = w, h
   Line_width = math.min(40*App.width(Em), App.screen.width-50)
diff --git a/main_tests.lua b/main_tests.lua
new file mode 100644
index 0000000..f9dac71
--- /dev/null
+++ b/main_tests.lua
@@ -0,0 +1,29 @@
+function test_resize_window()
+  io.write('\ntest_resize_window')
+  Filename = 'foo'
+  App.screen.init{width=Margin_left+300, height=300}
+  check_eq(App.screen.width, Margin_left+300, 'F - test_resize_window/baseline/width')
+  check_eq(App.screen.height, 300, 'F - test_resize_window/baseline/height')
+  App.resize(200, 400)
+  check_eq(App.screen.width, 200, 'F - test_resize_window/width')
+  check_eq(App.screen.height, 400, 'F - test_resize_window/height')
+  -- TODO: how to make assertions about when App.update got past the early exit?
+end
+
+function test_adjust_line_width()
+  io.write('\ntest_adjust_line_width')
+  Filename = 'foo'
+  App.screen.init{width=Margin_left+300, height=300}
+  Line_width = 256
+  App.draw()  -- initialize button
+  App.run_after_mouse_press(Margin_left+256, Margin_top-3, 1)
+  App.mouse_move(Margin_left+200, 37)
+  -- no change for some time
+  App.wait_fake_time(0.01)
+  App.update(0)
+  check_eq(Line_width, 256, 'F - test_adjust_line_width/early')
+  -- after 0.1s the change takes
+  App.wait_fake_time(0.1)
+  App.update(0)
+  check_eq(Line_width, 200, 'F - test_adjust_line_width')
+end