[various] Removed references to deprecated TestWindow APIs (#4558)

Removed references to deprecated `TestWindow` APIs.

Closes [flutter #122912](https://github.com/flutter/flutter/issues/122912)
This commit is contained in:
pdblasi-google
2023-08-02 18:43:07 -07:00
committed by GitHub
parent f24d5ba3a8
commit 051d20ae3d
6 changed files with 35 additions and 87 deletions

View File

@ -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(

View File

@ -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<Widget> children = List<Widget>.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(

View File

@ -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);

View File

@ -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);

View File

@ -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);
});

View File

@ -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 {