-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Issue1898.cs
128 lines (111 loc) · 4.45 KB
/
Issue1898.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
using AToolbarPlacement = Xamarin.Forms.PlatformConfiguration.AndroidSpecific.ToolbarPlacement;
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
using WindowsOS = Xamarin.Forms.PlatformConfiguration.Windows;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github5000)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1898, "TabbedPage Page not watching icon changes", PlatformAffected.Android, issueTestNumber: 1)]
public class Issue1898 : TestTabbedPage
{
protected override void Init() =>
Issue1898Setup.SetupTabbedPage(this, AToolbarPlacement.Top);
#if UITEST
[Test]
public void TabIconsAndTitlesChange() =>
Issue1898Setup.RunUITests(RunningApp);
#endif
}
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1898, "TabbedPage Page not watching icon changes", issueTestNumber: 2)]
public partial class Issue1898_2 : TestTabbedPage
{
protected override void Init() =>
Issue1898Setup.SetupTabbedPage(this, AToolbarPlacement.Bottom);
#if UITEST && __ANDROID__
[Test]
public void TabBottomIconsAndTitlesChange() =>
Issue1898Setup.RunUITests(RunningApp);
#endif
}
[Preserve(AllMembers = true)]
internal class Issue1898Setup
{
#if UITEST
internal static void RunUITests(IApp RunningApp)
{
RunningApp.WaitForElement(Title1);
RunningApp.Tap(ChangeTitle1);
RunningApp.Tap(ChangeIcon1);
RunningApp.Tap(ChangeIconPage2);
RunningApp.Tap(ChangeIcon1Null);
RunningApp.WaitForElement(ChangeTitle1);
RunningApp.Tap(Title2);
RunningApp.Tap(ChangeTitle2);
RunningApp.Tap(ChangeIcon2);
RunningApp.Tap(ChangeIconPage1);
RunningApp.Tap(ChangeIcon2Null);
RunningApp.WaitForElement(ChangeTitle2);
}
#endif
const string Title1 = "Title 1";
const string ChangeTitle1 = "Change Title 1";
const string ChangeIcon1 = "Change Icon 1";
const string ChangeIconPage2 = "Change Icon on Page 2";
const string ChangeIcon1Null = "Null Icon 1";
const string Title2 = "Title 2";
const string ChangeTitle2 = "Change Title 2";
const string ChangeIcon2 = "Change Icon 2";
const string ChangeIconPage1 = "Change Icon on Page 1";
const string ChangeIcon2Null = "Null Icon 2";
internal static void SetupTabbedPage(TabbedPage tabbedPage, AToolbarPlacement placement)
{
ContentPage Issue1898PageOne = new ContentPage() { Title = Title1, IconImageSource = "bank.png" };
ContentPage Issue1898PageTwo = new ContentPage() { Title = Title2, IconImageSource = "bank.png" };
Issue1898PageOne.Content =
new StackLayout
{
Margin = 20,
Children =
{
new Label(){ Text = "Click through each button on each tab to make sure they do what they say they do" },
new Button(){ Text = ChangeTitle1, Command = new Command(() => Issue1898PageOne.Title = ChangeTitle1) },
new Button(){ Text = ChangeIcon1, Command = new Command(() => Issue1898PageOne.IconImageSource = "coffee.png")},
new Button(){ Text = ChangeIconPage2, Command = new Command(() => Issue1898PageTwo.IconImageSource = "coffee.png")},
new Button(){ Text = ChangeIcon1Null, Command = new Command(() => Issue1898PageOne.IconImageSource = null)},
}
};
Issue1898PageTwo.Content =
new StackLayout
{
Margin = 20,
Children =
{
new Button(){ Text = ChangeTitle2, Command = new Command(() => Issue1898PageTwo.Title = ChangeTitle2) },
new Button(){ Text = ChangeIcon2, Command = new Command(() => Issue1898PageTwo.IconImageSource = "bank.png")},
new Button(){ Text = ChangeIconPage1, Command = new Command(() => Issue1898PageOne.IconImageSource = "calculator.png")},
new Button(){ Text = ChangeIcon2Null, Command = new Command(() => Issue1898PageTwo.IconImageSource = null)},
}
};
tabbedPage.Children.Add(Issue1898PageOne);
tabbedPage.Children.Add(Issue1898PageTwo);
#pragma warning disable CS0618 // Type or member is obsolete
tabbedPage.On<Android>().SetBarItemColor(Color.Blue);
tabbedPage.On<Android>().SetBarSelectedItemColor(Color.Green);
#pragma warning restore CS0618 // Type or member is obsolete
tabbedPage.On<Android>().SetToolbarPlacement(placement);
tabbedPage.On<WindowsOS>().SetHeaderIconsEnabled(true);
}
}
}