-
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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> |
| 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(); | ||
| } | ||
| } | ||
| 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"); | ||
|
|
||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,5 +178,28 @@ public void StackLayoutOrientation() | |
| layout = new StackLayout().LoadFromXaml(xaml); | ||
| Assert.AreEqual(StackOrientation.Horizontal, layout.Orientation); | ||
| } | ||
|
|
||
| [Test] | ||
| public void OnIdiomReturnsBindablePropertyDefaultWhenNotSet() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. look at what other tests are doing, in the Issues folder. it needs a xaml and a xaml.cs file. this doesn't test XamlC inflation
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, sorry about that — I hadn’t opened Xaml.UnitTests until a few hours ago. :) |
||
| { | ||
| var xaml = @" | ||
| <Button | ||
| xmlns=""http://schemas.microsoft.com/dotnet/2021/maui"" | ||
| xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" | ||
| Text=""Sample Button"" | ||
| HeightRequest=""{OnIdiom Tablet=50}"" />"; | ||
|
|
||
| mockDeviceInfo.Idiom = DeviceIdiom.Tablet; | ||
| var button = new Button().LoadFromXaml(xaml); | ||
| Assert.AreEqual(50, button.HeightRequest); | ||
|
|
||
| foreach (var idiom in new[] { DeviceIdiom.Phone, DeviceIdiom.Desktop, DeviceIdiom.TV, DeviceIdiom.Watch }) | ||
| { | ||
| mockDeviceInfo.Idiom = idiom; | ||
| button = new Button().LoadFromXaml(xaml); | ||
| Assert.AreEqual(-1, button.HeightRequest, $"Expected default value -1 for idiom {idiom}"); | ||
| } | ||
| } | ||
|
|
||
| } | ||
| } | ||
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