From 71ac7f55b3ddbd4322b123dc1e2462d843aa5dd0 Mon Sep 17 00:00:00 2001 From: Valentin Vignal <32538273+ValentinVignal@users.noreply.github.com> Date: Wed, 19 Jun 2024 15:40:31 +0800 Subject: [PATCH] Add tests for about_list_tile.0.dart (#150181) Contributes to https://github.com/flutter/flutter/issues/130459 It adds a test for - `examples/api/lib/material/about/about_list_tile.0.dart` --- dev/bots/check_code_samples.dart | 1 - .../about/about_list_tile.0_test.dart | 67 +++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 examples/api/test/material/about/about_list_tile.0_test.dart diff --git a/dev/bots/check_code_samples.dart b/dev/bots/check_code_samples.dart index f1a19fb871..577ef4e228 100644 --- a/dev/bots/check_code_samples.dart +++ b/dev/bots/check_code_samples.dart @@ -339,7 +339,6 @@ final Set _knownMissingTests = { 'examples/api/test/material/search_anchor/search_anchor.0_test.dart', 'examples/api/test/material/search_anchor/search_anchor.1_test.dart', 'examples/api/test/material/search_anchor/search_anchor.2_test.dart', - 'examples/api/test/material/about/about_list_tile.0_test.dart', 'examples/api/test/material/selection_area/selection_area.0_test.dart', 'examples/api/test/material/scaffold/scaffold_messenger.of.0_test.dart', 'examples/api/test/material/scaffold/scaffold_messenger.0_test.dart', diff --git a/examples/api/test/material/about/about_list_tile.0_test.dart b/examples/api/test/material/about/about_list_tile.0_test.dart new file mode 100644 index 0000000000..389a6d2dfd --- /dev/null +++ b/examples/api/test/material/about/about_list_tile.0_test.dart @@ -0,0 +1,67 @@ +// 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/about/about_list_tile.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('It should show the about dialog after clicking on the button', (WidgetTester tester) async { + await tester.pumpWidget(const example.AboutListTileExampleApp()); + + expect(find.widgetWithText(AppBar, 'Show About Example'), findsOne); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Show About Example')); + await tester.pumpAndSettle(); + + expect(find.byType(AboutDialog), findsOne); + expect(find.widgetWithText(AboutDialog, 'Show About Example'), findsOne); + expect(find.text('August 2019'), findsOne); + expect(find.byType(FlutterLogo), findsOne); + expect(find.text('\u{a9} 2014 The Flutter Authors'), findsOne); + expect( + find.text( + "Flutter is Google's UI toolkit for building beautiful, " + 'natively compiled applications for mobile, web, and desktop ' + 'from a single codebase. Learn more about Flutter at ' + 'https://flutter.dev.', + findRichText: true, + ), + findsOne, + ); + }); + + testWidgets('It should show the about dialog after clicking on about list tile in the drawer', (WidgetTester tester) async { + await tester.pumpWidget(const example.AboutListTileExampleApp()); + + expect(find.widgetWithText(AppBar, 'Show About Example'), findsOne); + + await tester.tap(find.byType(DrawerButton)); + await tester.pumpAndSettle(); + + expect(find.byType(Drawer), findsOne); + expect(find.widgetWithText(AboutListTile, 'About Show About Example'), findsOne); + expect(find.widgetWithIcon(AboutListTile, Icons.info), findsOne); + + await tester.tap(find.widgetWithIcon(AboutListTile, Icons.info)); + await tester.pumpAndSettle(); + + expect(find.byType(AboutDialog), findsOne); + expect(find.widgetWithText(AboutDialog, 'Show About Example'), findsOne); + expect(find.text('August 2019'), findsOne); + expect(find.byType(FlutterLogo), findsOne); + expect(find.text('\u{a9} 2014 The Flutter Authors'), findsOne); + expect( + find.text( + "Flutter is Google's UI toolkit for building beautiful, " + 'natively compiled applications for mobile, web, and desktop ' + 'from a single codebase. Learn more about Flutter at ' + 'https://flutter.dev.', + findRichText: true, + ), + findsOne, + ); + }); +}