Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: sky/tests/layout/custom.sky

Issue 1055263002: Make custom layout actually work. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/rendering/RenderObject.h ('k') | sky/tests/layout/custom-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <parent style='background-color: lightblue;'>
2 <child style='background-color: pink;'>
3 <grandchild style='background-color: red; width: 25px; height: 25px;'></gran dchild>
4 </child>
5 <child2 style='background-color: salmon; height: 25px;' />
6 </parent>
7
8 <script>
9 import "../resources/third_party/unittest/unittest.dart";
10 import "../resources/unit.dart";
11
12 import 'dart:async';
13 import 'dart:sky';
14
15 void main() {
16 initUnit();
17
18 var first = true;
19
20 var parent = document.querySelector('parent');
21 var firstChild = parent.firstElementChild;
22 var secondChild = parent.lastElementChild;
23
24 parent.setLayoutManager(() {
25 if (first) {
26 first = false;
27 parent.width = 200.0;
28 } else {
29 parent.width = 150.0;
30 }
31
32 firstChild.width = 100.0;
33 firstChild.layout();
34 firstChild.x = 100.0;
35 firstChild.y = 50.0;
36 firstChild.height = 50.0;
37
38 // The second element correctly gets it's width from it's container.
39 // TODO(ojan): Change the layout method to take in availableWidth
40 // so code doesn't need to mess with setNeedsLayout dirty bits
41 // in the middle of layout and so the parent and child don't need
42 // to coordinate as much about expectations.
43 secondChild.setNeedsLayout();
44 secondChild.layout();
45
46 parent.height = 100.0;
47 });
48
49 void assertNonChangingValues() {
50 expect(parent.offsetHeight, equals(100));
51 expect(parent.offsetTop, equals(0));
52 expect(parent.offsetLeft, equals(0));
53
54 expect(firstChild.offsetWidth, equals(100));
55 expect(firstChild.offsetHeight, equals(50));
56 expect(firstChild.offsetTop, equals(50));
57 expect(firstChild.offsetLeft, equals(100));
58
59 expect(secondChild.offsetHeight, equals(25));
60 expect(secondChild.offsetTop, equals(0));
61 expect(secondChild.offsetLeft, equals(0));
62 };
63
64 test("should have the right sizes after layout", () {
65 Completer completer = new Completer();
66
67 window.requestAnimationFrame((_) {
68 expect(parent.offsetWidth, equals(200));
69 expect(secondChild.offsetWidth, equals(200));
70 assertNonChangingValues();
71
72 parent.setNeedsLayout();
73
74 window.requestAnimationFrame((_) {
75 expect(parent.offsetWidth, equals(150));
76 expect(secondChild.offsetWidth, equals(150));
77 assertNonChangingValues();
78 completer.complete();
79 });
80 });
81
82 return completer.future;
83 });
84 }
85 </script>
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderObject.h ('k') | sky/tests/layout/custom-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698