OLD | NEW |
---|---|
(Empty) | |
1 <!-- | |
2 TODO(chongz): Remove this file and import from w3c tests after approved. | |
dtapuska
2015/11/04 21:36:31
Pls reference the crbug
| |
3 https://github.com/w3c/touch-events/issues/45 | |
4 --> | |
5 <!DOCTYPE HTML> | |
6 <html> | |
7 <!-- | |
8 Test cases for Touch Events v1 Recommendation | |
9 http://www.w3.org/TR/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 createTouch and createTouchList Interface 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({explicit_done: true}); | |
29 | |
30 function check_touch_clientXY(touch) { | |
31 assert_equals(touch.clientX, touch.pageX - window.pageXOffset, " touch.clientX is touch.pageX - window.pageXOffset."); | |
32 assert_equals(touch.clientY, touch.pageY - window.pageYOffset, " touch.clientY is touch.pageY - window.pageYOffset."); | |
33 } | |
34 | |
35 function run() { | |
36 var target0 = document.getElementById("target0"); | |
37 var touch1, touch2; | |
38 | |
39 test(function() { | |
40 touch1 = document.createTouch(window, target0, 42, 15, 2 0, 35, 40); | |
41 assert_equals(touch1.target, target0, "touch.target is t arget0"); | |
42 assert_equals(touch1.identifier, 42, "touch.identifier i s requested value"); | |
43 assert_equals(touch1.pageX, 15, "touch.pageX is requeste d value"); | |
44 assert_equals(touch1.pageY, 20, "touch.pageY is requeste d value"); | |
45 check_touch_clientXY(touch1); | |
46 assert_equals(touch1.screenX, 35, "touch.screenX is requ ested value"); | |
47 assert_equals(touch1.screenY, 40, "touch.screenY is requ ested value"); | |
48 }, "document.createTouch exists and creates a Touch object with requested properties"); | |
49 | |
50 touch2 = document.createTouch(window, target0, 44, 25, 30, 45, 5 0); | |
51 | |
52 var touchList; | |
53 | |
54 test(function() { | |
55 touchList = document.createTouchList(); | |
56 assert_equals(touchList.length, 0, "touchList.length is 0"); | |
57 }, "document.createTouchList exists and correctly creates a Touc hList from zero Touch objects"); | |
58 | |
59 if (touchList) | |
60 check_TouchList_object(touchList); | |
61 | |
62 test(function() { | |
63 touchList = document.createTouchList(touch1); | |
64 assert_equals(touchList.length, 1, "touchList.length is 1"); | |
65 assert_equals(touchList.item(0), touch1, "touchList.item (0) is input touch1"); | |
66 }, "document.createTouchList exists and correctly creates a Touc hList from a single Touch"); | |
67 | |
68 if (touchList) | |
69 check_TouchList_object(touchList); | |
70 | |
71 test(function() { | |
72 touchList = document.createTouchList(touch1, touch2); | |
73 assert_equals(touchList.length, 2, "touchList.length is 2"); | |
74 assert_equals(touchList.item(0), touch1, "touchList.item (0) is input touch1"); | |
75 assert_equals(touchList.item(1), touch2, "touchList.item (1) is input touch2"); | |
76 }, "document.createTouchList exists and correctly creates a Touc hList from two Touch objects"); | |
77 | |
78 if (touchList) | |
79 check_TouchList_object(touchList); | |
80 | |
81 target0.innerHTML = "Test complete." | |
82 done(); | |
83 } | |
84 </script> | |
85 <style> | |
86 div { | |
87 margin: 0em; | |
88 padding: 2em; | |
89 } | |
90 #target0 { | |
91 background: yellow; | |
92 border: 1px solid orange; | |
93 } | |
94 </style> | |
95 </head> | |
96 <body onload="run()"> | |
97 <h1>Touch Events: createTouch and createTouchList tests</h1> | |
98 <div id="target0">Please wait for test to complete...</div> | |
99 <div id="log"></div> | |
100 </body> | |
101 </html> | |
OLD | NEW |