6
#include"SDL/SDL_image.h"
15
void onLoadedData(void *arg, void *buffer, int size) {
16
printf("onLoadedData %d\n", (int)arg);
18
assert(size == 329895);
19
assert((int)arg == 135);
20
unsigned char *b = (unsigned char*)buffer;
22
assert(b[1122] == 128);
23
assert(b[1123] == 201);
24
assert(b[202125] == 218);
28
void onErrorData(void *arg) {
29
printf("onErrorData %d\n", (int)arg);
31
assert((int)arg == 246);
37
if (counter++ == 60) {
38
printf("%d\n", get_count);
43
static bool fired = false;
46
emscripten_async_wget_data(
47
"http://localhost:8888/screenshot.png",
51
emscripten_async_wget_data(
52
"http://localhost:8888/fail_me",
57
} else if (get_count == 5) {
58
assert(IMG_Load("/tmp/screen_shot.png"));
59
assert(data_ok == 1 && data_bad == 1);
60
emscripten_cancel_main_loop();
63
assert(get_count <= 5);
66
void onLoaded(const char* file) {
67
if (strcmp(file, "/tmp/test.html") && strcmp(file, "/tmp/screen_shot.png")) {
71
if (FILE * f = fopen(file, "r")) {
72
printf("exists: %s\n", file);
75
printf("file empty: %s\n", file);
81
printf("!exists: %s\n", file);
85
printf("onLoaded %s\n", file);
88
void onError(const char* file) {
89
if (strcmp(file, "/tmp/null")) {
94
printf("onError %s\n", file);
98
emscripten_async_wget(
99
"http://localhost:8888/this_is_not_a_file",
104
emscripten_async_wget(
105
"http://localhost:8888/test.html",
110
emscripten_async_wget(
111
"http://localhost:8888/screenshot.png",
112
"/tmp/screen_shot.png",
116
emscripten_set_main_loop(wait_wgets, 0, 0);