align_test.dart 1.29 KB
Newer Older
Hixie's avatar
Hixie 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
import 'package:flutter/widgets.dart';
Adam Barth's avatar
Adam Barth committed
7 8
import 'package:test/test.dart';

Adam Barth's avatar
Adam Barth committed
9
import 'widget_tester.dart';
Adam Barth's avatar
Adam Barth committed
10 11

void main() {
12
  test('Align smoke test', () {
13 14 15 16
    testWidgets((WidgetTester tester) {
      tester.pumpWidget(
        new Align(
          child: new Container(),
17
          alignment: const FractionalOffset(0.75, 0.75)
18 19
        )
      );
Adam Barth's avatar
Adam Barth committed
20

21 22 23
      tester.pumpWidget(
        new Align(
          child: new Container(),
24
          alignment: const FractionalOffset(0.5, 0.5)
25 26 27
        )
      );
    });
Adam Barth's avatar
Adam Barth committed
28
  });
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

  test('Shrink wraps in finite space', () {
    testWidgets((WidgetTester tester) {
      GlobalKey alignKey = new GlobalKey();
      tester.pumpWidget(
        new ScrollableViewport(
          child: new Align(
            key: alignKey,
            child: new Container(
              width: 10.0,
              height: 10.0
            ),
            alignment: const FractionalOffset(0.50, 0.50)
          )
        )
      );

      RenderBox box = alignKey.currentContext.findRenderObject();
      expect(box.size.width, equals(800.0));
      expect(box.size.height, equals(10.0));
    });
  });
Adam Barth's avatar
Adam Barth committed
51
}