Skip to content

Commit 1a4b83b

Browse files
Tests: Organize some non-test files a bit
1 parent bba047a commit 1a4b83b

File tree

6 files changed

+113
-112
lines changed

6 files changed

+113
-112
lines changed

tests/automation.lua

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
test.Step(
2+
"Automation hook",
3+
function()
4+
local bank_offset = 0x10000
5+
6+
7+
-- Addr must include bank offset
8+
function PrintWinfo(addr)
9+
local bank = addr & 0xFF0000
10+
function u8(offset)
11+
return apple2.ReadRAMDevice(addr + offset)
12+
end
13+
function u16(offset)
14+
return u8(offset) | (u8(offset+1) << 8)
15+
end
16+
function s16(offset)
17+
local v = u16(offset)
18+
if v & 0x8000 == 0 then
19+
return v
20+
else
21+
return 0x10000 - v
22+
end
23+
end
24+
25+
local id = u8(0)
26+
print(string.format("id: %d", id))
27+
print(string.format("title: %q", mgtk.GetWindowName(id, bank_offset)))
28+
29+
local crect = mgtk.GetWindowContentRect(id, bank_offset)
30+
print(string.format("geometry: %d,%d - %dx%d", crect[1], crect[2], crect[3], crect[4]))
31+
32+
local nextptr = u16(56)
33+
34+
local rect = mgtk.GetWinFrameRect(id)
35+
print(string.format("frame: %d,%d - %dx%d",
36+
rect[1], rect[2], rect[3], rect[4]))
37+
38+
if nextptr ~= 0 then
39+
print("")
40+
PrintWinfo(bank + nextptr)
41+
end
42+
end
43+
44+
function DumpWindows()
45+
local num_windows = a2dtest.GetWindowCount()
46+
if num_windows == 0 then
47+
print("(no windows)")
48+
else
49+
print("" .. num_windows .. " open windows")
50+
PrintWinfo(0x10000 + mgtk.GetWinPtr(mgtk.FrontWindow()))
51+
end
52+
end
53+
54+
function NameFromEnum(enum, value)
55+
for k,v in pairs(enum) do
56+
if v == value then
57+
return k
58+
end
59+
end
60+
return string.format("(not found: %d)", value)
61+
end
62+
63+
function ProbeCenter()
64+
local win, area = mgtk.FindWindow(280,96)
65+
print("window at center? " .. win .. " area: " .. NameFromEnum(mgtk.area, area))
66+
if win ~= 0 then
67+
local ctl, part = mgtk.FindControlEx(280,96,win)
68+
print("ctl: " .. NameFromEnum(mgtk.ctl,ctl) .. " part: " .. NameFromEnum(mgtk.part,part))
69+
end
70+
end
71+
72+
DumpWindows()
73+
ProbeCenter()
74+
75+
print("-----------------------")
76+
77+
a2d.OpenPath("/A2.DESKTOP")
78+
79+
DumpWindows()
80+
ProbeCenter()
81+
82+
83+
print("-----------------------")
84+
85+
a2d.OpenPath("/A2.DESKTOP/APPLE.MENU/TOYS", true)
86+
87+
DumpWindows()
88+
ProbeCenter()
89+
90+
end)

tests/disks.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
test.Step(
2+
"No error",
3+
function()
4+
test.Snap("verify boot volume is in top right")
5+
a2d.SelectPath("/A2.DESKTOP/READ.ME")
6+
a2d.InvokeMenuItem(a2d.FILE_MENU, a2d.FILE_COPY_TO)
7+
apple2.ControlKey("D")
8+
a2d.WaitForRepaint()
9+
test.Snap("verify boot volume is first disk")
10+
end)
Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,6 @@ DISKARGS="-hard1 $HARDIMG -flop1 $FLOP1IMG"
66
77
======================================== ENDCONFIG ]]--
88

