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

Side by Side Diff: LayoutTests/fast/events/touch/emulate-touch-events.html

Issue 145003002: [DevTools] Switch from blink-based to content-based touch emulation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: another rebase Created 6 years, 8 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
« no previous file with comments | « no previous file | LayoutTests/fast/events/touch/emulate-touch-events-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../../../resources/js-test.js"></script>
5 <div id="touchtarget" style="width: 100px; height: 100px; background-color: blue "></div>
6 <p id="description"></p>
7 <div id="console"></div>
8 <script>
9 var div = document.getElementById("touchtarget");
10 var lastEvent = null;
11 var touchEventsReceived = 0;
12 var EXPECTED_TOUCH_EVENTS_TOTAL = 3;
13
14 function touchEventCallback(event) {
15 if (window.eventSender) {
16 lastEvent = event;
17 verifyTouch(touchEventsReceived++);
18 } else
19 debug(event.type);
20
21 // TODO: Touch emulation shouldn't generate mouse events regardless of wheth er
22 // preventDefault is called. http://crbug.com/278300.
23 event.preventDefault();
24
25 if (window.testRunner && touchEventsReceived == EXPECTED_TOUCH_EVENTS_TOTAL) {
26 window.internals.settings.setTouchEventEmulationEnabled(false);
27 finishJSTest();
28 }
29 }
30
31 function mouseMoveCallback(e) {
32 debug("FAIL: Unexpected mousemove event: " + e.clientX + ", " + e.clientY);
33 }
34
35 div.addEventListener("touchstart", touchEventCallback, false);
36 div.addEventListener("touchmove", touchEventCallback, false);
37 div.addEventListener("touchend", touchEventCallback, false);
38 div.addEventListener("mousemove", mouseMoveCallback, false);
39
40 function verifyTouchEvent(type, totalTouchCount, changedTouchCount, targetTouchC ount)
41 {
42 shouldBeEqualToString("lastEvent.type", type);
43 shouldBe("lastEvent.touches.length", totalTouchCount.toString());
44 shouldBe("lastEvent.changedTouches.length", changedTouchCount.toString());
45 shouldBe("lastEvent.targetTouches.length", targetTouchCount.toString());
46 shouldBe("lastEvent.pageX", "0");
47 shouldBe("lastEvent.pageY", "0");
48 }
49
50 function verifyTouchPoint(list, point, x, y, id)
51 {
52 shouldBe("lastEvent." + list + "[" + point + "].pageX", x.toString());
53 shouldBe("lastEvent." + list + "[" + point + "].pageY", y.toString());
54 shouldBe("lastEvent." + list + "[" + point + "].clientX", x.toString());
55 shouldBe("lastEvent." + list + "[" + point + "].clientY", y.toString());
56 shouldBe("lastEvent." + list + "[" + point + "].identifier", id.toString());
57 }
58
59 function verifyTouch(which) {
60 switch (which) {
61 case 0:
62 verifyTouchEvent("touchstart", 1, 1, 1);
63 shouldBe("lastEvent.shiftKey", "true");
64 shouldBe("lastEvent.altKey", "true");
65 shouldBe("lastEvent.ctrlKey", "false");
66 shouldBe("lastEvent.metaKey", "false");
67 shouldBeEqualToString("lastEvent.touches[0].target.id", "touchtarget");
68 verifyTouchPoint("touches", 0, 10, 10, 0);
69 verifyTouchPoint("changedTouches", 0, 10, 10, 0);
70 verifyTouchPoint("targetTouches", 0, 10, 10, 0);
71 break;
72 case 1:
73 verifyTouchEvent("touchmove", 1, 1, 1);
74 verifyTouchPoint("touches", 0, 20, 30, 0);
75 break;
76 case 2:
77 verifyTouchEvent("touchend", 0, 1, 0);
78 verifyTouchPoint("changedTouches", 0, 20, 30, 0);
79 shouldBe("lastEvent.shiftKey", "false");
80 shouldBe("lastEvent.altKey", "true");
81 shouldBe("lastEvent.ctrlKey", "true");
82 shouldBe("lastEvent.metaKey", "false");
83 break;
84 default:
85 testFailed("Wrong number of touch events! (" + which + ")");
86 }
87 }
88
89 function mouseEventSequence()
90 {
91 eventSender.mouseMoveTo(10, 10);
92 eventSender.mouseDown(0, ["shiftKey", "altKey"]);
93 eventSender.mouseMoveTo(20, 30);
94 eventSender.mouseUp(0, ["altKey", "ctrlKey"]);
95 }
96
97 if (window.eventSender && window.internals && window.internals.settings) {
98 description("This tests single touch event emulation using mouse events.");
99
100 window.eventSender.dragMode = false;
101 window.jsTestIsAsync = true;
102 window.internals.settings.setTouchEventEmulationEnabled(true);
103
104 shouldBe("'ontouchstart' in window", "true");
105 shouldBe("'ontouchend' in document", "true");
106
107 mouseEventSequence();
108 } else
109 debug("This test requires DumpRenderTree. Tap on the blue rect to log.");
110 </script>
111 </body>
112 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/events/touch/emulate-touch-events-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698