OLD | NEW |
1 var div = document.createElement("div"); | 1 var div = document.createElement("div"); |
2 div.id = "touchtarget"; | 2 div.id = "touchtarget"; |
3 div.style.width = "100px"; | 3 div.style.width = "100px"; |
4 div.style.height = "100px"; | 4 div.style.height = "100px"; |
5 div.style.backgroundColor = "blue"; | 5 div.style.backgroundColor = "blue"; |
6 | 6 |
7 var lastEvent = null; | 7 var lastEvent = null; |
8 var touchEventsReceived = 0; | 8 var touchEventsReceived = 0; |
9 var EXPECTED_TOUCH_EVENTS_TOTAL = 5; | 9 var EXPECTED_TOUCH_EVENTS_TOTAL = 5; |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 function verifyTouchEvent(type, totalTouchCount, changedTouchCount, targetTouchC
ount) | 33 function verifyTouchEvent(type, totalTouchCount, changedTouchCount, targetTouchC
ount) |
34 { | 34 { |
35 shouldBeEqualToString("lastEvent.type", type); | 35 shouldBeEqualToString("lastEvent.type", type); |
36 shouldBe("lastEvent.touches.length", totalTouchCount.toString()); | 36 shouldBe("lastEvent.touches.length", totalTouchCount.toString()); |
37 shouldBe("lastEvent.changedTouches.length", changedTouchCount.toString()); | 37 shouldBe("lastEvent.changedTouches.length", changedTouchCount.toString()); |
38 shouldBe("lastEvent.targetTouches.length", targetTouchCount.toString()); | 38 shouldBe("lastEvent.targetTouches.length", targetTouchCount.toString()); |
39 shouldBe("lastEvent.pageX", "0"); | 39 shouldBe("lastEvent.pageX", "0"); |
40 shouldBe("lastEvent.pageY", "0"); | 40 shouldBe("lastEvent.pageY", "0"); |
41 } | 41 } |
42 | 42 |
43 function verifyTouchPoint(list, point, x, y, id, rx, ry) | 43 function verifyTouchPoint(list, point, x, y, id, rx, ry, tilt, tiltDir) |
44 { | 44 { |
45 shouldBe("lastEvent." + list + "[" + point + "].pageX", x.toString()); | 45 shouldBe("lastEvent." + list + "[" + point + "].pageX", x.toString()); |
46 shouldBe("lastEvent." + list + "[" + point + "].pageY", y.toString()); | 46 shouldBe("lastEvent." + list + "[" + point + "].pageY", y.toString()); |
47 shouldBe("lastEvent." + list + "[" + point + "].clientX", x.toString()); | 47 shouldBe("lastEvent." + list + "[" + point + "].clientX", x.toString()); |
48 shouldBe("lastEvent." + list + "[" + point + "].clientY", y.toString()); | 48 shouldBe("lastEvent." + list + "[" + point + "].clientY", y.toString()); |
49 shouldBe("lastEvent." + list + "[" + point + "].identifier", id.toString()); | 49 shouldBe("lastEvent." + list + "[" + point + "].identifier", id.toString()); |
50 if (eventSender.setTouchPointRadius) { | 50 if (eventSender.setTouchPointRadius) { |
51 shouldBe("lastEvent." + list + "[" + point + "].webkitRadiusX", rx.toStr
ing()); | 51 shouldBe("lastEvent." + list + "[" + point + "].webkitRadiusX", rx.toStr
ing()); |
52 shouldBe("lastEvent." + list + "[" + point + "].webkitRadiusY", ry.toStr
ing()); | 52 shouldBe("lastEvent." + list + "[" + point + "].webkitRadiusY", ry.toStr
ing()); |
53 } | 53 } |
| 54 if (eventSender.setTouchPointTilt) { |
| 55 shouldBe("lastEvent." + list + "[" + point + "].tilt", tilt.toString()); |
| 56 shouldBe("lastEvent." + list + "[" + point + "].tiltDirection", tiltDir.
toString()); |
| 57 } |
54 } | 58 } |
55 | 59 |
56 function verifyTouch(which) { | 60 function verifyTouch(which) { |
57 switch (which) { | 61 switch (which) { |
58 case 0: | 62 case 0: |
59 verifyTouchEvent("touchstart", 1, 1, 1); | 63 verifyTouchEvent("touchstart", 1, 1, 1); |
60 shouldBe("lastEvent.shiftKey", "false"); | 64 shouldBe("lastEvent.shiftKey", "false"); |
61 shouldBeEqualToString("lastEvent.touches[0].target.id", "touchtarget"
); | 65 shouldBeEqualToString("lastEvent.touches[0].target.id", "touchtarget"
); |
62 verifyTouchPoint("touches", 0, 10, 10, 0, 10, 10); | 66 verifyTouchPoint("touches", 0, 10, 10, 0, 10, 10, 10, 10); |
63 verifyTouchPoint("changedTouches", 0, 10, 10, 0, 10, 10); | 67 verifyTouchPoint("changedTouches", 0, 10, 10, 0, 10, 10, 10, 10); |
64 verifyTouchPoint("targetTouches", 0, 10, 10, 0, 10, 10); | 68 verifyTouchPoint("targetTouches", 0, 10, 10, 0, 10, 10, 10, 10); |
65 break; | 69 break; |
66 case 1: | 70 case 1: |
67 verifyTouchEvent("touchmove", 1, 1, 1); | 71 verifyTouchEvent("touchmove", 1, 1, 1); |
68 verifyTouchPoint("touches", 0, 50, 50, 0, 12, 12); | 72 verifyTouchPoint("touches", 0, 50, 50, 0, 12, 12, 45, 60); |
69 shouldBe("lastEvent.shiftKey", "true"); | 73 shouldBe("lastEvent.shiftKey", "true"); |
70 shouldBe("lastEvent.altKey", "true"); | 74 shouldBe("lastEvent.altKey", "true"); |
71 shouldBe("lastEvent.ctrlKey", "false"); | 75 shouldBe("lastEvent.ctrlKey", "false"); |
72 shouldBe("lastEvent.metaKey", "false"); | 76 shouldBe("lastEvent.metaKey", "false"); |
73 break; | 77 break; |
74 case 2: | 78 case 2: |
75 verifyTouchEvent("touchend", 0, 1, 0); | 79 verifyTouchEvent("touchend", 0, 1, 0); |
76 verifyTouchPoint("changedTouches", 0, 50, 50, 0, 12, 12); | 80 verifyTouchPoint("changedTouches", 0, 50, 50, 0, 12, 12, 45, 60); |
77 shouldBe("lastEvent.shiftKey", "false"); | 81 shouldBe("lastEvent.shiftKey", "false"); |
78 shouldBe("lastEvent.altKey", "false"); | 82 shouldBe("lastEvent.altKey", "false"); |
79 break; | 83 break; |
80 case 3: | 84 case 3: |
81 verifyTouchEvent("touchstart", 1, 1, 1); | 85 verifyTouchEvent("touchstart", 1, 1, 1); |
82 shouldBeEqualToString("lastEvent.targetTouches[0].target.tagName", "
DIV"); | 86 shouldBeEqualToString("lastEvent.targetTouches[0].target.tagName", "
DIV"); |
83 break; | 87 break; |
84 case 4: | 88 case 4: |
85 verifyTouchEvent("touchmove", 1, 1, 1); | 89 verifyTouchEvent("touchmove", 1, 1, 1); |
86 shouldBeEqualToString("lastEvent.touches[0].target.tagName", "DIV"); | 90 shouldBeEqualToString("lastEvent.touches[0].target.tagName", "DIV"); |
87 break; | 91 break; |
88 | 92 |
89 default: testFailed("Wrong number of touch events! (" + which + ")"); | 93 default: testFailed("Wrong number of touch events! (" + which + ")"); |
90 } | 94 } |
91 } | 95 } |
92 | 96 |
93 function singleTouchSequence() | 97 function singleTouchSequence() |
94 { | 98 { |
95 if (eventSender.setTouchPointRadius) | 99 if (eventSender.setTouchPointRadius) |
96 eventSender.setTouchPointRadius(10,10); | 100 eventSender.setTouchPointRadius(10,10); |
97 eventSender.addTouchPoint(10, 10); | 101 eventSender.addTouchPoint(10, 10); |
| 102 if (eventSender.setTouchPointTilt) |
| 103 eventSender.setTouchPointTilt(0,10,10,false); |
98 eventSender.touchStart(); | 104 eventSender.touchStart(); |
99 | 105 |
100 if (eventSender.setTouchPointRadius) | 106 if (eventSender.setTouchPointRadius) |
101 eventSender.setTouchPointRadius(12,12); | 107 eventSender.setTouchPointRadius(12,12); |
| 108 if (eventSender.setTouchPointTilt) |
| 109 eventSender.setTouchPointTilt(0,45,60,true); |
102 eventSender.updateTouchPoint(0, 50, 50); | 110 eventSender.updateTouchPoint(0, 50, 50); |
103 eventSender.setTouchModifier("shift", true); | 111 eventSender.setTouchModifier("shift", true); |
104 eventSender.setTouchModifier("alt", true); | 112 eventSender.setTouchModifier("alt", true); |
105 eventSender.touchMove(); | 113 eventSender.touchMove(); |
106 | 114 |
107 eventSender.setTouchModifier("shift", false); | 115 eventSender.setTouchModifier("shift", false); |
108 eventSender.setTouchModifier("alt", false); | 116 eventSender.setTouchModifier("alt", false); |
109 | 117 |
110 eventSender.releaseTouchPoint(0); | 118 eventSender.releaseTouchPoint(0); |
111 eventSender.touchEnd(); | 119 eventSender.touchEnd(); |
(...skipping 20 matching lines...) Expand all Loading... |
132 | 140 |
133 lastEvent = null; | 141 lastEvent = null; |
134 eventSender.clearTouchPoints(); | 142 eventSender.clearTouchPoints(); |
135 touchTargets(); | 143 touchTargets(); |
136 | 144 |
137 } else { | 145 } else { |
138 debug("This test requires DumpRenderTree. Tap on the blue rect to log.") | 146 debug("This test requires DumpRenderTree. Tap on the blue rect to log.") |
139 } | 147 } |
140 | 148 |
141 | 149 |
OLD | NEW |