OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Test touch adjustment to a non-rectilinear element.</title> | 4 <title>Test touch adjustment to a non-rectilinear element.</title> |
5 <script src="../resources/js-test.js"></script> | 5 <script src="../resources/js-test.js"></script> |
6 <script src="resources/touchadjustment.js"></script> | 6 <script src="resources/touchadjustment.js"></script> |
7 <style> | 7 <style> |
8 body { margin: 0px; padding: 0px; } | 8 body { margin: 0px; padding: 0px; } |
9 #container { | 9 #container { |
10 -webkit-box-sizing: border-box; | 10 -webkit-box-sizing: border-box; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 // Touch overlaps bounding-box of element, but not the actual bounds. | 74 // Touch overlaps bounding-box of element, but not the actual bounds. |
75 testTouchPoint(touchPoint(71, 0, 20), e.container); | 75 testTouchPoint(touchPoint(71, 0, 20), e.container); |
76 testTouchPoint(touchPoint(71, 60, 20), e.container); | 76 testTouchPoint(touchPoint(71, 60, 20), e.container); |
77 } | 77 } |
78 | 78 |
79 function testAdjustedPoints() | 79 function testAdjustedPoints() |
80 { | 80 { |
81 debug('\nAdjusted point within bounds'); | 81 debug('\nAdjusted point within bounds'); |
82 var adjustedPoint = adjustTouchPoint(touchPoint(20, 0, 20)) | 82 var adjustedPoint = adjustTouchPoint(touchPoint(20, 0, 20)) |
83 shouldBeWithin(adjustedPoint, touchPoint(20, 0, 20)); | 83 // Note: we allow 1 pixel of slop here due to corresponding 1px |
| 84 // padding FIXME in HitTestLocation::rectForPoint. |
| 85 shouldBeWithin(adjustedPoint, touchPoint(20.5, 0.5, 20.5)); |
84 | 86 |
85 adjustedPoint = adjustTouchPoint(touchPoint(60, 60, 20)) | 87 adjustedPoint = adjustTouchPoint(touchPoint(60, 60, 20)) |
86 shouldBeWithin(adjustedPoint, touchPoint(60, 60, 20)); | 88 shouldBeWithin(adjustedPoint, touchPoint(60, 60, 20)); |
87 | 89 |
88 adjustedPoint = adjustTouchPoint(touchPoint(0, 60, 40, 20)) | 90 adjustedPoint = adjustTouchPoint(touchPoint(0, 60, 40, 20)) |
89 shouldBeWithin(adjustedPoint, touchPoint(0, 60, 40, 20)); | 91 shouldBeWithin(adjustedPoint, touchPoint(0, 60, 40, 20)); |
90 | 92 |
91 adjustedPoint = adjustTouchPoint(touchPoint(70, 20, 20, 40)) | 93 adjustedPoint = adjustTouchPoint(touchPoint(70, 20, 20, 40)) |
92 shouldBeWithin(adjustedPoint, touchPoint(70, 20, 20, 40)); | 94 shouldBeWithin(adjustedPoint, touchPoint(70, 20, 20, 40)); |
93 } | 95 } |
94 | 96 |
95 function runTests() | 97 function runTests() |
96 { | 98 { |
97 document.addEventListener('click', function() {}, false); | 99 document.addEventListener('click', function() {}, false); |
98 if (window.testRunner && window.internals && internals.touchNodeAdjusted
ToBestClickableNode) { | 100 if (window.testRunner && window.internals && internals.touchNodeAdjusted
ToBestClickableNode) { |
99 description(document.title); | 101 description(document.title); |
100 testDirectTouches(); | 102 testDirectTouches(); |
101 testAdjustedTouches(); | 103 testAdjustedTouches(); |
102 testAdjustedPoints() | 104 testAdjustedPoints() |
103 e.container.style.display = 'none'; | 105 e.container.style.display = 'none'; |
104 } | 106 } |
105 } | 107 } |
106 runTests(); | 108 runTests(); |
107 </script> | 109 </script> |
108 | 110 |
109 </body> | 111 </body> |
110 </html> | 112 </html> |
OLD | NEW |