OLD | NEW |
1 <sky> | 1 <sky> |
2 <style> | 2 <style> |
3 foo { width: 100px; height: 100px; background: blue; } | 3 foo, parent { width: 100px; height: 100px; background: blue; } |
4 bar { width: 100px; height: 100px; background: purple; } | 4 bar { width: 100px; height: 100px; background: purple; } |
| 5 parent { display: paragraph; } |
| 6 child { background: salmon; } |
5 </style> | 7 </style> |
6 <foo /><bar /> | 8 <foo /><bar /> |
| 9 <parent> |
| 10 <child>Foo bar</child> |
| 11 </parent> |
7 <script> | 12 <script> |
8 import "../resources/third_party/unittest/unittest.dart"; | 13 import "../resources/third_party/unittest/unittest.dart"; |
9 import "../resources/unit.dart"; | 14 import "../resources/unit.dart"; |
10 | 15 |
11 import "dart:sky"; | 16 import "dart:sky"; |
12 | 17 |
13 void main() { | 18 void main() { |
14 initUnit(); | 19 initUnit(); |
15 | 20 |
16 test("should hit test", () { | 21 test("should hit test", () { |
17 // FIXME: We should have much better hit-testing coverage, at least: | 22 // FIXME: We should have much better hit-testing coverage, at least: |
18 // inline content (both sections of a wrapped run) | 23 // inline content (both sections of a wrapped run) |
19 // text node | 24 // text node |
20 // flex box | 25 // flex box |
21 // display: paragraph | 26 // display: paragraph |
22 // position: absolute | 27 // position: absolute |
23 // position: relative | 28 // position: relative |
24 // z-order (missing, zero, positive and negative) | 29 // z-order (missing, zero, positive and negative) |
25 expect(document.elementFromPoint(50, 50).tagName, equals('foo')); | 30 expect(document.elementFromPoint(50, 50).tagName, equals('foo')); |
26 expect(document.elementFromPoint(50, 150).tagName, equals('bar')); | 31 expect(document.elementFromPoint(50, 150).tagName, equals('bar')); |
27 expect(document.elementFromPoint(50, 250).tagName, equals('sky')); | 32 expect(document.elementFromPoint(150, 50).tagName, equals('sky')); |
| 33 }); |
| 34 |
| 35 void hitTestWithChildren() { |
| 36 expect(document.elementFromPoint(50, 210).tagName, equals('child')); |
| 37 // Right of the <child> inline. |
| 38 expect(document.elementFromPoint(95, 210).tagName, equals('parent')); |
| 39 // Below the <child> inline. |
| 40 expect(document.elementFromPoint(50, 275).tagName, equals('parent')); |
| 41 } |
| 42 |
| 43 test("should hit test child and parent", () { |
| 44 hitTestWithChildren(); |
| 45 }); |
| 46 |
| 47 test("should hit test child with layered parent", () { |
| 48 document.querySelector('parent').style.setProperty("transform", "translate3d
(0, 0, 0)"); |
| 49 hitTestWithChildren(); |
28 }); | 50 }); |
29 } | 51 } |
30 </script> | 52 </script> |
31 </sky> | 53 </sky> |
OLD | NEW |