37
37
test_mouse_activity(MovieTester& tester, const character* text, const character* text2, bool covered, bool enabled)
39
39
rgba red(255,0,0,255);
40
rgba dark_red(128,0,0,255);
40
41
rgba covered_red(127,126,0,255); // red, covered by 50% black
42
rgba covered_dark_red(64,120,0,255); // dark red, covered by 50% black
41
43
rgba yellow(255,255,0,255);
44
rgba dark_yellow(128,128,0,255);
42
45
rgba covered_yellow(128,255,0,255); // yellow, covered by 50% black
46
rgba covered_dark_yellow(64,184,0,255); // dark yellow, covered by 50% black
43
47
rgba green(0,255,0,255);
45
49
// roll over the middle of the square, this should change
49
53
check_equals(string(text->get_text_value()), string("MouseOver"));
50
54
check_equals(string(text2->get_text_value()), string("RollOver"));
51
55
check(tester.isMouseOverMouseEntity());
52
// check that pixel @ 60,60 is yellow !
53
if ( covered ) { check_pixel(60, 60, 2, covered_yellow, 2); }
54
else { check_pixel(60, 60, 2, yellow, 2); }
58
// check that pixel @ 60,60 is yellow (covered)
59
check_pixel(60, 60, 2, covered_yellow, 2);
60
// check that pixel @ 72,64 is dark_yellow (covered)
61
check_pixel(72, 64, 2, covered_dark_yellow, 2);
65
// check that pixel @ 60,60 is yellow
66
check_pixel(60, 60, 2, yellow, 2);
67
// check that pixel @ 72,64 is dark_yellow
68
check_pixel(72, 64, 2, dark_yellow, 2);
56
check_equals(string(text->get_text_value()), string("MouseOut"));
57
check_equals(string(text2->get_text_value()), string("RollOut"));
71
check_equals(string(text->get_text_value()), string("MouseUpOutside"));
72
check_equals(string(text2->get_text_value()), string("ReleaseOutside"));
58
73
check(!tester.isMouseOverMouseEntity());
59
// check that pixel @ 60,60 is red !
60
if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
61
else { check_pixel(60, 60, 2, red, 2); }
76
// check that pixel @ 60,60 is red (covered)
77
check_pixel(60, 60, 2, covered_red, 2);
78
// check that pixel @ 72,64 is dark_red (covered)
79
check_pixel(72, 64, 2, covered_dark_red, 2);
83
// check that pixel @ 60,60 is red
84
check_pixel(60, 60, 2, red, 2);
85
// check that pixel @ 72,64 is dark_red
86
check_pixel(72, 64, 2, dark_red, 2);
64
90
// press the mouse button, this should change
71
97
// check that pixel @ 60,60 is green !
72
98
check_pixel(60, 60, 2, green, 2);
74
check_equals(string(text->get_text_value()), string("MouseOut"));
75
check_equals(string(text2->get_text_value()), string("RollOut"));
100
check_equals(string(text->get_text_value()), string("MouseUpOutside"));
101
check_equals(string(text2->get_text_value()), string("ReleaseOutside"));
76
102
check(!tester.isMouseOverMouseEntity());
77
103
// check that pixel @ 60,60 is red !
78
104
if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
90
116
if ( covered ) { check_pixel(60, 60, 2, covered_yellow, 2); }
91
117
else { check_pixel(60, 60, 2, yellow, 2); }
93
check_equals(string(text->get_text_value()), string("MouseOut"));
94
check_equals(string(text2->get_text_value()), string("RollOut"));
119
check_equals(string(text->get_text_value()), string("MouseUpOutside"));
120
check_equals(string(text2->get_text_value()), string("ReleaseOutside"));
95
121
check(!tester.isMouseOverMouseEntity());
96
122
// check that pixel @ 60,60 is red !
97
123
if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
101
127
// roll off the square, this should change
102
128
// the textfield value, if enabled
103
129
tester.movePointerTo(39, 60);
104
check_equals(string(text->get_text_value()), string("MouseOut"));
105
check_equals(string(text2->get_text_value()), string("RollOut"));
131
check_equals(string(text->get_text_value()), string("MouseOut"));
132
check_equals(string(text2->get_text_value()), string("RollOut"));
134
check_equals(string(text->get_text_value()), string("MouseUpOutside"));
135
check_equals(string(text2->get_text_value()), string("ReleaseOutside"));
106
137
check(!tester.isMouseOverMouseEntity());
107
138
// check that pixel @ 60,60 is red !
108
139
if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
111
142
// press the mouse button, this should not change anything
112
143
// as we're outside of the button.
113
144
tester.pressMouseButton();
114
check_equals(string(text->get_text_value()), string("MouseOut"));
115
check_equals(string(text2->get_text_value()), string("RollOut"));
146
check_equals(string(text->get_text_value()), string("MouseOut"));
147
check_equals(string(text2->get_text_value()), string("RollOut"));
149
check_equals(string(text->get_text_value()), string("MouseUpOutside"));
150
check_equals(string(text2->get_text_value()), string("ReleaseOutside"));
116
152
check(!tester.isMouseOverMouseEntity());
117
153
// check that pixel @ 60,60 is red !
118
154
if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
121
157
// depress the mouse button, this should not change anything
122
158
// as we're outside of the button.
123
159
tester.depressMouseButton();
124
check_equals(string(text->get_text_value()), string("MouseOut"));
125
check_equals(string(text2->get_text_value()), string("RollOut"));
161
check_equals(string(text->get_text_value()), string("MouseOut"));
162
check_equals(string(text2->get_text_value()), string("RollOut"));
164
check_equals(string(text->get_text_value()), string("MouseUpOutside"));
165
check_equals(string(text2->get_text_value()), string("ReleaseOutside"));
126
167
check(!tester.isMouseOverMouseEntity());
127
168
// check that pixel @ 60,60 is red !
128
169
if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
140
181
if ( covered ) { check_pixel(60, 60, 2, covered_yellow, 2); }
141
182
else { check_pixel(60, 60, 2, yellow, 2); }
143
check_equals(string(text->get_text_value()), string("MouseOut"));
144
check_equals(string(text2->get_text_value()), string("RollOut"));
184
check_equals(string(text->get_text_value()), string("MouseUpOutside"));
185
check_equals(string(text2->get_text_value()), string("ReleaseOutside"));
145
186
check(!tester.isMouseOverMouseEntity());
146
187
// check that pixel @ 60,60 is red !
147
188
if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
157
198
// check that pixel @ 60,60 is green !
158
199
check_pixel(60, 60, 2, rgba(0,255,0,255), 2);
160
check_equals(string(text->get_text_value()), string("MouseOut"));
161
check_equals(string(text2->get_text_value()), string("RollOut"));
201
check_equals(string(text->get_text_value()), string("MouseUpOutside"));
202
check_equals(string(text2->get_text_value()), string("ReleaseOutside"));
162
203
check(!tester.isMouseOverMouseEntity());
163
204
// check that pixel @ 60,60 is red !
164
205
if ( covered ) { check_pixel(60, 60, 2, covered_red, 2); }
172
213
tester.depressMouseButton();
175
xcheck_equals(string(text->get_text_value()), string("MouseUpOutside"));
176
xcheck_equals(string(text2->get_text_value()), string("ReleaseOutside"));
216
check_equals(string(text->get_text_value()), string("MouseUpOutside"));
217
check_equals(string(text2->get_text_value()), string("ReleaseOutside"));
178
check_equals(string(text->get_text_value()), string("MouseOut"));
179
check_equals(string(text2->get_text_value()), string("RollOut"));
219
check_equals(string(text->get_text_value()), string("MouseUpOutside"));
220
check_equals(string(text2->get_text_value()), string("ReleaseOutside"));
192
233
sprite_instance* root = tester.getRootMovie();
195
check_equals(root->get_frame_count(), 4);
236
check_equals(root->get_frame_count(), 7);
197
238
check_equals(root->get_current_frame(), 0);
199
const character* mc1 = tester.findDisplayItemByName(*root, "square1");
201
check_equals(mc1->get_depth(), 2+character::staticDepthOffset);
203
240
const character* text = tester.findDisplayItemByName(*root, "textfield");
212
249
check_equals(string(text->get_text_value()), idleString);
213
250
check_equals(string(text2->get_text_value()), idleString);
214
251
check_equals(string(text3->get_text_value()), idleString);
254
check_equals(root->get_current_frame(), 1);
256
const character* mc1 = tester.findDisplayItemByName(*root, "square1");
258
check_equals(mc1->get_depth(), 2+character::staticDepthOffset);
215
260
check(!tester.isMouseOverMouseEntity());
216
261
// check that pixel @ 60,60 is red !
217
262
rgba red(255,0,0,255);
218
263
check_pixel(60, 60, 2, red, 2);
220
for (size_t fno=0; fno<root->get_frame_count(); fno++)
266
check_equals(root->get_current_frame(), 2);
268
check_equals(root->get_current_frame(), 2); // need to roll out
270
tester.movePointerTo(60, 60); // roll over the square
271
check_equals(root->get_current_frame(), 2); // need to roll out
272
tester.movePointerTo(0, 0); // roll out, should go to next frame
273
check_equals(root->get_current_frame(), 3);
275
for (size_t fno=root->get_current_frame(); fno<root->get_frame_count(); fno++)
222
277
const character* square_back = tester.findDisplayItemByDepth(*root, 1+character::staticDepthOffset);
223
278
const character* square_front = tester.findDisplayItemByDepth(*root, 3+character::staticDepthOffset);
228
283
check(!square_back);
229
284
check(!square_front);
232
287
check(square_back);
233
288
check(!square_front);
236
291
check(square_back);
237
292
check(square_front);