Added missing tests for ButtonStyle example (#147457)
Added missing tests for ButtonStyle example. Issue #130459
This commit is contained in:
parent
c785a49d0e
commit
774ef8acf4
@ -317,7 +317,6 @@ final Set<String> _knownMissingTests = <String>{
|
||||
'examples/api/test/material/selectable_region/selectable_region.0_test.dart',
|
||||
'examples/api/test/material/text_field/text_field.2_test.dart',
|
||||
'examples/api/test/material/text_field/text_field.1_test.dart',
|
||||
'examples/api/test/material/button_style/button_style.0_test.dart',
|
||||
'examples/api/test/material/range_slider/range_slider.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',
|
||||
|
@ -0,0 +1,74 @@
|
||||
// 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/button_style/button_style.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'Shows ElevatedButtons, FilledButtons, OutlinedButtons and TextButtons in enabled and disabled states',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.ButtonApp());
|
||||
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) {
|
||||
return widget is ElevatedButton && widget.onPressed == null;
|
||||
}),
|
||||
findsOne,
|
||||
);
|
||||
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) {
|
||||
return widget is ElevatedButton && widget.onPressed != null;
|
||||
}),
|
||||
findsOne,
|
||||
);
|
||||
|
||||
// One OutlinedButton with onPressed null.
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) {
|
||||
return widget is OutlinedButton && widget.onPressed == null;
|
||||
}),
|
||||
findsOne,
|
||||
);
|
||||
|
||||
// One OutlinedButton with onPressed not null.
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) {
|
||||
return widget is OutlinedButton && widget.onPressed != null;
|
||||
}),
|
||||
findsOne,
|
||||
);
|
||||
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) {
|
||||
return widget is TextButton && widget.onPressed == null;
|
||||
}),
|
||||
findsOne,
|
||||
);
|
||||
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) {
|
||||
return widget is TextButton && widget.onPressed != null;
|
||||
}),
|
||||
findsOne,
|
||||
);
|
||||
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) {
|
||||
return widget is FilledButton && widget.onPressed != null;
|
||||
}),
|
||||
findsNWidgets(2),
|
||||
);
|
||||
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) {
|
||||
return widget is FilledButton && widget.onPressed == null;
|
||||
}),
|
||||
findsNWidgets(2),
|
||||
);
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user