Skip to content

Commit 2478ccf

Browse files
Tests: More 'expect nothing happened' usage
1 parent 1d5e8a9 commit 2478ccf

File tree

8 files changed

+87
-66
lines changed

8 files changed

+87
-66
lines changed

tests/alerts.lua

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ test.Step(
1010
function()
1111
a2d.AddShortcut("/A2.DESKTOP/READ.ME")
1212
a2d.RenamePath("/A2.DESKTOP/READ.ME", "README")
13-
a2d.OAShortcut("1")
14-
test.Snap("verify alert shown")
15-
apple2.EscapeKey()
16-
a2d.WaitForRepaint()
17-
test.Snap("verify alert dismissed")
13+
a2dtest.ExpectNothingHappened(function()
14+
a2d.OAShortcut("1")
15+
test.Snap("verify alert shown")
16+
apple2.EscapeKey()
17+
a2d.WaitForRepaint()
18+
end)
1819
end)
1920

2021
test.Step(
@@ -24,12 +25,13 @@ test.Step(
2425
a2d.ToggleOptionShowShortcutsOnStartup() -- Enable
2526
a2d.Reboot()
2627

27-
apple2.Type("1")
28-
a2d.DialogOK()
29-
test.Snap("verify alert shown")
30-
apple2.EscapeKey()
31-
a2d.WaitForRepaint()
32-
test.Snap("verify alert dismissed")
28+
a2dtest.ExpectNothingHappened(function()
29+
apple2.Type("1")
30+
a2d.DialogOK()
31+
test.Snap("verify alert shown")
32+
apple2.EscapeKey()
33+
a2d.WaitForRepaint()
34+
end)
3335

3436
apple2.Type("D") -- Desktop
3537
a2d.WaitForRestart()
@@ -84,8 +86,7 @@ test.Step(
8486
emu.wait(2/60)
8587
test.Snap("verify down on yes")
8688
m.MoveByApproximately(20, 20)
87-
m.ButtonUp()
88-
test.Snap("verify nothing happened")
89+
a2dtest.ExpectNothingHappened(m.ButtonUp)
8990
m.MoveToApproximately(yes_x,btn_y)
9091
m.Click()
9192
emu.wait(5) -- allow copy to continue
@@ -95,8 +96,7 @@ test.Step(
9596
emu.wait(2/60)
9697
test.Snap("verify down on no")
9798
m.MoveByApproximately(20, 20)
98-
m.ButtonUp()
99-
test.Snap("verify nothing happened")
99+
a2dtest.ExpectNothingHappened(m.ButtonUp)
100100
m.MoveToApproximately(yes_x,btn_y)
101101
m.Click()
102102
emu.wait(5) -- allow copy to continue
@@ -106,8 +106,7 @@ test.Step(
106106
emu.wait(2/60)
107107
test.Snap("verify down on all")
108108
m.MoveByApproximately(20, 20)
109-
m.ButtonUp()
110-
test.Snap("verify nothing happened")
109+
a2dtest.ExpectNothingHappened(m.ButtonUp)
111110
m.MoveToApproximately(all_x,btn_y)
112111
m.Click()
113112
emu.wait(5) -- allow copy to continue

tests/close_all.lua

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
test.Step(
99
"Close all using modifier-click",
1010
function()
11-
a2d.OpenPath("/A2.DESKTOP/EXTRAS", true) -- leave parent open
12-
a2d.InMouseKeysMode(function(m)
13-
m.MoveToApproximately(40, 26)
14-
apple2.PressOA()
15-
m.Click()
16-
apple2.ReleaseOA()
11+
a2dtest.ExpectNothingHappened(function()
12+
a2d.ClearSelection()
13+
a2d.OpenPath("/A2.DESKTOP/EXTRAS", true) -- leave parent open
14+
a2d.InMouseKeysMode(function(m)
15+
m.MoveToApproximately(40, 26)
16+
apple2.PressOA()
17+
m.Click()
18+
apple2.ReleaseOA()
19+
a2d.WaitForRepaint()
20+
m.MoveToApproximately(0,0)
21+
end)
22+
a2d.ClearSelection()
1723
end)
18-
a2d.WaitForRepaint()
19-
test.Snap("verify all windows closed")
2024
end)
2125

2226
test.Variants(
@@ -25,14 +29,17 @@ test.Variants(
2529
"Close all using shortcut - caps lock off",
2630
},
2731
function(idx)
28-
a2d.OpenPath("/A2.DESKTOP/EXTRAS", true) -- leave parent open
29-
if idx == 1 then
30-
a2d.OASAShortcut("W")
31-
else
32-
a2d.OASAShortcut("w")
33-
end
34-
a2d.WaitForRepaint()
35-
test.Snap("verify all windows closed")
32+
a2d.ClearSelection()
33+
a2dtest.ExpectNothingHappened(function()
34+
a2d.OpenPath("/A2.DESKTOP/EXTRAS", true) -- leave parent open
35+
if idx == 1 then
36+
a2d.OASAShortcut("W")
37+
else
38+
a2d.OASAShortcut("w")
39+
end
40+
a2d.WaitForRepaint()
41+
a2d.ClearSelection()
42+
end)
3643
end)
3744

3845
--[[

tests/date_and_time.lua

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,20 @@ end)
2222
test.Step(
2323
"Escape and Return",
2424
function()
25-
a2d.InvokeMenuItem(a2d.APPLE_MENU, a2d.CONTROL_PANELS)
26-
a2d.SelectAndOpen("DATE.AND.TIME")
27-
apple2.ReturnKey()
28-
a2d.WaitForRepaint()
29-
test.Snap("verify dialog closed")
30-
a2d.SelectAndOpen("DATE.AND.TIME")
31-
apple2.EscapeKey()
32-
a2d.WaitForRepaint()
33-
test.Snap("verify dialog closed")
25+
a2d.SelectPath("/A2.DESKTOP/APPLE.MENU/CONTROL.PANELS/DATE.AND.TIME")
26+
27+
a2dtest.ExpectNothingHappened(function()
28+
a2d.OpenSelection()
29+
apple2.ReturnKey()
30+
a2d.WaitForRepaint()
31+
end)
32+
33+
a2dtest.ExpectNothingHappened(function()
34+
a2d.OpenSelection()
35+
apple2.EscapeKey()
36+
a2d.WaitForRepaint()
37+
end)
38+
3439
a2d.CloseAllWindows()
3540
end)
3641

tests/desk_accessories.lua

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,19 @@ function CloseWindowTest(name, path, x, y)
6767
test.Step(
6868
name .. " closes on OA+W",
6969
function()
70-
a2d.OpenPath(path)
71-
a2d.OAShortcut("W")
72-
a2d.WaitForRepaint()
73-
test.Snap("verify window closed on OA+W")
74-
75-
a2d.OpenPath(path)
76-
a2d.WaitForRepaint()
77-
a2d.OAShortcut("w")
78-
test.Snap("verify window closed on OA+w")
70+
a2d.SelectPath(path)
71+
a2dtest.ExpectNothingHappened(function()
72+
a2d.OpenSelection()
73+
a2d.OAShortcut("W")
74+
a2d.WaitForRepaint()
75+
end)
76+
77+
a2d.SelectPath(path)
78+
a2dtest.ExpectNothingHappened(function()
79+
a2d.OpenSelection()
80+
a2d.WaitForRepaint()
81+
a2d.OAShortcut("w")
82+
end)
7983
end)
8084
end
8185

tests/dos33_import.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ test.Step(
1717
function()
1818
a2d.SelectAndOpen("DOS33.IMPORT")
1919
test.Snap("verify OK button is disabled ")
20-
apple2.ReturnKey()
21-
test.Snap("verify nothing happened")
20+
a2dtest.ExpectNothingHappened(apple2.ReturnKey)
2221
apple2.DownArrowKey() -- select drive
2322
test.Snap("verify OK button is enabled")
2423
apple2.ReturnKey()
@@ -72,8 +71,7 @@ test.Step(
7271
apple2.DownArrowKey() -- select drive
7372
apple2.ReturnKey()
7473
emu.wait(10) -- floppy catalog
75-
apple2.ReturnKey()
76-
test.Snap("verify nothing happens")
74+
a2dtest.ExpectNothingHappened(apple2.ReturnKey)
7775
apple2.DownArrowKey() -- select file
7876
apple2.ReturnKey()
7977
test.Snap("verify Import button flashes")

tests/image_preview.lua

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,23 @@ apple2.SetMonitorType(apple2.MONITOR_TYPE_VIDEO7)
1010
test.Step(
1111
"Escape exits",
1212
function()
13-
a2d.OpenPath("/A2.DESKTOP/SAMPLE.MEDIA/MONARCH")
14-
apple2.EscapeKey()
15-
a2d.WaitForRepaint()
16-
test.Snap("verify preview exited")
13+
a2d.SelectPath("/A2.DESKTOP/SAMPLE.MEDIA/MONARCH")
14+
a2dtest.ExpectNothingHappened(function()
15+
a2d.OpenSelection()
16+
apple2.EscapeKey()
17+
a2d.WaitForRepaint()
18+
end)
1719
end)
1820

1921
test.Step(
2022
"OA+W exits",
2123
function()
22-
a2d.OpenPath("/A2.DESKTOP/SAMPLE.MEDIA/MONARCH")
23-
a2d.OAShortcut("W")
24-
a2d.WaitForRepaint()
25-
test.Snap("verify preview exited")
24+
a2d.SelectPath("/A2.DESKTOP/SAMPLE.MEDIA/MONARCH")
25+
a2dtest.ExpectNothingHappened(function()
26+
a2d.OpenSelection()
27+
a2d.OAShortcut("W")
28+
a2d.WaitForRepaint()
29+
end)
2630
end)
2731

2832
test.Step(

tests/lib/a2d.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,12 @@ function a2d.OpenPath(path, opt_leave_parent)
274274
end
275275
end
276276

277+
function a2d.SplitPath(path)
278+
return path:match("^(.*)/([^/]+)$")
279+
end
280+
277281
function a2d.SelectPath(path)
278-
local base, name = path:match("^(.*)/([^/]+)$")
282+
local base, name = a2d.SplitPath(path)
279283
if base ~= "" then
280284
a2d.OpenPath(base)
281285
end
@@ -328,7 +332,7 @@ function a2d.CreateFolder(path)
328332
local name = path
329333
if path:match("/") then
330334
local base
331-
base, name = path:match("^(.*)/([^/]+)$")
335+
base, name = a2d.SplitPath(path)
332336
if base ~= "" then
333337
a2d.OpenPath(base)
334338
end

tests/lib/apple2.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ end
819819

820820
function apple2.GetDoubleHiresByte(row, col)
821821
local bank, addr = GetDHRByteAddress(row, col)
822-
return apple2.ReadRAMDevice(addr + 0x10000 * (1-bank))
822+
return apple2.ReadRAMDevice(addr + 0x10000 * (1-bank)) & 0x7F
823823
end
824824

825825
function apple2.SetDoubleHiresByte(row, col, value)

0 commit comments

Comments
 (0)