align_test.dart 1.21 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.

Adam Barth's avatar
Adam Barth committed
5
import 'package:flutter_test/flutter_test.dart';
6
import 'package:flutter/rendering.dart';
7
import 'package:flutter/widgets.dart';
Adam Barth's avatar
Adam Barth committed
8 9

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

18
    await tester.pumpWidget(
19 20 21 22 23
      new Align(
        child: new Container(),
        alignment: const FractionalOffset(0.5, 0.5)
      )
    );
Adam Barth's avatar
Adam Barth committed
24
  });
25

26
  testWidgets('Shrink wraps in finite space', (WidgetTester tester) async {
27
    GlobalKey alignKey = new GlobalKey();
28
    await tester.pumpWidget(
29 30 31 32 33 34 35 36
      new ScrollableViewport(
        child: new Align(
          key: alignKey,
          child: new Container(
            width: 10.0,
            height: 10.0
          ),
          alignment: const FractionalOffset(0.50, 0.50)
37
        )
38 39
      )
    );
40

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