Skip to content
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

Remove unsupported targets in Device class #4491

Merged
merged 19 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ public void BindingWithStaticConverter()
[TestCase("{OnPlatform Android=20, macOS=25}", "macOS", 25)]
[TestCase("{OnPlatform Android=20, Tizen=25}", "Tizen", 25)]
[TestCase("{OnPlatform Android=20, WinUI=25}", "WinUI", 25)]
[TestCase("{OnPlatform Android=20, UWP=25}", "WinUI", 25)]
[TestCase("{OnPlatform Android=20, WinUI=25, UWP=20}", "WinUI", 25)]
[TestCase("{OnPlatform Android=20, UWP=25}", "UWP", 25)]
[TestCase("{OnPlatform Android=20, WPF=25}", "WPF", 25)]
[TestCase("{OnPlatform 20}", "Android", 20)]
Expand Down
45 changes: 45 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/OnPlatformTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,51 @@ public void TypeConverterAndDerivedTypes()
image = new Image().LoadFromXaml(xaml);
Assert.AreEqual("icon_twitter.png", (image.Source as FileImageSource).File);
}

[Test]
public void UWPisWinUI()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

{
var xaml = @"
<Image xmlns=""http://schemas.microsoft.com/dotnet/2021/maui""
xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"">
<Image.Source>
<OnPlatform x:TypeArguments=""ImageSource"">
<On Platform=""iOS"">icon_twitter.png</On>
<On Platform=""Android"">icon_twitter.png</On>
<On Platform=""UWP"">Images/icon_twitter.png</On>
</OnPlatform>
</Image.Source>
</Image>";

Image image;

mockDeviceInfo.Platform = DevicePlatform.WinUI;
image = new Image().LoadFromXaml(xaml);
Assert.AreEqual("Images/icon_twitter.png", (image.Source as FileImageSource).File);
}

[Test]
public void ChecksPreferWinUI()
{
var xaml = @"
<Image xmlns=""http://schemas.microsoft.com/dotnet/2021/maui""
xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"">
<Image.Source>
<OnPlatform x:TypeArguments=""ImageSource"">
<On Platform=""iOS"">icon_twitter.png</On>
<On Platform=""Android"">icon_twitter.png</On>
<On Platform=""UWP"">Images/icon_twitter.png</On>
<On Platform=""WinUI"">Images/icon_twitter_preferred.png</On>
</OnPlatform>
</Image.Source>
</Image>";

Image image;

mockDeviceInfo.Platform = DevicePlatform.WinUI;
image = new Image().LoadFromXaml(xaml);
Assert.AreEqual("Images/icon_twitter_preferred.png", (image.Source as FileImageSource).File);
}
}

[TestFixture]
Expand Down