Skip to content

Commit 397fadc

Browse files
Tests: Add tests for window headers
1 parent b33c49b commit 397fadc

File tree

4 files changed

+73
-4
lines changed

4 files changed

+73
-4
lines changed

notes/testplan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ For the following cases, open `/TESTS` and `/TESTS/FOLDER`:
748748
* Launch DeskTop. In the Options control panel, check "Preserve uppercase and lowercase in names". Rename one volume with mixed case e.g. "vol1.MIXED". Rename a second volume with differently mixed case, e.g. "VOL2.mixed". Drag the first volume to the second. Verify that the newly created folder is named with the same case as the dragged volume.
749749

750750

751-
## Window Headers
751+
## Window Headers - covered by `tests/window_headers.lua`
752752

753753
* Open a folder with no items. Verify window header says "0 Items"
754754
* Open a folder with only one item. Verify window header says "1 Item"

res/tests.hdv

0 Bytes
Binary file not shown.

tests/lib/a2d.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,13 @@ function a2d.DeletePath(path)
311311
end
312312

313313
function a2d.CreateFolder(path)
314-
local base, name = path:match("^(.*)/([^/]+)$")
315-
if base ~= "" then
316-
a2d.OpenPath(base)
314+
if path:match("/") then
315+
local base, name = path:match("^(.*)/([^/]+)$")
316+
if base ~= "" then
317+
a2d.OpenPath(base)
318+
end
319+
else
320+
name = path
317321
end
318322
a2d.InvokeMenuItem(a2d.FILE_MENU, a2d.FILE_NEW_FOLDER)
319323
apple2.ControlKey("X") -- clear

tests/window_headers.lua

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
--[[ BEGINCONFIG ========================================
2+
3+
MODELARGS="-sl1 ramfactor -sl2 mouse -sl7 cffa2 -aux ext80"
4+
DISKARGS="-hard1 $HARDIMG -hard2 res/tests.hdv "
5+
6+
======================================== ENDCONFIG ]]--
7+
8+
test.Step(
9+
"Item counts",
10+
function()
11+
a2d.OpenPath("/TESTS/WINDOWS/HEADERS/EMPTY")
12+
test.Snap("verify header says '0 Items'")
13+
a2d.OpenPath("/TESTS/WINDOWS/HEADERS/ONE.ITEM")
14+
test.Snap("verify header says '1 Item'")
15+
a2d.OpenPath("/TESTS/WINDOWS/HEADERS/TWO.ITEMS")
16+
test.Snap("verify header says '2 Items'")
17+
18+
a2d.OpenPath("/TESTS/WINDOWS/HEADERS/EMPTY")
19+
a2d.CreateFolder("NEW")
20+
test.Snap("verify header says '1 Item'")
21+
22+
a2d.OpenPath("/TESTS/WINDOWS/HEADERS/ONE.ITEM")
23+
a2d.CreateFolder("NEW")
24+
test.Snap("verify header says '2 Ites'")
25+
end)
26+
27+
test.Step(
28+
"Available space",
29+
function()
30+
a2d.OpenPath("/RAM1")
31+
test.Snap("note 'K in disk' and 'K available'")
32+
a2d.CreateFolder("NEW")
33+
test.Snap("verify 'K in disk' increased by 0.5 and 'K available' decreased by 0 or 1")
34+
a2d.CreateFolder("NEW2")
35+
test.Snap("verify 'K in disk' increased by 0.5 and 'K available' decreased by 0 or 1")
36+
37+
a2d.CloseAllWindows()
38+
a2d.SelectAll()
39+
a2d.OAShortcut("O") -- File > Open
40+
a2d.CycleWindows()
41+
test.Snap("note 'K in disk' and 'K available'")
42+
a2d.CreateFolder("NEW3")
43+
test.Snap("verify 'K in disk' increased by 0, 0.5, or 1 and 'K available' decreased by 0, 0.5, or 1")
44+
a2d.CreateFolder("NEW4")
45+
test.Snap("verify 'K in disk' increased by 0, 0.5, or 1 and 'K available' decreased by 0, 0.5, or 1")
46+
end)
47+
48+
test.Step(
49+
"Header clipping",
50+
function()
51+
a2d.OpenPath("/TESTS")
52+
a2d.MoveWindowBy(-150, 0)
53+
test.Snap("verify left edge of header text is cut off")
54+
a2d.MoveWindowBy(400, 0)
55+
test.Snap("verify right edge of header text is cut off")
56+
a2d.MoveWindowBy(-250, 0)
57+
58+
a2d.GrowWindowBy(-100,-50)
59+
test.Snap("both scrollbars?")
60+
61+
a2d.MoveWindowBy(-150, 0)
62+
test.Snap("verify left edge of header text is cut off")
63+
a2d.MoveWindowBy(450, 0)
64+
test.Snap("verify right edge of header text is cut off")
65+
end)

0 commit comments

Comments
 (0)