1 #include "EventTest.hpp"
3 #include "io/event.hpp"
10 CPPUNIT_TEST_SUITE_REGISTRATION(blank::test::EventTest);
17 void EventTest::setUp() {
21 void EventTest::tearDown() {
29 string string_cast(const T &val) {
37 #if SDL_VERSION_ATLEAST(2, 0, 4)
39 void EventTest::testAudioDevice() {
41 event.type = SDL_AUDIODEVICEADDED;
42 event.adevice.which = 1;
43 event.adevice.iscapture = false;
44 CPPUNIT_ASSERT_EQUAL_MESSAGE(
45 "output format of SDL audio device event",
46 string("audio device added: device ID: 1, capture: no"), string_cast(event));
47 event.adevice.which = 2;
48 event.adevice.iscapture = true;
49 CPPUNIT_ASSERT_EQUAL_MESSAGE(
50 "output format of SDL audio device event",
51 string("audio device added: device ID: 2, capture: yes"), string_cast(event));
52 event.type = SDL_AUDIODEVICEREMOVED;
53 event.adevice.which = 3;
54 event.adevice.iscapture = false;
55 CPPUNIT_ASSERT_EQUAL_MESSAGE(
56 "output format of SDL audio device event",
57 string("audio device removed: device ID: 3, capture: no"), string_cast(event));
58 event.adevice.which = 4;
59 event.adevice.iscapture = true;
60 CPPUNIT_ASSERT_EQUAL_MESSAGE(
61 "output format of SDL audio device event",
62 string("audio device removed: device ID: 4, capture: yes"), string_cast(event));
67 void EventTest::testController() {
69 event.type = SDL_CONTROLLERAXISMOTION;
70 event.caxis.which = 0;
72 event.caxis.value = 16384;
73 CPPUNIT_ASSERT_EQUAL_MESSAGE(
74 "output format of SDL controller axis event",
75 string("controller axis motion: controller ID: 0, axis ID: 1, value: 0.5"), string_cast(event));
77 event.type = SDL_CONTROLLERBUTTONDOWN;
78 event.cbutton.which = 2;
79 event.cbutton.button = 3;
80 event.cbutton.state = SDL_PRESSED;
81 CPPUNIT_ASSERT_EQUAL_MESSAGE(
82 "output format of SDL controller button event",
83 string("controller button down: controller ID: 2, button ID: 3, state: pressed"), string_cast(event));
84 event.type = SDL_CONTROLLERBUTTONUP;
85 event.cbutton.which = 4;
86 event.cbutton.button = 5;
87 event.cbutton.state = SDL_RELEASED;
88 CPPUNIT_ASSERT_EQUAL_MESSAGE(
89 "output format of SDL controller button event",
90 string("controller button up: controller ID: 4, button ID: 5, state: released"), string_cast(event));
92 event.type = SDL_CONTROLLERDEVICEADDED;
93 event.cdevice.which = 6;
94 CPPUNIT_ASSERT_EQUAL_MESSAGE(
95 "output format of SDL controller device event",
96 string("controller device added: controller ID: 6"), string_cast(event));
97 event.type = SDL_CONTROLLERDEVICEREMOVED;
98 event.cdevice.which = 7;
99 CPPUNIT_ASSERT_EQUAL_MESSAGE(
100 "output format of SDL controller device event",
101 string("controller device removed: controller ID: 7"), string_cast(event));
102 event.type = SDL_CONTROLLERDEVICEREMAPPED;
103 event.cdevice.which = 8;
104 CPPUNIT_ASSERT_EQUAL_MESSAGE(
105 "output format of SDL controller device event",
106 string("controller device remapped: controller ID: 8"), string_cast(event));
109 void EventTest::testDollar() {
111 event.type = SDL_DOLLARGESTURE;
112 event.dgesture.touchId = 0;
113 event.dgesture.gestureId = 1;
114 event.dgesture.numFingers = 2;
115 event.dgesture.error = 3;
116 event.dgesture.x = 4;
117 event.dgesture.y = 5;
118 CPPUNIT_ASSERT_EQUAL_MESSAGE(
119 "output format of SDL dollar gesture event",
120 string("dollar gesture: device ID: 0, gesture ID: 1, fingers: 2, error: 3, position: 4 5"), string_cast(event));
122 event.type = SDL_DOLLARRECORD;
123 event.dgesture.touchId = 6;
124 event.dgesture.gestureId = 7;
125 event.dgesture.numFingers = 8;
126 event.dgesture.error = 9;
127 event.dgesture.x = 10;
128 event.dgesture.y = 11;
129 CPPUNIT_ASSERT_EQUAL_MESSAGE(
130 "output format of SDL dollar record event",
131 string("dollar record: device ID: 6, gesture ID: 7, fingers: 8, error: 9, position: 10 11"), string_cast(event));
134 void EventTest::testDrop() {
135 char filename[] = "/dev/random";
137 event.type = SDL_DROPFILE;
138 event.drop.file = filename;
139 CPPUNIT_ASSERT_EQUAL_MESSAGE(
140 "output format of SDL drop file event",
141 string("drop file: file: ") + filename, string_cast(event));
144 void EventTest::testFinger() {
146 event.type = SDL_FINGERMOTION;
147 event.tfinger.touchId = 0;
148 event.tfinger.fingerId = 1;
151 event.tfinger.dx = 4;
152 event.tfinger.dy = 5;
153 event.tfinger.pressure = 6;
154 CPPUNIT_ASSERT_EQUAL_MESSAGE(
155 "output format of SDL finger motion event",
156 string("finger motion: device ID: 0, finger ID: 1, position: 2 3, delta: 4 5, pressure: 6"), string_cast(event));
158 event.type = SDL_FINGERDOWN;
159 event.tfinger.touchId = 7;
160 event.tfinger.fingerId = 8;
162 event.tfinger.y = 10;
163 event.tfinger.dx = 11;
164 event.tfinger.dy = 12;
165 event.tfinger.pressure = 13;
166 CPPUNIT_ASSERT_EQUAL_MESSAGE(
167 "output format of SDL finger down event",
168 string("finger down: device ID: 7, finger ID: 8, position: 9 10, delta: 11 12, pressure: 13"), string_cast(event));
170 event.type = SDL_FINGERUP;
171 event.tfinger.touchId = 14;
172 event.tfinger.fingerId = 15;
173 event.tfinger.x = 16;
174 event.tfinger.y = 17;
175 event.tfinger.dx = 18;
176 event.tfinger.dy = 19;
177 event.tfinger.pressure = 20;
178 CPPUNIT_ASSERT_EQUAL_MESSAGE(
179 "output format of SDL finger up event",
180 string("finger up: device ID: 14, finger ID: 15, position: 16 17, delta: 18 19, pressure: 20"), string_cast(event));
183 void EventTest::testKey() {
185 event.type = SDL_KEYDOWN;
186 event.key.windowID = 0;
187 event.key.state = SDL_PRESSED;
188 event.key.repeat = 0;
189 event.key.keysym.scancode = SDL_SCANCODE_0;
190 event.key.keysym.sym = SDLK_0;
191 event.key.keysym.mod = KMOD_NONE;
192 CPPUNIT_ASSERT_EQUAL_MESSAGE(
193 "output format of SDL key down event",
194 string("key down: window ID: 0, state: pressed, repeat: no, keysym: "
195 "scancode: ") + to_string(int(SDL_SCANCODE_0)) + ", sym: "
196 + to_string(int(SDLK_0)) +" (\"0\")", string_cast(event));
197 event.key.windowID = 2;
198 event.key.repeat = 1;
199 event.key.keysym.scancode = SDL_SCANCODE_BACKSPACE;
200 event.key.keysym.sym = SDLK_BACKSPACE;
201 event.key.keysym.mod = KMOD_LCTRL | KMOD_LALT;
202 CPPUNIT_ASSERT_EQUAL_MESSAGE(
203 "output format of SDL key down event",
204 string("key down: window ID: 2, state: pressed, repeat: yes, keysym: "
205 "scancode: ") + to_string(int(SDL_SCANCODE_BACKSPACE)) + ", sym: "
206 + to_string(int(SDLK_BACKSPACE)) +" (\"Backspace\"), mod: LCTRL LALT", string_cast(event));
208 event.type = SDL_KEYUP;
209 event.key.windowID = 1;
210 event.key.state = SDL_RELEASED;
211 event.key.repeat = 0;
212 event.key.keysym.scancode = SDL_SCANCODE_SYSREQ;
213 event.key.keysym.sym = SDLK_SYSREQ;
214 event.key.keysym.mod = KMOD_LSHIFT | KMOD_RALT;
215 CPPUNIT_ASSERT_EQUAL_MESSAGE(
216 "output format of SDL key up event",
217 string("key up: window ID: 1, state: released, repeat: no, keysym: "
218 "scancode: ") + to_string(int(SDL_SCANCODE_SYSREQ)) + ", sym: "
219 + to_string(int(SDLK_SYSREQ)) +" (\"SysReq\"), mod: LSHIFT RALT", string_cast(event));
220 event.key.windowID = 3;
221 event.key.repeat = 1;
222 event.key.keysym.scancode = SDL_SCANCODE_L;
223 event.key.keysym.sym = SDLK_l;
224 event.key.keysym.mod = KMOD_RSHIFT | KMOD_RCTRL | KMOD_LGUI;
225 CPPUNIT_ASSERT_EQUAL_MESSAGE(
226 "output format of SDL key up event",
227 string("key up: window ID: 3, state: released, repeat: yes, keysym: "
228 "scancode: ") + to_string(int(SDL_SCANCODE_L)) + ", sym: "
229 + to_string(int(SDLK_l)) +" (\"L\"), mod: RSHIFT RCTRL LSUPER", string_cast(event));
230 event.key.windowID = 4;
231 event.key.repeat = 2;
232 event.key.keysym.scancode = SDL_SCANCODE_VOLUMEUP;
233 event.key.keysym.sym = SDLK_VOLUMEUP;
234 event.key.keysym.mod = KMOD_RGUI | KMOD_NUM | KMOD_CAPS | KMOD_MODE;
235 CPPUNIT_ASSERT_EQUAL_MESSAGE(
236 "output format of SDL key up event",
237 string("key up: window ID: 4, state: released, repeat: yes, keysym: "
238 "scancode: ") + to_string(int(SDL_SCANCODE_VOLUMEUP)) + ", sym: "
239 + to_string(int(SDLK_VOLUMEUP)) +" (\"VolumeUp\"), mod: RSUPER NUM CAPS ALTGR", string_cast(event));
242 void EventTest::testJoystick() {
244 event.type = SDL_JOYAXISMOTION;
245 event.jaxis.which = 0;
246 event.jaxis.axis = 1;
247 event.jaxis.value = 16384;
248 CPPUNIT_ASSERT_EQUAL_MESSAGE(
249 "output format of SDL joystick axis motion event",
250 string("joystick axis motion: joystick ID: 0, axis ID: 1, value: 0.5"), string_cast(event));
252 event.type = SDL_JOYBALLMOTION;
253 event.jball.which = 2;
254 event.jball.ball = 3;
255 event.jball.xrel = 4;
256 event.jball.yrel = 5;
257 CPPUNIT_ASSERT_EQUAL_MESSAGE(
258 "output format of SDL joystick ball motion event",
259 string("joystick ball motion: joystick ID: 2, ball ID: 3, delta: 4 5"), string_cast(event));
261 event.type = SDL_JOYHATMOTION;
262 event.jhat.which = 6;
264 event.jhat.value = SDL_HAT_LEFTUP;
265 CPPUNIT_ASSERT_EQUAL_MESSAGE(
266 "output format of SDL joystick hat motion event",
267 string("joystick hat motion: joystick ID: 6, hat ID: 7, value: left up"), string_cast(event));
268 event.jhat.value = SDL_HAT_UP;
269 CPPUNIT_ASSERT_EQUAL_MESSAGE(
270 "output format of SDL joystick hat motion event",
271 string("joystick hat motion: joystick ID: 6, hat ID: 7, value: up"), string_cast(event));
272 event.jhat.value = SDL_HAT_RIGHTUP;
273 CPPUNIT_ASSERT_EQUAL_MESSAGE(
274 "output format of SDL joystick hat motion event",
275 string("joystick hat motion: joystick ID: 6, hat ID: 7, value: right up"), string_cast(event));
276 event.jhat.value = SDL_HAT_LEFT;
277 CPPUNIT_ASSERT_EQUAL_MESSAGE(
278 "output format of SDL joystick hat motion event",
279 string("joystick hat motion: joystick ID: 6, hat ID: 7, value: left"), string_cast(event));
280 event.jhat.value = SDL_HAT_CENTERED;
281 CPPUNIT_ASSERT_EQUAL_MESSAGE(
282 "output format of SDL joystick hat motion event",
283 string("joystick hat motion: joystick ID: 6, hat ID: 7, value: center"), string_cast(event));
284 event.jhat.value = SDL_HAT_RIGHT;
285 CPPUNIT_ASSERT_EQUAL_MESSAGE(
286 "output format of SDL joystick hat motion event",
287 string("joystick hat motion: joystick ID: 6, hat ID: 7, value: right"), string_cast(event));
288 event.jhat.value = SDL_HAT_LEFTDOWN;
289 CPPUNIT_ASSERT_EQUAL_MESSAGE(
290 "output format of SDL joystick hat motion event",
291 string("joystick hat motion: joystick ID: 6, hat ID: 7, value: left down"), string_cast(event));
292 event.jhat.value = SDL_HAT_DOWN;
293 CPPUNIT_ASSERT_EQUAL_MESSAGE(
294 "output format of SDL joystick hat motion event",
295 string("joystick hat motion: joystick ID: 6, hat ID: 7, value: down"), string_cast(event));
296 event.jhat.value = SDL_HAT_RIGHTDOWN;
297 CPPUNIT_ASSERT_EQUAL_MESSAGE(
298 "output format of SDL joystick hat motion event",
299 string("joystick hat motion: joystick ID: 6, hat ID: 7, value: right down"), string_cast(event));
300 event.jhat.value = -1;
301 CPPUNIT_ASSERT_EQUAL_MESSAGE(
302 "output format of SDL joystick hat motion event",
303 string("joystick hat motion: joystick ID: 6, hat ID: 7, value: unknown"), string_cast(event));
305 event.type = SDL_JOYBUTTONDOWN;
306 event.jbutton.which = 8;
307 event.jbutton.button = 9;
308 event.jbutton.state = SDL_PRESSED;
309 CPPUNIT_ASSERT_EQUAL_MESSAGE(
310 "output format of SDL joystick button down event",
311 string("joystick button down: joystick ID: 8, button ID: 9, state: pressed"), string_cast(event));
312 event.type = SDL_JOYBUTTONUP;
313 event.jbutton.which = 10;
314 event.jbutton.button = 11;
315 event.jbutton.state = SDL_RELEASED;
316 CPPUNIT_ASSERT_EQUAL_MESSAGE(
317 "output format of SDL joystick button up event",
318 string("joystick button up: joystick ID: 10, button ID: 11, state: released"), string_cast(event));
320 event.type = SDL_JOYDEVICEADDED;
321 event.jdevice.which = 12;
322 CPPUNIT_ASSERT_EQUAL_MESSAGE(
323 "output format of SDL joystick device added event",
324 string("joystick device added: joystick ID: 12"), string_cast(event));
325 event.type = SDL_JOYDEVICEREMOVED;
326 event.jdevice.which = 13;
327 CPPUNIT_ASSERT_EQUAL_MESSAGE(
328 "output format of SDL joystick device removed event",
329 string("joystick device removed: joystick ID: 13"), string_cast(event));
332 void EventTest::testMouse() {
334 event.type = SDL_MOUSEMOTION;
335 event.motion.windowID = 0;
336 event.motion.which = 1;
339 event.motion.xrel = 4;
340 event.motion.yrel = 5;
341 event.motion.state = 0;
342 CPPUNIT_ASSERT_EQUAL_MESSAGE(
343 "output format of SDL mouse motion event",
344 string("mouse motion: window ID: 0, mouse ID: 1, position: 2 3, delta: 4 5"), string_cast(event));
345 event.motion.windowID = 6;
346 event.motion.which = 7;
349 event.motion.xrel = 10;
350 event.motion.yrel = 11;
351 event.motion.state = SDL_BUTTON_LMASK | SDL_BUTTON_MMASK | SDL_BUTTON_RMASK;
352 CPPUNIT_ASSERT_EQUAL_MESSAGE(
353 "output format of SDL mouse motion event",
354 string("mouse motion: window ID: 6, mouse ID: 7, position: 8 9, delta: 10 11, buttons: left middle right"), string_cast(event));
355 event.motion.state = SDL_BUTTON_X1MASK | SDL_BUTTON_X2MASK;
356 CPPUNIT_ASSERT_EQUAL_MESSAGE(
357 "output format of SDL mouse motion event",
358 string("mouse motion: window ID: 6, mouse ID: 7, position: 8 9, delta: 10 11, buttons: X1 X2"), string_cast(event));
360 event.type = SDL_MOUSEBUTTONDOWN;
361 event.button.windowID = 0;
362 event.button.which = 1;
363 event.button.button = SDL_BUTTON_LEFT;
364 event.button.state = SDL_PRESSED;
365 event.button.clicks = 2;
368 CPPUNIT_ASSERT_EQUAL_MESSAGE(
369 "output format of SDL mouse button down event",
370 string("mouse button down: window ID: 0, mouse ID: 1, button: left, state: pressed, clicks: 2, position: 3 4"), string_cast(event));
371 event.type = SDL_MOUSEBUTTONUP;
372 event.button.windowID = 5;
373 event.button.which = 6;
374 event.button.button = SDL_BUTTON_MIDDLE;
375 event.button.clicks = 7;
378 CPPUNIT_ASSERT_EQUAL_MESSAGE(
379 "output format of SDL mouse button up event",
380 string("mouse button up: window ID: 5, mouse ID: 6, button: middle, state: pressed, clicks: 7, position: 8 9"), string_cast(event));
381 event.button.button = SDL_BUTTON_RIGHT;
382 CPPUNIT_ASSERT_EQUAL_MESSAGE(
383 "output format of SDL mouse button up event",
384 string("mouse button up: window ID: 5, mouse ID: 6, button: right, state: pressed, clicks: 7, position: 8 9"), string_cast(event));
385 event.button.button = SDL_BUTTON_X1;
386 CPPUNIT_ASSERT_EQUAL_MESSAGE(
387 "output format of SDL mouse button up event",
388 string("mouse button up: window ID: 5, mouse ID: 6, button: X1, state: pressed, clicks: 7, position: 8 9"), string_cast(event));
389 event.button.button = SDL_BUTTON_X2;
390 CPPUNIT_ASSERT_EQUAL_MESSAGE(
391 "output format of SDL mouse button up event",
392 string("mouse button up: window ID: 5, mouse ID: 6, button: X2, state: pressed, clicks: 7, position: 8 9"), string_cast(event));
393 event.button.button = SDL_BUTTON_X2 + 1;
394 CPPUNIT_ASSERT_EQUAL_MESSAGE(
395 "output format of SDL mouse button up event",
396 string("mouse button up: window ID: 5, mouse ID: 6, button: ") + to_string(int(SDL_BUTTON_X2 + 1)) + ", state: pressed, clicks: 7, position: 8 9", string_cast(event));
398 event.type = SDL_MOUSEWHEEL;
399 event.wheel.windowID = 0;
400 event.wheel.which = 1;
403 #if SDL_VERSION_ATLEAST(2, 0, 4)
404 event.wheel.direction = SDL_MOUSEWHEEL_NORMAL;
405 CPPUNIT_ASSERT_EQUAL_MESSAGE(
406 "output format of SDL mouse wheel event",
407 string("mouse wheel: window ID: 0, mouse ID: 1, delta: 2 3, direction: normal"), string_cast(event));
408 event.wheel.windowID = 4;
409 event.wheel.which = 5;
412 event.wheel.direction = SDL_MOUSEWHEEL_FLIPPED;
413 CPPUNIT_ASSERT_EQUAL_MESSAGE(
414 "output format of SDL mouse wheel event",
415 string("mouse wheel: window ID: 4, mouse ID: 5, delta: 6 7, direction: flipped"), string_cast(event));
417 CPPUNIT_ASSERT_EQUAL_MESSAGE(
418 "output format of SDL mouse wheel event",
419 string("mouse wheel: window ID: 0, mouse ID: 1, delta: 2 3"), string_cast(event));
423 void EventTest::testMultiGesture() {
425 event.type = SDL_MULTIGESTURE;
426 event.mgesture.touchId = 0;
427 event.mgesture.dTheta = 1;
428 event.mgesture.dDist = 2;
429 event.mgesture.x = 3;
430 event.mgesture.y = 4;
431 event.mgesture.numFingers = 5;
432 CPPUNIT_ASSERT_EQUAL_MESSAGE(
433 "output format of SDL multi gesture event",
434 string("multi gesture: device ID: 0, theta: 1, distance: 2, position: 3 4, fingers: 5"), string_cast(event));
437 void EventTest::testQuit() {
439 event.type = SDL_QUIT;
440 CPPUNIT_ASSERT_EQUAL_MESSAGE(
441 "output format of SDL quit event",
442 string("quit: quit"), string_cast(event));
445 void EventTest::testSysWM() {
447 event.type = SDL_SYSWMEVENT;
448 event.syswm.msg = nullptr;
449 CPPUNIT_ASSERT_EQUAL_MESSAGE(
450 "output format of SDL sys wm event",
451 string("sys wm: without message"), string_cast(event));
453 event.syswm.msg = &msg;
454 CPPUNIT_ASSERT_EQUAL_MESSAGE(
455 "output format of SDL sys wm event",
456 string("sys wm: with message"), string_cast(event));
459 void EventTest::testText() {
461 event.type = SDL_TEXTEDITING;
462 event.edit.windowID = 0;
463 event.edit.text[0] = '\303';
464 event.edit.text[1] = '\244';
465 event.edit.text[2] = '\0';
466 event.edit.start = 1;
467 event.edit.length = 2;
468 CPPUNIT_ASSERT_EQUAL_MESSAGE(
469 "output format of SDL text editing event",
470 string("text editing: window ID: 0, text: \"รค\", start: 1, length: 2"), string_cast(event));
472 event.type = SDL_TEXTINPUT;
473 event.text.windowID = 3;
474 event.text.text[0] = '\0';
475 CPPUNIT_ASSERT_EQUAL_MESSAGE(
476 "output format of SDL text input event",
477 string("text input: window ID: 3, text: \"\""), string_cast(event));
480 void EventTest::testUser() {
482 event.type = SDL_USEREVENT;
483 event.user.windowID = 0;
485 event.user.data1 = nullptr;
486 event.user.data2 = reinterpret_cast<void *>(1);
487 CPPUNIT_ASSERT_EQUAL_MESSAGE(
488 "output format of SDL user event",
489 string("user: window ID: 0, code: 1, data 1: 0, data 2: 0x1"), string_cast(event));
492 void EventTest::testWindow() {
494 event.type = SDL_WINDOWEVENT;
495 event.window.event = SDL_WINDOWEVENT_SHOWN;
496 event.window.windowID = 0;
497 CPPUNIT_ASSERT_EQUAL_MESSAGE(
498 "output format of SDL window event",
499 string("window: shown, window ID: 0"), string_cast(event));
501 event.window.event = SDL_WINDOWEVENT_HIDDEN;
502 event.window.windowID = 1;
503 CPPUNIT_ASSERT_EQUAL_MESSAGE(
504 "output format of SDL window event",
505 string("window: hidden, window ID: 1"), string_cast(event));
507 event.window.event = SDL_WINDOWEVENT_EXPOSED;
508 event.window.windowID = 2;
509 CPPUNIT_ASSERT_EQUAL_MESSAGE(
510 "output format of SDL window event",
511 string("window: exposed, window ID: 2"), string_cast(event));
513 event.window.event = SDL_WINDOWEVENT_MOVED;
514 event.window.windowID = 3;
515 event.window.data1 = 4;
516 event.window.data2 = 5;
517 CPPUNIT_ASSERT_EQUAL_MESSAGE(
518 "output format of SDL window event",
519 string("window: moved, window ID: 3, position: 4 5"), string_cast(event));
521 event.window.event = SDL_WINDOWEVENT_RESIZED;
522 event.window.windowID = 6;
523 event.window.data1 = 7;
524 event.window.data2 = 8;
525 CPPUNIT_ASSERT_EQUAL_MESSAGE(
526 "output format of SDL window event",
527 string("window: resized, window ID: 6, size: 7x8"), string_cast(event));
529 event.window.event = SDL_WINDOWEVENT_SIZE_CHANGED;
530 event.window.windowID = 9;
531 event.window.data1 = 10;
532 event.window.data2 = 11;
533 CPPUNIT_ASSERT_EQUAL_MESSAGE(
534 "output format of SDL window event",
535 string("window: size changed, window ID: 9, size: 10x11"), string_cast(event));
537 event.window.event = SDL_WINDOWEVENT_MINIMIZED;
538 event.window.windowID = 12;
539 CPPUNIT_ASSERT_EQUAL_MESSAGE(
540 "output format of SDL window event",
541 string("window: minimized, window ID: 12"), string_cast(event));
543 event.window.event = SDL_WINDOWEVENT_MAXIMIZED;
544 event.window.windowID = 13;
545 CPPUNIT_ASSERT_EQUAL_MESSAGE(
546 "output format of SDL window event",
547 string("window: maximized, window ID: 13"), string_cast(event));
549 event.window.event = SDL_WINDOWEVENT_RESTORED;
550 event.window.windowID = 14;
551 CPPUNIT_ASSERT_EQUAL_MESSAGE(
552 "output format of SDL window event",
553 string("window: restored, window ID: 14"), string_cast(event));
555 event.window.event = SDL_WINDOWEVENT_ENTER;
556 event.window.windowID = 15;
557 CPPUNIT_ASSERT_EQUAL_MESSAGE(
558 "output format of SDL window event",
559 string("window: mouse entered, window ID: 15"), string_cast(event));
561 event.window.event = SDL_WINDOWEVENT_LEAVE;
562 event.window.windowID = 16;
563 CPPUNIT_ASSERT_EQUAL_MESSAGE(
564 "output format of SDL window event",
565 string("window: mouse left, window ID: 16"), string_cast(event));
567 event.window.event = SDL_WINDOWEVENT_FOCUS_GAINED;
568 event.window.windowID = 17;
569 CPPUNIT_ASSERT_EQUAL_MESSAGE(
570 "output format of SDL window event",
571 string("window: focus gained, window ID: 17"), string_cast(event));
573 event.window.event = SDL_WINDOWEVENT_FOCUS_LOST;
574 event.window.windowID = 18;
575 CPPUNIT_ASSERT_EQUAL_MESSAGE(
576 "output format of SDL window event",
577 string("window: focus lost, window ID: 18"), string_cast(event));
579 event.window.event = SDL_WINDOWEVENT_CLOSE;
580 event.window.windowID = 19;
581 CPPUNIT_ASSERT_EQUAL_MESSAGE(
582 "output format of SDL window event",
583 string("window: closed, window ID: 19"), string_cast(event));
585 event.window.event = SDL_WINDOWEVENT_NONE;
586 CPPUNIT_ASSERT_EQUAL_MESSAGE(
587 "output format of SDL window event",
588 string("window: unknown"), string_cast(event));
591 void EventTest::testUnknown() {
593 // SDL_LASTEVENT holds the number of entries in the enum and therefore
594 // shouldn't be recognized as any valid event type
595 event.type = SDL_LASTEVENT;
596 CPPUNIT_ASSERT_EQUAL_MESSAGE(
597 "output format of SDL user event",
598 string("unknown"), string_cast(event));