-
Notifications
You must be signed in to change notification settings - Fork 2k
[Shapes] Line: Fix asymmetric Stretch.None path translation when right/bottom edge overflows #34385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kubaflo
merged 7 commits into
dotnet:inflight/current
from
NirmalKumarYuvaraj:fix-11404
Mar 28, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cf48e37
Fixed 11404
NirmalKumarYuvaraj e3a87ae
More refactoring
NirmalKumarYuvaraj 0074281
Add device test and update UI test for Issue11404 to use position-bas…
NirmalKumarYuvaraj 5d6eca7
Add tests for Issue26961 and StrokeThickness regression verification
NirmalKumarYuvaraj 60e4270
Remove device tests for Line PathForBounds — UI tests cover the same …
NirmalKumarYuvaraj 822faeb
removed 26961 test
NirmalKumarYuvaraj 20aecf7
updated 11404 Platforms
NirmalKumarYuvaraj 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
109 changes: 109 additions & 0 deletions
109
src/Controls/tests/TestCases.HostApp/Issues/Issue11404.cs
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,109 @@ | ||
| using Microsoft.Maui.Controls.Shapes; | ||
| using Microsoft.Maui.Graphics; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 11404, "Line coordinates not computed correctly", PlatformAffected.All)] | ||
| public class Issue11404 : ContentPage | ||
| { | ||
| readonly Line _line1; | ||
| readonly Line _line2; | ||
| readonly Label _resultLabel; | ||
|
|
||
| public Issue11404() | ||
| { | ||
| Title = "Issue11404"; | ||
|
|
||
| _line1 = new Line | ||
| { | ||
| X1 = 0, | ||
| Y1 = 0, | ||
| X2 = 100, | ||
| Y2 = 100, | ||
| Stroke = new SolidColorBrush(Colors.Red), | ||
| StrokeThickness = 10 | ||
| }; | ||
|
|
||
| _line2 = new Line | ||
| { | ||
| X1 = 200, | ||
| Y1 = 0, | ||
| X2 = 100, | ||
| Y2 = 100, | ||
| Stroke = new SolidColorBrush(Colors.Red), | ||
| StrokeThickness = 10 | ||
| }; | ||
|
|
||
| var line3 = new Line | ||
| { | ||
| X1 = 200, | ||
| Y1 = 0, | ||
| X2 = 100, | ||
| Y2 = 100, | ||
| Stroke = new SolidColorBrush(Colors.Black), | ||
| StrokeThickness = 1 | ||
| }; | ||
|
|
||
| var grid = new Grid | ||
| { | ||
| WidthRequest = 200, | ||
| HeightRequest = 200, | ||
| BackgroundColor = Colors.LightGray | ||
| }; | ||
|
|
||
| grid.Children.Add(_line1); | ||
| grid.Children.Add(_line2); | ||
| grid.Children.Add(line3); | ||
|
|
||
| _resultLabel = new Label | ||
| { | ||
| Text = "Checking...", | ||
| AutomationId = "SymmetryResult", | ||
| Margin = new Thickness(10), | ||
| HorizontalOptions = LayoutOptions.Center | ||
| }; | ||
|
|
||
| var descriptionLabel = new Label | ||
| { | ||
| Text = "Two thick red lines should form a symmetric V shape. SymmetryResult should show 'Pass'.", | ||
| Margin = new Thickness(10), | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| AutomationId = "DescriptionLabel" | ||
| }; | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Children = { grid, _resultLabel, descriptionLabel } | ||
| }; | ||
|
|
||
| SizeChanged += OnPageSizeChanged; | ||
| } | ||
|
|
||
| void OnPageSizeChanged(object sender, EventArgs e) | ||
| { | ||
| SizeChanged -= OnPageSizeChanged; | ||
| UpdateSymmetryResult(); | ||
| } | ||
|
|
||
| void UpdateSymmetryResult() | ||
| { | ||
| // Use the fixed view bounds matching the grid size | ||
| var viewBounds = new Rect(0, 0, 200, 200); | ||
|
|
||
| var path1 = ((IShape)_line1).PathForBounds(viewBounds); | ||
| var path2 = ((IShape)_line2).PathForBounds(viewBounds); | ||
|
|
||
| var bounds1 = path1.GetBoundsByFlattening(1); | ||
| var bounds2 = path2.GetBoundsByFlattening(1); | ||
|
|
||
| // line1 (0,0)→(100,100) and line2 (200,0)→(100,100) are symmetric around X=100. | ||
| // After correct transformation: bounds1.Left + bounds2.Right ≈ 200 | ||
| // and bounds1.Right + bounds2.Left ≈ 200. | ||
| const float tolerance = 2f; | ||
| bool isSymmetric = | ||
| Math.Abs(bounds1.Left + bounds2.Right - 200f) < tolerance && | ||
| Math.Abs(bounds1.Right + bounds2.Left - 200f) < tolerance; | ||
|
|
||
| _resultLabel.Text = isSymmetric ? "Pass" : "Fail"; | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue11404.cs
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,32 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| { | ||
| public class Issue11404 : _IssuesUITest | ||
| { | ||
| public Issue11404(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Line coordinates not computed correctly"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Shape)] | ||
| public void LineWithReversedCoordinatesShouldRenderSymmetrical() | ||
| { | ||
| App.WaitForElement("DescriptionLabel"); | ||
|
|
||
| // Wait for the symmetry check to complete (SizeChanged fires after layout) | ||
| App.WaitForElement("SymmetryResult"); | ||
|
|
||
| // The HostApp computes path bounds for both lines and checks symmetry. | ||
| // "Pass" means bounds1.Left + bounds2.Right ≈ 200 and bounds1.Right + bounds2.Left ≈ 200, | ||
| // proving the path coordinates are symmetric around the center axis (X=100). | ||
| var result = App.FindElement("SymmetryResult").GetText(); | ||
| Assert.That(result, Is.EqualTo("Pass"), | ||
| "Line paths should be symmetric: path coordinates for mirror-image lines should mirror around center axis X=100"); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.