Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: LayoutTests/fast/events/touch/script-tests/basic-single-touch-events.js

Issue 750013004: Added experimental tilt and tiltDirection to the Touch interface (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed WebInputEventConversionTest Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 eventSender.addTouchPoint(10, 10); 99 eventSender.addTouchPoint(10, 10);
96 if (eventSender.setTouchPointRadius) 100 if (eventSender.setTouchPointRadius)
97 eventSender.setTouchPointRadius(0, 10, 10, false); 101 eventSender.setTouchPointRadius(0, 10, 10, false);
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(0, 12, 12, true); 107 eventSender.setTouchPointRadius(0, 12, 12, true);
108 if (eventSender.setTouchPointTilt)
109 eventSender.setTouchPointTilt(0, 45, 60, true);
110
102 eventSender.updateTouchPoint(0, 50, 50); 111 eventSender.updateTouchPoint(0, 50, 50);
103 eventSender.setTouchModifier("shift", true); 112 eventSender.setTouchModifier("shift", true);
104 eventSender.setTouchModifier("alt", true); 113 eventSender.setTouchModifier("alt", true);
105 eventSender.touchMove(); 114 eventSender.touchMove();
106 115
107 eventSender.setTouchModifier("shift", false); 116 eventSender.setTouchModifier("shift", false);
108 eventSender.setTouchModifier("alt", false); 117 eventSender.setTouchModifier("alt", false);
109 118
110 eventSender.releaseTouchPoint(0); 119 eventSender.releaseTouchPoint(0);
111 eventSender.touchEnd(); 120 eventSender.touchEnd();
(...skipping 20 matching lines...) Expand all
132 141
133 lastEvent = null; 142 lastEvent = null;
134 eventSender.clearTouchPoints(); 143 eventSender.clearTouchPoints();
135 touchTargets(); 144 touchTargets();
136 145
137 } else { 146 } else {
138 debug("This test requires DumpRenderTree. Tap on the blue rect to log.") 147 debug("This test requires DumpRenderTree. Tap on the blue rect to log.")
139 } 148 }
140 149
141 150
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698