Unverified Commit c0ea00ed authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Prefer moreOrLessEquals over closeTo (#64915)

Flutter's `moreOrLessEquals` has a few advantages over `closeTo` from
the `matcher` package:

   * It emits the epsilon value in the test result on failure.
   * It uses a named parameter for epsilon, which improves readability
     at the call site.
   * It has a reasonable default for epsilon in cases where something
     more specific isn't required.

Using it also has the nice property that it aids in its own discovery
when when people go looking for such functionality in new tests.

This change also includes a couple unrelated whitespace formatting cleanups.
parent fd22fc3e
...@@ -261,17 +261,19 @@ void main() { ...@@ -261,17 +261,19 @@ void main() {
startHandle: const Offset(0.0, -0.3), startHandle: const Offset(0.0, -0.3),
endHandle: const Offset(1.3, 1.3), endHandle: const Offset(1.3, 1.3),
); );
expect(curve.transform(0.0).dx, closeTo(0.0, 1e-6)); const double tolerance = 1e-6;
expect(curve.transform(0.0).dy, closeTo(0.0, 1e-6)); expect(curve.transform(0.0).dx, moreOrLessEquals(0.0, epsilon: tolerance));
expect(curve.transform(0.25).dx, closeTo(0.0966945, 1e-6)); expect(curve.transform(0.0).dy, moreOrLessEquals(0.0, epsilon: tolerance));
expect(curve.transform(0.25).dy, closeTo(0.2626806, 1e-6)); expect(curve.transform(0.25).dx, moreOrLessEquals(0.0966945, epsilon: tolerance));
expect(curve.transform(0.5).dx, closeTo(0.33, 1e-6)); expect(curve.transform(0.25).dy, moreOrLessEquals(0.2626806, epsilon: tolerance));
expect(curve.transform(0.5).dy, closeTo(0.25, 1e-6)); expect(curve.transform(0.5).dx, moreOrLessEquals(0.33, epsilon: tolerance));
expect(curve.transform(0.75).dx, closeTo(0.570260, 1e-6)); expect(curve.transform(0.5).dy, moreOrLessEquals(0.25, epsilon: tolerance));
expect(curve.transform(0.75).dy, closeTo(0.883085, 1e-6)); expect(curve.transform(0.75).dx, moreOrLessEquals(0.570260, epsilon: tolerance));
expect(curve.transform(1.0).dx, closeTo(1.0, 1e-6)); expect(curve.transform(0.75).dy, moreOrLessEquals(0.883085, epsilon: tolerance));
expect(curve.transform(1.0).dy, closeTo(1.0, 1e-6)); expect(curve.transform(1.0).dx, moreOrLessEquals(1.0, epsilon: tolerance));
expect(curve.transform(1.0).dy, moreOrLessEquals(1.0, epsilon: tolerance));
}); });
test('CatmullRomSpline enforces contract', () { test('CatmullRomSpline enforces contract', () {
expect(() { expect(() {
CatmullRomSpline(null); CatmullRomSpline(null);
...@@ -295,6 +297,7 @@ void main() { ...@@ -295,6 +297,7 @@ void main() {
CatmullRomSpline(const <Offset>[Offset.zero, Offset.zero, Offset.zero, Offset.zero], tension: 2.0); CatmullRomSpline(const <Offset>[Offset.zero, Offset.zero, Offset.zero, Offset.zero], tension: 2.0);
}, throwsAssertionError); }, throwsAssertionError);
}); });
test('CatmullRomSpline interpolates values properly when precomputed', () { test('CatmullRomSpline interpolates values properly when precomputed', () {
final CatmullRomSpline curve = CatmullRomSpline.precompute( final CatmullRomSpline curve = CatmullRomSpline.precompute(
const <Offset>[ const <Offset>[
...@@ -310,17 +313,19 @@ void main() { ...@@ -310,17 +313,19 @@ void main() {
startHandle: const Offset(0.0, -0.3), startHandle: const Offset(0.0, -0.3),
endHandle: const Offset(1.3, 1.3), endHandle: const Offset(1.3, 1.3),
); );
expect(curve.transform(0.0).dx, closeTo(0.0, 1e-6)); const double tolerance = 1e-6;
expect(curve.transform(0.0).dy, closeTo(0.0, 1e-6)); expect(curve.transform(0.0).dx, moreOrLessEquals(0.0, epsilon: tolerance));
expect(curve.transform(0.25).dx, closeTo(0.0966945, 1e-6)); expect(curve.transform(0.0).dy, moreOrLessEquals(0.0, epsilon: tolerance));
expect(curve.transform(0.25).dy, closeTo(0.2626806, 1e-6)); expect(curve.transform(0.25).dx, moreOrLessEquals(0.0966945, epsilon: tolerance));
expect(curve.transform(0.5).dx, closeTo(0.33, 1e-6)); expect(curve.transform(0.25).dy, moreOrLessEquals(0.2626806, epsilon: tolerance));
expect(curve.transform(0.5).dy, closeTo(0.25, 1e-6)); expect(curve.transform(0.5).dx, moreOrLessEquals(0.33, epsilon: tolerance));
expect(curve.transform(0.75).dx, closeTo(0.570260, 1e-6)); expect(curve.transform(0.5).dy, moreOrLessEquals(0.25, epsilon: tolerance));
expect(curve.transform(0.75).dy, closeTo(0.883085, 1e-6)); expect(curve.transform(0.75).dx, moreOrLessEquals(0.570260, epsilon: tolerance));
expect(curve.transform(1.0).dx, closeTo(1.0, 1e-6)); expect(curve.transform(0.75).dy, moreOrLessEquals(0.883085, epsilon: tolerance));
expect(curve.transform(1.0).dy, closeTo(1.0, 1e-6)); expect(curve.transform(1.0).dx, moreOrLessEquals(1.0, epsilon: tolerance));
expect(curve.transform(1.0).dy, moreOrLessEquals(1.0, epsilon: tolerance));
}); });
test('CatmullRomSpline enforces contract when precomputed', () { test('CatmullRomSpline enforces contract when precomputed', () {
expect(() { expect(() {
CatmullRomSpline.precompute(null); CatmullRomSpline.precompute(null);
...@@ -344,6 +349,7 @@ void main() { ...@@ -344,6 +349,7 @@ void main() {
CatmullRomSpline.precompute(const <Offset>[Offset.zero, Offset.zero, Offset.zero, Offset.zero], tension: 2.0); CatmullRomSpline.precompute(const <Offset>[Offset.zero, Offset.zero, Offset.zero, Offset.zero], tension: 2.0);
}, throwsAssertionError); }, throwsAssertionError);
}); });
test('CatmullRomCurve interpolates given points correctly', () { test('CatmullRomCurve interpolates given points correctly', () {
final CatmullRomCurve curve = CatmullRomCurve( final CatmullRomCurve curve = CatmullRomCurve(
const <Offset>[ const <Offset>[
...@@ -356,15 +362,16 @@ void main() { ...@@ -356,15 +362,16 @@ void main() {
// These values are approximations. // These values are approximations.
const double tolerance = 1e-6; const double tolerance = 1e-6;
expect(curve.transform(0.0), closeTo(0.0, tolerance)); expect(curve.transform(0.0), moreOrLessEquals(0.0, epsilon: tolerance));
expect(curve.transform(0.01), closeTo(0.012874734350170863, tolerance)); expect(curve.transform(0.01), moreOrLessEquals(0.012874734350170863, epsilon: tolerance));
expect(curve.transform(0.2), closeTo(0.24989646045277542, tolerance)); expect(curve.transform(0.2), moreOrLessEquals(0.24989646045277542, epsilon: tolerance));
expect(curve.transform(0.33), closeTo(0.250037698527661, tolerance)); expect(curve.transform(0.33), moreOrLessEquals(0.250037698527661, epsilon: tolerance));
expect(curve.transform(0.5), closeTo(0.9999057323235939, tolerance)); expect(curve.transform(0.5), moreOrLessEquals(0.9999057323235939, epsilon: tolerance));
expect(curve.transform(0.6), closeTo(0.9357294964536621, tolerance)); expect(curve.transform(0.6), moreOrLessEquals(0.9357294964536621, epsilon: tolerance));
expect(curve.transform(0.8), closeTo(0.7500423402378034, tolerance)); expect(curve.transform(0.8), moreOrLessEquals(0.7500423402378034, epsilon: tolerance));
expect(curve.transform(1.0), closeTo(1.0, tolerance)); expect(curve.transform(1.0), moreOrLessEquals(1.0, epsilon: tolerance));
}); });
test('CatmullRomCurve interpolates given points correctly when precomputed', () { test('CatmullRomCurve interpolates given points correctly when precomputed', () {
final CatmullRomCurve curve = CatmullRomCurve.precompute( final CatmullRomCurve curve = CatmullRomCurve.precompute(
const <Offset>[ const <Offset>[
...@@ -377,15 +384,16 @@ void main() { ...@@ -377,15 +384,16 @@ void main() {
// These values are approximations. // These values are approximations.
const double tolerance = 1e-6; const double tolerance = 1e-6;
expect(curve.transform(0.0), closeTo(0.0, tolerance)); expect(curve.transform(0.0), moreOrLessEquals(0.0, epsilon: tolerance));
expect(curve.transform(0.01), closeTo(0.012874734350170863, tolerance)); expect(curve.transform(0.01), moreOrLessEquals(0.012874734350170863, epsilon: tolerance));
expect(curve.transform(0.2), closeTo(0.24989646045277542, tolerance)); expect(curve.transform(0.2), moreOrLessEquals(0.24989646045277542, epsilon: tolerance));
expect(curve.transform(0.33), closeTo(0.250037698527661, tolerance)); expect(curve.transform(0.33), moreOrLessEquals(0.250037698527661, epsilon: tolerance));
expect(curve.transform(0.5), closeTo(0.9999057323235939, tolerance)); expect(curve.transform(0.5), moreOrLessEquals(0.9999057323235939, epsilon: tolerance));
expect(curve.transform(0.6), closeTo(0.9357294964536621, tolerance)); expect(curve.transform(0.6), moreOrLessEquals(0.9357294964536621, epsilon: tolerance));
expect(curve.transform(0.8), closeTo(0.7500423402378034, tolerance)); expect(curve.transform(0.8), moreOrLessEquals(0.7500423402378034, epsilon: tolerance));
expect(curve.transform(1.0), closeTo(1.0, tolerance)); expect(curve.transform(1.0), moreOrLessEquals(1.0, epsilon: tolerance));
}); });
test('CatmullRomCurve enforces contract', () { test('CatmullRomCurve enforces contract', () {
expect(() { expect(() {
CatmullRomCurve(null); CatmullRomCurve(null);
...@@ -507,6 +515,7 @@ void main() { ...@@ -507,6 +515,7 @@ void main() {
); );
}, throwsAssertionError); }, throwsAssertionError);
}); });
test('CatmullRomCurve enforces contract when precomputed', () { test('CatmullRomCurve enforces contract when precomputed', () {
expect(() { expect(() {
CatmullRomCurve.precompute(null); CatmullRomCurve.precompute(null);
......
...@@ -782,46 +782,46 @@ void main() { ...@@ -782,46 +782,46 @@ void main() {
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, 600.0); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, 600.0);
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(470.0, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(470.0, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(374.3, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(374.3, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(337.1, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(337.1, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(325.3, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(325.3, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(320.8, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(320.8, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(319.3, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(319.3, epsilon: 0.1));
// Action sheet has reached final height // Action sheet has reached final height
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(319.3, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(319.3, epsilon: 0.1));
// Exit animation // Exit animation
await tester.tapAt(const Offset(20.0, 20.0)); await tester.tapAt(const Offset(20.0, 20.0));
await tester.pump(); await tester.pump();
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(319.3, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(319.3, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(449.3, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(449.3, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(544.9, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(544.9, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(582.1, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(582.1, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(593.9, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(593.9, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(598.5, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(598.5, epsilon: 0.1));
// Action sheet has disappeared // Action sheet has disappeared
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
...@@ -859,23 +859,23 @@ void main() { ...@@ -859,23 +859,23 @@ void main() {
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, 600.0); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, 600.0);
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(470.0, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(470.0, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(374.3, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(374.3, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(337.1, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(337.1, epsilon: 0.1));
// Exit animation // Exit animation
await tester.tapAt(const Offset(20.0, 20.0)); await tester.tapAt(const Offset(20.0, 20.0));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(374.3, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(374.3, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, closeTo(470.0, 0.1)); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, moreOrLessEquals(470.0, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, 600.0); expect(tester.getTopLeft(find.byType(CupertinoActionSheet)).dy, 600.0);
......
...@@ -961,31 +961,31 @@ void main() { ...@@ -961,31 +961,31 @@ void main() {
// Enter animation. // Enter animation.
await tester.pump(); await tester.pump();
Transform transform = tester.widget(find.byType(Transform)); Transform transform = tester.widget(find.byType(Transform));
expect(transform.transform[0], closeTo(1.3, 0.01)); expect(transform.transform[0], moreOrLessEquals(1.3, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
transform = tester.widget(find.byType(Transform)); transform = tester.widget(find.byType(Transform));
expect(transform.transform[0], closeTo(1.145, 0.001)); expect(transform.transform[0], moreOrLessEquals(1.145, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
transform = tester.widget(find.byType(Transform)); transform = tester.widget(find.byType(Transform));
expect(transform.transform[0], closeTo(1.044, 0.001)); expect(transform.transform[0], moreOrLessEquals(1.044, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
transform = tester.widget(find.byType(Transform)); transform = tester.widget(find.byType(Transform));
expect(transform.transform[0], closeTo(1.013, 0.001)); expect(transform.transform[0], moreOrLessEquals(1.013, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
transform = tester.widget(find.byType(Transform)); transform = tester.widget(find.byType(Transform));
expect(transform.transform[0], closeTo(1.003, 0.001)); expect(transform.transform[0], moreOrLessEquals(1.003, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
transform = tester.widget(find.byType(Transform)); transform = tester.widget(find.byType(Transform));
expect(transform.transform[0], closeTo(1.000, 0.001)); expect(transform.transform[0], moreOrLessEquals(1.000, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
transform = tester.widget(find.byType(Transform)); transform = tester.widget(find.byType(Transform));
expect(transform.transform[0], closeTo(1.000, 0.001)); expect(transform.transform[0], moreOrLessEquals(1.000, epsilon: 0.001));
await tester.tap(find.text('Delete')); await tester.tap(find.text('Delete'));
...@@ -1042,50 +1042,50 @@ void main() { ...@@ -1042,50 +1042,50 @@ void main() {
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
transition = tester.firstWidget(find.byType(FadeTransition)); transition = tester.firstWidget(find.byType(FadeTransition));
expect(transition.opacity.value, closeTo(0.40, 0.001)); expect(transition.opacity.value, moreOrLessEquals(0.40, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
transition = tester.firstWidget(find.byType(FadeTransition)); transition = tester.firstWidget(find.byType(FadeTransition));
expect(transition.opacity.value, closeTo(0.437, 0.001)); expect(transition.opacity.value, moreOrLessEquals(0.437, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
transition = tester.firstWidget(find.byType(FadeTransition)); transition = tester.firstWidget(find.byType(FadeTransition));
expect(transition.opacity.value, closeTo(0.55, 0.001)); expect(transition.opacity.value, moreOrLessEquals(0.55, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
transition = tester.firstWidget(find.byType(FadeTransition)); transition = tester.firstWidget(find.byType(FadeTransition));
expect(transition.opacity.value, closeTo(0.737, 0.001)); expect(transition.opacity.value, moreOrLessEquals(0.737, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
transition = tester.firstWidget(find.byType(FadeTransition)); transition = tester.firstWidget(find.byType(FadeTransition));
expect(transition.opacity.value, closeTo(1.0, 0.001)); expect(transition.opacity.value, moreOrLessEquals(1.0, epsilon: 0.001));
await tester.tap(find.text('Delete')); await tester.tap(find.text('Delete'));
// Exit animation, look at reverse FadeTransition. // Exit animation, look at reverse FadeTransition.
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
transition = tester.widgetList(find.byType(FadeTransition)).elementAt(1) as FadeTransition; transition = tester.widgetList(find.byType(FadeTransition)).elementAt(1) as FadeTransition;
expect(transition.opacity.value, closeTo(0.500, 0.001)); expect(transition.opacity.value, moreOrLessEquals(0.500, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
transition = tester.widgetList(find.byType(FadeTransition)).elementAt(1) as FadeTransition; transition = tester.widgetList(find.byType(FadeTransition)).elementAt(1) as FadeTransition;
expect(transition.opacity.value, closeTo(0.332, 0.001)); expect(transition.opacity.value, moreOrLessEquals(0.332, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
transition = tester.widgetList(find.byType(FadeTransition)).elementAt(1) as FadeTransition; transition = tester.widgetList(find.byType(FadeTransition)).elementAt(1) as FadeTransition;
expect(transition.opacity.value, closeTo(0.188, 0.001)); expect(transition.opacity.value, moreOrLessEquals(0.188, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
transition = tester.widgetList(find.byType(FadeTransition)).elementAt(1) as FadeTransition; transition = tester.widgetList(find.byType(FadeTransition)).elementAt(1) as FadeTransition;
expect(transition.opacity.value, closeTo(0.081, 0.001)); expect(transition.opacity.value, moreOrLessEquals(0.081, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
transition = tester.widgetList(find.byType(FadeTransition)).elementAt(1) as FadeTransition; transition = tester.widgetList(find.byType(FadeTransition)).elementAt(1) as FadeTransition;
expect(transition.opacity.value, closeTo(0.019, 0.001)); expect(transition.opacity.value, moreOrLessEquals(0.019, epsilon: 0.001));
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
transition = tester.widgetList(find.byType(FadeTransition)).elementAt(1) as FadeTransition; transition = tester.widgetList(find.byType(FadeTransition)).elementAt(1) as FadeTransition;
expect(transition.opacity.value, closeTo(0.0, 0.001)); expect(transition.opacity.value, moreOrLessEquals(0.0, epsilon: 0.001));
}); });
testWidgets('Actions are accessible by key', (WidgetTester tester) async { testWidgets('Actions are accessible by key', (WidgetTester tester) async {
......
...@@ -43,7 +43,7 @@ void main() { ...@@ -43,7 +43,7 @@ void main() {
expect(widget2TopLeft.dx, greaterThan(widget1InitialTopLeft.dx)); expect(widget2TopLeft.dx, greaterThan(widget1InitialTopLeft.dx));
// Will need to be changed if the animation curve or duration changes. // Will need to be changed if the animation curve or duration changes.
expect(widget1TransientTopLeft.dx, closeTo(130, 1.0)); expect(widget1TransientTopLeft.dx, moreOrLessEquals(130, epsilon: 1.0));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -68,7 +68,7 @@ void main() { ...@@ -68,7 +68,7 @@ void main() {
expect(widget2TopLeft.dx, greaterThan(widget1InitialTopLeft.dx)); expect(widget2TopLeft.dx, greaterThan(widget1InitialTopLeft.dx));
// Will need to be changed if the animation curve or duration changes. // Will need to be changed if the animation curve or duration changes.
expect(widget1TransientTopLeft.dx, closeTo(249, 1.0)); expect(widget1TransientTopLeft.dx, moreOrLessEquals(249, epsilon: 1.0));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
......
...@@ -438,68 +438,68 @@ void main() { ...@@ -438,68 +438,68 @@ void main() {
// entire screen. // entire screen.
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(443.7, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(443.7, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(291.9, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(291.9, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(168.2, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(168.2, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(89.5, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(89.5, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(48.1, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(48.1, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(26.1, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(26.1, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(14.3, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(14.3, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(7.41, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(7.41, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(3.0, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(3.0, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(0.0, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(0.0, epsilon: 0.1));
// Exit animation // Exit animation
await tester.tap(find.text('Close')); await tester.tap(find.text('Close'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(156.3, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(156.3, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(308.1, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(308.1, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(431.7, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(431.7, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(510.4, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(510.4, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(551.8, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(551.8, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(573.8, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(573.8, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(585.6, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(585.6, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(592.6, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(592.6, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(596.9, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(596.9, epsilon: 0.1));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(600.0, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, moreOrLessEquals(600.0, epsilon: 0.1));
}); });
Future<void> testParallax(WidgetTester tester, {@required bool fromFullscreenDialog}) async { Future<void> testParallax(WidgetTester tester, {@required bool fromFullscreenDialog}) async {
...@@ -536,51 +536,51 @@ void main() { ...@@ -536,51 +536,51 @@ void main() {
// Enter animation. // Enter animation.
await tester.tap(find.text('Button')); await tester.tap(find.text('Button'));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(0.0, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(0.0, epsilon: 0.1));
await tester.pump(); await tester.pump();
// We use a higher number of intervals since the animation has to scale the // We use a higher number of intervals since the animation has to scale the
// entire screen. // entire screen.
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(-70.0, 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-70.0, epsilon: 1.0));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(-137.0, 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-137.0, epsilon: 1.0));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(-192.0, 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-192.0, epsilon: 1.0));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(-227.0, 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-227.0, epsilon: 1.0));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(-246.0, 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-246.0, epsilon: 1.0));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(-255.0, 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-255.0, epsilon: 1.0));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(-260.0, 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-260.0, epsilon: 1.0));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(-264.0, 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-264.0, epsilon: 1.0));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(-266.0, 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-266.0, epsilon: 1.0));
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(-267.0, 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-267.0, epsilon: 1.0));
// Exit animation // Exit animation
await tester.tap(find.text('Button')); await tester.tap(find.text('Button'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 40)); await tester.pump(const Duration(milliseconds: 40));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(-198.0, 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-198.0, epsilon: 1.0));
await tester.pump(const Duration(milliseconds: 360)); await tester.pump(const Duration(milliseconds: 360));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(-0.0, 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-0.0, epsilon: 1.0));
} }
testWidgets('CupertinoPageRoute has parallax when non fullscreenDialog route is pushed on top', (WidgetTester tester) async { testWidgets('CupertinoPageRoute has parallax when non fullscreenDialog route is pushed on top', (WidgetTester tester) async {
...@@ -625,7 +625,7 @@ void main() { ...@@ -625,7 +625,7 @@ void main() {
// Enter animation. // Enter animation.
await tester.tap(find.text('Button')); await tester.tap(find.text('Button'));
expect(tester.getTopLeft(find.byType(Placeholder)).dx, closeTo(0.0, 0.1)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(0.0, epsilon: 0.1));
await tester.pump(); await tester.pump();
// We use a higher number of intervals since the animation has to scale the // We use a higher number of intervals since the animation has to scale the
......
...@@ -3462,8 +3462,8 @@ void main() { ...@@ -3462,8 +3462,8 @@ void main() {
expect(focusNode.hasFocus, true); expect(focusNode.hasFocus, true);
// The EditableText is at the top. // The EditableText is at the top.
expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, closeTo(size.height, .0001)); expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, moreOrLessEquals(size.height, epsilon: .0001));
expect(tester.getTopLeft(find.byType(EditableText)).dy, closeTo(206.0, .0001)); expect(tester.getTopLeft(find.byType(EditableText)).dy, moreOrLessEquals(206.0, epsilon: .0001));
}); });
testWidgets('align center', (WidgetTester tester) async { testWidgets('align center', (WidgetTester tester) async {
...@@ -3510,8 +3510,8 @@ void main() { ...@@ -3510,8 +3510,8 @@ void main() {
expect(focusNode.hasFocus, true); expect(focusNode.hasFocus, true);
// The EditableText is at the center. // The EditableText is at the center.
expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, closeTo(size.height, .0001)); expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, moreOrLessEquals(size.height, epsilon: .0001));
expect(tester.getTopLeft(find.byType(EditableText)).dy, closeTo(291.5, .0001)); expect(tester.getTopLeft(find.byType(EditableText)).dy, moreOrLessEquals(291.5, epsilon: .0001));
}); });
testWidgets('align bottom', (WidgetTester tester) async { testWidgets('align bottom', (WidgetTester tester) async {
...@@ -3558,8 +3558,8 @@ void main() { ...@@ -3558,8 +3558,8 @@ void main() {
expect(focusNode.hasFocus, true); expect(focusNode.hasFocus, true);
// The EditableText is at the bottom. // The EditableText is at the bottom.
expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, closeTo(size.height, .0001)); expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, moreOrLessEquals(size.height, epsilon: .0001));
expect(tester.getTopLeft(find.byType(EditableText)).dy, closeTo(377.0, .0001)); expect(tester.getTopLeft(find.byType(EditableText)).dy, moreOrLessEquals(377.0, epsilon: .0001));
}); });
testWidgets('align as a double', (WidgetTester tester) async { testWidgets('align as a double', (WidgetTester tester) async {
...@@ -3606,8 +3606,8 @@ void main() { ...@@ -3606,8 +3606,8 @@ void main() {
expect(focusNode.hasFocus, true); expect(focusNode.hasFocus, true);
// The EditableText is near the bottom. // The EditableText is near the bottom.
expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, closeTo(size.height, .0001)); expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, moreOrLessEquals(size.height, epsilon: .0001));
expect(tester.getTopLeft(find.byType(EditableText)).dy, closeTo(355.625, .0001)); expect(tester.getTopLeft(find.byType(EditableText)).dy, moreOrLessEquals(355.625, epsilon: .0001));
}); });
}); });
...@@ -3660,8 +3660,8 @@ void main() { ...@@ -3660,8 +3660,8 @@ void main() {
expect(focusNode.hasFocus, true); expect(focusNode.hasFocus, true);
// The EditableText is at the center. Same as without prefix. // The EditableText is at the center. Same as without prefix.
expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, closeTo(size.height, .0001)); expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, moreOrLessEquals(size.height, epsilon: .0001));
expect(tester.getTopLeft(find.byType(EditableText)).dy, closeTo(291.5, .0001)); expect(tester.getTopLeft(find.byType(EditableText)).dy, moreOrLessEquals(291.5, epsilon: .0001));
}); });
testWidgets('align top', (WidgetTester tester) async { testWidgets('align top', (WidgetTester tester) async {
...@@ -3714,8 +3714,8 @@ void main() { ...@@ -3714,8 +3714,8 @@ void main() {
// The prefix is at the top, and the EditableText is centered within its // The prefix is at the top, and the EditableText is centered within its
// height. // height.
expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, closeTo(size.height, .0001)); expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, moreOrLessEquals(size.height, epsilon: .0001));
expect(tester.getTopLeft(find.byType(EditableText)).dy, closeTo(241.5, .0001)); expect(tester.getTopLeft(find.byType(EditableText)).dy, moreOrLessEquals(241.5, epsilon: .0001));
}); });
testWidgets('align bottom', (WidgetTester tester) async { testWidgets('align bottom', (WidgetTester tester) async {
...@@ -3768,8 +3768,8 @@ void main() { ...@@ -3768,8 +3768,8 @@ void main() {
// The prefix is at the bottom, and the EditableText is centered within // The prefix is at the bottom, and the EditableText is centered within
// its height. // its height.
expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, closeTo(size.height, .0001)); expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, moreOrLessEquals(size.height, epsilon: .0001));
expect(tester.getTopLeft(find.byType(EditableText)).dy, closeTo(341.5, .0001)); expect(tester.getTopLeft(find.byType(EditableText)).dy, moreOrLessEquals(341.5, epsilon: .0001));
}); });
testWidgets('align as a double', (WidgetTester tester) async { testWidgets('align as a double', (WidgetTester tester) async {
...@@ -3821,8 +3821,8 @@ void main() { ...@@ -3821,8 +3821,8 @@ void main() {
expect(focusNode.hasFocus, true); expect(focusNode.hasFocus, true);
// The EditableText is near the bottom. // The EditableText is near the bottom.
expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, closeTo(size.height, .0001)); expect(tester.getTopLeft(find.byType(CupertinoTextField)).dy, moreOrLessEquals(size.height, epsilon: .0001));
expect(tester.getTopLeft(find.byType(EditableText)).dy, closeTo(329.0, .0001)); expect(tester.getTopLeft(find.byType(EditableText)).dy, moreOrLessEquals(329.0, epsilon: .0001));
}); });
}); });
......
...@@ -24,7 +24,7 @@ void main() { ...@@ -24,7 +24,7 @@ void main() {
final double dyDelta2 = thirdPosition.dy - secondPosition.dy; final double dyDelta2 = thirdPosition.dy - secondPosition.dy;
// If the animation were linear, these two values would be the same. // If the animation were linear, these two values would be the same.
expect(dyDelta1, isNot(closeTo(dyDelta2, 0.1))); expect(dyDelta1, isNot(moreOrLessEquals(dyDelta2, epsilon: 0.1)));
} }
testWidgets('Tapping on a modal BottomSheet should not dismiss it', (WidgetTester tester) async { testWidgets('Tapping on a modal BottomSheet should not dismiss it', (WidgetTester tester) async {
......
...@@ -684,11 +684,11 @@ void main() { ...@@ -684,11 +684,11 @@ void main() {
}) { }) {
expect( expect(
tester.getTopLeft(dialogFinder).dx, tester.getTopLeft(dialogFinder).dx,
closeTo(tester.getTopLeft(finder).dx - unscaledValue * paddingScaleFactors[textScaleFactor], 1e-6), moreOrLessEquals(tester.getTopLeft(finder).dx - unscaledValue * paddingScaleFactors[textScaleFactor]),
); );
expect( expect(
tester.getBottomLeft(dialogFinder).dx, tester.getBottomLeft(dialogFinder).dx,
closeTo(tester.getBottomLeft(finder).dx - unscaledValue * paddingScaleFactors[textScaleFactor], 1e-6), moreOrLessEquals(tester.getBottomLeft(finder).dx - unscaledValue * paddingScaleFactors[textScaleFactor]),
); );
} }
...@@ -700,11 +700,11 @@ void main() { ...@@ -700,11 +700,11 @@ void main() {
}) { }) {
expect( expect(
tester.getTopRight(dialogFinder).dx, tester.getTopRight(dialogFinder).dx,
closeTo(tester.getTopRight(finder).dx + unscaledValue * paddingScaleFactors[textScaleFactor], 1e-6), moreOrLessEquals(tester.getTopRight(finder).dx + unscaledValue * paddingScaleFactors[textScaleFactor]),
); );
expect( expect(
tester.getBottomRight(dialogFinder).dx, tester.getBottomRight(dialogFinder).dx,
closeTo(tester.getBottomRight(finder).dx + unscaledValue * paddingScaleFactors[textScaleFactor], 1e-6), moreOrLessEquals(tester.getBottomRight(finder).dx + unscaledValue * paddingScaleFactors[textScaleFactor]),
); );
} }
...@@ -716,11 +716,11 @@ void main() { ...@@ -716,11 +716,11 @@ void main() {
}) { }) {
expect( expect(
tester.getTopLeft(dialogFinder).dy, tester.getTopLeft(dialogFinder).dy,
closeTo(tester.getTopLeft(finder).dy - unscaledValue * paddingScaleFactors[textScaleFactor], 1e-6), moreOrLessEquals(tester.getTopLeft(finder).dy - unscaledValue * paddingScaleFactors[textScaleFactor]),
); );
expect( expect(
tester.getTopRight(dialogFinder).dy, tester.getTopRight(dialogFinder).dy,
closeTo(tester.getTopRight(finder).dy - unscaledValue * paddingScaleFactors[textScaleFactor], 1e-6), moreOrLessEquals(tester.getTopRight(finder).dy - unscaledValue * paddingScaleFactors[textScaleFactor]),
); );
} }
...@@ -732,11 +732,11 @@ void main() { ...@@ -732,11 +732,11 @@ void main() {
}) { }) {
expect( expect(
tester.getBottomLeft(dialogFinder).dy, tester.getBottomLeft(dialogFinder).dy,
closeTo(tester.getBottomRight(finder).dy + unscaledValue * paddingScaleFactors[textScaleFactor], 1e-6), moreOrLessEquals(tester.getBottomRight(finder).dy + unscaledValue * paddingScaleFactors[textScaleFactor]),
); );
expect( expect(
tester.getBottomRight(dialogFinder).dy, tester.getBottomRight(dialogFinder).dy,
closeTo(tester.getBottomRight(finder).dy + unscaledValue * paddingScaleFactors[textScaleFactor], 1e-6), moreOrLessEquals(tester.getBottomRight(finder).dy + unscaledValue * paddingScaleFactors[textScaleFactor]),
); );
} }
......
...@@ -1353,10 +1353,10 @@ void main() { ...@@ -1353,10 +1353,10 @@ void main() {
// 12 - bottom padding // 12 - bottom padding
expect(tester.getSize(find.byType(InputDecorator)).width, 800.0); expect(tester.getSize(find.byType(InputDecorator)).width, 800.0);
expect(tester.getSize(find.byType(InputDecorator)).height, closeTo(128.0, .0001)); expect(tester.getSize(find.byType(InputDecorator)).height, moreOrLessEquals(128.0, epsilon: .0001));
expect(tester.getSize(find.text('text')).height, 20.0); expect(tester.getSize(find.text('text')).height, 20.0);
expect(tester.getSize(find.byKey(pKey)).height, 100.0); expect(tester.getSize(find.byKey(pKey)).height, 100.0);
expect(tester.getTopLeft(find.text('text')).dy, closeTo(96, .0001)); // 12 + 100 - 16 expect(tester.getTopLeft(find.text('text')).dy, moreOrLessEquals(96, epsilon: .0001)); // 12 + 100 - 16
expect(tester.getTopLeft(find.byKey(pKey)).dy, 12.0); expect(tester.getTopLeft(find.byKey(pKey)).dy, 12.0);
// layout is a row: [prefix text suffix] // layout is a row: [prefix text suffix]
...@@ -1403,10 +1403,10 @@ void main() { ...@@ -1403,10 +1403,10 @@ void main() {
// positioned at 19, and the text is at 19+100-16=103. // positioned at 19, and the text is at 19+100-16=103.
expect(tester.getSize(find.byType(InputDecorator)).width, 800.0); expect(tester.getSize(find.byType(InputDecorator)).width, 800.0);
expect(tester.getSize(find.byType(InputDecorator)).height, closeTo(144, .0001)); expect(tester.getSize(find.byType(InputDecorator)).height, moreOrLessEquals(144, epsilon: .0001));
expect(tester.getSize(find.text('text')).height, 20.0); expect(tester.getSize(find.text('text')).height, 20.0);
expect(tester.getSize(find.byKey(pKey)).height, 100.0); expect(tester.getSize(find.byKey(pKey)).height, 100.0);
expect(tester.getTopLeft(find.text('text')).dy, closeTo(103, .0001)); expect(tester.getTopLeft(find.text('text')).dy, moreOrLessEquals(103, epsilon: .0001));
expect(tester.getTopLeft(find.byKey(pKey)).dy, 19.0); expect(tester.getTopLeft(find.byKey(pKey)).dy, 19.0);
// layout is a row: [prefix text suffix] // layout is a row: [prefix text suffix]
...@@ -1745,7 +1745,7 @@ void main() { ...@@ -1745,7 +1745,7 @@ void main() {
); );
// Same as the default case above. // Same as the default case above.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(12.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(12.0, epsilon: .0001));
}); });
testWidgets('align center', (WidgetTester tester) async { testWidgets('align center', (WidgetTester tester) async {
...@@ -1768,7 +1768,7 @@ void main() { ...@@ -1768,7 +1768,7 @@ void main() {
); );
// Below the top aligned case. // Below the top aligned case.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(290.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(290.0, epsilon: .0001));
}); });
testWidgets('align bottom', (WidgetTester tester) async { testWidgets('align bottom', (WidgetTester tester) async {
...@@ -1791,7 +1791,7 @@ void main() { ...@@ -1791,7 +1791,7 @@ void main() {
); );
// Below the center aligned case. // Below the center aligned case.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(568.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(568.0, epsilon: .0001));
}); });
testWidgets('align as a double', (WidgetTester tester) async { testWidgets('align as a double', (WidgetTester tester) async {
...@@ -1814,7 +1814,7 @@ void main() { ...@@ -1814,7 +1814,7 @@ void main() {
); );
// In between the center and bottom aligned cases. // In between the center and bottom aligned cases.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(498.5, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(498.5, epsilon: .0001));
}); });
}); });
...@@ -1841,7 +1841,7 @@ void main() { ...@@ -1841,7 +1841,7 @@ void main() {
// Similar to the case without a border, but with a little extra room at // Similar to the case without a border, but with a little extra room at
// the top to make room for the border. // the top to make room for the border.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(24.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(24.0, epsilon: .0001));
}); });
testWidgets('align center (default)', (WidgetTester tester) async { testWidgets('align center (default)', (WidgetTester tester) async {
...@@ -1865,7 +1865,7 @@ void main() { ...@@ -1865,7 +1865,7 @@ void main() {
); );
// Below the top aligned case. // Below the top aligned case.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(289.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(289.0, epsilon: .0001));
}); });
testWidgets('align bottom', (WidgetTester tester) async { testWidgets('align bottom', (WidgetTester tester) async {
...@@ -1889,7 +1889,7 @@ void main() { ...@@ -1889,7 +1889,7 @@ void main() {
); );
// Below the center aligned case. // Below the center aligned case.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(564.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(564.0, epsilon: .0001));
}); });
}); });
...@@ -1919,7 +1919,7 @@ void main() { ...@@ -1919,7 +1919,7 @@ void main() {
); );
// Same as the default case above. // Same as the default case above.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(96, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(96, epsilon: .0001));
expect(tester.getTopLeft(find.byKey(pKey)).dy, 12.0); expect(tester.getTopLeft(find.byKey(pKey)).dy, 12.0);
}); });
...@@ -1948,7 +1948,7 @@ void main() { ...@@ -1948,7 +1948,7 @@ void main() {
); );
// Same as the default case above. // Same as the default case above.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(96.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(96.0, epsilon: .0001));
expect(tester.getTopLeft(find.byKey(pKey)).dy, 12.0); expect(tester.getTopLeft(find.byKey(pKey)).dy, 12.0);
}); });
...@@ -1977,7 +1977,7 @@ void main() { ...@@ -1977,7 +1977,7 @@ void main() {
); );
// Top of the input + 100 prefix height - overlap // Top of the input + 100 prefix height - overlap
expect(tester.getTopLeft(find.text(text)).dy, closeTo(96.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(96.0, epsilon: .0001));
expect(tester.getTopLeft(find.byKey(pKey)).dy, 12.0); expect(tester.getTopLeft(find.byKey(pKey)).dy, 12.0);
}); });
}); });
...@@ -2010,8 +2010,8 @@ void main() { ...@@ -2010,8 +2010,8 @@ void main() {
); );
// In the middle of the expanded InputDecorator. // In the middle of the expanded InputDecorator.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(331.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(331.0, epsilon: .0001));
expect(tester.getTopLeft(find.byKey(pKey)).dy, closeTo(247.0, .0001)); expect(tester.getTopLeft(find.byKey(pKey)).dy, moreOrLessEquals(247.0, epsilon: .0001));
}); });
testWidgets('InputDecorator tall prefix with border align top', (WidgetTester tester) async { testWidgets('InputDecorator tall prefix with border align top', (WidgetTester tester) async {
...@@ -2041,7 +2041,7 @@ void main() { ...@@ -2041,7 +2041,7 @@ void main() {
); );
// Above the center example. // Above the center example.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(108.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(108.0, epsilon: .0001));
// The prefix is positioned at the top of the input, so this value is // The prefix is positioned at the top of the input, so this value is
// the same as the top aligned test without a prefix. // the same as the top aligned test without a prefix.
expect(tester.getTopLeft(find.byKey(pKey)).dy, 24.0); expect(tester.getTopLeft(find.byKey(pKey)).dy, 24.0);
...@@ -2074,8 +2074,8 @@ void main() { ...@@ -2074,8 +2074,8 @@ void main() {
); );
// Below the center example. // Below the center example.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(564.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(564.0, epsilon: .0001));
expect(tester.getTopLeft(find.byKey(pKey)).dy, closeTo(480.0, .0001)); expect(tester.getTopLeft(find.byKey(pKey)).dy, moreOrLessEquals(480.0, epsilon: .0001));
}); });
testWidgets('InputDecorator tall prefix with border align double', (WidgetTester tester) async { testWidgets('InputDecorator tall prefix with border align double', (WidgetTester tester) async {
...@@ -2105,8 +2105,8 @@ void main() { ...@@ -2105,8 +2105,8 @@ void main() {
); );
// Between the top and center examples. // Between the top and center examples.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(354.3, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(354.3, epsilon: .0001));
expect(tester.getTopLeft(find.byKey(pKey)).dy, closeTo(270.3, .0001)); expect(tester.getTopLeft(find.byKey(pKey)).dy, moreOrLessEquals(270.3, epsilon: .0001));
}); });
}); });
...@@ -2133,7 +2133,7 @@ void main() { ...@@ -2133,7 +2133,7 @@ void main() {
// The label causes the text to start slightly lower than it would // The label causes the text to start slightly lower than it would
// otherwise. // otherwise.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(28.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(28.0, epsilon: .0001));
}); });
testWidgets('align center', (WidgetTester tester) async { testWidgets('align center', (WidgetTester tester) async {
...@@ -2158,7 +2158,7 @@ void main() { ...@@ -2158,7 +2158,7 @@ void main() {
// The label reduces the amount of space available for text, so the // The label reduces the amount of space available for text, so the
// center is slightly lower. // center is slightly lower.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(298.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(298.0, epsilon: .0001));
}); });
testWidgets('align bottom', (WidgetTester tester) async { testWidgets('align bottom', (WidgetTester tester) async {
...@@ -2183,7 +2183,7 @@ void main() { ...@@ -2183,7 +2183,7 @@ void main() {
// The label reduces the amount of space available for text, but the // The label reduces the amount of space available for text, but the
// bottom line is still in the same place. // bottom line is still in the same place.
expect(tester.getTopLeft(find.text(text)).dy, closeTo(568.0, .0001)); expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(568.0, epsilon: .0001));
}); });
}); });
}); });
......
...@@ -185,11 +185,11 @@ void main() { ...@@ -185,11 +185,11 @@ void main() {
await tester.pump(const Duration(milliseconds: 1)); await tester.pump(const Duration(milliseconds: 1));
final RenderPhysicalShape modelC = getModel(tester); final RenderPhysicalShape modelC = getModel(tester);
expect(modelC.elevation, closeTo(0.0, 0.001)); expect(modelC.elevation, moreOrLessEquals(0.0, epsilon: 0.001));
await tester.pump(kThemeChangeDuration ~/ 2); await tester.pump(kThemeChangeDuration ~/ 2);
final RenderPhysicalShape modelD = getModel(tester); final RenderPhysicalShape modelD = getModel(tester);
expect(modelD.elevation, isNot(closeTo(0.0, 0.001))); expect(modelD.elevation, isNot(moreOrLessEquals(0.0, epsilon: 0.001)));
await tester.pump(kThemeChangeDuration); await tester.pump(kThemeChangeDuration);
final RenderPhysicalShape modelE = getModel(tester); final RenderPhysicalShape modelE = getModel(tester);
......
...@@ -20,7 +20,7 @@ void main() { ...@@ -20,7 +20,7 @@ void main() {
final double dyDelta2 = thirdPosition.dy - secondPosition.dy; final double dyDelta2 = thirdPosition.dy - secondPosition.dy;
// If the animation were linear, these two values would be the same. // If the animation were linear, these two values would be the same.
expect(dyDelta1, isNot(closeTo(dyDelta2, 0.1))); expect(dyDelta1, isNot(moreOrLessEquals(dyDelta2, epsilon: 0.1)));
} }
testWidgets('Verify that a BottomSheet can be rebuilt with ScaffoldFeatureController.setState()', (WidgetTester tester) async { testWidgets('Verify that a BottomSheet can be rebuilt with ScaffoldFeatureController.setState()', (WidgetTester tester) async {
......
...@@ -129,9 +129,9 @@ void main() { ...@@ -129,9 +129,9 @@ void main() {
final Offset target = topLeft + (bottomRight - topLeft) / 4.0; final Offset target = topLeft + (bottomRight - topLeft) / 4.0;
await tester.tapAt(target); await tester.tapAt(target);
expect(value, closeTo(0.25, 0.05)); expect(value, moreOrLessEquals(0.25, epsilon: 0.05));
expect(startValue, equals(0.5)); expect(startValue, equals(0.5));
expect(endValue, closeTo(0.25, 0.05)); expect(endValue, moreOrLessEquals(0.25, epsilon: 0.05));
await tester.pump(); // No animation should start. await tester.pump(); // No animation should start.
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
...@@ -179,7 +179,7 @@ void main() { ...@@ -179,7 +179,7 @@ void main() {
final Offset target = topLeft + (bottomRight - topLeft) / 4.0; final Offset target = topLeft + (bottomRight - topLeft) / 4.0;
await tester.tapAt(target); await tester.tapAt(target);
expect(value, closeTo(0.75, 0.05)); expect(value, moreOrLessEquals(0.75, epsilon: 0.05));
await tester.pump(); // No animation should start. await tester.pump(); // No animation should start.
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
...@@ -352,20 +352,20 @@ void main() { ...@@ -352,20 +352,20 @@ void main() {
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
expect(value, equals(0.0)); expect(value, equals(0.0));
expect(log.length, 5); expect(log.length, 5);
expect(log.last.dx, closeTo(386.6, 0.1)); expect(log.last.dx, moreOrLessEquals(386.6, epsilon: 0.1));
// With no more gesture or value changes, the thumb position should still // With no more gesture or value changes, the thumb position should still
// be redrawn in the animated position. // be redrawn in the animated position.
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
expect(value, equals(0.0)); expect(value, equals(0.0));
expect(log.length, 7); expect(log.length, 7);
expect(log.last.dx, closeTo(344.5, 0.1)); expect(log.last.dx, moreOrLessEquals(344.5, epsilon: 0.1));
// Final position. // Final position.
await tester.pump(const Duration(milliseconds: 80)); await tester.pump(const Duration(milliseconds: 80));
expectedLog.add(const Offset(24.0, 300.0)); expectedLog.add(const Offset(24.0, 300.0));
expect(value, equals(0.0)); expect(value, equals(0.0));
expect(log.length, 8); expect(log.length, 8);
expect(log.last.dx, closeTo(24.0, 0.1)); expect(log.last.dx, moreOrLessEquals(24.0, epsilon: 0.1));
await gesture.up(); await gesture.up();
}); });
...@@ -467,20 +467,20 @@ void main() { ...@@ -467,20 +467,20 @@ void main() {
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
expect(value, equals(0.0)); expect(value, equals(0.0));
expect(log.length, 5); expect(log.length, 5);
expect(log.last.dx, closeTo(386.6, 0.1)); expect(log.last.dx, moreOrLessEquals(386.6, epsilon: 0.1));
// With no more gesture or value changes, the thumb position should still // With no more gesture or value changes, the thumb position should still
// be redrawn in the animated position. // be redrawn in the animated position.
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
expect(value, equals(0.0)); expect(value, equals(0.0));
expect(log.length, 7); expect(log.length, 7);
expect(log.last.dx, closeTo(344.5, 0.1)); expect(log.last.dx, moreOrLessEquals(344.5, epsilon: 0.1));
// Final position. // Final position.
await tester.pump(const Duration(milliseconds: 80)); await tester.pump(const Duration(milliseconds: 80));
expectedLog.add(const Offset(24.0, 300.0)); expectedLog.add(const Offset(24.0, 300.0));
expect(value, equals(0.0)); expect(value, equals(0.0));
expect(log.length, 8); expect(log.length, 8);
expect(log.last.dx, closeTo(24.0, 0.1)); expect(log.last.dx, moreOrLessEquals(24.0, epsilon: 0.1));
await gesture.up(); await gesture.up();
}); });
......
...@@ -399,7 +399,7 @@ void main() { ...@@ -399,7 +399,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(controller.index, 5); expect(controller.index, 5);
// The center of the FFFFFF item is now at the TabBar's center // The center of the FFFFFF item is now at the TabBar's center
expect(tester.getCenter(find.text('FFFFFF')).dx, closeTo(400.0, 1.0)); expect(tester.getCenter(find.text('FFFFFF')).dx, moreOrLessEquals(400.0, epsilon: 1.0));
}); });
......
...@@ -3411,7 +3411,7 @@ void main() { ...@@ -3411,7 +3411,7 @@ void main() {
// line text field). // line text field).
final double lineHeight = findRenderEditable(tester).preferredLineHeight; final double lineHeight = findRenderEditable(tester).preferredLineHeight;
scrollableState = tester.firstState(find.byType(Scrollable)); scrollableState = tester.firstState(find.byType(Scrollable));
expect(scrollableState.position.pixels, closeTo(lineHeight, 0.1)); expect(scrollableState.position.pixels, moreOrLessEquals(lineHeight, epsilon: 0.1));
}); });
testWidgets('haptic feedback', (WidgetTester tester) async { testWidgets('haptic feedback', (WidgetTester tester) async {
...@@ -4758,8 +4758,8 @@ void main() { ...@@ -4758,8 +4758,8 @@ void main() {
// --------- rowBottomY // --------- rowBottomY
final double rowBottomY = tester.getBottomLeft(find.byType(Row)).dy; final double rowBottomY = tester.getBottomLeft(find.byType(Row)).dy;
expect(tester.getBottomLeft(find.byKey(keyA)).dy, closeTo(rowBottomY - 4.0, 0.001)); expect(tester.getBottomLeft(find.byKey(keyA)).dy, moreOrLessEquals(rowBottomY - 4.0, epsilon: 0.001));
expect(tester.getBottomLeft(find.text('abc')).dy, closeTo(rowBottomY - 2.0, 0.001)); expect(tester.getBottomLeft(find.text('abc')).dy, moreOrLessEquals(rowBottomY - 2.0, epsilon: 0.001));
expect(tester.getBottomLeft(find.byKey(keyB)).dy, rowBottomY); expect(tester.getBottomLeft(find.byKey(keyB)).dy, rowBottomY);
}); });
...@@ -4810,8 +4810,8 @@ void main() { ...@@ -4810,8 +4810,8 @@ void main() {
final double rowBottomY = tester.getBottomLeft(find.byType(Row)).dy; final double rowBottomY = tester.getBottomLeft(find.byType(Row)).dy;
// The values here should match the version with strut disabled ('TextField baseline alignment no-strut') // The values here should match the version with strut disabled ('TextField baseline alignment no-strut')
expect(tester.getBottomLeft(find.byKey(keyA)).dy, closeTo(rowBottomY - 4.0, 0.001)); expect(tester.getBottomLeft(find.byKey(keyA)).dy, moreOrLessEquals(rowBottomY - 4.0, epsilon: 0.001));
expect(tester.getBottomLeft(find.text('abc')).dy, closeTo(rowBottomY - 2.0, 0.001)); expect(tester.getBottomLeft(find.text('abc')).dy, moreOrLessEquals(rowBottomY - 2.0, epsilon: 0.001));
expect(tester.getBottomLeft(find.byKey(keyB)).dy, rowBottomY); expect(tester.getBottomLeft(find.byKey(keyB)).dy, rowBottomY);
}); });
......
...@@ -1310,8 +1310,8 @@ void main() { ...@@ -1310,8 +1310,8 @@ void main() {
final double textDy = tester.getBottomLeft(find.text('Text')).dy; final double textDy = tester.getBottomLeft(find.text('Text')).dy;
expect(firstToggleButtonDy, secondToggleButtonDy); expect(firstToggleButtonDy, secondToggleButtonDy);
expect(firstToggleButtonDy, closeTo(materialButtonDy - 2.0, 0.001)); expect(firstToggleButtonDy, moreOrLessEquals(materialButtonDy - 2.0, epsilon: 0.001));
expect(firstToggleButtonDy, closeTo(textDy - 4.0, 0.001)); expect(firstToggleButtonDy, moreOrLessEquals(textDy - 4.0, epsilon: 0.001));
}); });
testWidgets('Directionality test', (WidgetTester tester) async { testWidgets('Directionality test', (WidgetTester tester) async {
......
...@@ -5,25 +5,23 @@ ...@@ -5,25 +5,23 @@
import 'package:flutter/physics.dart'; import 'package:flutter/physics.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
const double _kEpsilon = .00001;
void main() { void main() {
test('Friction simulation positive velocity', () { test('Friction simulation positive velocity', () {
final FrictionSimulation friction = FrictionSimulation(0.135, 100.0, 100.0); final FrictionSimulation friction = FrictionSimulation(0.135, 100.0, 100.0);
expect(friction.x(0.0), closeTo(100.0, _kEpsilon)); expect(friction.x(0.0), moreOrLessEquals(100.0));
expect(friction.dx(0.0), closeTo(100.0, _kEpsilon)); expect(friction.dx(0.0), moreOrLessEquals(100.0));
expect(friction.x(0.1), closeTo(110.0, 1.0)); expect(friction.x(0.1), moreOrLessEquals(110.0, epsilon: 1.0));
expect(friction.x(0.5), closeTo(131.0, 1.0)); expect(friction.x(0.5), moreOrLessEquals(131.0, epsilon: 1.0));
expect(friction.x(2.0), closeTo(149.0, 1.0)); expect(friction.x(2.0), moreOrLessEquals(149.0, epsilon: 1.0));
expect(friction.finalX, closeTo(149.0, 1.0)); expect(friction.finalX, moreOrLessEquals(149.0, epsilon: 1.0));
expect(friction.timeAtX(100.0), 0.0); expect(friction.timeAtX(100.0), 0.0);
expect(friction.timeAtX(friction.x(0.1)), closeTo(0.1, _kEpsilon)); expect(friction.timeAtX(friction.x(0.1)), moreOrLessEquals(0.1));
expect(friction.timeAtX(friction.x(0.5)), closeTo(0.5, _kEpsilon)); expect(friction.timeAtX(friction.x(0.5)), moreOrLessEquals(0.5));
expect(friction.timeAtX(friction.x(2.0)), closeTo(2.0, _kEpsilon)); expect(friction.timeAtX(friction.x(2.0)), moreOrLessEquals(2.0));
expect(friction.timeAtX(-1.0), double.infinity); expect(friction.timeAtX(-1.0), double.infinity);
expect(friction.timeAtX(200.0), double.infinity); expect(friction.timeAtX(200.0), double.infinity);
...@@ -32,19 +30,19 @@ void main() { ...@@ -32,19 +30,19 @@ void main() {
test('Friction simulation negative velocity', () { test('Friction simulation negative velocity', () {
final FrictionSimulation friction = FrictionSimulation(0.135, 100.0, -100.0); final FrictionSimulation friction = FrictionSimulation(0.135, 100.0, -100.0);
expect(friction.x(0.0), closeTo(100.0, _kEpsilon)); expect(friction.x(0.0), moreOrLessEquals(100.0));
expect(friction.dx(0.0), closeTo(-100.0, _kEpsilon)); expect(friction.dx(0.0), moreOrLessEquals(-100.0));
expect(friction.x(0.1), closeTo(91.0, 1.0)); expect(friction.x(0.1), moreOrLessEquals(91.0, epsilon: 1.0));
expect(friction.x(0.5), closeTo(68.0, 1.0)); expect(friction.x(0.5), moreOrLessEquals(68.0, epsilon: 1.0));
expect(friction.x(2.0), closeTo(51.0, 1.0)); expect(friction.x(2.0), moreOrLessEquals(51.0, epsilon: 1.0));
expect(friction.finalX, closeTo(50, 1.0)); expect(friction.finalX, moreOrLessEquals(50, epsilon: 1.0));
expect(friction.timeAtX(100.0), 0.0); expect(friction.timeAtX(100.0), 0.0);
expect(friction.timeAtX(friction.x(0.1)), closeTo(0.1, _kEpsilon)); expect(friction.timeAtX(friction.x(0.1)), moreOrLessEquals(0.1));
expect(friction.timeAtX(friction.x(0.5)), closeTo(0.5, _kEpsilon)); expect(friction.timeAtX(friction.x(0.5)), moreOrLessEquals(0.5));
expect(friction.timeAtX(friction.x(2.0)), closeTo(2.0, _kEpsilon)); expect(friction.timeAtX(friction.x(2.0)), moreOrLessEquals(2.0));
expect(friction.timeAtX(101.0), double.infinity); expect(friction.timeAtX(101.0), double.infinity);
expect(friction.timeAtX(40.0), double.infinity); expect(friction.timeAtX(40.0), double.infinity);
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
// 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.
import 'package:flutter/foundation.dart';
import 'package:flutter/physics.dart'; import 'package:flutter/physics.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import '../flutter_test_alternative.dart'; import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
test('test_friction', () { test('test_friction', () {
...@@ -21,7 +22,7 @@ void main() { ...@@ -21,7 +22,7 @@ void main() {
expect(friction.dx(1.0), 120.0); expect(friction.dx(1.0), 120.0);
expect(friction.dx(2.0), 36.0); expect(friction.dx(2.0), 36.0);
expect(friction.dx(3.0), closeTo(10.8, 0.00001)); expect(friction.dx(3.0), moreOrLessEquals(10.8));
expect(friction.dx(4.0) < 3.5, true); expect(friction.dx(4.0) < 3.5, true);
expect(friction.isDone(5.0), true); expect(friction.isDone(5.0), true);
...@@ -48,10 +49,9 @@ void main() { ...@@ -48,10 +49,9 @@ void main() {
expect(friction.x(0.0), 10.0); expect(friction.x(0.0), 10.0);
expect(friction.dx(0.0), 600.0); expect(friction.dx(0.0), 600.0);
const double epsilon = 1e-4; expect(friction.isDone(1.0 + precisionErrorTolerance), true);
expect(friction.isDone(1.0 + epsilon), true); expect(friction.x(1.0), moreOrLessEquals(endPosition));
expect(friction.x(1.0), closeTo(endPosition, epsilon)); expect(friction.dx(1.0), moreOrLessEquals(endVelocity));
expect(friction.dx(1.0), closeTo(endVelocity, epsilon));
// Same scenario as above except that the velocities are // Same scenario as above except that the velocities are
// are negative. // are negative.
...@@ -65,9 +65,9 @@ void main() { ...@@ -65,9 +65,9 @@ void main() {
friction = FrictionSimulation.through( friction = FrictionSimulation.through(
startPosition, endPosition, startVelocity, endVelocity); startPosition, endPosition, startVelocity, endVelocity);
expect(friction.isDone(1.0 + epsilon), true); expect(friction.isDone(1.0 + precisionErrorTolerance), true);
expect(friction.x(1.0), closeTo(endPosition, epsilon)); expect(friction.x(1.0), moreOrLessEquals(endPosition));
expect(friction.dx(1.0), closeTo(endVelocity, epsilon)); expect(friction.dx(1.0), moreOrLessEquals(endVelocity));
}); });
test('BoundedFrictionSimulation control test', () { test('BoundedFrictionSimulation control test', () {
...@@ -248,14 +248,14 @@ void main() { ...@@ -248,14 +248,14 @@ void main() {
expect(scroll.x(0.0), 100); expect(scroll.x(0.0), 100);
expect(scroll.dx(0.0), 400.0); expect(scroll.dx(0.0), 400.0);
expect(scroll.x(1.0), closeTo(272.0, 1.0)); expect(scroll.x(1.0), moreOrLessEquals(272.0, epsilon: 1.0));
expect(scroll.dx(1.0), closeTo(54.0, 1.0)); expect(scroll.dx(1.0), moreOrLessEquals(54.0, epsilon: 1.0));
expect(scroll.dx(2.0), closeTo(7.0, 1.0)); expect(scroll.dx(2.0), moreOrLessEquals(7.0, epsilon: 1.0));
expect(scroll.dx(3.0), lessThan(1.0)); expect(scroll.dx(3.0), lessThan(1.0));
expect(scroll.isDone(5.0), true); expect(scroll.isDone(5.0), true);
expect(scroll.x(5.0), closeTo(300.0, 1.0)); expect(scroll.x(5.0), moreOrLessEquals(300.0, epsilon: 1.0));
}); });
test('over/under scroll spring', () { test('over/under scroll spring', () {
...@@ -270,33 +270,33 @@ void main() { ...@@ -270,33 +270,33 @@ void main() {
scroll.tolerance = const Tolerance(velocity: 45.0, distance: 1.5); scroll.tolerance = const Tolerance(velocity: 45.0, distance: 1.5);
expect(scroll.isDone(0.0), false); expect(scroll.isDone(0.0), false);
expect(scroll.x(0.0), closeTo(500.0, .0001)); expect(scroll.x(0.0), moreOrLessEquals(500.0));
expect(scroll.dx(0.0), closeTo(-7500.0, .0001)); expect(scroll.dx(0.0), moreOrLessEquals(-7500.0));
// Expect to reach 0.0 at about t=.07 at which point the simulation will // Expect to reach 0.0 at about t=.07 at which point the simulation will
// switch from friction to the spring // switch from friction to the spring
expect(scroll.isDone(0.065), false); expect(scroll.isDone(0.065), false);
expect(scroll.x(0.065), closeTo(42.0, 1.0)); expect(scroll.x(0.065), moreOrLessEquals(42.0, epsilon: 1.0));
expect(scroll.dx(0.065), closeTo(-6584.0, 1.0)); expect(scroll.dx(0.065), moreOrLessEquals(-6584.0, epsilon: 1.0));
// We've overscrolled (0.1 > 0.07). Trigger the underscroll // We've overscrolled (0.1 > 0.07). Trigger the underscroll
// simulation, and reverse direction // simulation, and reverse direction
expect(scroll.isDone(0.1), false); expect(scroll.isDone(0.1), false);
expect(scroll.x(0.1), closeTo(-123.0, 1.0)); expect(scroll.x(0.1), moreOrLessEquals(-123.0, epsilon: 1.0));
expect(scroll.dx(0.1), closeTo(-2613.0, 1.0)); expect(scroll.dx(0.1), moreOrLessEquals(-2613.0, epsilon: 1.0));
// Headed back towards 0.0 and slowing down. // Headed back towards 0.0 and slowing down.
expect(scroll.isDone(0.5), false); expect(scroll.isDone(0.5), false);
expect(scroll.x(0.5), closeTo(-15.0, 1.0)); expect(scroll.x(0.5), moreOrLessEquals(-15.0, epsilon: 1.0));
expect(scroll.dx(0.5), closeTo(124.0, 1.0)); expect(scroll.dx(0.5), moreOrLessEquals(124.0, epsilon: 1.0));
// Now jump back to the beginning, because we can. // Now jump back to the beginning, because we can.
expect(scroll.isDone(0.0), false); expect(scroll.isDone(0.0), false);
expect(scroll.x(0.0), closeTo(500.0, .0001)); expect(scroll.x(0.0), moreOrLessEquals(500.0));
expect(scroll.dx(0.0), closeTo(-7500.0, .0001)); expect(scroll.dx(0.0), moreOrLessEquals(-7500.0));
expect(scroll.isDone(2.0), true); expect(scroll.isDone(2.0), true);
expect(scroll.x(2.0), 0.0); expect(scroll.x(2.0), 0.0);
expect(scroll.dx(2.0), closeTo(0.0, 1.0)); expect(scroll.dx(2.0), moreOrLessEquals(0.0, epsilon: 1.0));
}); });
} }
...@@ -274,13 +274,13 @@ void main() { ...@@ -274,13 +274,13 @@ void main() {
// rendering widths in tests. // rendering widths in tests.
// TODO(gspencergoog): Figure out why this is, and fix it. https://github.com/flutter/flutter/issues/12357 // TODO(gspencergoog): Figure out why this is, and fix it. https://github.com/flutter/flutter/issues/12357
expect(boxes[0].toRect().width, anyOf(14.0, 13.0)); expect(boxes[0].toRect().width, anyOf(14.0, 13.0));
expect(boxes[0].toRect().height, closeTo(13.0, 0.0001)); expect(boxes[0].toRect().height, moreOrLessEquals(13.0, epsilon: 0.0001));
expect(boxes[1].toRect().width, anyOf(27.0, 26.0)); expect(boxes[1].toRect().width, anyOf(27.0, 26.0));
expect(boxes[1].toRect().height, closeTo(26.0, 0.0001)); expect(boxes[1].toRect().height, moreOrLessEquals(26.0, epsilon: 0.0001));
expect(boxes[2].toRect().width, anyOf(27.0, 26.0)); expect(boxes[2].toRect().width, anyOf(27.0, 26.0));
expect(boxes[2].toRect().height, closeTo(26.0, 0.0001)); expect(boxes[2].toRect().height, moreOrLessEquals(26.0, epsilon: 0.0001));
expect(boxes[3].toRect().width, anyOf(14.0, 13.0)); expect(boxes[3].toRect().width, anyOf(14.0, 13.0));
expect(boxes[3].toRect().height, closeTo(13.0, 0.0001)); expect(boxes[3].toRect().height, moreOrLessEquals(13.0, epsilon: 0.0001));
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/61016 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/61016
test('toStringDeep', () { test('toStringDeep', () {
......
...@@ -50,11 +50,11 @@ void main() { ...@@ -50,11 +50,11 @@ void main() {
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
transition = tester.widget(find.byType(FadeTransition).at(0)); transition = tester.widget(find.byType(FadeTransition).at(0));
expect(transition.opacity.value, closeTo(0.4, 0.01)); expect(transition.opacity.value, moreOrLessEquals(0.4, epsilon: 0.01));
transition = tester.widget(find.byType(FadeTransition).at(1)); transition = tester.widget(find.byType(FadeTransition).at(1));
expect(transition.opacity.value, closeTo(0.4, 0.01)); expect(transition.opacity.value, moreOrLessEquals(0.4, epsilon: 0.01));
transition = tester.widget(find.byType(FadeTransition).at(2)); transition = tester.widget(find.byType(FadeTransition).at(2));
expect(transition.opacity.value, closeTo(0.1, 0.01)); expect(transition.opacity.value, moreOrLessEquals(0.1, epsilon: 0.01));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
...@@ -338,11 +338,11 @@ void main() { ...@@ -338,11 +338,11 @@ void main() {
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
expect(StatefulTestState.generation, equals(3)); expect(StatefulTestState.generation, equals(3));
transition = tester.widget(find.byType(FadeTransition).at(0)); transition = tester.widget(find.byType(FadeTransition).at(0));
expect(transition.opacity.value, closeTo(0.4, 0.01)); expect(transition.opacity.value, moreOrLessEquals(0.4, epsilon: 0.01));
transition = tester.widget(find.byType(FadeTransition).at(1)); transition = tester.widget(find.byType(FadeTransition).at(1));
expect(transition.opacity.value, closeTo(0.4, 0.01)); expect(transition.opacity.value, moreOrLessEquals(0.4, epsilon: 0.01));
transition = tester.widget(find.byType(FadeTransition).at(2)); transition = tester.widget(find.byType(FadeTransition).at(2));
expect(transition.opacity.value, closeTo(0.1, 0.01)); expect(transition.opacity.value, moreOrLessEquals(0.1, epsilon: 0.01));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(StatefulTestState.generation, equals(3)); expect(StatefulTestState.generation, equals(3));
}); });
......
...@@ -263,11 +263,11 @@ void main() { ...@@ -263,11 +263,11 @@ void main() {
final double belowBaseline = math.max(belowBaseline1, belowBaseline2); final double belowBaseline = math.max(belowBaseline1, belowBaseline2);
expect(rowBox.size.height, greaterThan(textBox1.size.height)); expect(rowBox.size.height, greaterThan(textBox1.size.height));
expect(rowBox.size.height, greaterThan(textBox2.size.height)); expect(rowBox.size.height, greaterThan(textBox2.size.height));
expect(rowBox.size.height, closeTo(aboveBaseline + belowBaseline, .001)); expect(rowBox.size.height, moreOrLessEquals(aboveBaseline + belowBaseline, epsilon: .001));
expect(tester.getTopLeft(find.byKey(key1)).dy, 0); expect(tester.getTopLeft(find.byKey(key1)).dy, 0);
expect( expect(
tester.getTopLeft(find.byKey(key2)).dy, tester.getTopLeft(find.byKey(key2)).dy,
closeTo(aboveBaseline1 - aboveBaseline2, .001), moreOrLessEquals(aboveBaseline1 - aboveBaseline2, epsilon: .001),
); );
}); });
...@@ -321,7 +321,7 @@ void main() { ...@@ -321,7 +321,7 @@ void main() {
expect(tester.getTopLeft(find.byKey(key1)).dy, 0); expect(tester.getTopLeft(find.byKey(key1)).dy, 0);
expect( expect(
tester.getTopLeft(find.byKey(key2)).dy, tester.getTopLeft(find.byKey(key2)).dy,
closeTo(aboveBaseline1 - aboveBaseline2, .001), moreOrLessEquals(aboveBaseline1 - aboveBaseline2, epsilon: .001),
); );
}); });
}); });
......
...@@ -218,11 +218,11 @@ void main() { ...@@ -218,11 +218,11 @@ void main() {
Scrollable.ensureVisible(findContext(0)); Scrollable.ensureVisible(findContext(0));
await tester.pump(); await tester.pump();
expect(tester.getBottomRight(findKey(0)).dy, closeTo(100.0, 0.1)); expect(tester.getBottomRight(findKey(0)).dy, moreOrLessEquals(100.0, epsilon: 0.1));
Scrollable.ensureVisible(findContext(0), alignment: 1.0); Scrollable.ensureVisible(findContext(0), alignment: 1.0);
await tester.pump(); await tester.pump();
expect(tester.getTopLeft(findKey(0)).dy, closeTo(500.0, 0.1)); expect(tester.getTopLeft(findKey(0)).dy, moreOrLessEquals(500.0, epsilon: 0.1));
}); });
}); });
...@@ -474,11 +474,11 @@ void main() { ...@@ -474,11 +474,11 @@ void main() {
await prepare(321.0); await prepare(321.0);
Scrollable.ensureVisible(findContext(0)); Scrollable.ensureVisible(findContext(0));
await tester.pump(); await tester.pump();
expect(tester.getBottomRight(findKey(0)).dy, closeTo(100.0, 0.1)); expect(tester.getBottomRight(findKey(0)).dy, moreOrLessEquals(100.0, epsilon: 0.1));
Scrollable.ensureVisible(findContext(0), alignment: 1.0); Scrollable.ensureVisible(findContext(0), alignment: 1.0);
await tester.pump(); await tester.pump();
expect(tester.getTopLeft(findKey(0)).dy, closeTo(500.0, 0.1)); expect(tester.getTopLeft(findKey(0)).dy, moreOrLessEquals(500.0, epsilon: 0.1));
}); });
}); });
......
...@@ -467,25 +467,25 @@ Future<void> main() async { ...@@ -467,25 +467,25 @@ Future<void> main() async {
await tester.pump(duration * 0.25); await tester.pump(duration * 0.25);
expect( expect(
tester.getSize(find.byKey(secondKey)).height, tester.getSize(find.byKey(secondKey)).height,
closeTo(curve.transform(0.25) * deltaHeight + initialHeight, epsilon), moreOrLessEquals(curve.transform(0.25) * deltaHeight + initialHeight, epsilon: epsilon),
); );
await tester.pump(duration * 0.25); await tester.pump(duration * 0.25);
expect( expect(
tester.getSize(find.byKey(secondKey)).height, tester.getSize(find.byKey(secondKey)).height,
closeTo(curve.transform(0.50) * deltaHeight + initialHeight, epsilon), moreOrLessEquals(curve.transform(0.50) * deltaHeight + initialHeight, epsilon: epsilon),
); );
await tester.pump(duration * 0.25); await tester.pump(duration * 0.25);
expect( expect(
tester.getSize(find.byKey(secondKey)).height, tester.getSize(find.byKey(secondKey)).height,
closeTo(curve.transform(0.75) * deltaHeight + initialHeight, epsilon), moreOrLessEquals(curve.transform(0.75) * deltaHeight + initialHeight, epsilon: epsilon),
); );
await tester.pump(duration * 0.25); await tester.pump(duration * 0.25);
expect( expect(
tester.getSize(find.byKey(secondKey)).height, tester.getSize(find.byKey(secondKey)).height,
closeTo(curve.transform(1.0) * deltaHeight + initialHeight, epsilon), moreOrLessEquals(curve.transform(1.0) * deltaHeight + initialHeight, epsilon: epsilon),
); );
}); });
...@@ -720,7 +720,7 @@ Future<void> main() async { ...@@ -720,7 +720,7 @@ Future<void> main() async {
// 150ms so we should be just about back to where Hero 'a' started. // 150ms so we should be just about back to where Hero 'a' started.
const double epsilon = 0.001; const double epsilon = 0.001;
await tester.pump(const Duration(milliseconds: 99)); await tester.pump(const Duration(milliseconds: 99));
closeTo(tester.getSize(find.byKey(secondKey)).height - initialHeight, epsilon); moreOrLessEquals(tester.getSize(find.byKey(secondKey)).height - initialHeight, epsilon: epsilon);
// The flight is finished. We're back to where we started. // The flight is finished. We're back to where we started.
await tester.pump(const Duration(milliseconds: 300)); await tester.pump(const Duration(milliseconds: 300));
...@@ -790,7 +790,7 @@ Future<void> main() async { ...@@ -790,7 +790,7 @@ Future<void> main() async {
// 150ms so we should be just about back to where Hero 'a' started. // 150ms so we should be just about back to where Hero 'a' started.
const double epsilon = 0.001; const double epsilon = 0.001;
await tester.pump(const Duration(milliseconds: 99)); await tester.pump(const Duration(milliseconds: 99));
closeTo(tester.getSize(find.byKey(firstKey)).height - initialHeight, epsilon); moreOrLessEquals(tester.getSize(find.byKey(firstKey)).height - initialHeight, epsilon: epsilon);
// The flight is finished. We're back to where we started. // The flight is finished. We're back to where we started.
await tester.pump(const Duration(milliseconds: 300)); await tester.pump(const Duration(milliseconds: 300));
...@@ -1571,19 +1571,19 @@ Future<void> main() async { ...@@ -1571,19 +1571,19 @@ Future<void> main() async {
// pop, and it should end up where the push started. // pop, and it should end up where the push started.
await tester.pump(); await tester.pump();
expect(tester.getTopLeft(find.byKey(secondKey)).dx, closeTo(x4, epsilon)); expect(tester.getTopLeft(find.byKey(secondKey)).dx, moreOrLessEquals(x4, epsilon: epsilon));
await tester.pump(duration * 0.1); await tester.pump(duration * 0.1);
expect(tester.getTopLeft(find.byKey(secondKey)).dx, closeTo(x3, epsilon)); expect(tester.getTopLeft(find.byKey(secondKey)).dx, moreOrLessEquals(x3, epsilon: epsilon));
await tester.pump(duration * 0.1); await tester.pump(duration * 0.1);
expect(tester.getTopLeft(find.byKey(secondKey)).dx, closeTo(x2, epsilon)); expect(tester.getTopLeft(find.byKey(secondKey)).dx, moreOrLessEquals(x2, epsilon: epsilon));
await tester.pump(duration * 0.1); await tester.pump(duration * 0.1);
expect(tester.getTopLeft(find.byKey(secondKey)).dx, closeTo(x1, epsilon)); expect(tester.getTopLeft(find.byKey(secondKey)).dx, moreOrLessEquals(x1, epsilon: epsilon));
await tester.pump(duration * 0.1); await tester.pump(duration * 0.1);
expect(tester.getTopLeft(find.byKey(secondKey)).dx, closeTo(x0, epsilon)); expect(tester.getTopLeft(find.byKey(secondKey)).dx, moreOrLessEquals(x0, epsilon: epsilon));
// Below: show that a different pop Hero path is in fact taken after // Below: show that a different pop Hero path is in fact taken after
// a completed push transition. // a completed push transition.
...@@ -1612,10 +1612,10 @@ Future<void> main() async { ...@@ -1612,10 +1612,10 @@ Future<void> main() async {
await tester.pump(duration * 0.6); await tester.pump(duration * 0.6);
await tester.pump(duration * 0.1); await tester.pump(duration * 0.1);
expect(tester.getTopLeft(find.byKey(firstKey)).dx, isNot(closeTo(x4, epsilon))); expect(tester.getTopLeft(find.byKey(firstKey)).dx, isNot(moreOrLessEquals(x4, epsilon: epsilon)));
await tester.pump(duration * 0.1); await tester.pump(duration * 0.1);
expect(tester.getTopLeft(find.byKey(firstKey)).dx, isNot(closeTo(x3, epsilon))); expect(tester.getTopLeft(find.byKey(firstKey)).dx, isNot(moreOrLessEquals(x3, epsilon: epsilon)));
// At this point the flight path arcs do start to get pretty close so // At this point the flight path arcs do start to get pretty close so
// there's no point in comparing them. // there's no point in comparing them.
......
...@@ -383,22 +383,22 @@ void main() { ...@@ -383,22 +383,22 @@ void main() {
// It hits the boundary in the x direction first. // It hits the boundary in the x direction first.
await tester.pump(const Duration(milliseconds: 60)); await tester.pump(const Duration(milliseconds: 60));
translation = transformationController.value.getTranslation(); translation = transformationController.value.getTranslation();
expect(translation.x, closeTo(boundaryMargin, .000000001)); expect(translation.x, moreOrLessEquals(boundaryMargin, epsilon: 1e-9));
expect(translation.y, lessThan(boundaryMargin)); expect(translation.y, lessThan(boundaryMargin));
final double yWhenXHits = translation.y; final double yWhenXHits = translation.y;
// x is held to the boundary while y slides along. // x is held to the boundary while y slides along.
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
translation = transformationController.value.getTranslation(); translation = transformationController.value.getTranslation();
expect(translation.x, closeTo(boundaryMargin, .000000001)); expect(translation.x, moreOrLessEquals(boundaryMargin, epsilon: 1e-9));
expect(translation.y, greaterThan(yWhenXHits)); expect(translation.y, greaterThan(yWhenXHits));
expect(translation.y, lessThan(boundaryMargin)); expect(translation.y, lessThan(boundaryMargin));
// Eventually it ends up in the corner. // Eventually it ends up in the corner.
await tester.pumpAndSettle(); await tester.pumpAndSettle();
translation = transformationController.value.getTranslation(); translation = transformationController.value.getTranslation();
expect(translation.x, closeTo(boundaryMargin, .000000001)); expect(translation.x, moreOrLessEquals(boundaryMargin, epsilon: 1e-9));
expect(translation.y, closeTo(boundaryMargin, .000000001)); expect(translation.y, moreOrLessEquals(boundaryMargin, epsilon: 1e-9));
}); });
testWidgets('Scaling automatically causes a centering translation', (WidgetTester tester) async { testWidgets('Scaling automatically causes a centering translation', (WidgetTester tester) async {
...@@ -430,8 +430,8 @@ void main() { ...@@ -430,8 +430,8 @@ void main() {
await tester.flingFrom(childOffset, flingEnd, 1000.0); await tester.flingFrom(childOffset, flingEnd, 1000.0);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
translation = transformationController.value.getTranslation(); translation = transformationController.value.getTranslation();
expect(translation.x, closeTo(boundaryMargin, .000000001)); expect(translation.x, moreOrLessEquals(boundaryMargin, epsilon: 1e-9));
expect(translation.y, closeTo(boundaryMargin, .000000001)); expect(translation.y, moreOrLessEquals(boundaryMargin, epsilon: 1e-9));
// Zoom out so the entire child is visible. The child will also be // Zoom out so the entire child is visible. The child will also be
// translated in order to keep it inside the boundaries. // translated in order to keep it inside the boundaries.
...@@ -457,7 +457,7 @@ void main() { ...@@ -457,7 +457,7 @@ void main() {
expect(translation.y, lessThan(boundaryMargin)); expect(translation.y, lessThan(boundaryMargin));
expect(translation.x, greaterThan(0.0)); expect(translation.x, greaterThan(0.0));
expect(translation.y, greaterThan(0.0)); expect(translation.y, greaterThan(0.0));
expect(translation.x, closeTo(translation.y, .000000001)); expect(translation.x, moreOrLessEquals(translation.y, epsilon: 1e-9));
// Zoom in on a point that's not the center, and see that it remains at // Zoom in on a point that's not the center, and see that it remains at
// roughly the same location in the viewport after the zoom. // roughly the same location in the viewport after the zoom.
...@@ -482,8 +482,8 @@ void main() { ...@@ -482,8 +482,8 @@ void main() {
await gesture2.up(); await gesture2.up();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final Offset newSceneFocalPoint = transformationController.toScene(viewportFocalPoint); final Offset newSceneFocalPoint = transformationController.toScene(viewportFocalPoint);
expect(newSceneFocalPoint.dx, closeTo(sceneFocalPoint.dx, 1.0)); expect(newSceneFocalPoint.dx, moreOrLessEquals(sceneFocalPoint.dx, epsilon: 1.0));
expect(newSceneFocalPoint.dy, closeTo(sceneFocalPoint.dy, 1.0)); expect(newSceneFocalPoint.dy, moreOrLessEquals(sceneFocalPoint.dy, epsilon: 1.0));
}); });
testWidgets('Scaling automatically causes a centering translation even when alignPanAxis is set', (WidgetTester tester) async { testWidgets('Scaling automatically causes a centering translation even when alignPanAxis is set', (WidgetTester tester) async {
...@@ -522,8 +522,8 @@ void main() { ...@@ -522,8 +522,8 @@ void main() {
await tester.flingFrom(childOffset2, flingEnd2, 1000.0); await tester.flingFrom(childOffset2, flingEnd2, 1000.0);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
translation = transformationController.value.getTranslation(); translation = transformationController.value.getTranslation();
expect(translation.x, closeTo(boundaryMargin, .000000001)); expect(translation.x, moreOrLessEquals(boundaryMargin, epsilon: 1e-9));
expect(translation.y, closeTo(boundaryMargin, .000000001)); expect(translation.y, moreOrLessEquals(boundaryMargin, epsilon: 1e-9));
// Zoom out so the entire child is visible. The child will also be // Zoom out so the entire child is visible. The child will also be
// translated in order to keep it inside the boundaries. // translated in order to keep it inside the boundaries.
...@@ -549,7 +549,7 @@ void main() { ...@@ -549,7 +549,7 @@ void main() {
expect(translation.y, lessThan(boundaryMargin)); expect(translation.y, lessThan(boundaryMargin));
expect(translation.x, greaterThan(0.0)); expect(translation.x, greaterThan(0.0));
expect(translation.y, greaterThan(0.0)); expect(translation.y, greaterThan(0.0));
expect(translation.x, closeTo(translation.y, .000000001)); expect(translation.x, moreOrLessEquals(translation.y, epsilon: 1e-9));
// Zoom in on a point that's not the center, and see that it remains at // Zoom in on a point that's not the center, and see that it remains at
// roughly the same location in the viewport after the zoom. // roughly the same location in the viewport after the zoom.
...@@ -574,8 +574,8 @@ void main() { ...@@ -574,8 +574,8 @@ void main() {
await gesture2.up(); await gesture2.up();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final Offset newSceneFocalPoint = transformationController.toScene(viewportFocalPoint); final Offset newSceneFocalPoint = transformationController.toScene(viewportFocalPoint);
expect(newSceneFocalPoint.dx, closeTo(sceneFocalPoint.dx, 1.0)); expect(newSceneFocalPoint.dx, moreOrLessEquals(sceneFocalPoint.dx, epsilon: 1.0));
expect(newSceneFocalPoint.dy, closeTo(sceneFocalPoint.dy, 1.0)); expect(newSceneFocalPoint.dy, moreOrLessEquals(sceneFocalPoint.dy, epsilon: 1.0));
}); });
testWidgets('Can scale with mouse', (WidgetTester tester) async { testWidgets('Can scale with mouse', (WidgetTester tester) async {
...@@ -784,8 +784,8 @@ void main() { ...@@ -784,8 +784,8 @@ void main() {
final Vector3 closestPoint = InteractiveViewer.getNearestPointOnLine(point, a , b); final Vector3 closestPoint = InteractiveViewer.getNearestPointOnLine(point, a , b);
expect(closestPoint.x, closeTo(-356.8, 0.1)); expect(closestPoint.x, moreOrLessEquals(-356.8, epsilon: 0.1));
expect(closestPoint.y, closeTo(205.8, 0.1)); expect(closestPoint.y, moreOrLessEquals(205.8, epsilon: 0.1));
}); });
}); });
...@@ -933,8 +933,8 @@ void main() { ...@@ -933,8 +933,8 @@ void main() {
final Vector3 nearestPoint = InteractiveViewer.getNearestPointInside(point, quad); final Vector3 nearestPoint = InteractiveViewer.getNearestPointInside(point, quad);
expect(nearestPoint.x, closeTo(5.8, 0.1)); expect(nearestPoint.x, moreOrLessEquals(5.8, epsilon: 0.1));
expect(nearestPoint.y, closeTo(10.8, 0.1)); expect(nearestPoint.y, moreOrLessEquals(10.8, epsilon: 0.1));
}); });
}); });
} }
...@@ -1465,21 +1465,21 @@ void main() { ...@@ -1465,21 +1465,21 @@ void main() {
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect( expect(
modalBarrierAnimation.value.alpha, modalBarrierAnimation.value.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.25), 1.0), closeTo(_getExpectedBarrierTweenAlphaValue(0.25), 1),
); );
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect( expect(
modalBarrierAnimation.value.alpha, modalBarrierAnimation.value.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.50), 1.0), closeTo(_getExpectedBarrierTweenAlphaValue(0.50), 1),
); );
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect( expect(
modalBarrierAnimation.value.alpha, modalBarrierAnimation.value.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.75), 1.0), closeTo(_getExpectedBarrierTweenAlphaValue(0.75), 1),
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -1528,21 +1528,21 @@ void main() { ...@@ -1528,21 +1528,21 @@ void main() {
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect( expect(
modalBarrierAnimation.value.alpha, modalBarrierAnimation.value.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.25), 1.0), closeTo(_getExpectedBarrierTweenAlphaValue(0.25), 1),
); );
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect( expect(
modalBarrierAnimation.value.alpha, modalBarrierAnimation.value.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.50), 1.0), closeTo(_getExpectedBarrierTweenAlphaValue(0.50), 1),
); );
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect( expect(
modalBarrierAnimation.value.alpha, modalBarrierAnimation.value.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.75), 1.0), closeTo(_getExpectedBarrierTweenAlphaValue(0.75), 1),
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
......
...@@ -411,7 +411,7 @@ void main() { ...@@ -411,7 +411,7 @@ void main() {
AxisDirection.down, AxisDirection.down,
); );
p.paint(testCanvas, size); p.paint(testCanvas, size);
expect(captureRect().height, closeTo(fullThumbExtent, .000001)); expect(captureRect().height, moreOrLessEquals(fullThumbExtent, epsilon: 1e-6));
// Scrolling just to the very end also gives a full sized thumb. // Scrolling just to the very end also gives a full sized thumb.
p.update( p.update(
...@@ -421,7 +421,7 @@ void main() { ...@@ -421,7 +421,7 @@ void main() {
AxisDirection.down, AxisDirection.down,
); );
p.paint(testCanvas, size); p.paint(testCanvas, size);
expect(captureRect().height, closeTo(fullThumbExtent, .000001)); expect(captureRect().height, moreOrLessEquals(fullThumbExtent, epsilon: 1e-6));
// Scrolling just past the end shrinks the thumb slightly. // Scrolling just past the end shrinks the thumb slightly.
p.update( p.update(
...@@ -431,7 +431,7 @@ void main() { ...@@ -431,7 +431,7 @@ void main() {
AxisDirection.down, AxisDirection.down,
); );
p.paint(testCanvas, size); p.paint(testCanvas, size);
expect(captureRect().height, closeTo(fullThumbExtent, 2.0)); expect(captureRect().height, moreOrLessEquals(fullThumbExtent, epsilon: 2.0));
// Scrolling way past the end shrinks the thumb to minimum. // Scrolling way past the end shrinks the thumb to minimum.
p.update( p.update(
......
...@@ -1777,8 +1777,8 @@ void main() { ...@@ -1777,8 +1777,8 @@ void main() {
// --------- rowBottomY // --------- rowBottomY
final double rowBottomY = tester.getBottomLeft(find.byType(Row)).dy; final double rowBottomY = tester.getBottomLeft(find.byType(Row)).dy;
expect(tester.getBottomLeft(find.byKey(keyA)).dy, closeTo(rowBottomY - 4.0, 0.001)); expect(tester.getBottomLeft(find.byKey(keyA)).dy, moreOrLessEquals(rowBottomY - 4.0, epsilon: 1e-3));
expect(tester.getBottomLeft(find.text('abc')).dy, closeTo(rowBottomY - 2.0, 0.001)); expect(tester.getBottomLeft(find.text('abc')).dy, moreOrLessEquals(rowBottomY - 2.0, epsilon: 1e-3));
expect(tester.getBottomLeft(find.byKey(keyB)).dy, rowBottomY); expect(tester.getBottomLeft(find.byKey(keyB)).dy, rowBottomY);
}); });
...@@ -1824,8 +1824,8 @@ void main() { ...@@ -1824,8 +1824,8 @@ void main() {
// --------- rowBottomY // --------- rowBottomY
final double rowBottomY = tester.getBottomLeft(find.byType(Row)).dy; final double rowBottomY = tester.getBottomLeft(find.byType(Row)).dy;
expect(tester.getBottomLeft(find.byKey(keyA)).dy, closeTo(rowBottomY - 4.0, 0.001)); expect(tester.getBottomLeft(find.byKey(keyA)).dy, moreOrLessEquals(rowBottomY - 4.0, epsilon: 1e-3));
expect(tester.getBottomLeft(find.text('abc')).dy, closeTo(rowBottomY - 2.0, 0.001)); expect(tester.getBottomLeft(find.text('abc')).dy, moreOrLessEquals(rowBottomY - 2.0, epsilon: 1e-3));
expect(tester.getBottomLeft(find.byKey(keyB)).dy, rowBottomY); expect(tester.getBottomLeft(find.byKey(keyB)).dy, rowBottomY);
}); });
......
...@@ -45,14 +45,14 @@ void main() { ...@@ -45,14 +45,14 @@ void main() {
final Rect spacer3Rect = tester.getRect(find.byType(Spacer).at(2)); final Rect spacer3Rect = tester.getRect(find.byType(Spacer).at(2));
final Rect spacer4Rect = tester.getRect(find.byType(Spacer).at(3)); final Rect spacer4Rect = tester.getRect(find.byType(Spacer).at(3));
expect(spacer1Rect.size.height, 0.0); expect(spacer1Rect.size.height, 0.0);
expect(spacer1Rect.size.width, closeTo(93.8, 0.1)); expect(spacer1Rect.size.width, moreOrLessEquals(93.8, epsilon: 0.1));
expect(spacer1Rect.left, closeTo(696.3, 0.1)); expect(spacer1Rect.left, moreOrLessEquals(696.3, epsilon: 0.1));
expect(spacer2Rect.size.width, closeTo(93.8, 0.1)); expect(spacer2Rect.size.width, moreOrLessEquals(93.8, epsilon: 0.1));
expect(spacer2Rect.left, closeTo(592.5, 0.1)); expect(spacer2Rect.left, moreOrLessEquals(592.5, epsilon: 0.1));
expect(spacer3Rect.size.width, spacer2Rect.size.width * 2.0); expect(spacer3Rect.size.width, spacer2Rect.size.width * 2.0);
expect(spacer3Rect.left, closeTo(395.0, 0.1)); expect(spacer3Rect.left, moreOrLessEquals(395.0, epsilon: 0.1));
expect(spacer4Rect.size.width, spacer3Rect.size.width * 2.0); expect(spacer4Rect.size.width, spacer3Rect.size.width * 2.0);
expect(spacer4Rect.left, closeTo(10.0, 0.1)); expect(spacer4Rect.left, moreOrLessEquals(10.0, epsilon: 0.1));
}); });
testWidgets('Spacer takes up space.', (WidgetTester tester) async { testWidgets('Spacer takes up space.', (WidgetTester tester) async {
......
...@@ -141,13 +141,13 @@ void main() { ...@@ -141,13 +141,13 @@ void main() {
expect(actualDecoration.color, const Color(0xFF505050)); expect(actualDecoration.color, const Color(0xFF505050));
expect(actualDecoration.border, isA<Border>()); expect(actualDecoration.border, isA<Border>());
final Border border = actualDecoration.border as Border; final Border border = actualDecoration.border as Border;
expect(border.left.width, closeTo(1.9, 0.1)); expect(border.left.width, moreOrLessEquals(1.9, epsilon: 0.1));
expect(border.left.style, BorderStyle.solid); expect(border.left.style, BorderStyle.solid);
expect(border.left.color, const Color(0xFF151515)); expect(border.left.color, const Color(0xFF151515));
expect(actualDecoration.borderRadius.resolve(TextDirection.ltr).topLeft.x, closeTo(6.8, 0.1)); expect(actualDecoration.borderRadius.resolve(TextDirection.ltr).topLeft.x, moreOrLessEquals(6.8, epsilon: 0.1));
expect(actualDecoration.shape, BoxShape.rectangle); expect(actualDecoration.shape, BoxShape.rectangle);
expect(actualDecoration.boxShadow[0].blurRadius, closeTo(3.1, 0.1)); expect(actualDecoration.boxShadow[0].blurRadius, moreOrLessEquals(3.1, epsilon: 0.1));
expect(actualDecoration.boxShadow[0].spreadRadius, closeTo(1.2, 0.1)); expect(actualDecoration.boxShadow[0].spreadRadius, moreOrLessEquals(1.2, epsilon: 0.1));
// Scaling a shadow doesn't change the color. // Scaling a shadow doesn't change the color.
expect(actualDecoration.boxShadow[0].color, const Color(0x66000000)); expect(actualDecoration.boxShadow[0].color, const Color(0x66000000));
}); });
......
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