Permalink
Browse files

Finish `fromDomTouch()`

  • Loading branch information...
1 parent b40554e commit b3643f45778bb31bc3ead51fc3fb4f303e0dce3c @davidaurelio davidaurelio committed Feb 27, 2013
Showing with 22 additions and 8 deletions.
  1. +5 −2 src/renderer/event.js
  2. +17 −6 test/renderer/event-spec.js
View
@@ -6,7 +6,10 @@ define(function() {
mousedown: 'pointerdown',
mousemove: 'pointermove',
mouseover: 'mouseover',
- mouseout: 'mouseout'
+ mouseout: 'mouseout',
+ touchstart: 'pointerdown',
+ touchmove: 'pointermove',
+ touchend: 'pointerup'
};
/** @const */
@@ -125,7 +128,7 @@ define(function() {
PointerEvent.fromDomTouch = function(domTouch, domEvent, stageX, stageY) {
var clientX = domTouch.clientX, clientY = domTouch.clientY;
var pointerEvent = new PointerEvent(
- undefined,
+ eventTypeMap[domEvent.type],
clientX - stageX,
clientY - stageY,
clientX,
@@ -101,7 +101,7 @@ define([
mouseout: 'mouseout'
},
function(expectedType, domEventType) {
- it('should create ' + expectedType + ' events to ' + domEventType + ' events', function() {
+ it('should create ' + expectedType + ' events for ' + domEventType + ' events', function() {
var pointerEvent = PointerEvent.fromDomMouseEvent(
createDomMouseEvent(domEventType), stageX, stageY
);
@@ -127,11 +127,6 @@ define([
changedTouches: [containedTouch]
};
}
- function createDomTouchendEvent() {
- var touch = createDomTouchEvent('touchend');
- touch.touches.length = 0;
- return touch;
- }
it('should return a PointerEvent', function() {
var domTouch = createDomTouch(clientX, clientY);
@@ -163,6 +158,22 @@ define([
touchId: domTouch.identifier
});
});
+
+ eachProperty(
+ {
+ touchstart: 'pointerdown',
+ touchmove: 'pointermove',
+ touchend: 'pointerup'
+ },
+ function(expectedType, domEventType) {
+ it('should create ' + expectedType + ' events for ' + domEventType + ' events', function() {
+ var domTouch = createDomTouch(clientX, clientY);
+ var domEvent = createDomTouchEvent(domEventType, domTouch);
+ var pointerEvent = PointerEvent.fromDomTouch(domTouch, domEvent, stageX, stageY);
+ expect(pointerEvent).toHaveOwnProperties({type: expectedType});
+ });
+ }
+ )
});
});

0 comments on commit b3643f4

Please sign in to comment.