Test cover more tests with leak tracking. (#133828)
This commit is contained in:
parent
0f3bd90d9b
commit
78ff1226c9
@ -9,6 +9,7 @@ library;
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('CardTheme copyWith, ==, hashCode basics', () {
|
test('CardTheme copyWith, ==, hashCode basics', () {
|
||||||
@ -22,7 +23,7 @@ void main() {
|
|||||||
expect(identical(CardTheme.lerp(theme, theme, 0.5), theme), true);
|
expect(identical(CardTheme.lerp(theme, theme, 0.5), theme), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - Passing no CardTheme returns defaults', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Passing no CardTheme returns defaults', (WidgetTester tester) async {
|
||||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
theme: theme,
|
theme: theme,
|
||||||
@ -45,7 +46,7 @@ void main() {
|
|||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Card uses values from CardTheme', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Card uses values from CardTheme', (WidgetTester tester) async {
|
||||||
final CardTheme cardTheme = _cardTheme();
|
final CardTheme cardTheme = _cardTheme();
|
||||||
|
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
@ -67,7 +68,7 @@ void main() {
|
|||||||
expect(material.shape, cardTheme.shape);
|
expect(material.shape, cardTheme.shape);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Card widget properties take priority over theme', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Card widget properties take priority over theme', (WidgetTester tester) async {
|
||||||
const Clip clip = Clip.hardEdge;
|
const Clip clip = Clip.hardEdge;
|
||||||
const Color color = Colors.orange;
|
const Color color = Colors.orange;
|
||||||
const Color shadowColor = Colors.pink;
|
const Color shadowColor = Colors.pink;
|
||||||
@ -102,7 +103,7 @@ void main() {
|
|||||||
expect(material.shape, shape);
|
expect(material.shape, shape);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('CardTheme properties take priority over ThemeData properties', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('CardTheme properties take priority over ThemeData properties', (WidgetTester tester) async {
|
||||||
final CardTheme cardTheme = _cardTheme();
|
final CardTheme cardTheme = _cardTheme();
|
||||||
final ThemeData themeData = _themeData().copyWith(cardTheme: cardTheme);
|
final ThemeData themeData = _themeData().copyWith(cardTheme: cardTheme);
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ void main() {
|
|||||||
expect(material.color, cardTheme.color);
|
expect(material.color, cardTheme.color);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - ThemeData properties are used when no CardTheme is set', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - ThemeData properties are used when no CardTheme is set', (WidgetTester tester) async {
|
||||||
final ThemeData themeData = ThemeData(useMaterial3: true);
|
final ThemeData themeData = ThemeData(useMaterial3: true);
|
||||||
|
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
@ -131,7 +132,7 @@ void main() {
|
|||||||
expect(material.color, themeData.colorScheme.surface);
|
expect(material.color, themeData.colorScheme.surface);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - CardTheme customizes shape', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - CardTheme customizes shape', (WidgetTester tester) async {
|
||||||
const CardTheme cardTheme = CardTheme(
|
const CardTheme cardTheme = CardTheme(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
shape: BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))),
|
shape: BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))),
|
||||||
@ -165,7 +166,7 @@ void main() {
|
|||||||
// support is deprecated and the APIs are removed, these tests
|
// support is deprecated and the APIs are removed, these tests
|
||||||
// can be deleted.
|
// can be deleted.
|
||||||
|
|
||||||
testWidgets('Material2 - ThemeData properties are used when no CardTheme is set', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - ThemeData properties are used when no CardTheme is set', (WidgetTester tester) async {
|
||||||
final ThemeData themeData = ThemeData(useMaterial3: false);
|
final ThemeData themeData = ThemeData(useMaterial3: false);
|
||||||
|
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
@ -179,7 +180,7 @@ void main() {
|
|||||||
expect(material.color, themeData.cardColor);
|
expect(material.color, themeData.cardColor);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material2 - Passing no CardTheme returns defaults', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - Passing no CardTheme returns defaults', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
theme: ThemeData(useMaterial3: false),
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: const Scaffold(
|
home: const Scaffold(
|
||||||
@ -201,7 +202,7 @@ void main() {
|
|||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material2 - CardTheme customizes shape', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - CardTheme customizes shape', (WidgetTester tester) async {
|
||||||
const CardTheme cardTheme = CardTheme(
|
const CardTheme cardTheme = CardTheme(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
shape: BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))),
|
shape: BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))),
|
||||||
|
@ -743,7 +743,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material2 - CheckboxListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - CheckboxListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async {
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
|
|
||||||
const Color fillColor = Color(0xFF000000);
|
const Color fillColor = Color(0xFF000000);
|
||||||
@ -859,7 +859,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - CheckboxListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - CheckboxListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async {
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
|
|
||||||
const Color fillColor = Color(0xFF000000);
|
const Color fillColor = Color(0xFF000000);
|
||||||
|
@ -11,6 +11,7 @@ import 'package:flutter/rendering.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/src/gestures/constants.dart';
|
import 'package:flutter/src/gestures/constants.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||||
|
|
||||||
import '../widgets/semantics_tester.dart';
|
import '../widgets/semantics_tester.dart';
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ void main() {
|
|||||||
debugResetSemanticsIdCounter();
|
debugResetSemanticsIdCounter();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Theme(
|
Theme(
|
||||||
data: theme.copyWith(materialTapTargetSize: MaterialTapTargetSize.padded),
|
data: theme.copyWith(materialTapTargetSize: MaterialTapTargetSize.padded),
|
||||||
@ -60,7 +61,7 @@ void main() {
|
|||||||
expect(tester.getSize(find.byType(Checkbox)), const Size(40.0, 40.0));
|
expect(tester.getSize(find.byType(Checkbox)), const Size(40.0, 40.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox semantics', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox semantics', (WidgetTester tester) async {
|
||||||
final SemanticsHandle handle = tester.ensureSemantics();
|
final SemanticsHandle handle = tester.ensureSemantics();
|
||||||
|
|
||||||
await tester.pumpWidget(Theme(
|
await tester.pumpWidget(Theme(
|
||||||
@ -218,7 +219,7 @@ void main() {
|
|||||||
handle.dispose();
|
handle.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Can wrap Checkbox with Semantics', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Can wrap Checkbox with Semantics', (WidgetTester tester) async {
|
||||||
final SemanticsHandle handle = tester.ensureSemantics();
|
final SemanticsHandle handle = tester.ensureSemantics();
|
||||||
|
|
||||||
await tester.pumpWidget(Theme(
|
await tester.pumpWidget(Theme(
|
||||||
@ -247,7 +248,7 @@ void main() {
|
|||||||
handle.dispose();
|
handle.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox tristate: true', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox tristate: true', (WidgetTester tester) async {
|
||||||
bool? checkBoxValue;
|
bool? checkBoxValue;
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -294,7 +295,7 @@ void main() {
|
|||||||
expect(checkBoxValue, null);
|
expect(checkBoxValue, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('has semantics for tristate', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('has semantics for tristate', (WidgetTester tester) async {
|
||||||
final SemanticsTester semantics = SemanticsTester(tester);
|
final SemanticsTester semantics = SemanticsTester(tester);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Theme(
|
Theme(
|
||||||
@ -370,7 +371,7 @@ void main() {
|
|||||||
semantics.dispose();
|
semantics.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('has semantic events', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('has semantic events', (WidgetTester tester) async {
|
||||||
dynamic semanticEvent;
|
dynamic semanticEvent;
|
||||||
bool? checkboxValue = false;
|
bool? checkboxValue = false;
|
||||||
tester.binding.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, (dynamic message) async {
|
tester.binding.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, (dynamic message) async {
|
||||||
@ -413,7 +414,7 @@ void main() {
|
|||||||
semanticsTester.dispose();
|
semanticsTester.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material2 - Checkbox tristate rendering, programmatic transitions', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - Checkbox tristate rendering, programmatic transitions', (WidgetTester tester) async {
|
||||||
final ThemeData theme = ThemeData(useMaterial3: false);
|
final ThemeData theme = ThemeData(useMaterial3: false);
|
||||||
Widget buildFrame(bool? checkboxValue) {
|
Widget buildFrame(bool? checkboxValue) {
|
||||||
return Theme(
|
return Theme(
|
||||||
@ -473,7 +474,7 @@ void main() {
|
|||||||
expect(getCheckboxRenderer(), paints..line()); // null is rendered as a line (a "dash")
|
expect(getCheckboxRenderer(), paints..line()); // null is rendered as a line (a "dash")
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - Checkbox tristate rendering, programmatic transitions', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Checkbox tristate rendering, programmatic transitions', (WidgetTester tester) async {
|
||||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||||
Widget buildFrame(bool? checkboxValue) {
|
Widget buildFrame(bool? checkboxValue) {
|
||||||
return Theme(
|
return Theme(
|
||||||
@ -533,7 +534,7 @@ void main() {
|
|||||||
expect(getCheckboxRenderer(), paints..line()); // null is rendered as a line (a "dash")
|
expect(getCheckboxRenderer(), paints..line()); // null is rendered as a line (a "dash")
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material2 - Checkbox color rendering', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - Checkbox color rendering', (WidgetTester tester) async {
|
||||||
ThemeData theme = ThemeData(useMaterial3: false);
|
ThemeData theme = ThemeData(useMaterial3: false);
|
||||||
const Color borderColor = Color(0xff2196f3);
|
const Color borderColor = Color(0xff2196f3);
|
||||||
Color checkColor = const Color(0xffFFFFFF);
|
Color checkColor = const Color(0xffFFFFFF);
|
||||||
@ -588,7 +589,7 @@ void main() {
|
|||||||
expect(getCheckboxRenderer(), paints..path(color: activeColor));
|
expect(getCheckboxRenderer(), paints..path(color: activeColor));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - Checkbox color rendering', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Checkbox color rendering', (WidgetTester tester) async {
|
||||||
ThemeData theme = ThemeData(useMaterial3: true);
|
ThemeData theme = ThemeData(useMaterial3: true);
|
||||||
const Color borderColor = Color(0xFF6750A4);
|
const Color borderColor = Color(0xFF6750A4);
|
||||||
Color checkColor = const Color(0xffFFFFFF);
|
Color checkColor = const Color(0xffFFFFFF);
|
||||||
@ -641,8 +642,9 @@ void main() {
|
|||||||
expect(getCheckboxRenderer(), paints..path(color: activeColor));
|
expect(getCheckboxRenderer(), paints..path(color: activeColor));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material2 - Checkbox is focusable and has correct focus color', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - Checkbox is focusable and has correct focus color', (WidgetTester tester) async {
|
||||||
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
||||||
|
addTearDown(() => focusNode.dispose());
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
bool? value = true;
|
bool? value = true;
|
||||||
Widget buildApp({bool enabled = true}) {
|
Widget buildApp({bool enabled = true}) {
|
||||||
@ -711,8 +713,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - Checkbox is focusable and has correct focus color', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Checkbox is focusable and has correct focus color', (WidgetTester tester) async {
|
||||||
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
||||||
|
addTearDown(() => focusNode.dispose());
|
||||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
bool? value = true;
|
bool? value = true;
|
||||||
@ -782,7 +785,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox with splash radius set', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox with splash radius set', (WidgetTester tester) async {
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
const double splashRadius = 30;
|
const double splashRadius = 30;
|
||||||
Widget buildApp() {
|
Widget buildApp() {
|
||||||
@ -811,7 +814,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox starts the splash in center, even when tap is on the corner', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox starts the splash in center, even when tap is on the corner', (WidgetTester tester) async {
|
||||||
Widget buildApp() {
|
Widget buildApp() {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
theme: theme,
|
theme: theme,
|
||||||
@ -843,7 +846,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material2 - Checkbox can be hovered and has correct hover color', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - Checkbox can be hovered and has correct hover color', (WidgetTester tester) async {
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
bool? value = true;
|
bool? value = true;
|
||||||
final ThemeData theme = ThemeData(useMaterial3: false);
|
final ThemeData theme = ThemeData(useMaterial3: false);
|
||||||
@ -900,7 +903,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - Checkbox can be hovered and has correct hover color', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Checkbox can be hovered and has correct hover color', (WidgetTester tester) async {
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
bool? value = true;
|
bool? value = true;
|
||||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||||
@ -957,7 +960,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox can be toggled by keyboard shortcuts', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox can be toggled by keyboard shortcuts', (WidgetTester tester) async {
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
bool? value = true;
|
bool? value = true;
|
||||||
Widget buildApp({bool enabled = true}) {
|
Widget buildApp({bool enabled = true}) {
|
||||||
@ -998,7 +1001,7 @@ void main() {
|
|||||||
expect(value, isTrue);
|
expect(value, isTrue);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox responds to density changes.', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox responds to density changes.', (WidgetTester tester) async {
|
||||||
const Key key = Key('test');
|
const Key key = Key('test');
|
||||||
Future<void> buildTest(VisualDensity visualDensity) async {
|
Future<void> buildTest(VisualDensity visualDensity) async {
|
||||||
return tester.pumpWidget(
|
return tester.pumpWidget(
|
||||||
@ -1036,7 +1039,7 @@ void main() {
|
|||||||
expect(box.size, equals(const Size(60, 36)));
|
expect(box.size, equals(const Size(60, 36)));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox stops hover animation when removed from the tree.', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox stops hover animation when removed from the tree.', (WidgetTester tester) async {
|
||||||
const Key checkboxKey = Key('checkbox');
|
const Key checkboxKey = Key('checkbox');
|
||||||
bool? checkboxVal = true;
|
bool? checkboxVal = true;
|
||||||
|
|
||||||
@ -1090,7 +1093,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
testWidgets('Checkbox changes mouse cursor when hovered', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox changes mouse cursor when hovered', (WidgetTester tester) async {
|
||||||
// Test Checkbox() constructor
|
// Test Checkbox() constructor
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
@ -1195,7 +1198,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
testWidgets('Checkbox fill color resolves in enabled/disabled states', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox fill color resolves in enabled/disabled states', (WidgetTester tester) async {
|
||||||
const Color activeEnabledFillColor = Color(0xFF000001);
|
const Color activeEnabledFillColor = Color(0xFF000001);
|
||||||
const Color activeDisabledFillColor = Color(0xFF000002);
|
const Color activeDisabledFillColor = Color(0xFF000002);
|
||||||
|
|
||||||
@ -1239,8 +1242,10 @@ void main() {
|
|||||||
expect(getCheckboxRenderer(), paints..path(color: activeDisabledFillColor));
|
expect(getCheckboxRenderer(), paints..path(color: activeDisabledFillColor));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox fill color resolves in hovered/focused states', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox fill color resolves in hovered/focused states', (WidgetTester tester) async {
|
||||||
final FocusNode focusNode = FocusNode(debugLabel: 'checkbox');
|
final FocusNode focusNode = FocusNode(debugLabel: 'checkbox');
|
||||||
|
addTearDown(() => focusNode.dispose());
|
||||||
|
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
const Color hoveredFillColor = Color(0xFF000001);
|
const Color hoveredFillColor = Color(0xFF000001);
|
||||||
const Color focusedFillColor = Color(0xFF000002);
|
const Color focusedFillColor = Color(0xFF000002);
|
||||||
@ -1295,7 +1300,7 @@ void main() {
|
|||||||
expect(getCheckboxRenderer(), paints..path(color: hoveredFillColor));
|
expect(getCheckboxRenderer(), paints..path(color: hoveredFillColor));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox respects shape and side', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox respects shape and side', (WidgetTester tester) async {
|
||||||
const RoundedRectangleBorder roundedRectangleBorder =
|
const RoundedRectangleBorder roundedRectangleBorder =
|
||||||
RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(5)));
|
RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(5)));
|
||||||
|
|
||||||
@ -1338,8 +1343,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material2 - Checkbox default overlay color in active/pressed/focused/hovered states', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - Checkbox default overlay color in active/pressed/focused/hovered states', (WidgetTester tester) async {
|
||||||
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
||||||
|
addTearDown(() => focusNode.dispose());
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
|
|
||||||
final ThemeData theme = ThemeData(useMaterial3: false);
|
final ThemeData theme = ThemeData(useMaterial3: false);
|
||||||
@ -1405,8 +1411,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - Checkbox default overlay color in active/pressed/focused/hovered states', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Checkbox default overlay color in active/pressed/focused/hovered states', (WidgetTester tester) async {
|
||||||
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
||||||
|
addTearDown(() => focusNode.dispose());
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
|
|
||||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||||
@ -1470,8 +1477,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox overlay color resolves in active/pressed/focused/hovered states', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox overlay color resolves in active/pressed/focused/hovered states', (WidgetTester tester) async {
|
||||||
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
||||||
|
addTearDown(() => focusNode.dispose());
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
|
|
||||||
const Color fillColor = Color(0xFF000000);
|
const Color fillColor = Color(0xFF000000);
|
||||||
@ -1606,7 +1614,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Tristate Checkbox overlay color resolves in pressed active/inactive states', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Tristate Checkbox overlay color resolves in pressed active/inactive states', (WidgetTester tester) async {
|
||||||
const Color activePressedOverlayColor = Color(0xFF000001);
|
const Color activePressedOverlayColor = Color(0xFF000001);
|
||||||
const Color inactivePressedOverlayColor = Color(0xFF000002);
|
const Color inactivePressedOverlayColor = Color(0xFF000002);
|
||||||
|
|
||||||
@ -1713,7 +1721,7 @@ void main() {
|
|||||||
await gesture.up();
|
await gesture.up();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Do not crash when widget disappears while pointer is down', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Do not crash when widget disappears while pointer is down', (WidgetTester tester) async {
|
||||||
Widget buildCheckbox(bool show) {
|
Widget buildCheckbox(bool show) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
theme: theme,
|
theme: theme,
|
||||||
@ -1737,7 +1745,7 @@ void main() {
|
|||||||
await gesture.up();
|
await gesture.up();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox BorderSide side only applies when unselected in M2', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox BorderSide side only applies when unselected in M2', (WidgetTester tester) async {
|
||||||
const Color borderColor = Color(0xfff44336);
|
const Color borderColor = Color(0xfff44336);
|
||||||
const Color activeColor = Color(0xff123456);
|
const Color activeColor = Color(0xff123456);
|
||||||
const BorderSide side = BorderSide(
|
const BorderSide side = BorderSide(
|
||||||
@ -1801,7 +1809,7 @@ void main() {
|
|||||||
expect(getCheckboxRenderer(), paints..path(color: activeColor)); // checkbox fill
|
expect(getCheckboxRenderer(), paints..path(color: activeColor)); // checkbox fill
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material2 - Checkbox MaterialStateBorderSide applies unconditionally', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - Checkbox MaterialStateBorderSide applies unconditionally', (WidgetTester tester) async {
|
||||||
const Color borderColor = Color(0xfff44336);
|
const Color borderColor = Color(0xfff44336);
|
||||||
const BorderSide side = BorderSide(
|
const BorderSide side = BorderSide(
|
||||||
width: 4,
|
width: 4,
|
||||||
@ -1855,7 +1863,7 @@ void main() {
|
|||||||
expectBorder();
|
expectBorder();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - Checkbox MaterialStateBorderSide applies unconditionally', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Checkbox MaterialStateBorderSide applies unconditionally', (WidgetTester tester) async {
|
||||||
const Color borderColor = Color(0xfff44336);
|
const Color borderColor = Color(0xfff44336);
|
||||||
const BorderSide side = BorderSide(
|
const BorderSide side = BorderSide(
|
||||||
width: 4,
|
width: 4,
|
||||||
@ -1909,7 +1917,7 @@ void main() {
|
|||||||
expectBorder();
|
expectBorder();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('disabled checkbox shows tooltip', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('disabled checkbox shows tooltip', (WidgetTester tester) async {
|
||||||
const String longPressTooltip = 'long press tooltip';
|
const String longPressTooltip = 'long press tooltip';
|
||||||
const String tapTooltip = 'tap tooltip';
|
const String tapTooltip = 'tap tooltip';
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -1963,8 +1971,9 @@ void main() {
|
|||||||
expect(find.text(tapTooltip), findsOneWidget);
|
expect(find.text(tapTooltip), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - Checkbox has default error color when isError is set to true', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Checkbox has default error color when isError is set to true', (WidgetTester tester) async {
|
||||||
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
||||||
|
addTearDown(() => focusNode.dispose());
|
||||||
final ThemeData themeData = ThemeData(useMaterial3: true);
|
final ThemeData themeData = ThemeData(useMaterial3: true);
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
bool? value = true;
|
bool? value = true;
|
||||||
@ -2035,8 +2044,9 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - Checkbox MaterialStateBorderSide applies in error states', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Checkbox MaterialStateBorderSide applies in error states', (WidgetTester tester) async {
|
||||||
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
|
||||||
|
addTearDown(() => focusNode.dispose());
|
||||||
final ThemeData themeData = ThemeData(useMaterial3: true);
|
final ThemeData themeData = ThemeData(useMaterial3: true);
|
||||||
const Color borderColor = Color(0xffffeb3b);
|
const Color borderColor = Color(0xffffeb3b);
|
||||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
@ -2114,7 +2124,7 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - Checkbox has correct default shape', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Checkbox has correct default shape', (WidgetTester tester) async {
|
||||||
final ThemeData themeData = ThemeData(useMaterial3: true);
|
final ThemeData themeData = ThemeData(useMaterial3: true);
|
||||||
|
|
||||||
Widget buildApp() {
|
Widget buildApp() {
|
||||||
@ -2148,7 +2158,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox.adaptive shows the correct platform widget', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox.adaptive shows the correct platform widget', (WidgetTester tester) async {
|
||||||
Widget buildApp(TargetPlatform platform) {
|
Widget buildApp(TargetPlatform platform) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
theme: ThemeData(platform: platform),
|
theme: ThemeData(platform: platform),
|
||||||
@ -2180,7 +2190,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material2 - Checkbox respects fillColor when it is unchecked', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - Checkbox respects fillColor when it is unchecked', (WidgetTester tester) async {
|
||||||
final ThemeData theme = ThemeData(useMaterial3: false);
|
final ThemeData theme = ThemeData(useMaterial3: false);
|
||||||
const Color activeBackgroundColor = Color(0xff123456);
|
const Color activeBackgroundColor = Color(0xff123456);
|
||||||
const Color inactiveBackgroundColor = Color(0xff654321);
|
const Color inactiveBackgroundColor = Color(0xff654321);
|
||||||
@ -2233,7 +2243,7 @@ void main() {
|
|||||||
expect(getCheckboxRenderer(), paints..path(color: inactiveBackgroundColor));
|
expect(getCheckboxRenderer(), paints..path(color: inactiveBackgroundColor));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - Checkbox respects fillColor when it is unchecked', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Checkbox respects fillColor when it is unchecked', (WidgetTester tester) async {
|
||||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||||
const Color activeBackgroundColor = Color(0xff123456);
|
const Color activeBackgroundColor = Color(0xff123456);
|
||||||
const Color inactiveBackgroundColor = Color(0xff654321);
|
const Color inactiveBackgroundColor = Color(0xff654321);
|
||||||
|
@ -301,7 +301,7 @@ void main() {
|
|||||||
expect(_getCheckboxMaterial(tester), paints..path(color: selectedFillColor));
|
expect(_getCheckboxMaterial(tester), paints..path(color: selectedFillColor));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Checkbox theme overlay color resolves in active/pressed states', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Checkbox theme overlay color resolves in active/pressed states', (WidgetTester tester) async {
|
||||||
const Color activePressedOverlayColor = Color(0xFF000001);
|
const Color activePressedOverlayColor = Color(0xFF000001);
|
||||||
const Color inactivePressedOverlayColor = Color(0xFF000002);
|
const Color inactivePressedOverlayColor = Color(0xFF000002);
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ void main() {
|
|||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('debugCheckHasScaffoldMessenger control test', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('debugCheckHasScaffoldMessenger control test', (WidgetTester tester) async {
|
||||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
||||||
final SnackBar snackBar = SnackBar(
|
final SnackBar snackBar = SnackBar(
|
||||||
|
@ -4,9 +4,10 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('Material3 - Divider control test', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Divider control test', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(useMaterial3: true),
|
theme: ThemeData(useMaterial3: true),
|
||||||
@ -20,7 +21,7 @@ void main() {
|
|||||||
expect(decoration.border!.bottom.width, 1.0);
|
expect(decoration.border!.bottom.width, 1.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material2 - Divider control test', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - Divider control test', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(useMaterial3: false),
|
theme: ThemeData(useMaterial3: false),
|
||||||
@ -34,7 +35,7 @@ void main() {
|
|||||||
expect(decoration.border!.bottom.width, 0.0);
|
expect(decoration.border!.bottom.width, 0.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Divider custom thickness', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Divider custom thickness', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
@ -46,7 +47,7 @@ void main() {
|
|||||||
expect(decoration.border!.bottom.width, 5.0);
|
expect(decoration.border!.bottom.width, 5.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Horizontal divider custom indentation', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Horizontal divider custom indentation', (WidgetTester tester) async {
|
||||||
const double customIndent = 10.0;
|
const double customIndent = 10.0;
|
||||||
Rect dividerRect;
|
Rect dividerRect;
|
||||||
Rect lineRect;
|
Rect lineRect;
|
||||||
@ -91,7 +92,7 @@ void main() {
|
|||||||
expect(lineRect.right, dividerRect.right - customIndent);
|
expect(lineRect.right, dividerRect.right - customIndent);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material3 - Vertical Divider Test', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material3 - Vertical Divider Test', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(useMaterial3: true),
|
theme: ThemeData(useMaterial3: true),
|
||||||
@ -106,7 +107,7 @@ void main() {
|
|||||||
expect(border.left.width, 1.0);
|
expect(border.left.width, 1.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Material2 - Vertical Divider Test', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Material2 - Vertical Divider Test', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(useMaterial3: false),
|
theme: ThemeData(useMaterial3: false),
|
||||||
@ -121,7 +122,7 @@ void main() {
|
|||||||
expect(border.left.width, 0.0);
|
expect(border.left.width, 0.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Divider custom thickness', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Divider custom thickness', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
const Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
@ -134,7 +135,7 @@ void main() {
|
|||||||
expect(border.left.width, 5.0);
|
expect(border.left.width, 5.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Vertical Divider Test 2', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Vertical Divider Test 2', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(useMaterial3: false),
|
theme: ThemeData(useMaterial3: false),
|
||||||
@ -159,7 +160,7 @@ void main() {
|
|||||||
expect(find.byType(VerticalDivider), paints..path(strokeWidth: 0.0));
|
expect(find.byType(VerticalDivider), paints..path(strokeWidth: 0.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Vertical divider custom indentation', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Vertical divider custom indentation', (WidgetTester tester) async {
|
||||||
const double customIndent = 10.0;
|
const double customIndent = 10.0;
|
||||||
Rect dividerRect;
|
Rect dividerRect;
|
||||||
Rect lineRect;
|
Rect lineRect;
|
||||||
@ -205,7 +206,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Regression test for https://github.com/flutter/flutter/issues/39533
|
// Regression test for https://github.com/flutter/flutter/issues/39533
|
||||||
testWidgets('createBorderSide does not throw exception with null context', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('createBorderSide does not throw exception with null context', (WidgetTester tester) async {
|
||||||
// Passing a null context used to throw an exception but no longer does.
|
// Passing a null context used to throw an exception but no longer does.
|
||||||
expect(() => Divider.createBorderSide(null), isNot(throwsAssertionError));
|
expect(() => Divider.createBorderSide(null), isNot(throwsAssertionError));
|
||||||
expect(() => Divider.createBorderSide(null), isNot(throwsNoSuchMethodError));
|
expect(() => Divider.createBorderSide(null), isNot(throwsNoSuchMethodError));
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('DividerThemeData copyWith, ==, hashCode basics', () {
|
test('DividerThemeData copyWith, ==, hashCode basics', () {
|
||||||
@ -21,7 +22,7 @@ void main() {
|
|||||||
expect(dividerTheme.endIndent, null);
|
expect(dividerTheme.endIndent, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Default DividerThemeData debugFillProperties', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Default DividerThemeData debugFillProperties', (WidgetTester tester) async {
|
||||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||||
const DividerThemeData().debugFillProperties(builder);
|
const DividerThemeData().debugFillProperties(builder);
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ void main() {
|
|||||||
expect(description, <String>[]);
|
expect(description, <String>[]);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('DividerThemeData implements debugFillProperties', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('DividerThemeData implements debugFillProperties', (WidgetTester tester) async {
|
||||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||||
const DividerThemeData(
|
const DividerThemeData(
|
||||||
color: Color(0xFFFFFFFF),
|
color: Color(0xFFFFFFFF),
|
||||||
@ -58,7 +59,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
group('Material3 - Horizontal Divider', () {
|
group('Material3 - Horizontal Divider', () {
|
||||||
testWidgets('Passing no DividerThemeData returns defaults', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Passing no DividerThemeData returns defaults', (WidgetTester tester) async {
|
||||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
theme: theme,
|
theme: theme,
|
||||||
@ -82,7 +83,7 @@ void main() {
|
|||||||
expect(lineRect.right, dividerRect.right);
|
expect(lineRect.right, dividerRect.right);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Uses values from DividerThemeData', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Uses values from DividerThemeData', (WidgetTester tester) async {
|
||||||
final DividerThemeData dividerTheme = _dividerTheme();
|
final DividerThemeData dividerTheme = _dividerTheme();
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
theme: ThemeData(useMaterial3: true, dividerTheme: dividerTheme),
|
theme: ThemeData(useMaterial3: true, dividerTheme: dividerTheme),
|
||||||
@ -105,7 +106,7 @@ void main() {
|
|||||||
expect(lineRect.right, dividerRect.right - dividerTheme.endIndent!);
|
expect(lineRect.right, dividerRect.right - dividerTheme.endIndent!);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('DividerTheme overrides defaults', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('DividerTheme overrides defaults', (WidgetTester tester) async {
|
||||||
final DividerThemeData dividerTheme = _dividerTheme();
|
final DividerThemeData dividerTheme = _dividerTheme();
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
theme: ThemeData(useMaterial3: true),
|
theme: ThemeData(useMaterial3: true),
|
||||||
@ -123,7 +124,7 @@ void main() {
|
|||||||
expect(decoration.border!.bottom.color, dividerTheme.color);
|
expect(decoration.border!.bottom.color, dividerTheme.color);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Widget properties take priority over theme', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Widget properties take priority over theme', (WidgetTester tester) async {
|
||||||
const Color color = Colors.purple;
|
const Color color = Colors.purple;
|
||||||
const double height = 10.0;
|
const double height = 10.0;
|
||||||
const double thickness = 5.0;
|
const double thickness = 5.0;
|
||||||
@ -160,7 +161,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
group('Material3 - Vertical Divider', () {
|
group('Material3 - Vertical Divider', () {
|
||||||
testWidgets('Passing no DividerThemeData returns defaults', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Passing no DividerThemeData returns defaults', (WidgetTester tester) async {
|
||||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
theme: theme,
|
theme: theme,
|
||||||
@ -185,7 +186,7 @@ void main() {
|
|||||||
expect(lineRect.bottom, dividerRect.bottom);
|
expect(lineRect.bottom, dividerRect.bottom);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Uses values from DividerThemeData', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Uses values from DividerThemeData', (WidgetTester tester) async {
|
||||||
final DividerThemeData dividerTheme = _dividerTheme();
|
final DividerThemeData dividerTheme = _dividerTheme();
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
theme: ThemeData(dividerTheme: dividerTheme),
|
theme: ThemeData(dividerTheme: dividerTheme),
|
||||||
@ -209,7 +210,7 @@ void main() {
|
|||||||
expect(lineRect.bottom, dividerRect.bottom - dividerTheme.endIndent!);
|
expect(lineRect.bottom, dividerRect.bottom - dividerTheme.endIndent!);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('DividerTheme overrides defaults', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('DividerTheme overrides defaults', (WidgetTester tester) async {
|
||||||
final DividerThemeData dividerTheme = _dividerTheme();
|
final DividerThemeData dividerTheme = _dividerTheme();
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
theme: ThemeData(useMaterial3: true),
|
theme: ThemeData(useMaterial3: true),
|
||||||
@ -228,7 +229,7 @@ void main() {
|
|||||||
expect(border.left.color, dividerTheme.color);
|
expect(border.left.color, dividerTheme.color);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Widget properties take priority over theme', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Widget properties take priority over theme', (WidgetTester tester) async {
|
||||||
const Color color = Colors.purple;
|
const Color color = Colors.purple;
|
||||||
const double width = 10.0;
|
const double width = 10.0;
|
||||||
const double thickness = 5.0;
|
const double thickness = 5.0;
|
||||||
@ -271,7 +272,7 @@ void main() {
|
|||||||
// can be deleted.
|
// can be deleted.
|
||||||
|
|
||||||
group('Material2 - Horizontal Divider', () {
|
group('Material2 - Horizontal Divider', () {
|
||||||
testWidgets('Passing no DividerThemeData returns defaults', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Passing no DividerThemeData returns defaults', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
theme: ThemeData(useMaterial3: false),
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: const Scaffold(
|
home: const Scaffold(
|
||||||
@ -295,7 +296,7 @@ void main() {
|
|||||||
expect(lineRect.right, dividerRect.right);
|
expect(lineRect.right, dividerRect.right);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('DividerTheme overrides defaults', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('DividerTheme overrides defaults', (WidgetTester tester) async {
|
||||||
final DividerThemeData theme = _dividerTheme();
|
final DividerThemeData theme = _dividerTheme();
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
@ -314,7 +315,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
group('Material2 - Vertical Divider', () {
|
group('Material2 - Vertical Divider', () {
|
||||||
testWidgets('Passing no DividerThemeData returns defaults', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Passing no DividerThemeData returns defaults', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
theme: ThemeData(useMaterial3: false),
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: const Scaffold(
|
home: const Scaffold(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user