stack_test.dart 1.37 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1 2 3 4
// 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.

5
import 'package:flutter/rendering.dart';
6 7
import 'package:test/test.dart';

8
import 'rendering_tester.dart';
9 10 11

void main() {
  test('Stack can layout with top, right, bottom, left 0.0', () {
12
    final RenderBox size = new RenderConstrainedBox(
13 14
      additionalConstraints: new BoxConstraints.tight(const Size(100.0, 100.0))
    );
15

16
    final RenderBox red = new RenderDecoratedBox(
17
      decoration: const BoxDecoration(
18 19
        backgroundColor: const Color(0xFFFF0000)
      ),
20 21
      child: size
    );
22

23
    final RenderBox green = new RenderDecoratedBox(
24
      decoration: const BoxDecoration(
25
        backgroundColor: const Color(0xFFFF0000)
26 27
      )
    );
28

29 30
    final RenderBox stack = new RenderStack(children: <RenderBox>[red, green]);
    final StackParentData greenParentData = green.parentData;
Hixie's avatar
Hixie committed
31
    greenParentData
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
      ..top = 0.0
      ..right = 0.0
      ..bottom = 0.0
      ..left = 0.0;

    layout(stack, constraints: const BoxConstraints());

    expect(stack.size.width, equals(100.0));
    expect(stack.size.height, equals(100.0));

    expect(red.size.width, equals(100.0));
    expect(red.size.height, equals(100.0));

    expect(green.size.width, equals(100.0));
    expect(green.size.height, equals(100.0));
  });
}