OLD | NEW |
---|---|
(Empty) | |
1 <!-- | |
2 TODO(chongz): Remove this file and import from w3c tests after approved. | |
dtapuska
2015/11/04 21:36:32
same
| |
3 https://github.com/w3c/touch-events/issues/45 | |
4 --> | |
5 <!DOCTYPE HTML> | |
6 <html> | |
7 <!-- | |
8 Test cases for Touch Events v2 Recommendation | |
9 https://w3c.github.io/touch-events/ | |
10 | |
11 These tests are based on Mozilla-Nokia-Google's single-touch tests. | |
12 | |
13 The primary purpose of the tests in this document is checking that the creat eTouch and | |
14 createTouchList interfaces of the Touch Events APIs are correctly implemente d. | |
15 Other interactions are covered in other test files. | |
16 | |
17 This document references Test Assertions (abbrev TA below) written by Cathy Chan | |
18 http://www.w3.org/2010/webevents/wiki/TestAssertions | |
19 --> | |
20 | |
21 <head> | |
22 <title>Touch Events Touch and TouchEvent Constructor Tests</title> | |
23 <meta name="viewport" content="width=device-width"> | |
24 <script src="../../../resources/testharness.js"></script> | |
25 <script src="../../../resources/testharnessreport.js"></script> | |
26 <script src="touch-support.js"></script> | |
27 <script> | |
28 setup({ | |
29 explicit_done: true | |
30 }); | |
31 | |
32 function run() { | |
33 var target0 = document.getElementById("target0"); | |
34 var touch1, touch2; | |
35 var touchEvent1; | |
36 | |
37 test(function() { | |
38 touch1 = new Touch({ | |
39 identifier: 42, | |
40 target: target0, | |
41 pageX: 15, | |
dtapuska
2015/11/04 21:36:32
Should we verify that these are parsed as double v
| |
42 pageY: 20, | |
43 screenX: 35, | |
44 screenY: 40, | |
45 clientX: 10, | |
46 clientY: 15, | |
47 }); | |
48 check_Touch_object(touch1); | |
49 assert_equals(touch1.target, target0, "touch.target is target0"); | |
50 assert_equals(touch1.identifier, 42, "touch.identifier is requested valu e"); | |
51 assert_equals(touch1.pageX, 15, "touch.pageX is requested value"); | |
52 assert_equals(touch1.pageY, 20, "touch.pageY is requested value"); | |
53 assert_equals(touch1.screenX, 35, "touch.screenX is requested value"); | |
54 assert_equals(touch1.screenY, 40, "touch.screenY is requested value"); | |
55 // Constructor does not calculate clientX/Y in v2 | |
56 assert_equals(touch1.clientX, 10, "touch.clientX is requested value."); | |
57 assert_equals(touch1.clientY, 15, "touch.clientY is requested value."); | |
58 }, "Touch constructor exists and creates a Touch object with requested prope rties"); | |
59 | |
60 | |
61 test(function() { | |
62 touch1 = new Touch({ | |
63 identifier: 45, | |
64 target: target0, | |
65 pageX: 45, | |
66 pageY: 50, | |
67 screenX: 65, | |
68 screenY: 60, | |
69 clientX: 70, | |
70 clientY: 75, | |
71 }); | |
72 touch2 = new Touch({ | |
73 identifier: 52, | |
74 target: target0, | |
75 pageX: 15, | |
76 pageY: 20, | |
77 screenX: 15, | |
78 screenY: 20, | |
79 clientX: 15, | |
80 clientY: 20, | |
81 }); | |
82 | |
83 touchEvent1 = new TouchEvent("ontouchstart", { | |
84 touches: [touch1, touch2], | |
85 targetTouches: [touch1], | |
86 altKey: true, | |
87 metaKey: false, | |
88 }); | |
89 | |
90 check_TouchEvent(touchEvent1); | |
91 assert_equals(touchEvent1.type, "ontouchstart", "touchEvent.type is requ ested value"); | |
92 assert_equals(touchEvent1.touches[0], touch1, "touchEvent.touches[0] is requested value"); | |
93 assert_equals(touchEvent1.touches[1], touch2, "touchEvent.touches[1] is requested value"); | |
94 assert_equals(touchEvent1.touches.length, 2, "touchEvent.touches.length is requested value"); | |
dtapuska
2015/11/04 21:36:32
I'd expect the length checks first before accessin
| |
95 assert_equals(touchEvent1.targetTouches[0], touch1, "touchEvent.targetTo uches[0] is requested value"); | |
96 assert_equals(touchEvent1.targetTouches.length, 1, "touchEvent.targetTou ches.length is requested value"); | |
97 assert_equals(touchEvent1.changedTouches.length, 0, "touchEvent.changedT ouches.length is requested value"); | |
98 assert_equals(touchEvent1.altKey, true, "touchEvent.altKey is requested value"); | |
99 assert_equals(touchEvent1.metaKey, false, "touchEvent.metaKey is request ed value"); | |
100 assert_equals(touchEvent1.ctrlKey, false, "touchEvent.ctrlKey is request ed value"); | |
101 assert_equals(touchEvent1.shiftKey, false, "touchEvent.shiftKey is reque sted value."); | |
102 }, "TouchEvent constructor exists and creates a TouchEvent object with reque sted properties"); | |
103 | |
104 target0.innerHTML = "Test complete." | |
105 done(); | |
106 } | |
107 </script> | |
108 <style> | |
109 div { | |
110 margin: 0em; | |
111 padding: 2em; | |
112 } | |
113 | |
114 #target0 { | |
115 background: yellow; | |
116 border: 1px solid orange; | |
117 } | |
118 </style> | |
119 </head> | |
120 | |
121 <body onload="run()"> | |
122 <h1>Touch Events: Touch and TouchEvent constructor tests</h1> | |
123 <div id="target0">Please wait for test to complete...</div> | |
124 <div id="log"></div> | |
125 </body> | |
126 | |
127 </html> | |
OLD | NEW |