forked from firka/flutter
Add tests for material_state_border_side.0_test.dart (#151089)
Contributes to https://github.com/flutter/flutter/issues/130459 It adds a test for - `examples/api/test/material/material_state/material_state_border_side.0_test.dart`
This commit is contained in:
@@ -311,7 +311,6 @@ class SampleChecker {
|
||||
final Set<String> _knownMissingTests = <String>{
|
||||
'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_border_side.0_test.dart',
|
||||
'examples/api/test/material/material_state/material_state_outlined_border.0_test.dart',
|
||||
'examples/api/test/material/material_state/material_state_property.0_test.dart',
|
||||
'examples/api/test/material/selectable_region/selectable_region.0_test.dart',
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
// 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_border_side.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
Finder findBorderColor(Color color) {
|
||||
return find.byWidgetPredicate((Widget widget) {
|
||||
if (widget is! Material) {
|
||||
return false;
|
||||
}
|
||||
final ShapeBorder? shape = widget.shape;
|
||||
if (shape is! OutlinedBorder) {
|
||||
return false;
|
||||
}
|
||||
return shape.side.color == color;
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets(
|
||||
'FilterChip displays the correct border when selected',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: example.MaterialStateBorderSideExampleApp(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(findBorderColor(Colors.red), findsOne);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'FilterChip displays the correct border when not selected',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: example.MaterialStateBorderSideExampleApp(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byType(FilterChip));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(findBorderColor(const Color(0xff79747e)), findsOne);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user