Skip to content

Commit 606a4f8

Browse files
Tests: Finish up RAMCard coverage
Also, make MultiSnap only take pictures if something changed and move to a2dtest.
1 parent 134960b commit 606a4f8

File tree

10 files changed

+160
-44
lines changed

10 files changed

+160
-44
lines changed

notes/testplan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ For the following cases, open `/TESTS` and `/TESTS/FOLDER`:
882882
* Launch DeskTop. Using drag/drop, try to delete a GS/OS forked file. When the delete confirmation dialog is shown, click OK. When an alert is shown, click OK. Verify that the source window is updated.
883883
* Launch DeskTop. Using File > Delete try to delete a GS/OS forked file, where the containing window is visible. When the delete confirmation dialog is shown, click OK. When an alert is shown, click OK. Verify that the containing window is updated.
884884

885-
## RAMCard - WIP in `tests/ramcard.lua` and `tests/no_ramcard.lua`
885+
## RAMCard - covered by `tests/ramcard*.lua` and `tests/progress_counts.lua`
886886

887887
* Repeat the following:
888888
* For these permutations:

tests/close_window.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ test.Step(
6161
a2d.InMouseKeysMode(function(m)
6262
m.MoveToApproximately(x, y)
6363
m.Click()
64-
test.MultiSnap(10, "verify close animation ran")
64+
a2dtest.MultiSnap(120, "verify close animation ran")
6565
end)
6666
a2d.CloseAllWindows()
6767
end)
@@ -73,7 +73,7 @@ test.Step(
7373

7474
-- NOTE: This is extremely timing-sensitive
7575
a2d.OAShortcut("W", {no_wait=true})
76-
test.MultiSnap(10, "verify close animation ran")
76+
a2dtest.MultiSnap(120, "verify close animation ran")
7777

7878
a2d.CloseAllWindows()
7979
end)
@@ -118,8 +118,8 @@ test.Step(
118118
a2d.CloseWindow()
119119

120120
-- NOTE: This is extremely timing-sensitive
121-
apple2.OAKey("W")
122-
test.MultiSnap(8, "verify windows animates into volume icon")
121+
a2d.OAShortcut("W", {no_wait=true})
122+
a2dtest.MultiSnap(120, "verify windows animates into volume icon")
123123

124124
a2d.WaitForRepaint()
125125
test.Snap("verify volume icon is selected")
@@ -135,8 +135,8 @@ test.Step(
135135
a2d.SelectAndOpen("SUBFOLDER")
136136

137137
-- NOTE: This is extremely timing-sensitive
138-
apple2.OAKey("W")
139-
test.MultiSnap(32, "verify windows animates into folder icon")
138+
a2d.OAShortcut("W", {no_wait=true})
139+
a2dtest.MultiSnap(120, "verify windows animates into folder icon")
140140

141141
a2d.WaitForRepaint()
142142
test.Snap("verify SUBFOLDER icon is selected")
@@ -155,8 +155,8 @@ test.Step(
155155
a2d.CycleWindows() -- put FOLDER on top
156156

157157
-- NOTE: This is extremely timing-sensitive
158-
apple2.OAKey("W")
159-
test.MultiSnap(10, "verify windows animates into volume icon")
158+
a2d.OAShortcut("W", {no_wait=true})
159+
a2dtest.MultiSnap(120, "verify windows animates into volume icon")
160160

161161
a2d.WaitForRepaint()
162162
test.Snap("verify volume icon is selected")

tests/control_panel.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ test.Step(
7474
function()
7575
a2d.OpenPath("/A2.DESKTOP/APPLE.MENU/CONTROL.PANELS/CONTROL.PANEL")
7676
apple2.MoveMouse(apple2.SCREEN_WIDTH/2, apple2.SCREEN_HEIGHT/2)
77-
a2d.OAShortcut("2")
77+
a2d.OAShortcut("2", {no_wait=true})
7878
-- NOTE: Mouse shouldn't move at all, but POSMOUSE in emulators is sketch
79-
test.MultiSnap(3, "verify mouse cursor doesn't move significantly")
80-
a2d.OAShortcut("3")
81-
test.MultiSnap(3, "verify mouse cursor doesn't move significantly")
82-
a2d.OAShortcut("2")
83-
test.MultiSnap(3, "verify mouse cursor doesn't move significantly")
79+
a2dtest.MultiSnap(30, "verify mouse cursor doesn't move significantly")
80+
a2d.OAShortcut("3", {no_wait=true})
81+
a2dtest.MultiSnap(30, "verify mouse cursor doesn't move significantly")
82+
a2d.OAShortcut("2", {no_wait=true})
83+
a2dtest.MultiSnap(30, "verify mouse cursor doesn't move significantly")
8484
end)

tests/lib/a2d.lua

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,11 @@ function a2d.ClearSelection()
305305
a2d.WaitForRepaint()
306306
end
307307

308-
function a2d.DialogOK()
308+
function a2d.DialogOK(options)
309309
apple2.ReturnKey()
310-
a2d.WaitForRepaint()
310+
if not options or not options.no_wait then
311+
a2d.WaitForRepaint()
312+
end
311313
end
312314

313315
function a2d.DialogCancel()
@@ -396,20 +398,29 @@ function a2d.CycleWindows()
396398
a2d.WaitForRepaint()
397399
end
398400

399-
function a2d.AddShortcut(path)
401+
function a2d.AddShortcut(path, options)
400402
a2d.SelectPath(path)
401403
a2d.InvokeMenuItem(a2d.SHORTCUTS_MENU, a2d.SHORTCUTS_ADD_A_SHORTCUT)
404+
405+
if options then
406+
if options.copy == "boot" then
407+
a2d.OAShortcut("3")
408+
elseif options.copy == "use" then
409+
a2d.OAShortcut("4")
410+
end
411+
end
412+
402413
a2d.DialogOK()
403414
end
404415

405-
function a2d.CopySelectionTo(path)
416+
function a2d.CopySelectionTo(path, is_volume, options)
406417
-- Assert: there is a selection
407418
--[[
408419
But we don't know if it's 1 or more than 1 so we index
409420
from the bottom of the menu, which is a fixed number.
410421
TODO: Make this less hacky
411422
]]--
412-
a2d.InvokeMenuItem(a2d.FILE_MENU, -3)
423+
a2d.InvokeMenuItem(a2d.FILE_MENU, is_volume and -2 or -3)
413424

414425
--Automate file picker dialog
415426
apple2.ControlKey("D") -- Drives
@@ -419,13 +430,17 @@ function a2d.CopySelectionTo(path)
419430
apple2.ControlKey("O") -- Open
420431
a2d.WaitForRepaint()
421432
end
422-
a2d.DialogOK()
423-
emu.wait(10)
433+
a2d.DialogOK(options)
434+
435+
if not options or not options.no_wait then
436+
emu.wait(10)
437+
end
424438
end
425439

426-
function a2d.CopyPath(src, dst)
440+
function a2d.CopyPath(src, dst, options)
427441
a2d.SelectPath(src)
428-
a2d.CopySelectionTo(dst)
442+
local is_volume = not src:match("^/.*/")
443+
a2d.CopySelectionTo(dst, is_volume, options)
429444
end
430445

431446
--------------------------------------------------

tests/lib/a2dtest.lua

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,18 @@ function a2dtest.ExpectAlertNotShowing()
254254
test.Expect(not a2dtest.IsAlertShowing(), "an alert should not be showing", nil, 1)
255255
end
256256

257-
function a2dtest.WaitForAlert()
258-
for i = 1, 30 do
257+
function a2dtest.WaitForAlert(options)
258+
local timeout = 30
259+
if options and options.timeout then
260+
timeout = options.timeout
261+
end
262+
for i = 1, timeout do
259263
if a2dtest.IsAlertShowing() then
260264
return
261265
end
262266
emu.wait(1)
263267
end
264-
test.Failure("Timeout (30s) waiting for alert")
268+
test.Failure(string.format("Timeout (%ds) waiting for alert", timeout))
265269
end
266270

267271
--------------------------------------------------
@@ -276,4 +280,18 @@ end
276280

277281
--------------------------------------------------
278282

283+
function a2dtest.MultiSnap(frames, opt_title)
284+
local last = nil
285+
for i=1,frames/2 do
286+
local dhr = a2dtest.SnapshotDHRWithoutClock()
287+
if not last or not a2dtest.CompareDHR(last, dhr) then
288+
test.Snap(opt_title)
289+
last = dhr
290+
end
291+
emu.wait(2/60)
292+
end
293+
end
294+
295+
--------------------------------------------------
296+
279297
return a2dtest

tests/lib/test.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,6 @@ function test.Snap(opt_title)
8282
snap(opt_title)
8383
end
8484

85-
function test.MultiSnap(frames, opt_title)
86-
for i=1,frames do
87-
snap(opt_title)
88-
emu.wait(1/60)
89-
end
90-
end
91-
9285
--------------------------------------------------
9386
-- Expectations
9487
--------------------------------------------------

tests/open.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ test.Step(
107107
function()
108108
a2d.SelectPath("/A2.DESKTOP")
109109
a2d.OAShortcut("O", {no_wait=true})
110-
test.MultiSnap(12, "verify open animation starts at volume icon")
110+
a2dtest.MultiSnap(120, "verify open animation starts at volume icon")
111111
a2d.CloseAllWindows()
112112
a2d.ClearSelection()
113113
end)

tests/progress_counts.lua

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--[[ BEGINCONFIG ========================================
2+
3+
MODELARGS="-sl1 ramfactor -sl2 mouse -sl7 cffa2 -aux ext80"
4+
DISKARGS="-hard1 $HARDIMG -hard2 res/disk_a.2mg"
5+
6+
======================================== ENDCONFIG ]]--
7+
8+
test.Step(
9+
"Copy progress of shortcut in root directory",
10+
function()
11+
-- configuration
12+
a2d.ToggleOptionCopyToRAMCard()
13+
a2d.CloseAllWindows()
14+
a2d.Reboot()
15+
a2d.WaitForCopyToRAMCard()
16+
17+
-- Copy to RAMDisk, (shortcut in root directory)
18+
a2d.OpenPath("/A")
19+
a2d.InvokeMenuItem(a2d.APPLE_MENU, a2d.RUN_BASIC_HERE)
20+
a2d.WaitForRestart()
21+
apple2.TypeLine("CREATE DUMMY,T$01")
22+
apple2.TypeLine("BSAVE DUMMY,T$01,,A$2000,L123")
23+
apple2.TypeLine("BYE")
24+
a2d.WaitForRestart()
25+
a2d.AddShortcut("/A/DUMMY", {copy="use"})
26+
a2d.OAShortcut("1", {no_wait=true})
27+
a2dtest.MultiSnap(120, "shortcut copy progress bottoms out at 0")
28+
a2dtest.WaitForAlert()
29+
a2d.DialogOK()
30+
31+
-- cleanup
32+
a2d.EraseVolume("RAM1")
33+
a2d.DeletePath("/A2.DESKTOP/LOCAL")
34+
a2d.Reboot()
35+
end)
36+
37+
test.Step(
38+
"Copy progress of a volume",
39+
function()
40+
a2d.CopyPath("/A2.DESKTOP/READ.ME", "/A")
41+
a2d.CopyPath("/A", "/RAM1", {no_wait=true})
42+
emu.wait(20/60)
43+
a2dtest.MultiSnap(120, "volume copy progress bottoms out at 0")
44+
end)

tests/ramcard.lua

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ DISKARGS="-hard1 $HARDIMG"
55
66
======================================== ENDCONFIG ]]--
77

8-
9-
--[[============================================================
10-
11-
"RAMCard" tests (poor naming)
12-
13-
============================================================]]--
14-
15-
168
function RenameTest(name, proc)
179
test.Variants(
1810
{
@@ -185,4 +177,3 @@ RenameTest(
185177
a2d.DialogCancel()
186178
a2d.WaitForRepaint()
187179
end)
188-

tests/ramcard_ejected.lua

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
--[[ BEGINCONFIG ========================================
2+
3+
MODEL="apple2cp"
4+
MODELARGS="-ramsize 1152K"
5+
DISKARGS="-flop3 $HARDIMG -flop1 res/prodos_floppy1.dsk"
6+
7+
======================================== ENDCONFIG ]]--
8+
9+
test.Step(
10+
"Volume order",
11+
function()
12+
test.Snap("verify A2.DESKTOP volume in top right")
13+
14+
a2d.SelectPath("/A2.DESKTOP")
15+
a2d.InvokeMenuItem(a2d.FILE_MENU, a2d.FILE_COPY_TO-4)
16+
apple2.ControlKey("D") -- Drives
17+
a2d.WaitForRepaint()
18+
19+
test.Snap("verify A2.DESKTOP volume is first")
20+
21+
a2d.DialogCancel()
22+
end)
23+
24+
25+
test.Step(
26+
"Volume order when copied to RAMCard, ejected",
27+
function()
28+
a2d.ToggleOptionCopyToRAMCard() -- Enable
29+
a2d.CloseAllWindows()
30+
a2d.InvokeMenuItem(a2d.STARTUP_MENU, 2) -- Slot 5
31+
emu.wait(240) -- copying from floppy is very slow
32+
33+
test.Snap("verify A2.DESKTOP volume in top right")
34+
35+
a2d.SelectPath("/A2.DESKTOP")
36+
a2d.InvokeMenuItem(a2d.FILE_MENU, a2d.FILE_COPY_TO-4)
37+
apple2.ControlKey("D") -- Drives
38+
a2d.WaitForRepaint()
39+
40+
test.Snap("verify A2.DESKTOP volume is first")
41+
42+
a2d.DialogCancel()
43+
44+
a2d.OpenPath("/RAM4/DESKTOP/EXTRAS/BASIC.SYSTEM")
45+
local drive = apple2.Get35Drive1()
46+
local current = drive.filename
47+
drive:unload()
48+
apple2.TypeLine("BYE")
49+
a2d.WaitForRestart()
50+
51+
test.Snap("verify volumes appear in order")
52+
53+
drive:load(current)
54+
end)
55+

0 commit comments

Comments
 (0)