summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla29453.cs
blob: 3170a76614ddfbe1acc77141e7c891a10c7c6358 (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
using System;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls
{
#if UITEST
	[Category(UITestCategories.LifeCycle)]
#endif

	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Bugzilla, 29453, "Navigation.PopAsync(false) in Entry.Completed handler => System.ArgumentException", PlatformAffected.Android)]
	public class Bugzilla29453 : TestContentPage // or TestMasterDetailPage, etc ...
	{
		protected override void Init ()
		{
			var page1Layout = new StackLayout {
				Children = {
					new Label {
#pragma warning disable 618
						XAlign = TextAlignment.Center,
#pragma warning restore 618
						Text = "Page 1"
					}
				}
			};

			var page2Layout = new StackLayout {
				Children = {
					new Label {
#pragma warning disable 618
						XAlign = TextAlignment.Center,
#pragma warning restore 618
						Text = "Page 2"
					}
				}
			};

			var entry = new Entry { AutomationId = "entryText" };

			entry.Completed += async (sender, args) => {
				await Navigation.PopAsync (false);
			};

			page2Layout.Children.Add (entry);

			var page2 = new ContentPage {
				Content = page2Layout
			};

			var button = new Button {
				Text = "Go to page 2",
				AutomationId = "btnGotoPage2",
				Command = new Command (async () => await Navigation.PushAsync (page2))
			};

			page1Layout.Children.Add (button);
			Content = page1Layout;
		}

		#if UITEST
		[Test]
		public void Bugzilla29453Test ()
		{
			RunningApp.Screenshot ("I am at Issue Bugzilla29453");
			RunningApp.WaitForElement (q => q.Marked ("Page 1"));
			RunningApp.Tap (q => q.Marked ("btnGotoPage2"));
			RunningApp.Tap (q => q.Marked ("entryText"));
			RunningApp.EnterText ("XF");
			RunningApp.PressEnter ();
			RunningApp.WaitForElement (q => q.Marked ("Page 1"));
		}
#endif
	}
}