rotated_box_test.dart 1.65 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
            textDirection: TextDirection.ltr,
20
            mainAxisSize: MainAxisSize.min,
21 22 23 24 25 26
            children: <Widget>[
              new GestureDetector(
                onTap: () { log.add('left'); },
                child: new Container(
                  width: 100.0,
                  height: 40.0,
27 28
                  color: Colors.blue[500],
                ),
29 30 31 32 33 34
              ),
              new GestureDetector(
                onTap: () { log.add('right'); },
                child: new Container(
                  width: 75.0,
                  height: 65.0,
35 36
                  color: Colors.blue[500],
                ),
37
              ),
38 39 40 41
            ],
          ),
        ),
      ),
42
    );
43

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

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

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