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

using Xamarin.Forms.CustomAttributes;
using System.Collections;
using System.Linq;
using System.Collections.Generic;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest.iOS;
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve(AllMembers = true)]
	[Issue(IssueTracker.Bugzilla, 21177, "Using a UICollectionView in a ViewRenderer results in issues with selection")]
	public class Bugzilla21177 : TestContentPage
	{
		public class CollectionView : View
		{
			public event EventHandler<int> ItemSelected;

			public void InvokeItemSelected(int index)
			{
				if (ItemSelected != null)
				{
					ItemSelected.Invoke(this, index);
				}
			}
		}

		protected override void Init()
		{
			var view = new CollectionView() { AutomationId = "view" };
			view.ItemSelected += View_ItemSelected;
			Content = view;
		}

		private void View_ItemSelected(object sender, int e)
		{
			DisplayAlert("Success", "Success", "Cancel");
		}

#if UITEST && __IOS__
		[Test]
		public void Bugzilla21177Test()
		{
			RunningApp.WaitForElement(q => q.Marked("#1"));
			RunningApp.Tap(q => q.Marked("#1"));
			RunningApp.WaitForElement(q => q.Marked("Success"));
			RunningApp.Tap(q => q.Marked("Cancel"));
		}
#endif
	}
}