-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Don't underline HyperlinkButton if not ImplicitTextBlock
- Loading branch information
1 parent
5209b3a
commit c1ef8c1
Showing
5 changed files
with
112 additions
and
3 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...RuntimeTests/Tests/Windows_UI_Xaml_Controls/HyperlinkButtonTests/Given_HyperlinkButton.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,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Private.Infrastructure; | ||
using Windows.UI.Text; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Media; | ||
|
||
namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls.HyperlinkButtonTests | ||
{ | ||
[TestClass] | ||
public class Given_HyperlinkButton | ||
{ | ||
[TestMethod] | ||
[RunsOnUIThread] | ||
public async Task When_HyperlinkButton_With_Implicit_Content_Should_Be_UnderlinedAsync() | ||
{ | ||
var SUT = new HyperlinkButtonPage(); | ||
TestServices.WindowHelper.WindowContent = SUT; | ||
await TestServices.WindowHelper.WaitForIdle(); | ||
|
||
var underlinedImplicitTextBlock = VisualTreeHelper.GetChild(SUT.ShouldBeUnderlinedHyperlinkButton.GetTemplateChild("ContentPresenter"), 0) as TextBlock; | ||
Assert.IsInstanceOfType(underlinedImplicitTextBlock, typeof(ImplicitTextBlock)); | ||
Assert.AreEqual(TextDecorations.Underline, underlinedImplicitTextBlock.TextDecorations); | ||
|
||
var notUnderlinedTextBlock = VisualTreeHelper.GetChild(SUT.ShouldNotBeUnderlinedHyperlinkButton.GetTemplateChild("ContentPresenter"), 0) as TextBlock; | ||
Assert.IsNotInstanceOfType(notUnderlinedTextBlock, typeof(ImplicitTextBlock)); | ||
Assert.AreEqual(TextDecorations.None, notUnderlinedTextBlock.TextDecorations); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...RuntimeTests/Tests/Windows_UI_Xaml_Controls/HyperlinkButtonTests/HyperlinkButtonPage.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,17 @@ | ||
<Page | ||
x:Class="Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls.HyperlinkButtonTests.HyperlinkButtonPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls.HyperlinkButtonTests" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
<StackPanel> | ||
<HyperlinkButton x:Name="ShouldBeUnderlined_HyperlinkButton">Should be underlined text</HyperlinkButton> | ||
<HyperlinkButton x:Name="ShouldNotBeUnderlined_HyperlinkButton"> | ||
<TextBlock x:Name="ShouldNotBeUnderlined_TextBlock">Shouldn't be underlined text</TextBlock> | ||
</HyperlinkButton> | ||
</StackPanel> | ||
</Page> |
34 changes: 34 additions & 0 deletions
34
...timeTests/Tests/Windows_UI_Xaml_Controls/HyperlinkButtonTests/HyperlinkButtonPage.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,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 | ||
|
||
namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls.HyperlinkButtonTests | ||
{ | ||
/// <summary> | ||
/// An empty page that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class HyperlinkButtonPage : Page | ||
{ | ||
public HyperlinkButton ShouldBeUnderlinedHyperlinkButton => ShouldBeUnderlined_HyperlinkButton; | ||
public HyperlinkButton ShouldNotBeUnderlinedHyperlinkButton => ShouldNotBeUnderlined_HyperlinkButton; | ||
public TextBlock ShouldNotBeUnderlinedTextBlock => ShouldNotBeUnderlined_TextBlock; | ||
|
||
public HyperlinkButtonPage() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} | ||
} |
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
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