Skip to content

Commit

Permalink
Updates flutter/test/cupertino to no longer use TestWindow (#122325)
Browse files Browse the repository at this point in the history
Updates `flutter/test/cupertino` to no longer use `TestWindow`
  • Loading branch information
pdblasi-google authored Mar 9, 2023
1 parent 57171a3 commit 67e17e4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/flutter/test/cupertino/scrollbar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void main() {

const double inset = 3;
const double scaleFactor = 2;
final Size screenSize = tester.binding.window.physicalSize / tester.binding.window.devicePixelRatio;
final Size screenSize = tester.view.physicalSize / tester.view.devicePixelRatio;

final ScrollController scrollController = ScrollController();
await tester.pumpWidget(
Expand Down
34 changes: 13 additions & 21 deletions packages/flutter/test/cupertino/text_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// no-shuffle:
// //TODO(gspencergoog): Remove this tag once this test's state leaks/test
// dependencies have been fixed.
// https://github.com/flutter/flutter/issues/85160
// Fails with "flutter test --test-randomize-ordering-seed=456"
// reduced-test-set:
// This file is run as part of a reduced test set in CI on Mac and Windows
// machines.
@Tags(<String>['reduced-test-set', 'no-shuffle'])
@Tags(<String>['reduced-test-set'])
library;

import 'dart:ui' as ui show BoxHeightStyle, BoxWidthStyle, Color;
Expand Down Expand Up @@ -5003,9 +4998,11 @@ void main() {

group('Text selection toolbar', () {
testWidgets('Collapsed selection works', (WidgetTester tester) async {
tester.view.physicalSize = const Size(400, 400);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);

EditableText.debugDeterministicCursor = true;
tester.binding.window.physicalSizeTestValue = const Size(400, 400);
tester.binding.window.devicePixelRatioTestValue = 1;
TextEditingController controller;
EditableTextState state;
Offset bottomLeftSelectionPosition;
Expand Down Expand Up @@ -5183,15 +5180,14 @@ void main() {
),
),
);

tester.binding.window.clearPhysicalSizeTestValue();
tester.binding.window.clearDevicePixelRatioTestValue();
});

testWidgets('selecting multiple words works', (WidgetTester tester) async {
tester.view.physicalSize = const Size(400, 400);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);

EditableText.debugDeterministicCursor = true;
tester.binding.window.physicalSizeTestValue = const Size(400, 400);
tester.binding.window.devicePixelRatioTestValue = 1;
final TextEditingController controller;
final EditableTextState state;

Expand Down Expand Up @@ -5253,15 +5249,14 @@ void main() {
),
),
);

tester.binding.window.clearPhysicalSizeTestValue();
tester.binding.window.clearDevicePixelRatioTestValue();
});

testWidgets('selecting multiline works', (WidgetTester tester) async {
tester.view.physicalSize = const Size(400, 400);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);

EditableText.debugDeterministicCursor = true;
tester.binding.window.physicalSizeTestValue = const Size(400, 400);
tester.binding.window.devicePixelRatioTestValue = 1;
final TextEditingController controller;
final EditableTextState state;

Expand Down Expand Up @@ -5327,9 +5322,6 @@ void main() {
),
),
);

tester.binding.window.clearPhysicalSizeTestValue();
tester.binding.window.clearDevicePixelRatioTestValue();
});

// This is a regression test for
Expand Down
8 changes: 4 additions & 4 deletions packages/flutter/test/cupertino/text_selection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ void main() {

testWidgets("When a menu item doesn't fit, a second page is used.", (WidgetTester tester) async {
// Set the screen size to more narrow, so that Paste can't fit.
tester.binding.window.physicalSizeTestValue = const Size(800, 800);
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
tester.view.physicalSize = const Size(800, 800);
addTearDown(tester.view.reset);

final TextEditingController controller = TextEditingController(text: 'abc def ghi');
await tester.pumpWidget(CupertinoApp(
Expand Down Expand Up @@ -318,8 +318,8 @@ void main() {
testWidgets('A smaller menu puts each button on its own page.', (WidgetTester tester) async {
// Set the screen size to more narrow, so that two buttons can't fit on
// the same page.
tester.binding.window.physicalSizeTestValue = const Size(640, 800);
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
tester.view.physicalSize = const Size(640, 800);
addTearDown(tester.view.reset);

final TextEditingController controller = TextEditingController(text: 'abc def ghi');
await tester.pumpWidget(CupertinoApp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ void main() {

testWidgets('does not paginate if children fit with zero margin', (WidgetTester tester) async {
final List<Widget> children = List<Widget>.generate(7, (int i) => const TestBox());
final double spacerWidth = 1.0 / tester.binding.window.devicePixelRatio;
final double dividerWidth = 1.0 / tester.binding.window.devicePixelRatio;
final double spacerWidth = 1.0 / tester.view.devicePixelRatio;
final double dividerWidth = 1.0 / tester.view.devicePixelRatio;
const double borderRadius = 8.0; // Should match _kToolbarBorderRadius
final double width = 7 * TestBox.itemWidth + 6 * (dividerWidth + 2 * spacerWidth) + 2 * borderRadius;
await tester.pumpWidget(
Expand Down

0 comments on commit 67e17e4

Please sign in to comment.