summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla26233.cs
blob: 4b4d859ce3363a2011edd3c9f20c0ef535a6d3e5 (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
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.ListView)]
#endif

	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Bugzilla, 26233, "Windows phone crashing when going back to page containing listview with Frame inside ViewCell")]
	public class Bugzilla26233 : TestContentPage 
	{
		protected override void Init ()
		{
			var listview = new ListView ();
			listview.ItemTemplate = new DataTemplate (typeof (ItemTemplate));
			listview.ItemsSource = new string[] { "item", "item", "item", "item", "item" };
			var btnBack = new Button { Text = "back", Command = new Command (() => Navigation.PopAsync ()) };
			listview.ItemSelected += (s, e) => Navigation.PushAsync (new ContentPage { Content = btnBack });
			var btnPush = new Button {
				Text = "Next",
				AutomationId = "btnPush",
				Command = new Command (() => Navigation.PushAsync (new ContentPage { Content = btnBack }))
			};
				
			Content = new StackLayout { Children = { btnPush, listview } };
		}

		[Preserve (AllMembers = true)]
		internal class ItemTemplate : ViewCell
		{
			public ItemTemplate ()
			{
				var frame = new Frame ();
				frame.Content = new StackLayout { Children = { new Label { Text = "hello 1" } } };
				View = frame;
			}
		}

#if UITEST
		[Test]
		public void DoesntCrashOnNavigatingBackToThePage ()
		{
			RunningApp.WaitForElement (q => q.Marked ("btnPush"));
			RunningApp.Tap (q => q.Marked ("btnPush"));
			RunningApp.WaitForElement (q => q.Marked ("back"));
			RunningApp.Screenshot ("I see the back button");
			RunningApp.Tap (q => q.Marked ("back"));
			RunningApp.WaitForElement (q => q.Marked ("btnPush"));
		}
#endif
	}
}