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