Skip to content

Commit 051d20a

Browse files
[various] Removed references to deprecated TestWindow APIs (#4558)
Removed references to deprecated `TestWindow` APIs. Closes [flutter #122912](flutter/flutter#122912)
1 parent f24d5ba commit 051d20a

File tree

6 files changed

+35
-87
lines changed

6 files changed

+35
-87
lines changed

packages/dynamic_layouts/example/test/staggered_example_test.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@ import 'package:flutter_test/flutter_test.dart';
99
void main() {
1010
testWidgets('StaggeredExample lays out children correctly',
1111
(WidgetTester tester) async {
12-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
13-
// ignore: deprecated_member_use
14-
tester.binding.window.physicalSizeTestValue = const Size(400, 200);
15-
16-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
17-
// ignore: deprecated_member_use
18-
tester.binding.window.devicePixelRatioTestValue = 1.0;
12+
tester.view.physicalSize = const Size(400, 200);
13+
tester.view.devicePixelRatio = 1.0;
14+
addTearDown(tester.view.reset);
1915

2016
await tester.pumpWidget(
2117
const MaterialApp(

packages/dynamic_layouts/test/staggered_layout_test.dart

Lines changed: 24 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ void main() {
1111
testWidgets(
1212
'DynamicGridView works when using DynamicSliverGridDelegateWithFixedCrossAxisCount',
1313
(WidgetTester tester) async {
14-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
15-
// ignore: deprecated_member_use
16-
tester.binding.window.physicalSizeTestValue = const Size(400, 100);
17-
18-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
19-
// ignore: deprecated_member_use
20-
tester.binding.window.devicePixelRatioTestValue = 1.0;
14+
tester.view.physicalSize = const Size(400, 100);
15+
tester.view.devicePixelRatio = 1.0;
16+
addTearDown(tester.view.reset);
2117

2218
await tester.pumpWidget(
2319
MaterialApp(
@@ -59,13 +55,9 @@ void main() {
5955
testWidgets(
6056
'DynamicGridView works when using DynamicSliverGridDelegateWithMaxCrossAxisExtent',
6157
(WidgetTester tester) async {
62-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
63-
// ignore: deprecated_member_use
64-
tester.binding.window.physicalSizeTestValue = const Size(440, 100);
65-
66-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
67-
// ignore: deprecated_member_use
68-
tester.binding.window.devicePixelRatioTestValue = 1.0;
58+
tester.view.physicalSize = const Size(440, 100);
59+
tester.view.devicePixelRatio = 1.0;
60+
addTearDown(tester.view.reset);
6961

7062
await tester.pumpWidget(
7163
MaterialApp(
@@ -106,13 +98,9 @@ void main() {
10698
group('DynamicGridView.staggered', () {
10799
testWidgets('DynamicGridView.staggered works with simple layout',
108100
(WidgetTester tester) async {
109-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
110-
// ignore: deprecated_member_use
111-
tester.binding.window.physicalSizeTestValue = const Size(400, 100);
112-
113-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
114-
// ignore: deprecated_member_use
115-
tester.binding.window.devicePixelRatioTestValue = 1.0;
101+
tester.view.physicalSize = const Size(400, 100);
102+
tester.view.devicePixelRatio = 1.0;
103+
addTearDown(tester.view.reset);
116104

117105
await tester.pumpWidget(
118106
MaterialApp(
@@ -158,13 +146,9 @@ void main() {
158146
});
159147
testWidgets('DynamicGridView.staggered works with a horizontal grid',
160148
(WidgetTester tester) async {
161-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
162-
// ignore: deprecated_member_use
163-
tester.binding.window.physicalSizeTestValue = const Size(100, 500);
164-
165-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
166-
// ignore: deprecated_member_use
167-
tester.binding.window.devicePixelRatioTestValue = 1.0;
149+
tester.view.physicalSize = const Size(100, 500);
150+
tester.view.devicePixelRatio = 1.0;
151+
addTearDown(tester.view.reset);
168152

169153
await tester.pumpWidget(
170154
MaterialApp(
@@ -216,13 +200,9 @@ void main() {
216200
});
217201
testWidgets('DynamicGridView.staggered works with a reversed grid',
218202
(WidgetTester tester) async {
219-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
220-
// ignore: deprecated_member_use
221-
tester.binding.window.physicalSizeTestValue = const Size(600, 200);
222-
223-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
224-
// ignore: deprecated_member_use
225-
tester.binding.window.devicePixelRatioTestValue = 1.0;
203+
tester.view.physicalSize = const Size(600, 200);
204+
tester.view.devicePixelRatio = 1.0;
205+
addTearDown(tester.view.reset);
226206

227207
await tester.pumpWidget(
228208
MaterialApp(
@@ -290,13 +270,10 @@ void main() {
290270

291271
testWidgets('DynamicGridView.staggered deletes children appropriately',
292272
(WidgetTester tester) async {
293-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
294-
// ignore: deprecated_member_use
295-
tester.binding.window.physicalSizeTestValue = const Size(600, 1000);
273+
tester.view.physicalSize = const Size(600, 1000);
274+
tester.view.devicePixelRatio = 1.0;
275+
addTearDown(tester.view.reset);
296276

297-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
298-
// ignore: deprecated_member_use
299-
tester.binding.window.devicePixelRatioTestValue = 1.0;
300277
final List<Widget> children = List<Widget>.generate(
301278
50,
302279
(int index) => SizedBox(
@@ -375,13 +352,9 @@ void main() {
375352
group('DynamicGridView.builder', () {
376353
testWidgets('DynamicGridView.builder works with a staggered layout',
377354
(WidgetTester tester) async {
378-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
379-
// ignore: deprecated_member_use
380-
tester.binding.window.physicalSizeTestValue = const Size(400, 100);
381-
382-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
383-
// ignore: deprecated_member_use
384-
tester.binding.window.devicePixelRatioTestValue = 1.0;
355+
tester.view.physicalSize = const Size(400, 100);
356+
tester.view.devicePixelRatio = 1.0;
357+
addTearDown(tester.view.reset);
385358

386359
await tester.pumpWidget(
387360
MaterialApp(
@@ -430,13 +403,9 @@ void main() {
430403
testWidgets(
431404
'DynamicGridView.builder works with an infinite grid using a staggered layout',
432405
(WidgetTester tester) async {
433-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
434-
// ignore: deprecated_member_use
435-
tester.binding.window.physicalSizeTestValue = const Size(400, 100);
436-
437-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
438-
// ignore: deprecated_member_use
439-
tester.binding.window.devicePixelRatioTestValue = 1.0;
406+
tester.view.physicalSize = const Size(400, 100);
407+
tester.view.devicePixelRatio = 1.0;
408+
addTearDown(tester.view.reset);
440409

441410
await tester.pumpWidget(
442411
MaterialApp(

packages/dynamic_layouts/test/wrap_layout_test.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,7 @@ void main() {
508508
expect(find.text('Item 4'), findsNothing);
509509
await tester.binding.setSurfaceSize(const Size(280, 100));
510510
// resets the screen to its original size after the test end
511-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
512-
// ignore: deprecated_member_use
513-
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
511+
addTearDown(tester.view.resetPhysicalSize);
514512
await tester.pumpAndSettle();
515513
expect(find.text('Item 0'), findsOneWidget);
516514
expect(find.text('Item 1'), findsOneWidget);
@@ -572,9 +570,7 @@ void main() {
572570

573571
await tester.binding.setSurfaceSize(const Size(560, 100));
574572
// resets the screen to its original size after the test end
575-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
576-
// ignore: deprecated_member_use
577-
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
573+
addTearDown(tester.view.resetPhysicalSize);
578574
await tester.pumpAndSettle();
579575

580576
expect(find.text('Item 0'), findsOneWidget);

packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,11 @@ void runTests() {
5858
} else {
5959
expect(
6060
coordinate.x,
61-
((rect.center.dx - rect.topLeft.dx) *
62-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
63-
// ignore: deprecated_member_use
64-
tester.binding.window.devicePixelRatio)
61+
((rect.center.dx - rect.topLeft.dx) * tester.view.devicePixelRatio)
6562
.round());
6663
expect(
6764
coordinate.y,
68-
((rect.center.dy - rect.topLeft.dy) *
69-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
70-
// ignore: deprecated_member_use
71-
tester.binding.window.devicePixelRatio)
65+
((rect.center.dy - rect.topLeft.dy) * tester.view.devicePixelRatio)
7266
.round());
7367
}
7468
await tester.binding.setSurfaceSize(null);

packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -470,17 +470,11 @@ void googleMapsTests() {
470470
final Rect rect = tester.getRect(find.byKey(key));
471471
expect(
472472
coordinate.x,
473-
((rect.center.dx - rect.topLeft.dx) *
474-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
475-
// ignore: deprecated_member_use
476-
tester.binding.window.devicePixelRatio)
473+
((rect.center.dx - rect.topLeft.dx) * tester.view.devicePixelRatio)
477474
.round());
478475
expect(
479476
coordinate.y,
480-
((rect.center.dy - rect.topLeft.dy) *
481-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
482-
// ignore: deprecated_member_use
483-
tester.binding.window.devicePixelRatio)
477+
((rect.center.dy - rect.topLeft.dy) * tester.view.devicePixelRatio)
484478
.round());
485479
await tester.binding.setSurfaceSize(null);
486480
});

packages/google_sign_in/google_sign_in/test/widgets_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,8 @@ void main() {
101101
photoUrl: 'photoUrl',
102102
);
103103

104-
// TODO(pdblasi-google): Update `window` usages to new API after 3.9.0 is in stable. https://github.com/flutter/flutter/issues/122912
105-
// ignore: deprecated_member_use
106-
tester.binding.window.physicalSizeTestValue = const Size(100, 100);
104+
tester.view.physicalSize = const Size(100, 100);
105+
addTearDown(tester.view.reset);
107106

108107
await HttpOverrides.runZoned(
109108
() async {

0 commit comments

Comments
 (0)