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

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

void main() {
  testWidgets('GridTile control test', (WidgetTester tester) async {
10 11
    final Key headerKey = UniqueKey();
    final Key footerKey = UniqueKey();
12

13 14 15
    await tester.pumpWidget(MaterialApp(
      home: GridTile(
        header: GridTileBar(
16 17 18 19 20 21
          key: headerKey,
          leading: const Icon(Icons.thumb_up),
          title: const Text('Header'),
          subtitle: const Text('Subtitle'),
          trailing: const Icon(Icons.thumb_up),
        ),
22
        footer: GridTileBar(
23 24 25
          key: footerKey,
          title: const Text('Footer'),
          backgroundColor: Colors.black38,
26
        ),
27 28 29 30 31
        child: DecoratedBox(
          decoration: BoxDecoration(
            color: Colors.green[500],
          ),
        ),
32 33 34 35 36 37
      ),
    ));

    expect(find.text('Header'), findsOneWidget);
    expect(find.text('Footer'), findsOneWidget);

38 39 40 41
    expect(
      tester.getBottomLeft(find.byKey(headerKey)).dy,
      lessThan(tester.getTopLeft(find.byKey(footerKey)).dy),
    );
42

Ian Hickson's avatar
Ian Hickson committed
43 44 45
    await tester.pumpWidget(
      const Directionality(
        textDirection: TextDirection.ltr,
46
        child: GridTile(child: Text('Simple')),
Ian Hickson's avatar
Ian Hickson committed
47 48
      ),
    );
49 50 51 52

    expect(find.text('Simple'), findsOneWidget);
  });
}