-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[net9.0][Enhancement] FontImageSource defaults and style (#23602)
* FontImageSource defaults and style * Added tests * Added snapshots
- Loading branch information
Showing
9 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Binary file added
BIN
+23 KB
src/Controls/tests/TestCases.Android.Tests/snapshots/android/Issue13474Test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions
20
src/Controls/tests/TestCases.HostApp/Issues/Issue13474.xaml
This file contains 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,20 @@ | ||
<?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="Maui.Controls.Sample.Issues.Issue13474"> | ||
<ContentPage.Resources> | ||
<Style TargetType="FontImageSource"> | ||
<Setter Property="FontFamily" Value="FontAwesome"/> | ||
<Setter Property="Color" Value="Red"/> | ||
</Style> | ||
</ContentPage.Resources> | ||
|
||
<VerticalStackLayout> | ||
<ImageButton | ||
HeightRequest="100" | ||
WidthRequest="100" | ||
BackgroundColor="Green" | ||
AutomationId="imageButton" | ||
Source="{FontImageSource Glyph=''}"/> | ||
</VerticalStackLayout> | ||
</ContentPage> |
11 changes: 11 additions & 0 deletions
11
src/Controls/tests/TestCases.HostApp/Issues/Issue13474.xaml.cs
This file contains 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 Maui.Controls.Sample.Issues; | ||
|
||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 13474, "FontImageSource defaults and style", PlatformAffected.All)] | ||
public partial class Issue13474 : ContentPage | ||
{ | ||
public Issue13474() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue13474.cs
This file contains 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,23 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues | ||
{ | ||
public class Issue13474 : _IssuesUITest | ||
{ | ||
public Issue13474(TestDevice device) : base(device) { } | ||
|
||
public override string Issue => "FontImageSource defaults and style"; | ||
|
||
[Test] | ||
[Category(UITestCategories.ImageButton)] | ||
public void Issue13474Test() | ||
{ | ||
App.WaitForElement("imageButton"); | ||
|
||
// The test passes if font family and color is applied | ||
VerifyScreenshot(); | ||
} | ||
} | ||
} |
Binary file added
BIN
+5.61 KB
src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/Issue13474Test.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
+25.5 KB
src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/Issue13474Test.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 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,21 @@ | ||
<?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.Maui13474"> | ||
<ContentPage.Resources> | ||
<Style TargetType="FontImageSource"> | ||
<Setter Property="FontFamily" Value="FontAwesome"/> | ||
<Setter Property="Color" Value="Red"/> | ||
</Style> | ||
</ContentPage.Resources> | ||
|
||
<VerticalStackLayout> | ||
<ImageButton | ||
x:Name="imageButton" | ||
HeightRequest="100" | ||
WidthRequest="100" | ||
BackgroundColor="Green" | ||
AutomationId="imageButton" | ||
Source="{FontImageSource Glyph=''}"/> | ||
</VerticalStackLayout> | ||
</ContentPage> |
52 changes: 52 additions & 0 deletions
52
src/Controls/tests/Xaml.UnitTests/Issues/Maui13474.xaml.cs
This file contains 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 System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.Maui.ApplicationModel; | ||
using Microsoft.Maui.Controls.Core.UnitTests; | ||
using Microsoft.Maui.Controls.Shapes; | ||
using Microsoft.Maui.Devices; | ||
using Microsoft.Maui.Dispatching; | ||
|
||
using Microsoft.Maui.Graphics; | ||
using Microsoft.Maui.UnitTests; | ||
using NUnit.Framework; | ||
|
||
namespace Microsoft.Maui.Controls.Xaml.UnitTests; | ||
|
||
public partial class Maui13474 | ||
{ | ||
public Maui13474() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public Maui13474(bool useCompiledXaml) | ||
{ | ||
//this stub will be replaced at compile time | ||
} | ||
|
||
[TestFixture] | ||
class Test | ||
{ | ||
[SetUp] | ||
public void Setup() | ||
{ | ||
Application.SetCurrentApplication(new MockApplication()); | ||
DispatcherProvider.SetCurrent(new DispatcherProviderStub()); | ||
} | ||
|
||
[TearDown] public void TearDown() => AppInfo.SetCurrent(null); | ||
|
||
[Test] | ||
public void FontImageSourceIsAppliedFromSharedResources([Values(false, true)] bool useCompiledXaml) | ||
{ | ||
var page = new Maui13474(useCompiledXaml); | ||
var fontImageSource = page.imageButton.Source as FontImageSource; | ||
Assert.AreEqual(fontImageSource.Color, Colors.Red); | ||
Assert.AreEqual(fontImageSource.FontFamily, "FontAwesome"); | ||
} | ||
} | ||
} |