From 3e9864a50149d9f475902f736680c90e5d531bc0 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Thu, 10 Aug 2023 11:30:46 -0700 Subject: [PATCH 1/3] relax layout test to fix tree --- .ci/flutter_master.version | 2 +- .../example/test/wrap_example_test.dart | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.ci/flutter_master.version b/.ci/flutter_master.version index f21b3ff5628..f3cb739bbec 100644 --- a/.ci/flutter_master.version +++ b/.ci/flutter_master.version @@ -1 +1 @@ -dd9764ec3447018abd5a9f0a6be1c7e4474a99c7 +685141bf3b5ff4a90589fd77784776e011dd5fcc \ No newline at end of file diff --git a/packages/dynamic_layouts/example/test/wrap_example_test.dart b/packages/dynamic_layouts/example/test/wrap_example_test.dart index c517a9e0936..54b8730a1b5 100644 --- a/packages/dynamic_layouts/example/test/wrap_example_test.dart +++ b/packages/dynamic_layouts/example/test/wrap_example_test.dart @@ -8,6 +8,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { + void withinTolerance(Offset actual, Offset expected, double tolerance) { + expect(actual.dx, (double actual) => actual <= expected.dx + tolerance); + expect(actual.dx, (double actual) => actual >= expected.dx - tolerance); + expect(actual.dy, (double actual) => actual <= expected.dy + tolerance); + expect(actual.dy, (double actual) => actual >= expected.dy - tolerance); + } + testWidgets('Check that the children are layed out.', (WidgetTester tester) async { const MaterialApp app = MaterialApp( @@ -39,10 +46,10 @@ void main() { : const Offset(381.0, 224.0); // See if they are in expected position. - expect(tester.getTopLeft(find.text('Index 0')), offset0); - expect(tester.getTopLeft(find.text('Index 1')), offset1); - expect(tester.getTopLeft(find.text('Index 3')), offset3); - expect(tester.getTopLeft(find.text('Index 4')), offset4); + withinTolerance(tester.getTopLeft(find.text('Index 0')), offset0, 0.125); + withinTolerance(tester.getTopLeft(find.text('Index 1')), offset1, 0.125); + withinTolerance(tester.getTopLeft(find.text('Index 3')), offset3, 0.125); + withinTolerance(tester.getTopLeft(find.text('Index 4')), offset4, 0.125); }); } From 28a1b9caad213d0d3484ff885d19e08f446937be Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Thu, 10 Aug 2023 14:15:20 -0700 Subject: [PATCH 2/3] remove web exception --- .../example/test/wrap_example_test.dart | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/dynamic_layouts/example/test/wrap_example_test.dart b/packages/dynamic_layouts/example/test/wrap_example_test.dart index 830a98d71b5..b5f65bc4e4d 100644 --- a/packages/dynamic_layouts/example/test/wrap_example_test.dart +++ b/packages/dynamic_layouts/example/test/wrap_example_test.dart @@ -9,10 +9,26 @@ import 'package:flutter_test/flutter_test.dart'; void main() { void withinTolerance(Offset actual, Offset expected, double tolerance) { - expect(actual.dx, (double actual) => actual <= expected.dx + tolerance); - expect(actual.dx, (double actual) => actual >= expected.dx - tolerance); - expect(actual.dy, (double actual) => actual <= expected.dy + tolerance); - expect(actual.dy, (double actual) => actual >= expected.dy - tolerance); + expect( + actual.dx, + (double actual) => actual <= expected.dx + tolerance, + reason: '${actual.dx} <= ${expected.dx + tolerance}', + ); + expect( + actual.dx, + (double actual) => actual >= expected.dx - tolerance, + reason: '${actual.dx} >= ${expected.dx - tolerance}', + ); + expect( + actual.dy, + (double actual) => actual <= expected.dy + tolerance, + reason: '${actual.dy} <= ${expected.dy + tolerance}', + ); + expect( + actual.dy, + (double actual) => actual >= expected.dy - tolerance, + reason: '${actual.dy} >= ${expected.dy - tolerance}', + ); } testWidgets('Check that the children are layed out.', @@ -54,5 +70,5 @@ void main() { } double _getExpectedYOffset(double nonWeb) { - return kIsWeb ? nonWeb - 0.5 : nonWeb; + return nonWeb; } From b87963f5369a8d7a419a68656b8f74f2a047c16b Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Thu, 10 Aug 2023 14:39:44 -0700 Subject: [PATCH 3/3] clean up --- .../example/test/wrap_example_test.dart | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/packages/dynamic_layouts/example/test/wrap_example_test.dart b/packages/dynamic_layouts/example/test/wrap_example_test.dart index b5f65bc4e4d..0389892be32 100644 --- a/packages/dynamic_layouts/example/test/wrap_example_test.dart +++ b/packages/dynamic_layouts/example/test/wrap_example_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:example/wrap_layout_example.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -48,18 +47,14 @@ void main() { // Material 3 changes the expected layout positioning. final bool usesMaterial3 = (app.theme ?? ThemeData.light()).useMaterial3; - final Offset offset0 = usesMaterial3 - ? Offset(0.0, _getExpectedYOffset(91.0)) - : const Offset(0.0, 103.0); - final Offset offset1 = usesMaterial3 - ? Offset(65.0, _getExpectedYOffset(121.0)) - : const Offset(66.0, 124.0); - final Offset offset3 = usesMaterial3 - ? Offset(270.0, _getExpectedYOffset(171.0)) - : const Offset(271.0, 174.0); - final Offset offset4 = usesMaterial3 - ? Offset(380.0, _getExpectedYOffset(221.0)) - : const Offset(381.0, 224.0); + final Offset offset0 = + usesMaterial3 ? const Offset(0.0, 91.0) : const Offset(0.0, 103.0); + final Offset offset1 = + usesMaterial3 ? const Offset(65.0, 121.0) : const Offset(66.0, 124.0); + final Offset offset3 = + usesMaterial3 ? const Offset(270.0, 171.0) : const Offset(271.0, 174.0); + final Offset offset4 = + usesMaterial3 ? const Offset(380.0, 221.0) : const Offset(381.0, 224.0); // See if they are in expected position. withinTolerance(tester.getTopLeft(find.text('Index 0')), offset0, 0.2); @@ -68,7 +63,3 @@ void main() { withinTolerance(tester.getTopLeft(find.text('Index 4')), offset4, 0.2); }); } - -double _getExpectedYOffset(double nonWeb) { - return nonWeb; -}