aboutsummaryrefslogtreecommitdiff
path: root/tests/emscripten_fs_api_browser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/emscripten_fs_api_browser.cpp')
-rw-r--r--tests/emscripten_fs_api_browser.cpp38
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() {