Unverified Commit 846fcefd authored by Greg Price's avatar Greg Price Committed by GitHub

Fix surface-size state leak in material/paginated_data_table_test (framework...

Fix surface-size state leak in material/paginated_data_table_test (framework shuffle-all 3/n) (#123842)

Fix surface-size state leak in material/paginated_data_table_test (framework shuffle-all 3/n)
parent bf98fcf7
...@@ -2,13 +2,6 @@ ...@@ -2,13 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// 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=1000"
@Tags(<String>['no-shuffle'])
library;
import 'package:flutter/gestures.dart' show DragStartBehavior; import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -845,6 +838,7 @@ void main() { ...@@ -845,6 +838,7 @@ void main() {
testWidgets('PaginatedDataTable with optional column checkbox', (WidgetTester tester) async { testWidgets('PaginatedDataTable with optional column checkbox', (WidgetTester tester) async {
await binding.setSurfaceSize(const Size(800, 800)); await binding.setSurfaceSize(const Size(800, 800));
addTearDown(() => binding.setSurfaceSize(null));
Widget buildTable(bool checkbox) => MaterialApp( Widget buildTable(bool checkbox) => MaterialApp(
home: PaginatedDataTable( home: PaginatedDataTable(
...@@ -1004,6 +998,7 @@ void main() { ...@@ -1004,6 +998,7 @@ void main() {
testWidgets('PaginatedDataTable arrowHeadColor set properly', (WidgetTester tester) async { testWidgets('PaginatedDataTable arrowHeadColor set properly', (WidgetTester tester) async {
await binding.setSurfaceSize(const Size(800, 800)); await binding.setSurfaceSize(const Size(800, 800));
addTearDown(() => binding.setSurfaceSize(null));
const Color arrowHeadColor = Color(0xFFE53935); const Color arrowHeadColor = Color(0xFFE53935);
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -505,6 +505,17 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -505,6 +505,17 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// then flushes microtasks. /// then flushes microtasks.
/// ///
/// Set to null to use the default surface size. /// Set to null to use the default surface size.
///
/// To avoid affecting other tests by leaking state, a test that
/// uses this method should always reset the surface size to the default.
/// For example, using `addTearDown`:
/// ```dart
/// await binding.setSurfaceSize(someSize);
/// addTearDown(() => binding.setSurfaceSize(null));
/// ```
///
/// See also [TestFlutterView.physicalSize], which has a similar effect.
// TODO(pdblasi-google): Deprecate this. https://github.com/flutter/flutter/issues/123881
Future<void> setSurfaceSize(Size? size) { Future<void> setSurfaceSize(Size? size) {
return TestAsyncUtils.guard<void>(() async { return TestAsyncUtils.guard<void>(() async {
assert(inTest); assert(inTest);
......
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