summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla36780.cs
blob: fbc5c3d351b8b2343957f2d4f5edfa598bae1095 (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
76
77
78
79
80
81
82
83
84
85

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

#if UITEST
using Xamarin.UITest;
using Xamarin.Forms.Core.UITests;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
	[Category(UITestCategories.Gestures)]
#endif

	[Preserve(AllMembers = true)]
	[Issue(IssueTracker.Bugzilla, 36780, "[iOS] Multiple TapGestureRecognizers on an Object Are Not Fired", PlatformAffected.iOS)]
	public class Bugzilla36780 : TestContentPage 
	{
		const string Gesture1Success = "Gesture1Success";
		const string Gesture2Success = "Gesture2Success";
		const string Gesture3Success = "Gesture3Success";
		const string Waiting = "Waiting";
		const string TestImage = "TestImage";

		protected override void Init()
		{
			var gesture1Label = new Label { FontSize = 18, Text = Waiting };
			var gesture2Label = new Label { FontSize = 18, Text = Waiting };
			var gesture3Label = new Label { FontSize = 18, Text = Waiting };

			var testImage = new Image { Source = "coffee.png", AutomationId = TestImage, HeightRequest = 75 };

			testImage.GestureRecognizers.Add(new TapGestureRecognizer
			{
				Command = new Command(() =>
				{
					gesture1Label.Text = Gesture1Success;
				})
			});

			testImage.GestureRecognizers.Add(new TapGestureRecognizer
			{
				Command = new Command(() =>
				{
					gesture2Label.Text = Gesture2Success;
				})
			});

			testImage.GestureRecognizers.Add(new TapGestureRecognizer
			{
				Command = new Command(() =>
				{
					gesture3Label.Text = Gesture3Success;
				})
			});

			Content = new StackLayout
			{
				Padding = new Thickness(0, 20, 0, 0),
				Children =
				{
					gesture1Label,
					gesture2Label,
					gesture3Label,
					testImage
				}
			};
		}

#if UITEST
		[Test]
		public void MultipleTapGestures()
		{
			RunningApp.WaitForElement(TestImage);
			RunningApp.Tap(TestImage);

			RunningApp.WaitForElement(Gesture1Success);
			RunningApp.WaitForElement(Gesture2Success);
			RunningApp.WaitForElement(Gesture3Success);
		}
#endif
	}
}