From 0fe123931406d3fe678bf557450db8fb778724e2 Mon Sep 17 00:00:00 2001 From: Husnul Aman Date: Mon, 26 Aug 2024 14:29:33 +0300 Subject: [PATCH] Added missing test for SelectionArea example (#151585) Added missing test for SelectionArea example. Issue #130459 --- dev/bots/check_code_samples.dart | 1 - .../selection_area/selection_area.0_test.dart | 40 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 examples/api/test/material/selection_area/selection_area.0_test.dart diff --git a/dev/bots/check_code_samples.dart b/dev/bots/check_code_samples.dart index c37046959e..414659f134 100644 --- a/dev/bots/check_code_samples.dart +++ b/dev/bots/check_code_samples.dart @@ -319,7 +319,6 @@ final Set _knownMissingTests = { 'examples/api/test/material/color_scheme/dynamic_content_color.0_test.dart', 'examples/api/test/material/platform_menu_bar/platform_menu_bar.0_test.dart', 'examples/api/test/material/flexible_space_bar/flexible_space_bar.0_test.dart', - 'examples/api/test/material/selection_area/selection_area.0_test.dart', 'examples/api/test/material/app_bar/sliver_app_bar.2_test.dart', 'examples/api/test/material/app_bar/sliver_app_bar.3_test.dart', 'examples/api/test/material/navigation_rail/navigation_rail.extended_animation.0_test.dart', diff --git a/examples/api/test/material/selection_area/selection_area.0_test.dart b/examples/api/test/material/selection_area/selection_area.0_test.dart new file mode 100644 index 0000000000..071f072d6b --- /dev/null +++ b/examples/api/test/material/selection_area/selection_area.0_test.dart @@ -0,0 +1,40 @@ +// 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/selection_area/selection_area.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Texts are descendant of the SelectionArea', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SelectionAreaExampleApp(), + ); + + expect( + find.descendant( + of: find.byType(SelectionArea), + matching: find.byType(Text), + ), + findsExactly(4), + ); + + final List selectableTexts = [ + 'SelectionArea Sample', + 'Row 1', + 'Row 2', + 'Row 3', + ]; + + for (final String text in selectableTexts) { + expect( + find.descendant( + of: find.byType(SelectionArea), + matching: find.text(text), + ), + findsExactly(1), + ); + } + }); +}