Skip to content

Commit 3cffdf6

Browse files
Add tests for material_state_border_side.0_test.dart (flutter#151089)
Contributes to flutter#130459 It adds a test for - `examples/api/test/material/material_state/material_state_border_side.0_test.dart`
1 parent 484cddd commit 3cffdf6

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

dev/bots/check_code_samples.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ class SampleChecker {
311311
final Set<String> _knownMissingTests = <String>{
312312
'examples/api/test/material/bottom_app_bar/bottom_app_bar.2_test.dart',
313313
'examples/api/test/material/bottom_app_bar/bottom_app_bar.1_test.dart',
314-
'examples/api/test/material/material_state/material_state_border_side.0_test.dart',
315314
'examples/api/test/material/material_state/material_state_outlined_border.0_test.dart',
316315
'examples/api/test/material/material_state/material_state_property.0_test.dart',
317316
'examples/api/test/material/selectable_region/selectable_region.0_test.dart',
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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/material_state/material_state_border_side.0.dart'
7+
as example;
8+
import 'package:flutter_test/flutter_test.dart';
9+
10+
void main() {
11+
Finder findBorderColor(Color color) {
12+
return find.byWidgetPredicate((Widget widget) {
13+
if (widget is! Material) {
14+
return false;
15+
}
16+
final ShapeBorder? shape = widget.shape;
17+
if (shape is! OutlinedBorder) {
18+
return false;
19+
}
20+
return shape.side.color == color;
21+
});
22+
}
23+
24+
testWidgets(
25+
'FilterChip displays the correct border when selected',
26+
(WidgetTester tester) async {
27+
await tester.pumpWidget(
28+
const MaterialApp(
29+
home: Scaffold(
30+
body: example.MaterialStateBorderSideExampleApp(),
31+
),
32+
),
33+
);
34+
35+
expect(findBorderColor(Colors.red), findsOne);
36+
},
37+
);
38+
39+
testWidgets(
40+
'FilterChip displays the correct border when not selected',
41+
(WidgetTester tester) async {
42+
await tester.pumpWidget(
43+
const MaterialApp(
44+
home: Scaffold(
45+
body: example.MaterialStateBorderSideExampleApp(),
46+
),
47+
),
48+
);
49+
50+
await tester.tap(find.byType(FilterChip));
51+
await tester.pumpAndSettle();
52+
53+
expect(findBorderColor(const Color(0xff79747e)), findsOne);
54+
},
55+
);
56+
}

0 commit comments

Comments
 (0)