chip_test.dart 901 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// Copyright 2016 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/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets('Chip control test', (WidgetTester tester) async {
    bool didDeleteChip = false;
    await tester.pumpWidget(
      new MaterialApp(
        home: new Material(
          child: new Center(
            child: new Chip(
              avatar: new CircleAvatar(
17
                child: const Text('C')
18
              ),
19
              label: const Text('Chip'),
20 21 22 23 24 25 26 27 28 29 30 31 32 33
              onDeleted: () {
                didDeleteChip = true;
              }
            )
          )
        )
      )
    );

    expect(didDeleteChip, isFalse);
    await tester.tap(find.byType(Tooltip));
    expect(didDeleteChip, isTrue);
  });
}