-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fixed Maui.Graphics GetStringSize Inverts Width and Height #29574
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
Open
Dhivya-SF4094
wants to merge
6
commits into
dotnet:main
Choose a base branch
from
Dhivya-SF4094:fix-29562
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+68
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a83b4c2
Fixed incorrect width and height
Dhivya-SF4094 5fa5f66
Updated test sample
Dhivya-SF4094 f8e4b3f
Updated method name
Dhivya-SF4094 57c8929
Update shared test sample
Dhivya-SF4094 ba94188
Given width and height request for graphicsview in sample
Dhivya-SF4094 150e731
Added snapshots
Dhivya-SF4094 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
Binary file added
BIN
+10.9 KB
...sts/TestCases.Android.Tests/snapshots/android/GraphicsViewShouldNotWrapText.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,45 @@ | ||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[Issue(IssueTracker.Github, 29562, "Maui.Graphics GetStringSize Inverts Width and Height", PlatformAffected.UWP)] | ||
public class Issue29562 : ContentPage | ||
{ | ||
public Issue29562() | ||
{ | ||
var stack = new StackLayout(); | ||
var graphicsView = new GraphicsView | ||
{ | ||
HeightRequest = 300, | ||
WidthRequest = 300, | ||
}; | ||
|
||
graphicsView.Drawable = new Issue29562_drawable(); | ||
var label = new Label | ||
{ | ||
Text = "Text should displayed in single line.", | ||
AutomationId = "Label" | ||
}; | ||
|
||
stack.Children.Add(label); | ||
stack.Children.Add(graphicsView); | ||
Content = stack; | ||
} | ||
} | ||
|
||
class Issue29562_drawable : IDrawable | ||
{ | ||
public void Draw(ICanvas canvas, RectF dirtyRect) | ||
{ | ||
const string text = "Hello World"; | ||
var fontSize = 20; | ||
var font = new Microsoft.Maui.Graphics.Font("Arial"); | ||
|
||
// Measure text | ||
var textSize = canvas.GetStringSize(text, font, fontSize); | ||
|
||
float rectX = (dirtyRect.Width - textSize.Width) / 2; | ||
float rectY = (dirtyRect.Height - textSize.Height) / 2; | ||
|
||
var boxRect = new RectF(rectX, rectY, textSize.Width, textSize.Height); | ||
canvas.DrawString(text, boxRect, HorizontalAlignment.Left, VerticalAlignment.Top); | ||
} | ||
} |
Binary file added
BIN
+5.43 KB
...trols/tests/TestCases.Mac.Tests/snapshots/mac/GraphicsViewShouldNotWrapText.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions
22
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29562.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,22 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
||
public class Issue29562 : _IssuesUITest | ||
{ | ||
public Issue29562(TestDevice testDevice) : base(testDevice) | ||
{ | ||
} | ||
|
||
public override string Issue => "Maui.Graphics GetStringSize Inverts Width and Height"; | ||
|
||
[Test] | ||
[Category(UITestCategories.GraphicsView)] | ||
public void GraphicsViewShouldNotWrapText() | ||
{ | ||
App.WaitForElement("Label"); | ||
VerifyScreenshot(); | ||
} | ||
} |
Binary file added
BIN
+6.91 KB
...tests/TestCases.WinUI.Tests/snapshots/windows/GraphicsViewShouldNotWrapText.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.8 KB
...trols/tests/TestCases.iOS.Tests/snapshots/ios/GraphicsViewShouldNotWrapText.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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.
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.
Pending snapshots. Running a build.
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.
@jsuarezruiz Added the Snapshots.