From a90cc80a88e256d25b89bd843bae382a67eed682 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Wed, 3 Jun 2015 11:12:17 -0700 Subject: [PATCH] Fix min/max typo in BoxConstraints.deflate R=ianh@google.com Review URL: https://codereview.chromium.org/1153413003 --- sdk/lib/framework/rendering/box.dart | 4 ++-- tests/raw/padding_deflate-expected.txt | 7 +++++++ tests/raw/padding_deflate.dart | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/raw/padding_deflate-expected.txt create mode 100644 tests/raw/padding_deflate.dart diff --git a/sdk/lib/framework/rendering/box.dart b/sdk/lib/framework/rendering/box.dart index 100219477b9..f6bb40bf048 100644 --- a/sdk/lib/framework/rendering/box.dart +++ b/sdk/lib/framework/rendering/box.dart @@ -55,9 +55,9 @@ class BoxConstraints { double horizontal = edges.left + edges.right; double vertical = edges.top + edges.bottom; return new BoxConstraints( - minWidth: math.min(0.0, minWidth - horizontal), + minWidth: math.max(0.0, minWidth - horizontal), maxWidth: maxWidth - horizontal, - minHeight: math.min(0.0, minHeight - vertical), + minHeight: math.max(0.0, minHeight - vertical), maxHeight: maxHeight - vertical ); } diff --git a/tests/raw/padding_deflate-expected.txt b/tests/raw/padding_deflate-expected.txt new file mode 100644 index 00000000000..a6444cb469e --- /dev/null +++ b/tests/raw/padding_deflate-expected.txt @@ -0,0 +1,7 @@ +CONSOLE: unittest-suite-wait-for-done +CONSOLE: TestView enabled +CONSOLE: PASS: should not have a 0 sized colored Box +CONSOLE: +CONSOLE: All 1 tests passed. +CONSOLE: unittest-suite-success +DONE diff --git a/tests/raw/padding_deflate.dart b/tests/raw/padding_deflate.dart new file mode 100644 index 00000000000..ffda37cfaba --- /dev/null +++ b/tests/raw/padding_deflate.dart @@ -0,0 +1,26 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:sky' as sky; +import '../resources/third_party/unittest/unittest.dart'; +import '../resources/unit.dart'; +import '../resources/display_list.dart'; +import 'package:sky/framework/rendering/box.dart'; + +void main() { + initUnit(); + + test("should not have a 0 sized colored Box", () { + var coloredBox = new RenderDecoratedBox(); + var paddingBox = new RenderPadding(padding: const EdgeDims.all(10.0), + child: coloredBox); + RenderBox root = new RenderDecoratedBox( + child: paddingBox + ); + TestView renderView = new TestView(child: root); + renderView.layout(new ViewConstraints(width: sky.view.width, height: sky.view.height)); + expect(coloredBox.size.width, equals(sky.view.width - 20)); + expect(coloredBox.size.height, equals(sky.view.height - 20)); + }); +}