|
| 1 | +// Copyright 2014 The Flutter Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +import 'package:flutter/material.dart'; |
| 6 | +import 'package:flutter_api_samples/material/about/about_list_tile.0.dart' |
| 7 | + as example; |
| 8 | +import 'package:flutter_test/flutter_test.dart'; |
| 9 | + |
| 10 | +void main() { |
| 11 | + testWidgets('It should show the about dialog after clicking on the button', (WidgetTester tester) async { |
| 12 | + await tester.pumpWidget(const example.AboutListTileExampleApp()); |
| 13 | + |
| 14 | + expect(find.widgetWithText(AppBar, 'Show About Example'), findsOne); |
| 15 | + |
| 16 | + await tester.tap(find.widgetWithText(ElevatedButton, 'Show About Example')); |
| 17 | + await tester.pumpAndSettle(); |
| 18 | + |
| 19 | + expect(find.byType(AboutDialog), findsOne); |
| 20 | + expect(find.widgetWithText(AboutDialog, 'Show About Example'), findsOne); |
| 21 | + expect(find.text('August 2019'), findsOne); |
| 22 | + expect(find.byType(FlutterLogo), findsOne); |
| 23 | + expect(find.text('\u{a9} 2014 The Flutter Authors'), findsOne); |
| 24 | + expect( |
| 25 | + find.text( |
| 26 | + "Flutter is Google's UI toolkit for building beautiful, " |
| 27 | + 'natively compiled applications for mobile, web, and desktop ' |
| 28 | + 'from a single codebase. Learn more about Flutter at ' |
| 29 | + 'https://flutter.dev.', |
| 30 | + findRichText: true, |
| 31 | + ), |
| 32 | + findsOne, |
| 33 | + ); |
| 34 | + }); |
| 35 | + |
| 36 | + testWidgets('It should show the about dialog after clicking on about list tile in the drawer', (WidgetTester tester) async { |
| 37 | + await tester.pumpWidget(const example.AboutListTileExampleApp()); |
| 38 | + |
| 39 | + expect(find.widgetWithText(AppBar, 'Show About Example'), findsOne); |
| 40 | + |
| 41 | + await tester.tap(find.byType(DrawerButton)); |
| 42 | + await tester.pumpAndSettle(); |
| 43 | + |
| 44 | + expect(find.byType(Drawer), findsOne); |
| 45 | + expect(find.widgetWithText(AboutListTile, 'About Show About Example'), findsOne); |
| 46 | + expect(find.widgetWithIcon(AboutListTile, Icons.info), findsOne); |
| 47 | + |
| 48 | + await tester.tap(find.widgetWithIcon(AboutListTile, Icons.info)); |
| 49 | + await tester.pumpAndSettle(); |
| 50 | + |
| 51 | + expect(find.byType(AboutDialog), findsOne); |
| 52 | + expect(find.widgetWithText(AboutDialog, 'Show About Example'), findsOne); |
| 53 | + expect(find.text('August 2019'), findsOne); |
| 54 | + expect(find.byType(FlutterLogo), findsOne); |
| 55 | + expect(find.text('\u{a9} 2014 The Flutter Authors'), findsOne); |
| 56 | + expect( |
| 57 | + find.text( |
| 58 | + "Flutter is Google's UI toolkit for building beautiful, " |
| 59 | + 'natively compiled applications for mobile, web, and desktop ' |
| 60 | + 'from a single codebase. Learn more about Flutter at ' |
| 61 | + 'https://flutter.dev.', |
| 62 | + findRichText: true, |
| 63 | + ), |
| 64 | + findsOne, |
| 65 | + ); |
| 66 | + }); |
| 67 | +} |
0 commit comments