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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/touch-events/touch-touchevent-constructor.html

Issue 1985353002: Move the touch-events directory from web-platform-tests/ to wpt/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
(Empty)
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Touch and TouchEvent Constructor Tests</title>
5 <script src="../../../resources/testharness.js"></script>
6 <script src="../../../resources/testharnessreport.js"></script>
7 <script src="touch-support.js"></script>
8 </head>
9 <body>
10 <div id="target0"></div>
11 <script>
12 test(function() {
13 assert_throws(new TypeError(), function() {new Touch();}, "Touch constructor requires initialize dictionary");
14 assert_throws(new TypeError(), function() {new Touch({});}, "Touch construct or requires identifier and target");
15 }, "Create a Touch object with insufficient properties");
16
17 test(function() {
18 var testIdentifier = 74;
19 var testTarget = document.getElementById('target0');
20 var approxEpsilon = 0.00001;
21
22 var touch1 = new Touch({
23 identifier: testIdentifier,
24 target: testTarget,
25 });
26 check_Touch_object(touch1);
27 assert_equals(touch1.target, testTarget, "touch.target is requested value");
28 assert_equals(touch1.identifier, testIdentifier, "touch.identifier is reques ted value");
29 assert_approx_equals(touch1.pageX, 0, approxEpsilon, "touch.pageX is default value");
30 assert_approx_equals(touch1.pageY, 0, approxEpsilon, "touch.pageY is default value");
31 assert_approx_equals(touch1.screenX, 0, approxEpsilon, "touch.screenX is def ault value");
32 assert_approx_equals(touch1.screenY, 0, approxEpsilon, "touch.screenY is def ault value");
33 assert_approx_equals(touch1.clientX, 0, approxEpsilon, "touch.clientX is def ault value.");
34 assert_approx_equals(touch1.clientY, 0, approxEpsilon, "touch.clientY is def ault value.");
35 }, "Touch constructor exists and creates a Touch object with minimum properties" );
36
37 test(function() {
38 var testIdentifier = 42;
39 var testTarget = document.getElementById('target0');
40 var testPageX = 15;
41 var testPageY = 20.2;
42 var testScreenX = 35.34;
43 var testScreenY = 40.56;
44 var testClientX = 10.175;
45 var testClientY = 5;
46 var approxEpsilon = 0.00001;
47
48 var touch1 = new Touch({
49 identifier: testIdentifier,
50 target: testTarget,
51 pageX: testPageX,
52 pageY: testPageY,
53 screenX: testScreenX,
54 screenY: testScreenY,
55 clientX: testClientX,
56 clientY: testClientY,
57 });
58 check_Touch_object(touch1);
59 assert_equals(touch1.identifier, testIdentifier, "touch.identifier is reques ted value");
60 assert_equals(touch1.target, testTarget, "touch.target is requested value");
61 assert_approx_equals(touch1.pageX, testPageX, approxEpsilon, "touch.pageX is requested value");
62 assert_approx_equals(touch1.pageY, testPageY, approxEpsilon, "touch.pageY is requested value");
63 assert_approx_equals(touch1.screenX, testScreenX, approxEpsilon, "touch.scre enX is requested value");
64 assert_approx_equals(touch1.screenY, testScreenY, approxEpsilon, "touch.scre enY is requested value");
65 assert_approx_equals(touch1.clientX, testClientX, approxEpsilon, "touch.clie ntX is requested value.");
66 assert_approx_equals(touch1.clientY, testClientY, approxEpsilon, "touch.clie ntY is requested value.");
67 }, "Touch constructor exists and creates a Touch object with requested propertie s");
68
69
70 test(function() {
71 var testTarget = document.getElementById('target0');
72
73 var touch1 = new Touch({
74 identifier: 45,
75 target: testTarget,
76 pageX: 45,
77 pageY: 50,
78 screenX: 65,
79 screenY: 60,
80 clientX: 70,
81 clientY: 75,
82 });
83 var touch2 = new Touch({
84 identifier: 52,
85 target: testTarget,
86 pageX: 15,
87 pageY: 20,
88 screenX: 15,
89 screenY: 20,
90 clientX: 15,
91 clientY: 20,
92 });
93
94 var touchEvent1 = new TouchEvent("ontouchstart", {
95 touches: [touch1, touch2],
96 targetTouches: [touch1],
97 altKey: true,
98 metaKey: false,
99 });
100
101 check_TouchEvent(touchEvent1);
102 assert_equals(touchEvent1.type, "ontouchstart", "touchEvent.type is requeste d value");
103 assert_equals(touchEvent1.touches.length, 2, "touchEvent.touches.length is r equested value");
104 assert_equals(touchEvent1.touches[0], touch1, "touchEvent.touches[0] is requ ested value");
105 assert_equals(touchEvent1.touches[1], touch2, "touchEvent.touches[1] is requ ested value");
106 assert_equals(touchEvent1.targetTouches.length, 1, "touchEvent.targetTouches .length is requested value");
107 assert_equals(touchEvent1.targetTouches[0], touch1, "touchEvent.targetTouche s[0] is requested value");
108 assert_equals(touchEvent1.changedTouches.length, 0, "touchEvent.changedTouch es.length is requested value");
109 assert_equals(touchEvent1.altKey, true, "touchEvent.altKey is requested valu e");
110 assert_equals(touchEvent1.metaKey, false, "touchEvent.metaKey is requested v alue");
111 assert_equals(touchEvent1.ctrlKey, false, "touchEvent.ctrlKey is requested v alue");
112 assert_equals(touchEvent1.shiftKey, false, "touchEvent.shiftKey is requested value.");
113 }, "TouchEvent constructor exists and creates a TouchEvent object with requested properties");
114 </script>
115 </body>
116 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698