Skip to content

Commit

Permalink
Add tests for no-gesture interop
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Nov 4, 2016
1 parent 9c8eaa9 commit 4be7e9f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/unit/gestures-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,17 @@
});
</script>
</dom-module>

<dom-module id="x-no-gesture">
<template>
<button id="one" on-click="handle" on-down="noop">One</button>
<button id="two" on-click="handle">Two</button>
</template>
<script>
Polymer({
is: 'x-no-gesture',
behaviors: [EventCaptureBehavior],
noop: function(){}
})
</script>
</dom-module>
37 changes: 37 additions & 0 deletions test/unit/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,43 @@
assert.isNull(r.info.upfn, r.name + ' upfn');
});
});

suite('Interop', function() {
teardown(function() {
Polymer.Gestures.resetMouseCanceller();
});
function tap(target) {
var options = {bubbles: true, cancelable: true};
['touchstart', 'touchmove', 'touchend'].forEach(function(n) {
var ev = new CustomEvent(n, options);
ev.touches = ev.changedTouches = [
{
clientX: 0,
clientY: 0,
identifier: 1,
target: target
}
];
ev.clientX = 0;
ev.clientY = 0;
target.dispatchEvent(ev);
});
['mousedown', 'mousemove', 'mouseup', 'click'].forEach(function(n) {
var ev = new CustomEvent(n, options);
ev.button = 0;
ev.buttons = 1;
target.dispatchEvent(ev);
});
}
test('elements without gestures click reliably', function() {
var el = document.createElement('x-no-gesture');
document.body.appendChild(el);
CustomElements.takeRecords();
tap(el.$.one);
tap(el.$.two);
assert.equal(el.stream.length, 2);
});
});
});
</script>

Expand Down

0 comments on commit 4be7e9f

Please sign in to comment.