Skip to content

Commit 22fb331

Browse files
Added test
1 parent f99f227 commit 22fb331

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 24627, "[Windows] TitleBar Title FontAttributes", PlatformAffected.UWP)]
4+
public class Issue24627 : ContentPage
5+
{
6+
TitleBar customTitleBar;
7+
8+
public Issue24627()
9+
{
10+
customTitleBar = new TitleBar
11+
{
12+
Title = "MauiApp1",
13+
Subtitle = "Welcome to .NET MAUI",
14+
TitleFontAttributes = FontAttributes.Bold,
15+
HeightRequest = 32
16+
};
17+
18+
var label = new Label
19+
{
20+
Text = "Welcome to .NET MAUI",
21+
HorizontalOptions = LayoutOptions.Center,
22+
VerticalOptions = LayoutOptions.Center,
23+
};
24+
25+
var button = new Button
26+
{
27+
Text = "Set Title FontAttributes to None",
28+
AutomationId = "ChangeFAButton",
29+
Command = new Command(() =>
30+
{
31+
customTitleBar.TitleFontAttributes = FontAttributes.None;
32+
}),
33+
HorizontalOptions = LayoutOptions.Center,
34+
VerticalOptions = LayoutOptions.Center
35+
};
36+
37+
var verticalStack = new VerticalStackLayout
38+
{
39+
Children =
40+
{
41+
label,
42+
button
43+
},
44+
Spacing = 25,
45+
Padding = new Thickness(30, 0),
46+
VerticalOptions = LayoutOptions.Center
47+
};
48+
49+
Content = verticalStack;
50+
}
51+
52+
protected override void OnAppearing()
53+
{
54+
base.OnAppearing();
55+
if (Window is not null)
56+
{
57+
Window.TitleBar = customTitleBar;
58+
}
59+
else if (Shell.Current?.Window is not null)
60+
{
61+
Shell.Current.Window.TitleBar = customTitleBar;
62+
}
63+
}
64+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#if WINDOWS || MACCATALYST // TitleBar is only supported on Windows and MacCatalyst
2+
using NUnit.Framework;
3+
using UITest.Appium;
4+
using UITest.Core;
5+
6+
namespace Microsoft.Maui.TestCases.Tests.Issues;
7+
8+
public class Issue24627 : _IssuesUITest
9+
{
10+
public override string Issue => "[Windows] TitleBar Title FontAttributes";
11+
12+
public Issue24627(TestDevice device)
13+
: base(device)
14+
{ }
15+
16+
[Test, Order(1)]
17+
[Category(UITestCategories.TitleView)]
18+
public void VerifyTitleBarTitleFontAttributesBold()
19+
{
20+
App.WaitForElement("ChangeFAButton");
21+
VerifyScreenshot(includeTitleBar: true);
22+
}
23+
24+
[Test, Order(2)]
25+
[Category(UITestCategories.TitleView)]
26+
public void ChangeTitleBarTitleFontAttributesToNone()
27+
{
28+
App.WaitForElement("ChangeFAButton");
29+
App.Tap("ChangeFAButton");
30+
VerifyScreenshot(includeTitleBar: true);
31+
}
32+
}
33+
#endif

0 commit comments

Comments
 (0)