From 051d20ae3dec5fc472df3f3849ae500eb81528cf Mon Sep 17 00:00:00 2001 From: pdblasi-google <109253501+pdblasi-google@users.noreply.github.com> Date: Wed, 2 Aug 2023 18:43:07 -0700 Subject: [PATCH] [various] Removed references to deprecated `TestWindow` APIs (#4558) Removed references to deprecated `TestWindow` APIs. Closes [flutter #122912](https://github.com/flutter/flutter/issues/122912) --- .../example/test/staggered_example_test.dart | 10 +-- .../test/staggered_layout_test.dart | 79 ++++++------------- .../test/wrap_layout_test.dart | 8 +- .../integration_test/src/maps_controller.dart | 10 +-- .../integration_test/google_maps_tests.dart | 10 +-- .../google_sign_in/test/widgets_test.dart | 5 +- 6 files changed, 35 insertions(+), 87 deletions(-) diff --git a/packages/dynamic_layouts/example/test/staggered_example_test.dart b/packages/dynamic_layouts/example/test/staggered_example_test.dart index caa6c38aa7..c43b4ff413 100644 --- a/packages/dynamic_layouts/example/test/staggered_example_test.dart +++ b/packages/dynamic_layouts/example/test/staggered_example_test.dart @@ -9,13 +9,9 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('StaggeredExample lays out children correctly', (WidgetTester tester) async { - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.physicalSizeTestValue = const Size(400, 200); - - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatioTestValue = 1.0; + tester.view.physicalSize = const Size(400, 200); + tester.view.devicePixelRatio = 1.0; + addTearDown(tester.view.reset); await tester.pumpWidget( const MaterialApp( diff --git a/packages/dynamic_layouts/test/staggered_layout_test.dart b/packages/dynamic_layouts/test/staggered_layout_test.dart index 622f03aed6..e86b2b4e3d 100644 --- a/packages/dynamic_layouts/test/staggered_layout_test.dart +++ b/packages/dynamic_layouts/test/staggered_layout_test.dart @@ -11,13 +11,9 @@ void main() { testWidgets( 'DynamicGridView works when using DynamicSliverGridDelegateWithFixedCrossAxisCount', (WidgetTester tester) async { - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.physicalSizeTestValue = const Size(400, 100); - - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatioTestValue = 1.0; + tester.view.physicalSize = const Size(400, 100); + tester.view.devicePixelRatio = 1.0; + addTearDown(tester.view.reset); await tester.pumpWidget( MaterialApp( @@ -59,13 +55,9 @@ void main() { testWidgets( 'DynamicGridView works when using DynamicSliverGridDelegateWithMaxCrossAxisExtent', (WidgetTester tester) async { - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.physicalSizeTestValue = const Size(440, 100); - - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatioTestValue = 1.0; + tester.view.physicalSize = const Size(440, 100); + tester.view.devicePixelRatio = 1.0; + addTearDown(tester.view.reset); await tester.pumpWidget( MaterialApp( @@ -106,13 +98,9 @@ void main() { group('DynamicGridView.staggered', () { testWidgets('DynamicGridView.staggered works with simple layout', (WidgetTester tester) async { - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.physicalSizeTestValue = const Size(400, 100); - - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatioTestValue = 1.0; + tester.view.physicalSize = const Size(400, 100); + tester.view.devicePixelRatio = 1.0; + addTearDown(tester.view.reset); await tester.pumpWidget( MaterialApp( @@ -158,13 +146,9 @@ void main() { }); testWidgets('DynamicGridView.staggered works with a horizontal grid', (WidgetTester tester) async { - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.physicalSizeTestValue = const Size(100, 500); - - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatioTestValue = 1.0; + tester.view.physicalSize = const Size(100, 500); + tester.view.devicePixelRatio = 1.0; + addTearDown(tester.view.reset); await tester.pumpWidget( MaterialApp( @@ -216,13 +200,9 @@ void main() { }); testWidgets('DynamicGridView.staggered works with a reversed grid', (WidgetTester tester) async { - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.physicalSizeTestValue = const Size(600, 200); - - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatioTestValue = 1.0; + tester.view.physicalSize = const Size(600, 200); + tester.view.devicePixelRatio = 1.0; + addTearDown(tester.view.reset); await tester.pumpWidget( MaterialApp( @@ -290,13 +270,10 @@ void main() { testWidgets('DynamicGridView.staggered deletes children appropriately', (WidgetTester tester) async { - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.physicalSizeTestValue = const Size(600, 1000); + tester.view.physicalSize = const Size(600, 1000); + tester.view.devicePixelRatio = 1.0; + addTearDown(tester.view.reset); - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatioTestValue = 1.0; final List children = List.generate( 50, (int index) => SizedBox( @@ -375,13 +352,9 @@ void main() { group('DynamicGridView.builder', () { testWidgets('DynamicGridView.builder works with a staggered layout', (WidgetTester tester) async { - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.physicalSizeTestValue = const Size(400, 100); - - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatioTestValue = 1.0; + tester.view.physicalSize = const Size(400, 100); + tester.view.devicePixelRatio = 1.0; + addTearDown(tester.view.reset); await tester.pumpWidget( MaterialApp( @@ -430,13 +403,9 @@ void main() { testWidgets( 'DynamicGridView.builder works with an infinite grid using a staggered layout', (WidgetTester tester) async { - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.physicalSizeTestValue = const Size(400, 100); - - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatioTestValue = 1.0; + tester.view.physicalSize = const Size(400, 100); + tester.view.devicePixelRatio = 1.0; + addTearDown(tester.view.reset); await tester.pumpWidget( MaterialApp( diff --git a/packages/dynamic_layouts/test/wrap_layout_test.dart b/packages/dynamic_layouts/test/wrap_layout_test.dart index 1b0f7958c9..31daa8b347 100644 --- a/packages/dynamic_layouts/test/wrap_layout_test.dart +++ b/packages/dynamic_layouts/test/wrap_layout_test.dart @@ -508,9 +508,7 @@ void main() { expect(find.text('Item 4'), findsNothing); await tester.binding.setSurfaceSize(const Size(280, 100)); // resets the screen to its original size after the test end - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - addTearDown(tester.binding.window.clearPhysicalSizeTestValue); + addTearDown(tester.view.resetPhysicalSize); await tester.pumpAndSettle(); expect(find.text('Item 0'), findsOneWidget); expect(find.text('Item 1'), findsOneWidget); @@ -572,9 +570,7 @@ void main() { await tester.binding.setSurfaceSize(const Size(560, 100)); // resets the screen to its original size after the test end - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - addTearDown(tester.binding.window.clearPhysicalSizeTestValue); + addTearDown(tester.view.resetPhysicalSize); await tester.pumpAndSettle(); expect(find.text('Item 0'), findsOneWidget); diff --git a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart index 7b056b0d37..98ea6d932b 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart @@ -58,17 +58,11 @@ void runTests() { } else { expect( coordinate.x, - ((rect.center.dx - rect.topLeft.dx) * - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatio) + ((rect.center.dx - rect.topLeft.dx) * tester.view.devicePixelRatio) .round()); expect( coordinate.y, - ((rect.center.dy - rect.topLeft.dy) * - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatio) + ((rect.center.dy - rect.topLeft.dy) * tester.view.devicePixelRatio) .round()); } await tester.binding.setSurfaceSize(null); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart index 7c400434a3..a0a9d3049c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart @@ -470,17 +470,11 @@ void googleMapsTests() { final Rect rect = tester.getRect(find.byKey(key)); expect( coordinate.x, - ((rect.center.dx - rect.topLeft.dx) * - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatio) + ((rect.center.dx - rect.topLeft.dx) * tester.view.devicePixelRatio) .round()); expect( coordinate.y, - ((rect.center.dy - rect.topLeft.dy) * - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.devicePixelRatio) + ((rect.center.dy - rect.topLeft.dy) * tester.view.devicePixelRatio) .round()); await tester.binding.setSurfaceSize(null); }); diff --git a/packages/google_sign_in/google_sign_in/test/widgets_test.dart b/packages/google_sign_in/google_sign_in/test/widgets_test.dart index 5b4721114f..717edc3699 100644 --- a/packages/google_sign_in/google_sign_in/test/widgets_test.dart +++ b/packages/google_sign_in/google_sign_in/test/widgets_test.dart @@ -101,9 +101,8 @@ void main() { photoUrl: 'photoUrl', ); - // TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912 - // ignore: deprecated_member_use - tester.binding.window.physicalSizeTestValue = const Size(100, 100); + tester.view.physicalSize = const Size(100, 100); + addTearDown(tester.view.reset); await HttpOverrides.runZoned( () async {