-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix: OnIdiom Default Value Handling for ValueType Properties #28257
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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,9 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Controls.TestCases.HostApp.Issues.Issue9978" | ||
| Title="Issue9978"> | ||
| <VerticalStackLayout> | ||
| <Image AutomationId="MauiImage" Source="groceries.png" HeightRequest="{OnIdiom Tablet=100}" /> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
11 changes: 11 additions & 0 deletions
11
src/Controls/tests/TestCases.HostApp/Issues/Issue9978.xaml.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,11 @@ | ||
| namespace Controls.TestCases.HostApp.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 9978, "VisualElement.HeightRequest defaults to 0 instead of -1 when using OnIdiom default value", | ||
| PlatformAffected.All)] | ||
| public partial class Issue9978 : ContentPage | ||
| { | ||
| public Issue9978() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
| } | ||
24 changes: 24 additions & 0 deletions
24
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9978.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,24 @@ | ||
| using System; | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Tests.Issues; | ||
|
|
||
| public class Issue9978 : _IssuesUITest | ||
| { | ||
| public Issue9978(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "VisualElement.HeightRequest defaults to 0 instead of -1 when using OnIdiom default value"; | ||
|
|
||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Layout)] | ||
| public void Issue9978Test() | ||
| { | ||
| App.WaitForElement("MauiImage"); | ||
|
|
||
| } | ||
| } |
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,7 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Issues.Issue9978" | ||
| Title="Issue9978"> | ||
| <Button x:Name="mauiButton" Text="Sample Button" HeightRequest="{OnIdiom Tablet=50}" /> | ||
| </ContentPage> |
52 changes: 52 additions & 0 deletions
52
src/Controls/tests/Xaml.UnitTests/Issues/Issue9978.xaml.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,52 @@ | ||
| using Microsoft.Maui.Controls.Core.UnitTests; | ||
| using Microsoft.Maui.Devices; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Microsoft.Maui.Controls.Xaml.UnitTests.Issues; | ||
|
|
||
| public partial class Issue9978 : ContentPage | ||
| { | ||
| public Issue9978() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| public Issue9978(bool useCompiledXaml) | ||
| { | ||
| //this stub will be replaced at compile time | ||
| } | ||
|
|
||
| [TestFixture] | ||
| public class Tests | ||
| { | ||
| [TestCase(false)] | ||
| [TestCase(true)] | ||
| public void OnIdiomReturnsBindableDefaultIfNotSet(bool useCompiledXaml) | ||
| { | ||
| var idioms = new[] | ||
| { | ||
| DeviceIdiom.Tablet, | ||
| DeviceIdiom.Phone, | ||
| DeviceIdiom.Desktop, | ||
| DeviceIdiom.Watch, | ||
| DeviceIdiom.TV | ||
| }; | ||
|
|
||
| foreach (var idiom in idioms) | ||
| { | ||
| DeviceInfo.SetCurrent(new MockDeviceInfo { Idiom = idiom }); | ||
| var page = new Issue9978(useCompiledXaml); | ||
|
|
||
| if (idiom == DeviceIdiom.Tablet) | ||
| { | ||
| Assert.AreEqual(50, page.mauiButton.HeightRequest, $"Expected 50 for idiom Tablet"); | ||
| } | ||
| else | ||
| { | ||
| Assert.AreEqual(-1, page.mauiButton.HeightRequest, $"Expected -1 for idiom {idiom}"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
| } |
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
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.
I'd need this test in Xaml.UnitTest so we test for all xaml inflators