9-
10-
--[[============================================================
11-
12-
Test Script
13-
14-
============================================================]]--
15-
16-
test.Step(
17-
"Move Mouse",
18-
function()
19-
-- Move the mouse
20-
apple2.MoveMouse(480, 170)
21-
test.Snap("Mouse to 480,170")
22-
23-
-- Move the mouse
24-
apple2.MoveMouse(0, 0)
25-
test.Snap("Mouse to 0,0")
26-
end)
27-
289
test.Step(
2910
"swap images",
3011
function()

tests/infrastructure/mouse.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
test.Step(
2+
"Move Mouse",
3+
function()
4+
-- Move the mouse
5+
apple2.MoveMouse(480, 170)
6+
test.Snap("Mouse to 480,170")
7+
8+
-- Move the mouse
9+
apple2.MoveMouse(0, 0)
10+
test.Snap("Mouse to 0,0")
11+
end)

tests/investigations.lua

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -74,94 +74,3 @@ test.Step(
7474
a2d.InvokeMenuItem(a2d.SPECIAL_MENU, a2d.SPECIAL_CHECK_ALL_DRIVES)
7575
a2d.WaitForRestart()
7676
end)
77-
78-
test.Step(
79-
"Automation hook",
80-
function()
81-
local bank_offset = 0x10000
82-
83-
84-
-- Addr must include bank offset
85-
function PrintWinfo(addr)
86-
local bank = addr & 0xFF0000
87-
function u8(offset)
88-
return apple2.ReadRAMDevice(addr + offset)
89-
end
90-
function u16(offset)
91-
return u8(offset) | (u8(offset+1) << 8)
92-
end
93-
function s16(offset)
94-
local v = u16(offset)
95-
if v & 0x8000 == 0 then
96-
return v
97-
else
98-
return 0x10000 - v
99-
end
100-
end
101-
102-
local id = u8(0)
103-
print(string.format("id: %d", id))
104-
print(string.format("title: %q", mgtk.GetWindowName(id, bank_offset)))
105-
106-
local crect = mgtk.GetWindowContentRect(id, bank_offset)
107-
print(string.format("geometry: %d,%d - %dx%d", crect[1], crect[2], crect[3], crect[4]))
108-
109-
local nextptr = u16(56)
110-
111-
local rect = mgtk.GetWinFrameRect(id)
112-
print(string.format("frame: %d,%d - %dx%d",
113-
rect[1], rect[2], rect[3], rect[4]))
114-
115-
if nextptr ~= 0 then
116-
print("")
117-
PrintWinfo(bank + nextptr)
118-
end
119-
end
120-
121-
function DumpWindows()
122-
local num_windows = a2dtest.GetWindowCount()
123-
if num_windows == 0 then
124-
print("(no windows)")
125-
else
126-
print("" .. num_windows .. " open windows")
127-
PrintWinfo(0x10000 + mgtk.GetWinPtr(mgtk.FrontWindow()))
128-
end
129-
end
130-
131-
function NameFromEnum(enum, value)
132-
for k,v in pairs(enum) do
133-
if v == value then
134-
return k
135-
end
136-
end
137-
return string.format("(not found: %d)", value)
138-
end
139-
140-
function ProbeCenter()
141-
local win, area = mgtk.FindWindow(280,96)
142-
print("window at center? " .. win .. " area: " .. NameFromEnum(mgtk.area, area))
143-
if win ~= 0 then
144-
local ctl, part = mgtk.FindControlEx(280,96,win)
145-
print("ctl: " .. NameFromEnum(mgtk.ctl,ctl) .. " part: " .. NameFromEnum(mgtk.part,part))
146-
end
147-
end
148-
149-
DumpWindows()
150-
ProbeCenter()
151-
152-
print("-----------------------")
153-
154-
a2d.OpenPath("/A2.DESKTOP")
155-
156-
DumpWindows()
157-
ProbeCenter()
158-
159-
160-
print("-----------------------")
161-
162-
a2d.OpenPath("/A2.DESKTOP/APPLE.MENU/TOYS", true)
163-
164-
DumpWindows()
165-
ProbeCenter()
166-
167-
end)

tests/options.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test.Step(
1717

1818
a2d.CloseWindow()
1919
a2d.WaitForRepaint()
20-
test.Snap("verify no prompt to save")
20+
a2dtest.ExpectAlertNotShowing()
2121

2222
drive:load(current)
2323
a2d.CloseAllWindows()
@@ -35,7 +35,7 @@ test.Step(
3535

3636
a2d.CloseWindow()
3737
a2d.WaitForRepaint()
38-
test.Snap("verify prompt to save")
38+
a2dtest.ExpectAlertShowing()
3939
a2d.DialogCancel()
4040

4141
drive:load(current)

0 commit comments

Comments
 (0)