diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2014-04-15 20:44:30 +0300 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2014-04-15 20:44:30 +0300 |
commit | 8fb65c7a3e5f9c0d25f35a1401c98f7c32a744e5 (patch) | |
tree | 622322d960df89e12f712c36f121fccd0d667f3e /tests | |
parent | 153e0f6426ff908166abdf07be7f91601fbed07f (diff) |
Fix browser.test_sdl_touch to pass touch coordinates inside the canvas rectangle.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/sdl_touch.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/sdl_touch.c b/tests/sdl_touch.c index 1fce1df1..f6a8834b 100644 --- a/tests/sdl_touch.c +++ b/tests/sdl_touch.c @@ -66,9 +66,12 @@ int main() { for(var d in data) event[d] = data[d]; Module['canvas'].dispatchEvent(event); } - sendEvent('touchstart', { touches: [ { pageX: 300, pageY: 400, deviceID: 1, identifier: 1, force: 1 } ] }); - sendEvent('touchmove', { touches: [ { pageX: 350, pageY: 400, deviceID: 1, identifier: 1, force: 1 } ] }); - sendEvent('touchend', { changedTouches: [ { pageX: 350, pageY: 400, deviceID: 1, identifier: 1, force: 1 } ] }); + // Pass test coordinates in canvas element coordinate frame. + var x = Module['canvas'].getBoundingClientRect().x; + var y = Module['canvas'].getBoundingClientRect().y; + sendEvent('touchstart', { touches: [ { pageX: x+300, pageY: y+225, deviceID: 1, identifier: 1, force: 1 } ] }); + sendEvent('touchmove', { touches: [ { pageX: x+400, pageY: y+225, deviceID: 1, identifier: 1, force: 1 } ] }); + sendEvent('touchend', { changedTouches: [ { pageX: x+400, pageY: y+225, deviceID: 1, identifier: 1, force: 1 } ] }); ); #endif |