-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathYUnit_Mousy.ahk
178 lines (151 loc) · 3.57 KB
/
YUnit_Mousy.ahk
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#NoEnv
#SingleInstance force
#Include %A_ScriptDir%\Yunit\Yunit.ahk
#Include %A_ScriptDir%\Yunit\Window.ahk
#Include %A_ScriptDir%\Yunit\StdOut.ahk
#include <Windy\Mousy>
#include <Windy\Pointy>
#Warn All
#Warn LocalSameAsGlobal, Off
debug := 1
ReferenceVersion := "1.1.4"
;Yunit.Use(YunitStdOut, YunitWindow).Test(TempTestSuite)
Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, MiscTestSuite)
Return
class TempTestSuite
{
Begin() {
Global debug
this.r := new Mousy(debug)
}
move() {
OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>"
this.r.x := 100
this.r.y := 100
this.r.movespeed := 25
this.r.movemode := 1
this.r.x :=1000
this.r.movemode := 3
this.r.pos := new Pointy(500,500)
this.r.movemode := 2
this.r.pos := new Pointy(100,100)
OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<"
}
End() {
this.remove("r")
this.r :=
}
}
class MiscTestSuite
{
Begin() {
Global debug
this.r := new Mousy(debug)
}
Locate() {
Global debug
OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>"
this.r.locate()
OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<"
}
monitorID() {
Global debug
OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>"
this.r.monitorID := 1
Yunit.assert(this.r.monitorID == 1)
this.r.monitorID := 2
Yunit.assert(this.r.monitorID == 2)
this.r.x := 100
this.r.y := 100
Yunit.assert(this.r.monitorID == 1)
this.r.x := 2500
Yunit.assert(this.r.monitorID == 2)
OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<"
}
speed() {
OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>"
this.r.speed := 10
saveSpeed := this.r.speed
Yunit.assert(this.r.speed == 10)
this.r.speed := 1
Yunit.assert(this.r.speed == 1)
this.r.speed := 20
Yunit.assert(this.r.speed == 20)
this.r.speed := saveSpeed
Yunit.assert(this.r.speed == saveSpeed)
OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>"
}
move() {
OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>"
this.r.x := 100
this.r.y := 100
this.r.movespeed := 25
this.r.movemode := 1
this.r.x :=1000
this.r.movemode := 3
this.r.pos := new Pointy(500,500)
this.r.movemode := 2
this.r.pos := new Pointy(100,100)
OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<"
}
End() {
this.remove("r")
this.r :=
}
}
; Does not work within YUnit-TestSuite :-(
class ProblematicTestSuite
{
Begin() {
Global debug
this.r := new Mousy(debug)
}
confine() {
; This UnitTest fails due to failure with YUnit
OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>"
this.r.confine := false
this.r.pos(1,1)
pos := this.r.pos
OutputDebug % pos.Dump()
this.r.confineRect := new Recty(100,100,100,100)
this.r.confine := true
this.r.pos(1,1)
pos := this.r.pos
OutputDebug % pos.Dump()
this.r.confine := false
OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<"
}
trail() {
CoordMode,Mouse,Screen
OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>"
MouseMove, 1,1,10
savetrail := this.r.trail
this.r.trail := 7
MouseMove, 1000, 1000,10
Yunit.assert(this.r.trail == 7)
this.r.trail := 1
MouseMove, 1,1,10
Yunit.assert(this.r.trail == 1)
this.r.trail := savetrail
OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<"
}
End() {
this.remove("r")
this.r :=
}
}
class _BaseTestSuite {
Begin() {
}
Version() {
Global debug
OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>"
Global ReferenceVersion
obj := new Mousy(debug)
OutputDebug % "Mousy Version <" obj.version "> <-> Required <" ReferenceVersion ">"
Yunit.assert(obj.version == ReferenceVersion)
OutputDebug % ">>>>[" A_ThisFunc "]>>>>"
}
End() {
}
}