rotated_box_test.dart 1.77 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// 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 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
import 'package:test/test.dart';

void main() {
  test('Rotated box control test', () {
    testWidgets((WidgetTester tester) {
      List<String> log = <String>[];
      Key rotatedBoxKey = new UniqueKey();

      tester.pumpWidget(
        new Center(
          child: new RotatedBox(
            key: rotatedBoxKey,
            quarterTurns: 1,
            child: new Row(
21
              mainAxisAlignment: MainAxisAlignment.collapse,
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
              children: <Widget>[
                new GestureDetector(
                  onTap: () { log.add('left'); },
                  child: new Container(
                    width: 100.0,
                    height: 40.0,
                    decoration: new BoxDecoration(backgroundColor: Colors.blue[500])
                  )
                ),
                new GestureDetector(
                  onTap: () { log.add('right'); },
                  child: new Container(
                    width: 75.0,
                    height: 65.0,
                    decoration: new BoxDecoration(backgroundColor: Colors.blue[500])
                  )
                ),
              ]
            )
          )
        )
      );

      RenderBox box = tester.findElementByKey(rotatedBoxKey).renderObject;
      expect(box.size.width, equals(65.0));
      expect(box.size.height, equals(175.0));

      tester.tapAt(new Point(420.0, 280.0));
      expect(log, equals(['left']));
      log.clear();

      tester.tapAt(new Point(380.0, 320.0));
      expect(log, equals(['right']));
      log.clear();
    });
  });
}