rotated_box_test.dart 1.64 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
// @dart = 2.8

7 8 9 10
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';

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

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

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

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

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