rotated_box_test.dart 1.62 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
    final List<String> log = <String>[];
11
    final Key rotatedBoxKey = UniqueKey();
12

13
    await tester.pumpWidget(
14 15
      Center(
        child: RotatedBox(
16 17
          key: rotatedBoxKey,
          quarterTurns: 1,
18
          child: Row(
19
            textDirection: TextDirection.ltr,
20
            mainAxisSize: MainAxisSize.min,
21
            children: <Widget>[
22
              GestureDetector(
23
                onTap: () { log.add('left'); },
24
                child: Container(
25 26
                  width: 100.0,
                  height: 40.0,
27 28
                  color: Colors.blue[500],
                ),
29
              ),
30
              GestureDetector(
31
                onTap: () { log.add('right'); },
32
                child: Container(
33 34
                  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
  });
}