From 41a9d53fd4b8511f2ddcd3d41fb56d26eba31b93 Mon Sep 17 00:00:00 2001 From: Ojan Vafai Date: Wed, 15 Apr 2015 11:08:32 -0700 Subject: [PATCH] Make changing your layout manager work. If your layout manager changes, then you need to setNeedsLayout, otherwise the next frame doesn't even get scheduled. We already correctly handle going from not having layout to having one or vice versa by doing the more drastic reattaching since that requires changing your actual render class. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1060013005 --- engine/src/flutter/tests/layout/custom.sky | 45 +++++++++++++--------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/engine/src/flutter/tests/layout/custom.sky b/engine/src/flutter/tests/layout/custom.sky index 586dd26fe9d..e212a6e7a01 100644 --- a/engine/src/flutter/tests/layout/custom.sky +++ b/engine/src/flutter/tests/layout/custom.sky @@ -84,30 +84,39 @@ void main() { expect(secondChild.offsetWidth, equals(150)); assertNonChangingValues(); - parent.setLayoutManager(null); + parent.setLayoutManager(() { + parent.width = 250.0; + }); window.requestAnimationFrame((_) { - expect(parent.offsetWidth, equals(300)); - expect(parent.offsetHeight, equals(50)); - expect(parent.offsetTop, equals(0)); - expect(parent.offsetLeft, equals(0)); + expect(parent.offsetWidth, equals(250)); + assertNonChangingValues(); - expect(firstChild.offsetWidth, equals(300)); - expect(firstChild.offsetHeight, equals(25)); - expect(firstChild.offsetTop, equals(0)); - expect(firstChild.offsetLeft, equals(0)); + parent.setLayoutManager(null); - expect(secondChild.offsetWidth, equals(300)); - expect(secondChild.offsetHeight, equals(25)); - expect(secondChild.offsetTop, equals(25)); - expect(secondChild.offsetLeft, equals(0)); + window.requestAnimationFrame((_) { + expect(parent.offsetWidth, equals(300)); + expect(parent.offsetHeight, equals(50)); + expect(parent.offsetTop, equals(0)); + expect(parent.offsetLeft, equals(0)); - expect(grandChild.offsetWidth, equals(25)); - expect(grandChild.offsetHeight, equals(25)); - expect(grandChild.offsetTop, equals(0)); - expect(grandChild.offsetLeft, equals(0)); + expect(firstChild.offsetWidth, equals(300)); + expect(firstChild.offsetHeight, equals(25)); + expect(firstChild.offsetTop, equals(0)); + expect(firstChild.offsetLeft, equals(0)); - completer.complete(); + expect(secondChild.offsetWidth, equals(300)); + expect(secondChild.offsetHeight, equals(25)); + expect(secondChild.offsetTop, equals(25)); + expect(secondChild.offsetLeft, equals(0)); + + expect(grandChild.offsetWidth, equals(25)); + expect(grandChild.offsetHeight, equals(25)); + expect(grandChild.offsetTop, equals(0)); + expect(grandChild.offsetLeft, equals(0)); + + completer.complete(); + }); }); }); });