This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathShellTitleView.cs
80 lines (66 loc) · 1.78 KB
/
ShellTitleView.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.None, 0, "Shell Title View Test",
PlatformAffected.All)]
#if UITEST
[NUnit.Framework.Category(UITestCategories.Shell)]
[NUnit.Framework.Category(UITestCategories.TitleView)]
#endif
public class ShellTitleView : TestShell
{
protected override void Init()
{
AddTopTab(createContentPage("title 1"), "page 1");
AddTopTab(createContentPage(null), "page 2");
AddTopTab(createContentPage("title 3"), "page 3");
AddTopTab(createContentPage("title 4"), "page 4");
ContentPage createContentPage(string titleView)
{
ContentPage page = new ContentPage()
{
Content = new StackLayout()
{
Children =
{
new Label()
{
Text = "Click through the tabs and make sure title view changes and doesn't duplicate"
}
}
}
};
page.ToolbarItems.Add(new ToolbarItem() { IconImageSource = "coffee.png", Order = ToolbarItemOrder.Primary, Priority = 0 });
if (!string.IsNullOrWhiteSpace(titleView))
{
Shell.SetTitleView(page,
new StackLayout()
{
AutomationId = "TitleViewId",
Children = { new Label() { Text = titleView } }
});
}
return page;
}
}
#if UITEST && (__IOS__ || __ANDROID__)
[Test]
public void NoDuplicateTitleViews()
{
var titleView = RunningApp.WaitForElement("TitleViewId");
Assert.AreEqual(1, titleView.Length);
RunningApp.Tap("page 2");
RunningApp.Tap("page 3");
RunningApp.Tap("page 4");
titleView = RunningApp.WaitForElement("TitleViewId");
Assert.AreEqual(1, titleView.Length);
}
#endif
}
}