From 4af4cb89d50d1a54ab185cf70d2869fbba9bb00e Mon Sep 17 00:00:00 2001 From: Valentin Vignal <32538273+ValentinVignal@users.noreply.github.com> Date: Sat, 11 May 2024 08:37:04 +0800 Subject: [PATCH] Add test for scaffold.1.dart (#147966) Contributes to https://github.com/flutter/flutter/issues/130459 It adds test for `examples/api/lib/material/scaffold/scaffold.1.dart` --- dev/bots/check_code_samples.dart | 3 +-- .../material/scaffold/scaffold.1_test.dart | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 examples/api/test/material/scaffold/scaffold.1_test.dart diff --git a/dev/bots/check_code_samples.dart b/dev/bots/check_code_samples.dart index d0fffb7430..499a06fd8c 100644 --- a/dev/bots/check_code_samples.dart +++ b/dev/bots/check_code_samples.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. // To run this, from the root of the Flutter repository: -// bin/cache/dart-sdk/bin/dart --enable-asserts dev/bots/check_code_sample_links.dart +// bin/cache/dart-sdk/bin/dart --enable-asserts dev/bots/check_code_samples.dart import 'dart:io'; @@ -352,7 +352,6 @@ final Set _knownMissingTests = { 'examples/api/test/material/selection_area/selection_area.0_test.dart', 'examples/api/test/material/scaffold/scaffold.end_drawer.0_test.dart', 'examples/api/test/material/scaffold/scaffold.drawer.0_test.dart', - 'examples/api/test/material/scaffold/scaffold.1_test.dart', 'examples/api/test/material/scaffold/scaffold.of.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/scaffold/scaffold.1_test.dart b/examples/api/test/material/scaffold/scaffold.1_test.dart new file mode 100644 index 0000000000..a468b509b9 --- /dev/null +++ b/examples/api/test/material/scaffold/scaffold.1_test.dart @@ -0,0 +1,25 @@ +// 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/scaffold/scaffold.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('The count should be incremented when the floating action button is tapped', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ScaffoldExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'Sample Code'), findsOne); + expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne); + expect(find.text('You have pressed the button 0 times.'), findsOne); + + for (int i = 1; i <= 5; i++) { + await tester.tap(find.byType(FloatingActionButton)); + await tester.pump(); + expect(find.text('You have pressed the button $i times.'), findsOne); + } + }); +}