Skip to content

Commit f842201

Browse files
committed
make test_sdl_mouse more robust
1 parent 68d23c6 commit f842201

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/sdl_mouse.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,27 @@ void one() {
4343
}
4444
}
4545

46+
void main_2();
47+
4648
int main() {
4749
SDL_Init(SDL_INIT_VIDEO);
4850
SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE);
4951

5052
SDL_Rect rect = { 0, 0, 600, 450 };
5153
SDL_FillRect(screen, &rect, 0x2244ffff);
5254

55+
emscripten_async_call(main_2, 3000); // avoid startup delays and intermittent errors
56+
57+
return 0;
58+
}
59+
60+
void main_2() {
5361
emscripten_run_script("window.simulateMouseEvent(10, 20, -1)"); // move from 0,0 to 10,20
5462
emscripten_run_script("window.simulateMouseEvent(10, 20, 0)"); // click
5563
emscripten_run_script("window.simulateMouseEvent(10, 20, 0)"); // click some more, but this one should be ignored through PeepEvent
5664
emscripten_run_script("window.simulateMouseEvent(30, 77, -1)"); // move some more
5765
emscripten_run_script("window.simulateMouseEvent(30, 77, 1)"); // trigger the end
5866

5967
emscripten_set_main_loop(one, 0);
60-
61-
return 0;
6268
}
6369

0 commit comments

Comments
 (0)