Unverified Commit 0367d4f5 authored by Darren Austin's avatar Darren Austin Committed by GitHub

Fix test lifecycle clean up for screen size and semantics. (#62761)

parent 26f976f5
...@@ -884,6 +884,7 @@ void main() { ...@@ -884,6 +884,7 @@ void main() {
group('Semantics', () { group('Semantics', () {
testWidgets('calendar day mode', (WidgetTester tester) async { testWidgets('calendar day mode', (WidgetTester tester) async {
final SemanticsHandle semantics = tester.ensureSemantics(); final SemanticsHandle semantics = tester.ensureSemantics();
addTearDown(semantics.dispose);
await prepareDatePicker(tester, (Future<DateTime> date) async { await prepareDatePicker(tester, (Future<DateTime> date) async {
// Header // Header
...@@ -1096,12 +1097,11 @@ void main() { ...@@ -1096,12 +1097,11 @@ void main() {
isFocusable: true, isFocusable: true,
)); ));
}); });
semantics.dispose();
}); });
testWidgets('calendar year mode', (WidgetTester tester) async { testWidgets('calendar year mode', (WidgetTester tester) async {
final SemanticsHandle semantics = tester.ensureSemantics(); final SemanticsHandle semantics = tester.ensureSemantics();
addTearDown(semantics.dispose);
initialCalendarMode = DatePickerMode.year; initialCalendarMode = DatePickerMode.year;
await prepareDatePicker(tester, (Future<DateTime> date) async { await prepareDatePicker(tester, (Future<DateTime> date) async {
...@@ -1153,14 +1153,12 @@ void main() { ...@@ -1153,14 +1153,12 @@ void main() {
hasEnabledState: true, hasEnabledState: true,
isFocusable: true, isFocusable: true,
)); ));
}); });
semantics.dispose();
}); });
testWidgets('input mode', (WidgetTester tester) async { testWidgets('input mode', (WidgetTester tester) async {
final SemanticsHandle semantics = tester.ensureSemantics(); final SemanticsHandle semantics = tester.ensureSemantics();
addTearDown(semantics.dispose);
initialEntryMode = DatePickerEntryMode.input; initialEntryMode = DatePickerEntryMode.input;
await prepareDatePicker(tester, (Future<DateTime> date) async { await prepareDatePicker(tester, (Future<DateTime> date) async {
...@@ -1211,10 +1209,7 @@ void main() { ...@@ -1211,10 +1209,7 @@ void main() {
hasEnabledState: true, hasEnabledState: true,
isFocusable: true, isFocusable: true,
)); ));
}); });
semantics.dispose();
}); });
}); });
...@@ -1416,9 +1411,9 @@ void main() { ...@@ -1416,9 +1411,9 @@ void main() {
Future<void> _showPicker(WidgetTester tester, Size size, [double textScaleFactor = 1.0]) async { Future<void> _showPicker(WidgetTester tester, Size size, [double textScaleFactor = 1.0]) async {
tester.binding.window.physicalSizeTestValue = size; tester.binding.window.physicalSizeTestValue = size;
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
tester.binding.window.devicePixelRatioTestValue = 1.0; tester.binding.window.devicePixelRatioTestValue = 1.0;
tester.binding.window.clearPhysicalSizeTestValue(); addTearDown(tester.binding.window.clearDevicePixelRatioTestValue);
tester.binding.window.clearDevicePixelRatioTestValue();
await prepareDatePicker(tester, (Future<DateTime> date) async { await prepareDatePicker(tester, (Future<DateTime> date) async {
await tester.tap(find.text('OK')); await tester.tap(find.text('OK'));
}); });
......
...@@ -232,7 +232,9 @@ void main() { ...@@ -232,7 +232,9 @@ void main() {
Future<void> _showPicker(WidgetTester tester, Locale locale, Size size) async { Future<void> _showPicker(WidgetTester tester, Locale locale, Size size) async {
tester.binding.window.physicalSizeTestValue = size; tester.binding.window.physicalSizeTestValue = size;
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
tester.binding.window.devicePixelRatioTestValue = 1.0; tester.binding.window.devicePixelRatioTestValue = 1.0;
addTearDown(tester.binding.window.clearDevicePixelRatioTestValue);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Builder( home: Builder(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment