grid_title_test.dart 1.43 KB
Newer Older
1 2 3 4 5 6 7 8 9
// 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() {
  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 23
        child: DecoratedBox(
          decoration: BoxDecoration(
24 25 26
            color: Colors.green[500],
          ),
        ),
27
        footer: GridTileBar(
28 29 30
          key: footerKey,
          title: const Text('Footer'),
          backgroundColor: Colors.black38,
31 32 33 34 35 36 37
        ),
      ),
    ));

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

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

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

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