popupmenu.0_test.dart 1.13 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
// Copyright 2014 The Flutter 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_api_samples/material/popupmenu/popupmenu.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets('Can select a menu item', (WidgetTester tester) async {
    final Key popupButtonKey = UniqueKey();
    await tester.pumpWidget(
      MaterialApp(
        home: Scaffold(
          body: example.MyStatefulWidget(
            key: popupButtonKey,
          ),
        ),
      ),
    );

    await tester.tap(find.byKey(popupButtonKey));
    await tester.pump();
    await tester.pump(const Duration(seconds: 1)); // finish the menu animation
    await tester.tapAt(const Offset(1.0, 1.0));
    await tester.pumpAndSettle();
    expect(find.text('_selectedMenu: itemOne'), findsNothing);
  });
29 30 31 32 33

  testWidgets('Does not show debug banner', (WidgetTester tester) async {
    await tester.pumpWidget(const example.MyApp());
    expect(find.byType(CheckedModeBanner), findsNothing);
  });
34
}