flex_test.dart 1.46 KB
Newer Older
Hixie's avatar
Hixie committed
1 2 3 4
// 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.

Adam Barth's avatar
Adam Barth committed
5
import 'package:flutter_test/flutter_test.dart';
6
import 'package:flutter/rendering.dart';
7
import 'package:flutter/widgets.dart';
8 9

void main() {
10
  testWidgets('Can hit test flex children of stacks', (WidgetTester tester) async {
11
    bool didReceiveTap = false;
12
    await tester.pumpWidget(
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
      new Container(
        decoration: const BoxDecoration(
          backgroundColor: const Color(0xFF00FF00)
        ),
        child: new Stack(
          children: <Widget>[
            new Positioned(
              top: 10.0,
              left: 10.0,
              child: new Column(
                children: <Widget>[
                  new GestureDetector(
                    onTap: () {
                      didReceiveTap = true;
                    },
                    child: new Container(
                      decoration: const BoxDecoration(
                        backgroundColor: const Color(0xFF0000FF)
                      ),
                      width: 100.0,
                      height: 100.0,
                      child: new Center(
                        child: new Text('X')
36
                      )
37
                    )
38 39
                  )
                ]
40
              )
41 42
            )
          ]
43
        )
44 45
      )
    );
46

47
    await tester.tap(find.text('X'));
48
    expect(didReceiveTap, isTrue);
49 50
  });
}