diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-04-17 20:32:14 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-04-17 20:32:14 -0700 |
commit | 735637e9a10049f69525d57d3e50f4ad0b90850e (patch) | |
tree | 54c28b89f4eff2d734b5907dc1b5fef92ea23969 /tests | |
parent | 74690aa7e9dba5d729264536a6610120afa36315 (diff) |
add emscripten_async_call
Diffstat (limited to 'tests')
-rw-r--r-- | tests/emscripten_api_browser.cpp | 38 | ||||
-rwxr-xr-x | tests/runner.py | 5 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/emscripten_api_browser.cpp b/tests/emscripten_api_browser.cpp new file mode 100644 index 00000000..37ffbdd6 --- /dev/null +++ b/tests/emscripten_api_browser.cpp @@ -0,0 +1,38 @@ +#include<stdio.h> +#include<math.h> +#include<SDL.h> +#include<emscripten.h> +#include<assert.h> + +int last = 0; + +extern "C" { + +void third() { + int now = SDL_GetTicks(); + printf("thard! %d\n", now); + assert(fabs(now - last - 1000) < 500); + int result = 1; + REPORT_RESULT(); +} + +void second() { + int now = SDL_GetTicks(); + printf("sacond! %d\n", now); + assert(fabs(now - last - 500) < 250); + last = now; + emscripten_async_call(third, 1000); +} + +} + +int main() { + SDL_Init(0); + last = SDL_GetTicks(); + printf("frist! %d\n", last); + + emscripten_async_call(second, 500); + + return 1; +} + diff --git a/tests/runner.py b/tests/runner.py index 30078a9e..3a2b3537 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -7163,6 +7163,11 @@ elif 'browser' in str(sys.argv): Popen(['python', EMCC, program, '-o', 'program.html', '--pre-js', 'reftest.js'] + args).communicate() self.run_browser('program.html', '', '/report_result?0') + def test_emscripten_api(self): + open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(open(path_from_root('tests', 'emscripten_api_browser.cpp')).read())) + Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-o', 'page.html']).communicate() + self.run_browser('page.html', '', '/report_result?1') + elif 'benchmark' in str(sys.argv): # Benchmarks. Run them with argument |benchmark|. To run a specific test, do # |benchmark.test_X|. |