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

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Bugzilla, 28001, "[Android] TabbedPage: invisible tabs are not Disposed", PlatformAffected.Android)]
	public class Bugzilla28001 : TestContentPage
	{
		static int s_disposeCount;
		static Label s_lbl;

		void HandleDispose (object sender, EventArgs e)
		{
			s_disposeCount++;
			s_lbl.Text = string.Format ("Dispose {0} pages", s_disposeCount);
		}

		protected override void Init ()
		{
			s_lbl = new Label { AutomationId = "lblDisposedCound" };
			var tab1 = new DisposePage { Title = "Tab1" }; 
			var tab2 = new DisposePage { Title = "Tab2" };
			tab1.RendererDisposed += HandleDispose;				
			tab2.RendererDisposed += HandleDispose;

			tab2.PopAction = tab1.PopAction = async () => await Navigation.PopAsync ();

			var tabbedPage = new TabbedPage { Children = { tab1, tab2 } };
			var btm = new Button { Text = "Push" };

			btm.Clicked += async  (object sender, EventArgs e) => {
				await Navigation.PushAsync (tabbedPage);
			};

			Content = new StackLayout { Children = { btm, s_lbl } };
		}

	
		#if UITEST
		[Test]
		public void Bugzilla28001Test ()
		{
			RunningApp.Screenshot ("I am at Bugzilla 28001");
			RunningApp.Tap (q => q.Marked ("Push"));
			RunningApp.Tap (q => q.Marked ("Tab2"));
			RunningApp.Tap (q => q.Marked ("Tab1"));
			RunningApp.Tap (q => q.Marked ("Pop"));
			RunningApp.WaitForElement (q => q.Marked (string.Format ("Dispose {0} pages", 2)));
		
		}
#endif
	}
}