rotated_box_test.dart 1.61 KB
Newer Older
1 2 3 4 5 6 7 8
// 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';

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

13
    await tester.pumpWidget(
14 15 16 17 18
      new Center(
        child: new RotatedBox(
          key: rotatedBoxKey,
          quarterTurns: 1,
          child: new Row(
19
            mainAxisSize: MainAxisSize.min,
20 21 22 23 24 25
            children: <Widget>[
              new GestureDetector(
                onTap: () { log.add('left'); },
                child: new Container(
                  width: 100.0,
                  height: 40.0,
26 27
                  color: Colors.blue[500],
                ),
28 29 30 31 32 33
              ),
              new GestureDetector(
                onTap: () { log.add('right'); },
                child: new Container(
                  width: 75.0,
                  height: 65.0,
34 35
                  color: Colors.blue[500],
                ),
36
              ),
37 38 39 40
            ],
          ),
        ),
      ),
41
    );
42

43
    final RenderBox box = tester.renderObject(find.byKey(rotatedBoxKey));
44 45
    expect(box.size.width, equals(65.0));
    expect(box.size.height, equals(175.0));
46

47
    await tester.tapAt(const Offset(420.0, 280.0));
48
    expect(log, equals(<String>['left']));
49
    log.clear();
50

51
    await tester.tapAt(const Offset(380.0, 320.0));
52
    expect(log, equals(<String>['right']));
53
    log.clear();
54 55
  });
}