From 6829c6a9b95f1db169d315caff0140617d083872 Mon Sep 17 00:00:00 2001 From: Valentin Vignal <32538273+ValentinVignal@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:36:36 +0800 Subject: [PATCH] Add tests for `material_state_outlined_border.0.dart` (#156814) Contributes to https://github.com/flutter/flutter/issues/130459 It adds a test for - `examples/api/test/material/material_state/material_state_outlined_border.0_test.dart` --- dev/bots/check_code_samples.dart | 1 - ...material_state_outlined_border.0_test.dart | 58 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 examples/api/test/material/material_state/material_state_outlined_border.0_test.dart diff --git a/dev/bots/check_code_samples.dart b/dev/bots/check_code_samples.dart index 924b543571..f91e5adc7b 100644 --- a/dev/bots/check_code_samples.dart +++ b/dev/bots/check_code_samples.dart @@ -311,7 +311,6 @@ class SampleChecker { final Set _knownMissingTests = { 'examples/api/test/material/bottom_app_bar/bottom_app_bar.2_test.dart', 'examples/api/test/material/bottom_app_bar/bottom_app_bar.1_test.dart', - 'examples/api/test/material/material_state/material_state_outlined_border.0_test.dart', 'examples/api/test/material/selectable_region/selectable_region.0_test.dart', 'examples/api/test/material/selection_container/selection_container_disabled.0_test.dart', 'examples/api/test/material/selection_container/selection_container.0_test.dart', diff --git a/examples/api/test/material/material_state/material_state_outlined_border.0_test.dart b/examples/api/test/material/material_state/material_state_outlined_border.0_test.dart new file mode 100644 index 0000000000..05ee1e90f9 --- /dev/null +++ b/examples/api/test/material/material_state/material_state_outlined_border.0_test.dart @@ -0,0 +1,58 @@ +// 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/material_state/material_state_outlined_border.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + Finder findBorderShape(OutlinedBorder? shape) { + return find.descendant( + of: find.byType(FilterChip), + matching: find.byWidgetPredicate((Widget widget) { + if (widget is! Material) { + return false; + } + return widget.shape == shape; + }), + ); + } + + testWidgets( + 'FilterChip displays the correct border when selected', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.MaterialStateOutlinedBorderExampleApp(), + ); + + expect( + findBorderShape(const RoundedRectangleBorder( + side: BorderSide(color: Colors.transparent), + )), + findsOne, + ); + }, + ); + + testWidgets( + 'FilterChip displays the correct border when not selected', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.MaterialStateOutlinedBorderExampleApp(), + ); + + await tester.tap(find.byType(FilterChip)); + await tester.pumpAndSettle(); + + expect( + findBorderShape(RoundedRectangleBorder( + side: const BorderSide(color: Color(0xFFCAC4D0)), + borderRadius: BorderRadius.circular(8), + )), + findsOne, + ); + }, + ); +}