summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2923.cs
blob: 68c512297e0dd8cd46323e8b9d1ee54adae90715 (plain)
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
using System.Collections.ObjectModel;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Github, 2923, "First tab does not load until navigating", PlatformAffected.WinRT)]
	public class Issue2923 : TestTabbedPage
	{
		protected override void Init()
		{
			var tabOne = new ContentPage {
				Title = "Page One",
				BackgroundColor = Color.Blue,
			};

			var tabTwo = new ContentPage {
				Title = "Page Two",
				BackgroundColor = Color.Red,
				Content = new Label {
					AutomationId = "SecondPageLabel",
					Text = "Second Page"
				}
			};

			var buttonResetTabbedPage = new Button {
				Text = "Reset",
				AutomationId = "ResetButton",
				Command = new Command (() => {

					Children.Remove (tabOne);
					Children.Remove (tabTwo);

					Children.Add (new ContentPage {
						Title = "Reset page",
						BackgroundColor = Color.Green,
						Content = new Label {
							AutomationId = "ResetPageLabel",
							Text = "I was reset"
						}
					});

				})
			};

			tabOne.Content = new StackLayout {
				Children = {
					new Label {
						AutomationId = "FirstPageLabel",
						Text = "First Page"
					},
					buttonResetTabbedPage
				}
			};

			Children.Add (tabOne);
			Children.Add (tabTwo);
		}

#if UITEST
		[Test]
		public void Issue2923TestOne ()
		{
			RunningApp.WaitForElement (q => q.Marked ("FirstPageLabel"));
			RunningApp.Screenshot ("First Tab is showing");
		}

		[Test]
		public void Issue2923TestTwo ()
		{
			RunningApp.Tap (q => q.Marked ("ResetButton"));
			RunningApp.Screenshot ("Tabs Reset");
			RunningApp.WaitForElement (q => q.Marked ("ResetPageLabel"));
		}
#endif

	}
}