summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla26032.xaml.cs
blob: e45e6bb388ae1b807dc9a286849e866c14c69060 (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
using System;
using System.Collections.Generic;

using Xamarin.Forms;
using Xamarin.Forms.CustomAttributes;


#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Bugzilla, 26032, " ListView ItemTapped doesn't get called for the selected item ", PlatformAffected.iOS)]
	public partial class Bugzilla26032 : TestContentPage
	{
		#if APP
		public Bugzilla26032 ()
		{
			
			InitializeComponent ();
			var data = new[] { "1", "2", "3", "4", "5" };
			var dataContext = new[] { "1 Context", "2 Context", "3 Context", "4 Context", "5 Context" };
			List1.ItemsSource = data;
			List2.ItemsSource = dataContext;
		}


		public void OnItemTapped(object sender, ItemTappedEventArgs e)
		{
			Log.Text = string.Format("Item '{0}' tapped\n{1}", e.Item, Log.Text);
		}

		public void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
		{
			Log.Text = string.Format("Item '{0}' selected\n{1}", e.SelectedItem, Log.Text);
		}

		#endif

		protected override void Init ()
		{
		}


		#if UITEST
		[Test]
		public void SelectedItemTap ()
		{
			var id = "1";
			var idContext = "1 Context";
			var initalLog = "Item '{0}' tapped\nItem '{0}' selected\n";

			var forId1 = string.Format (initalLog, id);
			RunningApp.WaitForElement (q => q.Marked (id));
			RunningApp.Tap (q => q.Marked (id));
			RunningApp.WaitForElement (q => q.Text (forId1));
			RunningApp.Tap (q => q.Marked (id));
			forId1 = string.Format ( "Item '{0}' tapped\n" + initalLog, id);
			RunningApp.WaitForElement (q => q.Text (forId1));

			var forIdContext = string.Format (initalLog, idContext);
			RunningApp.WaitForElement (q => q.Marked (idContext));
			RunningApp.Tap (q => q.Marked (idContext));
			RunningApp.WaitForElement (q => q.Text (forIdContext + forId1));
			RunningApp.Tap (q => q.Marked (idContext));
			forIdContext = string.Format ( "Item '{0}' tapped\n" + initalLog, idContext);
			RunningApp.WaitForElement (q => q.Text (forIdContext + forId1));
		}
		#endif
	}
}