diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-01-11 16:17:16 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-01-11 16:17:16 -0800 |
commit | c47f7eba9be951c8e308e66c2541091c6b057af8 (patch) | |
tree | 59aed1cd174e91921e867955507c13f63303f40e /tests/emscripten_fs_api_browser.cpp | |
parent | ada59f0a9d23d8ec19ee6a1326977ddf6e93f5f9 (diff) | |
parent | 2113958017b5def518bd4bcf0bf77e8be233a93f (diff) |
Merge branch 'incoming'
Diffstat (limited to 'tests/emscripten_fs_api_browser.cpp')
-rw-r--r-- | tests/emscripten_fs_api_browser.cpp | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/tests/emscripten_fs_api_browser.cpp b/tests/emscripten_fs_api_browser.cpp index 9936a09c..0355287a 100644 --- a/tests/emscripten_fs_api_browser.cpp +++ b/tests/emscripten_fs_api_browser.cpp @@ -13,6 +13,7 @@ int data_ok = 0; int data_bad = 0; void onLoadedData(void *arg, void *buffer, int size) { + printf("onLoadedData %d\n", (int)arg); get_count++; assert(size == 329895); assert((int)arg == 135); @@ -25,29 +26,41 @@ void onLoadedData(void *arg, void *buffer, int size) { } void onErrorData(void *arg) { + printf("onErrorData %d\n", (int)arg); get_count++; assert((int)arg == 246); data_bad = 1; } +int counter = 0; void wait_wgets() { + if (counter++ == 60) { + printf("%d\n", get_count); + counter = 0; + } + if (get_count == 3) { - emscripten_async_wget_data( - "http://localhost:8888/screenshot.png", - (void*)135, - onLoadedData, - onErrorData); - emscripten_async_wget_data( - "http://localhost:8888/fail_me", - (void*)246, - onLoadedData, - onErrorData); + static bool fired = false; + if (!fired) { + fired = true; + emscripten_async_wget_data( + "http://localhost:8888/screenshot.png", + (void*)135, + onLoadedData, + onErrorData); + emscripten_async_wget_data( + "http://localhost:8888/fail_me", + (void*)246, + onLoadedData, + onErrorData); + } } else if (get_count == 5) { assert(IMG_Load("/tmp/screen_shot.png")); assert(data_ok == 1 && data_bad == 1); emscripten_cancel_main_loop(); REPORT_RESULT(); } + assert(get_count <= 5); } void onLoaded(const char* file) { @@ -55,8 +68,6 @@ void onLoaded(const char* file) { result = 0; } - printf("loaded: %s\n", file); - if (FILE * f = fopen(file, "r")) { printf("exists: %s\n", file); int c = fgetc (f); @@ -71,6 +82,7 @@ void onLoaded(const char* file) { } get_count++; + printf("onLoaded %s\n", file); } void onError(const char* file) { @@ -78,8 +90,8 @@ void onError(const char* file) { result = 0; } - printf("error: %s\n", file); get_count++; + printf("onError %s\n", file); } int main() { |