aboutsummaryrefslogtreecommitdiff
path: root/tests/sdl_quit.c
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-09-09 18:33:48 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-09-09 18:33:48 -0700
commit24e61522f29d3796c0a1d2736d6008006b2e4ad6 (patch)
tree8f730aba89278f06856275a4c6f7c226d8082f5a /tests/sdl_quit.c
parentb12e4059465169ae9302c3565b08fc30e9132781 (diff)
parent953ebf768763fe93a0af76f5007d1f69f91d6440 (diff)
Merge branch 'incoming'
Diffstat (limited to 'tests/sdl_quit.c')
-rw-r--r--tests/sdl_quit.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/sdl_quit.c b/tests/sdl_quit.c
new file mode 100644
index 00000000..1a07526f
--- /dev/null
+++ b/tests/sdl_quit.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <SDL/SDL.h>
+#include <SDL/SDL_ttf.h>
+#include <assert.h>
+#include <emscripten.h>
+
+int result = 0;
+
+void one() {
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+ switch(event.type) {
+ case SDL_QUIT: {
+ if (!result) { // prevent infinite recursion since REPORT_RESULT does window.close too.
+ result = 1;
+ REPORT_RESULT_INTERNAL(1);
+ }
+ }
+ }
+ }
+}
+
+void main_2();
+
+int main() {
+ SDL_Init(SDL_INIT_VIDEO);
+ SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE);
+
+ emscripten_set_main_loop(one, 0);
+
+ emscripten_run_script("setTimeout(function() { window.close() }, 2000)");
+}
+