summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32230.cs
blob: 220b4d194ffd226309bb0f5a39ca39ca076931c7 (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
using System;

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.Bugzilla, 32230, "isPresentedChanged raises multiple times")]
	public class Bugzilla32230 : TestMasterDetailPage // or TestMasterDetailPage, etc ...
	{
		Label _lblCount;
		Button _btnOpen;
		Button _btnClose;
		int _count;

		protected override void Init ()
		{
			_lblCount = new Label { Text = _count.ToString (), AutomationId = "lblCount" };
			_btnOpen = new Button { Text = "Open", AutomationId = "btnOpen", 
				Command = new Command (() => {
					IsPresented = true;
				})
			};
			_btnClose = new Button { Text = "Close", AutomationId = "btnClose", 
				Command = new Command (() => {
					IsPresented = false;
				})
			};

			Master = new ContentPage {
				Title = "Master",
				Content = new StackLayout { Children = { _lblCount, _btnClose } }
			};

			Detail = new NavigationPage (new ContentPage { Content = _btnOpen });
			IsPresentedChanged += (object sender, EventArgs e) => {
				_count++;
				_lblCount.Text = _count.ToString();
			};
		}

#if UITEST
		[Test]
		public void Bugzilla32230Test ()
		{
			RunningApp.Tap (q => q.Marked ("btnOpen"));
			Assert.AreEqual ("1", RunningApp.Query (q => q.Marked ("lblCount"))[0].Text);
			RunningApp.Tap (q => q.Marked ("btnClose"));
			RunningApp.Tap (q => q.Marked ("btnOpen"));
			Assert.AreEqual ("3", RunningApp.Query (q => q.Marked ("lblCount"))[0].Text);
		}
#endif
	}
}