OLD | NEW |
1 <parent style='background-color: lightblue;'> | 1 <root style="width: 300px"> |
2 <child style='background-color: pink;'> | 2 <parent style='background-color: lightblue;'> |
3 <grandchild style='background-color: red; width: 25px; height: 25px;'></gran
dchild> | 3 <child style='background-color: pink;'> |
4 </child> | 4 <grandchild style='background-color: red; width: 25px; height: 25px;'></gr
andchild> |
5 <child2 style='background-color: salmon; height: 25px;' /> | 5 </child> |
6 </parent> | 6 <child2 style='background-color: salmon; height: 25px;' /> |
| 7 </parent> |
| 8 </root> |
7 | 9 |
8 <script> | 10 <script> |
9 import "../resources/third_party/unittest/unittest.dart"; | 11 import "../resources/third_party/unittest/unittest.dart"; |
10 import "../resources/unit.dart"; | 12 import "../resources/unit.dart"; |
11 | 13 |
12 import 'dart:async'; | 14 import 'dart:async'; |
13 import 'dart:sky'; | 15 import 'dart:sky'; |
14 | 16 |
15 void main() { | 17 void main() { |
16 initUnit(); | 18 initUnit(); |
17 | 19 |
18 var first = true; | 20 var first = true; |
19 | 21 |
20 var parent = document.querySelector('parent'); | 22 var parent = document.querySelector('parent'); |
21 var firstChild = parent.firstElementChild; | 23 var firstChild = parent.firstElementChild; |
22 var secondChild = parent.lastElementChild; | 24 var secondChild = parent.lastElementChild; |
| 25 var grandChild = document.querySelector('grandchild'); |
23 | 26 |
24 parent.setLayoutManager(() { | 27 parent.setLayoutManager(() { |
25 if (first) { | 28 if (first) { |
26 parent.width = 200.0; | 29 parent.width = 200.0; |
27 } else { | 30 } else { |
28 parent.width = 150.0; | 31 parent.width = 150.0; |
29 } | 32 } |
30 | 33 |
31 firstChild.width = 100.0; | 34 firstChild.width = 100.0; |
32 firstChild.layout(); | 35 firstChild.layout(); |
(...skipping 18 matching lines...) Expand all Loading... |
51 expect(parent.offsetLeft, equals(0)); | 54 expect(parent.offsetLeft, equals(0)); |
52 | 55 |
53 expect(firstChild.offsetWidth, equals(100)); | 56 expect(firstChild.offsetWidth, equals(100)); |
54 expect(firstChild.offsetHeight, equals(50)); | 57 expect(firstChild.offsetHeight, equals(50)); |
55 expect(firstChild.offsetTop, equals(50)); | 58 expect(firstChild.offsetTop, equals(50)); |
56 expect(firstChild.offsetLeft, equals(100)); | 59 expect(firstChild.offsetLeft, equals(100)); |
57 | 60 |
58 expect(secondChild.offsetHeight, equals(25)); | 61 expect(secondChild.offsetHeight, equals(25)); |
59 expect(secondChild.offsetTop, equals(0)); | 62 expect(secondChild.offsetTop, equals(0)); |
60 expect(secondChild.offsetLeft, equals(0)); | 63 expect(secondChild.offsetLeft, equals(0)); |
| 64 |
| 65 expect(grandChild.offsetWidth, equals(25)); |
| 66 expect(grandChild.offsetHeight, equals(25)); |
| 67 expect(secondChild.offsetTop, equals(0)); |
| 68 expect(secondChild.offsetLeft, equals(0)); |
61 }; | 69 }; |
62 | 70 |
63 test("should have the right sizes after layout", () { | 71 test("should have the right sizes after layout", () { |
64 Completer completer = new Completer(); | 72 Completer completer = new Completer(); |
65 | 73 |
66 window.requestAnimationFrame((_) { | 74 window.requestAnimationFrame((_) { |
67 expect(parent.offsetWidth, equals(200)); | 75 expect(parent.offsetWidth, equals(200)); |
68 expect(secondChild.offsetWidth, equals(200)); | 76 expect(secondChild.offsetWidth, equals(200)); |
69 assertNonChangingValues(); | 77 assertNonChangingValues(); |
70 | 78 |
71 first = false; | 79 first = false; |
72 parent.setNeedsLayout(); | 80 parent.setNeedsLayout(); |
73 | 81 |
74 window.requestAnimationFrame((_) { | 82 window.requestAnimationFrame((_) { |
75 expect(parent.offsetWidth, equals(150)); | 83 expect(parent.offsetWidth, equals(150)); |
76 expect(secondChild.offsetWidth, equals(150)); | 84 expect(secondChild.offsetWidth, equals(150)); |
77 assertNonChangingValues(); | 85 assertNonChangingValues(); |
78 completer.complete(); | 86 |
| 87 parent.setLayoutManager(null); |
| 88 |
| 89 window.requestAnimationFrame((_) { |
| 90 expect(parent.offsetWidth, equals(300)); |
| 91 expect(parent.offsetHeight, equals(50)); |
| 92 expect(parent.offsetTop, equals(0)); |
| 93 expect(parent.offsetLeft, equals(0)); |
| 94 |
| 95 expect(firstChild.offsetWidth, equals(300)); |
| 96 expect(firstChild.offsetHeight, equals(25)); |
| 97 expect(firstChild.offsetTop, equals(0)); |
| 98 expect(firstChild.offsetLeft, equals(0)); |
| 99 |
| 100 expect(secondChild.offsetWidth, equals(300)); |
| 101 expect(secondChild.offsetHeight, equals(25)); |
| 102 expect(secondChild.offsetTop, equals(25)); |
| 103 expect(secondChild.offsetLeft, equals(0)); |
| 104 |
| 105 expect(grandChild.offsetWidth, equals(25)); |
| 106 expect(grandChild.offsetHeight, equals(25)); |
| 107 expect(grandChild.offsetTop, equals(0)); |
| 108 expect(grandChild.offsetLeft, equals(0)); |
| 109 |
| 110 completer.complete(); |
| 111 }); |
79 }); | 112 }); |
80 }); | 113 }); |
81 | 114 |
82 return completer.future; | 115 return completer.future; |
83 }); | 116 }); |
84 } | 117 } |
85 </script> | 118 </script> |
OLD | NEW |