This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] PathRef: do not use == with doubles in assertions #31382
Merged
fluttergithubbot
merged 1 commit into
flutter:main
from
yjbanov:remove-path-ref-asserts
Feb 11, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:test/bootstrap/browser.dart'; | ||
| import 'package:test/test.dart'; | ||
| import 'package:ui/src/engine.dart'; | ||
| import 'package:ui/ui.dart'; | ||
|
|
||
| // TODO(yjbanov): https://github.com/flutter/flutter/issues/76885 | ||
| const bool issue76885Exists = true; | ||
|
|
||
| void main() { | ||
| internalBootstrapBrowserTest(() => testMain); | ||
| } | ||
|
|
||
| void testMain() { | ||
| test('PathRef.getRRect with radius', () { | ||
| final SurfacePath path = SurfacePath(); | ||
| final RRect rrect = RRect.fromLTRBR(0, 0, 10, 10, const Radius.circular(2)); | ||
| path.addRRect(rrect); | ||
| expect(path.toRoundedRect(), rrect); | ||
| }); | ||
|
|
||
| test('PathRef.getRRect with radius larger than rect', () { | ||
| final SurfacePath path = SurfacePath(); | ||
| final RRect rrect = RRect.fromLTRBR(0, 0, 10, 10, const Radius.circular(20)); | ||
| path.addRRect(rrect); | ||
| expect( | ||
| path.toRoundedRect(), | ||
| // Path.addRRect will correct the radius to fit the dimensions, so when | ||
| // extracting the rrect out of the path we don't get the original. | ||
| RRect.fromLTRBR(0, 0, 10, 10, const Radius.circular(5)), | ||
| ); | ||
| }); | ||
|
|
||
| test('PathRef.getRRect with zero radius', () { | ||
| final SurfacePath path = SurfacePath(); | ||
| final RRect rrect = RRect.fromLTRBR(0, 0, 10, 10, const Radius.circular(0)); | ||
| path.addRRect(rrect); | ||
| expect(path.toRoundedRect(), isNull); | ||
| expect(path.toRect(), rrect.outerRect); | ||
| }); | ||
|
|
||
| test('PathRef.getRRect elliptical', () { | ||
| final SurfacePath path = SurfacePath(); | ||
| final RRect rrect = RRect.fromLTRBR(0, 0, 10, 10, const Radius.elliptical(2, 4)); | ||
| path.addRRect(rrect); | ||
| expect(path.toRoundedRect(), rrect); | ||
| }); | ||
|
|
||
| test('PathRef.getRRect elliptical zero x', () { | ||
| final SurfacePath path = SurfacePath(); | ||
| final RRect rrect = RRect.fromLTRBR(0, 0, 10, 10, const Radius.elliptical(0, 3)); | ||
| path.addRRect(rrect); | ||
| expect(path.toRoundedRect(), isNull); | ||
| expect(path.toRect(), rrect.outerRect); | ||
| }); | ||
|
|
||
| test('PathRef.getRRect elliptical zero y', () { | ||
| final SurfacePath path = SurfacePath(); | ||
| final RRect rrect = RRect.fromLTRBR(0, 0, 10, 10, const Radius.elliptical(3, 0)); | ||
| path.addRRect(rrect); | ||
| expect(path.toRoundedRect(), isNull); | ||
| expect(path.toRect(), rrect.outerRect); | ||
| }); | ||
|
|
||
| // This test demonstrates the issue with attempting to reconstruct an RRect | ||
| // with imprecision introduced by comparing double values. We should fix this | ||
| // by removing the need to reconstruct rrects: | ||
| // https://github.com/flutter/flutter/issues/76885 | ||
| test('PathRef.getRRect with nearly zero corner', () { | ||
| final SurfacePath path = SurfacePath(); | ||
| final RRect original = RRect.fromLTRBR(0, 0, 10, 10, const Radius.elliptical(0.00000001, 5)); | ||
| path.addRRect(original); | ||
| expect(path.toRoundedRect(), original); | ||
| }, skip: issue76885Exists); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!SPath.nearlyEqual(pts[2], pts[0]))?(Going by lines 256 and 291)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now just changing the asserts, but keeping the release functionality intact.