-
Notifications
You must be signed in to change notification settings - Fork 15
/
test.lua
134 lines (125 loc) · 3.2 KB
/
test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
do
echo("*** timeout test ***")
do
local backup = timeout
timeout = 1
spawn("cmd.exe","/c","timeout 3 >nul & echo hoge")
local rc = expect("hoge")
if rc ~= -2 then
echo("--> [NG]")
os.exit(1)
end
echo("--> [OK]")
end
echo("*** non-timeout test ***")
do
timeout = backup
local rc = expect("hoge")
if rc ~= 0 then
echo("--> [NG]")
os.exit(1)
end
echo("--> [OK]")
end
function testShot(word)
local screen = shot(2)
for i=1,#screen do
if string.find(screen[i],word,1,true) then
return true
end
end
return false
end
echo("*** shot test ***")
do
local screen = shot(2)
if not testShot("shot") then
echo("--> [NG]")
os.exit(1)
end
echo("--> [OK]")
end
echo("*** sleep test ***")
do
spawn("cmd.exe","/c","timeout 1 >nul & echo sleeptest")
if testShot("sleeptest") then
echo("--> [NG 1st/2]")
os.exit(1)
end
echo("--> [OK 1st/2]")
sleep(1)
if not testShot("sleeptest") then
echo("--> [NG 2nd/2]")
os.exit(1)
end
echo("--> [OK 2nd/2]")
end
echo("*** usleep test ***")
do
spawn("cmd.exe","/c","timeout 1 >nul & echo usleeptest")
if testShot("usleeptest") then
echo("--> [NG 1st/2]")
os.exit(1)
end
echo("--> [OK 1st/2]")
usleep(1001000)
if not testShot("usleeptest") then
echo("--> [NG 2nd/2]")
os.exit(1)
end
echo("--> [OK 2nd/2]")
end
echo("*** OLE test ***")
do
local fsObj = create_object("Scripting.FileSystemObject")
local folder= fsObj:GetFolder("C:\\")
local files = folder:_get("Files")
if files:_get("Count") > 0 then
echo("--> [OK]")
else
echo("--> [NG]")
os.exit(1)
end
end
echo("*** 'sendln(\"exit\")' to cmd.exe ***")
do
timeout = backup
local pid = spawn("cmd.exe")
if not pid then
os.exit(1)
end
sendln("exit")
wait(pid)
echo("--> [OK]")
end
echo("*** 'send \"exot←←i<CR>\"' to cmd.exe ***")
do
timeout = backup
local pid = spawn("cmd.exe")
if not pid then
os.exit(1)
end
send("exot")
sleep(1)
sendvkey(0x25) -- VK_LEFT
sendvkey(0x25) -- VK_LEFT
sendln("i")
wait(pid)
echo("--> [OK]")
end
echo "*** '\"rem exit\" and sendvkey(HOME,DEL,DEL,DEL,DEL) ****"
local pid = spawn("cmd.exe")
if not pid then
os.exit(1)
end
send("rem exit")
sleep(1)
sendvkey(0x24) -- HOME
sendvkey(0x2E) -- DELETE
sendvkey(0x2E) -- DELETE
sendvkey(0x2E) -- DELETE
sendvkey(0x2E) -- DELETE
sendln("")
wait(pid)
echo("--> [OK]")
end