Skip to content

Commit a89ee2b

Browse files
Tests: Fix a bunch of test regressions, Bitsy Bye helpers
Mostly typos. ramcard.lua was timing out after 3 simulated hours, so bumped the timeout up to 4. Also identified the cause of an "investigations" failure, which is an actual DeskTop issue, but not fixed yet.
1 parent 4f2c438 commit a89ee2b

File tree

12 files changed

+125
-84
lines changed

12 files changed

+125
-84
lines changed

bin/mametest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ fi
139139
if [ "$CONSOLE" ]; then
140140
SCRIPTARGS="-console"
141141
else
142-
TIMEOUT=10800 # 3 hours
142+
TIMEOUT=$(( 60 * 60 * 4 )) # 4 hours, simulated
143143
SCRIPTARGS="-seconds_to_run $TIMEOUT -autoboot_script $BASEDIR/tests/lib/autoboot.lua"
144144
export LUA_SCRIPT="$SCRIPT"
145145
fi

tests/get_info.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ end)
3434
--[[
3535
File > Get Info a folder containing 1 file. Verify that the size
3636
shows as "_size_K for 2 items".
37-
]]-
37+
]]--
3838
test.Step(
3939
"one item in folder",
4040
function()
@@ -232,7 +232,7 @@ end)
232232
Open a volume window containing a folder. Select the folder. File >
233233
Get Info. Check Locked. Click OK. Close the volume window. Re-open
234234
the volume window. Verify that the folder is still a folder.
235-
]]-
235+
]]--
236236
test.Step(
237237
"locking folder",
238238
function()

tests/investigations.lua

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,50 +27,22 @@ test.Step(
2727
a2d.WaitForRestart()
2828
a2d.InvokeMenuItem(a2d.SHORTCUTS_MENU, a2d.SHORTCUTS_ADD_A_SHORTCUT)
2929
test.Snap("keyboard shortcuts should not be enabled")
30+
a2d.DialogCancel()
3031
end)
3132

32-
3333
test.Step(
34-
"Ejecting floppy goes sideways",
34+
"OA+SA+Down hangs if disk was ejected",
3535
function()
3636
emu.wait(20)
3737
local drive = apple2.GetDiskIIS6D1()
3838
local current = drive.filename
3939
drive:unload()
4040

41+
-- OpenPath implicitly uses OA+SA+Down
4142
a2d.OpenPath("/FLOPPY1")
4243
a2dtest.ExpectAlertShowing()
43-
apple2.EscapeKey()
44-
45-
--[[
46-
we seem to hang here somehow?
47-
48-
can't reproduce it on the console though!
49-
50-
maybe we're accessing the disk when it is yanked? Do something
51-
modal perhaps?
44+
a2d.DialogOK()
45+
a2dtest.ExpectNotHanging()
5246

53-
CPU seems to still be chugging along, albeit in $C8xx space
54-
]]--
55-
56-
a2dtest.ExpectAlertNotShowing()
57-
emu.wait(60)
58-
test.Snap("Waited a long time")
59-
apple2.Type("TRASH")
60-
test.Snap("typed some shit")
61-
a2d.InMouseKeysMode(function(m)
62-
m.MoveByApproximately(apple2.SCREEN_WIDTH,apple2.SCREEN_HEIGHT)
63-
m.MoveByApproximately(-apple2.SCREEN_WIDTH,-apple2.SCREEN_HEIGHT)
64-
m.MoveByApproximately(apple2.SCREEN_WIDTH,apple2.SCREEN_HEIGHT)
65-
m.MoveByApproximately(-apple2.SCREEN_WIDTH,-apple2.SCREEN_HEIGHT)
66-
m.MoveByApproximately(apple2.SCREEN_WIDTH,apple2.SCREEN_HEIGHT)
67-
m.MoveByApproximately(-apple2.SCREEN_WIDTH,-apple2.SCREEN_HEIGHT)
68-
m.MoveByApproximately(apple2.SCREEN_WIDTH,apple2.SCREEN_HEIGHT)
69-
m.MoveByApproximately(-apple2.SCREEN_WIDTH,-apple2.SCREEN_HEIGHT)
70-
end)
71-
-- This seems to make us hang or crash?
72-
drive:load(current)
73-
74-
a2d.InvokeMenuItem(a2d.SPECIAL_MENU, a2d.SPECIAL_CHECK_ALL_DRIVES)
75-
a2d.WaitForRestart()
47+
-- Does not hang if OA+O is used instead of OA+SA+Down
7648
end)

tests/lib/a2d.lua

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

489489
function a2d.QuitAndRestart()
490490
a2d.Quit()
491-
apple2.ReturnKey() -- Launch PRODOS in Bitsy Bye
491+
apple2.BitsyInvokeFile("PRODOS")
492492
a2d.WaitForRestart()
493493
end
494494

tests/lib/apple2.lua

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -871,26 +871,91 @@ function apple2.SetDHRByte(row, col, value)
871871
apple2.WriteRAMDevice(addr + 0x10000 * (1-bank), value)
872872
end
873873

874-
function apple2.GrabTextScreen()
874+
function IterateTextScreen(char_cb, row_cb)
875875
local is80 = apple2.ReadSSW("RD80VID") > 127
876-
local screen = ""
876+
local isAlt = apple2.ReadSSW("RDALTCHAR") > 127
877877
for row = 0,23 do
878878
local base = 0x400 + (row - math.floor(row/8) * 8) * 0x80 + 40 * math.floor(row/8)
879879
for col = 0,39 do
880880
if is80 then
881-
byte = apple2.ReadRAMDevice(0x10000 + base + col)
882-
byte = byte & 0x7F
883-
screen = screen .. string.format("%c", byte)
881+
char_cb(apple2.ReadRAMDevice(0x10000 + base + col), isAlt)
884882
end
885-
byte = apple2.ReadRAMDevice(base + col)
886-
byte = byte & 0x7F
887-
screen = screen .. string.format("%c", byte)
883+
char_cb(apple2.ReadRAMDevice(base + col), isAlt)
888884
end
889-
screen = screen .. "\n"
885+
row_cb()
890886
end
887+
end
888+
function apple2.GrabTextScreen()
889+
-- Apple IIe and later, non-MouseText
890+
-- 0x00-0x1F: Inverse @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
891+
-- 0x20-0x3F: Inverse !"#$%&'()*+,-./0123456789:;<=>?@
892+
-- 0x40-0x5F: Flashing @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ (ALTCHAR - MouseText)
893+
-- 0x60-0x7F: Flashing !"#$%&'()*+,-./0123456789:;<=>?@ (ALTCHAR - inverse lower)
894+
-- 0x80-0x9F: Normal @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
895+
-- 0xA0-0xBF: Normal !"#$%&'()*+,-./0123456789:;<=>?@
896+
-- 0xC0-0xDF: Normal @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
897+
-- 0xE0-0xFF: Normal `abcdefghijklmnopqrstuvwxyz{|}~ `
898+
899+
local screen = ""
900+
IterateTextScreen(
901+
function(byte, isAlt)
902+
if byte < 0x20 then -- 0x00-0x1F: inverse upper
903+
byte = byte + 0x40
904+
elseif byte < 0x40 then -- 0x20-0x3F: inverse punctuation
905+
byte = byte
906+
elseif byte < 0x60 then -- 0x40-0x5F: flashing upper / MouseText
907+
if not isAlt then
908+
byte = byte
909+
else
910+
byte = 0x20 -- TODO: MouseText mapping
911+
end
912+
elseif byte < 0x80 then -- 0x60-0x7F: flashing punctuation / inverse lower
913+
if not isAlt then
914+
byte = byte - 0x40
915+
else
916+
byte = byte
917+
end
918+
elseif byte < 0xA0 then -- 0x80-0x9F: normal upper
919+
byte = byte - 0x40
920+
else -- 0xA0-0xFF: normal punctuation / upper / lower
921+
byte = byte - 0x80
922+
end
923+
screen = screen .. string.format("%c", byte)
924+
end,
925+
function()
926+
screen = screen .. "\n"
927+
end)
891928
return screen
892929
end
893930

931+
function apple2.GrabInverseText()
932+
local str = ""
933+
IterateTextScreen(
934+
function(byte, isAlt)
935+
if byte < 0x20 then -- 0x00-0x1F: inverse upper
936+
byte = byte + 0x40
937+
elseif byte < 0x40 then -- 0x20-0x3F: inverse punctuation
938+
byte = byte
939+
elseif byte < 0x60 then -- 0x40-0x5F: flashing upper / alt: MouseText
940+
return
941+
elseif byte < 0x80 then -- 0x60-0x7F: flashing punctuation / alt: inverse lower
942+
if not isAlt then
943+
return
944+
else
945+
byte = byte
946+
end
947+
elseif byte < 0xA0 then -- normal upper
948+
return
949+
else -- normal punctuation / upper / lower
950+
return
951+
end
952+
str = str .. string.format("%c", byte)
953+
end,
954+
function()
955+
end)
956+
return str
957+
end
958+
894959
function apple2.SnapshotDHR()
895960
local bytes = {}
896961
for row = 0,apple2.SCREEN_HEIGHT-1 do
@@ -915,4 +980,23 @@ end
915980

916981
--------------------------------------------------
917982

983+
-- TODO: Implement BitsyInvokePath (tab to volume, then iterate on path segments)
984+
985+
function apple2.BitsySelectSlotDrive(sd)
986+
while apple2.GrabTextScreen():match("[^:]+") ~= sd do
987+
apple2.TabKey()
988+
emu.wait(5)
989+
end
990+
end
991+
992+
function apple2.BitsyInvokeFile(name)
993+
while apple2.GrabInverseText() ~= name do
994+
apple2.DownArrowKey()
995+
emu.wait(1)
996+
end
997+
apple2.ReturnKey()
998+
end
999+
1000+
--------------------------------------------------
1001+
9181002
return apple2

tests/menus.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,10 @@ test.Step(
276276
emu.wait(5) -- floppies are slow
277277
a2d.Quit()
278278
apple2.GetDiskIIS6D1():unload()
279-
apple2.ReturnKey() -- PRODOS
279+
280+
apple2.BitsyInvokeFile("PRODOS")
280281
a2d.WaitForRestart()
282+
281283
a2d.OpenPath("/A2.DESKTOP")
282284
a2d.CloseWindow()
283285
a2d.OpenPath("/A2.DESKTOP")

tests/open_then_close.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ test.Step(
3131
"Solid Apple File > Open",
3232
function()
3333
a2d.SelectPath("/A2.DESKTOP/EXTRAS")
34-
local x, y = a2dtest.GetSelectedIconCoords()
35-
a2d.ClearSelection()
3634

3735
a2d.InMouseKeysMode(function(m)
38-
m.MoveToApproximately(x, y)
36+
m.MoveToApproximately(30, 5)
3937
apple2.PressSA()
4038
m.Click()
4139
m.MoveByApproximately(0, 25)

tests/ramcard_ejected.lua

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,8 @@ test.Step(
250250

251251
-- Restart DESKTOP.SYSTEM
252252

253-
-- TODO: Utility for driving Bitsy Bye
254-
-- NOTE: Will need to handle inverted characters
255-
256-
apple2.TabKey() -- to S3,D2
257-
apple2.TabKey() emu.wait(5) -- to S6,D1
258-
apple2.TabKey() emu.wait(5) -- to S5,D1
259-
apple2.DownArrowKey() -- CLOCK.SYSTEM
260-
apple2.DownArrowKey() -- README
261-
apple2.DownArrowKey() -- DESKTOP.SYSTEM
262-
apple2.ReturnKey()
253+
apple2.BitsySelectSlotDrive("S5,D1")
254+
apple2.BitsyInvokeFile("DESKTOP.SYSTEM")
263255
a2d.WaitForRestart()
264256

265257
-- Ensure no prompt for saving appears
@@ -301,18 +293,8 @@ test.Step(
301293

302294
a2d.Quit()
303295

304-
-- Restart DESKTOP.SYSTEM
305-
306-
-- TODO: Utility for driving Bitsy Bye
307-
-- NOTE: Will need to handle inverted characters
308-
309-
apple2.TabKey() -- to S3,D2
310-
apple2.TabKey() emu.wait(5) -- to S6,D1
311-
apple2.TabKey() emu.wait(5) -- to S5,D1
312-
apple2.DownArrowKey() -- CLOCK.SYSTEM
313-
apple2.DownArrowKey() -- README
314-
apple2.DownArrowKey() -- DESKTOP.SYSTEM
315-
apple2.ReturnKey()
296+
apple2.BitsySelectSlotDrive("S5,D1")
297+
apple2.BitsyInvokeFile("DESKTOP.SYSTEM")
316298
a2d.WaitForRestart()
317299

318300
-- Ensure no prompt for disk appears

tests/ramfactor.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ RAMCardTest(
6767
a2d.CloseWindow()
6868

6969
a2d.SelectPath("/A2.DESKTOP/LOCAL/DESKTOP.CONFIG")
70-
q test.Snap("verify DESKTOP.CONFIG selected")
70+
test.ExpectEqualsIgnoreCase(a2dtest.GetSelectedIconName(), "DESKTOP.CONFIG", "file should exist")
7171
end)
7272

7373

@@ -88,7 +88,7 @@ RAMCardTest(
8888
a2d.AddShortcut("/A2.DESKTOP/SAMPLE.MEDIA/KARATEKA.YELL")
8989

9090
a2d.SelectPath("/A2.DESKTOP/LOCAL/SELECTOR.LIST")
91-
test.Snap("verify SELECTOR.LIST selected")
91+
test.ExpectEqualsIgnoreCase(a2dtest.GetSelectedIconName(), "SELECTOR.LIST", "file should exist")
9292
end)
9393

9494
--[[
@@ -202,7 +202,7 @@ RAMCardTest(
202202
a2d.InMouseKeysMode(function(m)
203203
m.MoveToApproximately(icon_x, icon_y)
204204
m.ButtonDown()
205-
m.MoveToApproximately(dst_x, dst_y
205+
m.MoveToApproximately(dst_x, dst_y)
206206
m.ButtonUp()
207207
end)
208208
a2dtest.WaitForAlert()

tests/ramworks.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ test.Step(
4343

4444
a2d.ToggleOptionCopyToRAMCard() -- Enable
4545
a2d.Reboot()
46-
apple2.DownArrowKey() -- to PRODOS
47-
apple2.DownArrowKey() -- to CLOCK.SYSTEM
48-
apple2.ReturnKey()
46+
47+
-- In Bitsy Bye (since RAMAUX doesn't chain, it QUITs)
48+
test.Expect(apple2.GrabTextScreen():match("^S7,D1:/A2.DESKTOP"), "should be at S7,S1")
49+
apple2.BitsyInvokeFile("CLOCK.SYSTEM")
4950

5051
a2d.WaitForCopyToRAMCard()
5152
emu.wait(40) -- extra slow

0 commit comments

Comments
 (0)