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
|
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.Issues
{
#if UITEST
[Category(UITestCategories.Gestures)]
[Category(UITestCategories.IsEnabled)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 36703,
"TapGestureRecognizer inside initially disable Image will never fire Tapped event", PlatformAffected.All)]
public class Bugzilla36703 : TestContentPage
{
const string TestImage = "testimage";
const string Success = "Success";
const string Toggle = "toggle";
const string Testing = "Testing...";
protected override void Init()
{
var image = new Image { Source = "coffee.png", IsEnabled = false, AutomationId = TestImage };
var button = new Button { Text = $"Toggle IsEnabled (now {image.IsEnabled})", AutomationId = Toggle };
var resultLabel = new Label { Text = "Testing..."};
var instructions = new Label { Text = $"Tap the image. The '{Testing}' label should remain unchanged. "
+ $"Tap the 'Toggle IsEnabled' button. Now tap the image again."
+ $" The {Testing} Label should change its text to {Success}." };
button.Clicked += (sender, args) =>
{
image.IsEnabled = !image.IsEnabled;
button.Text = $"Toggle IsEnabled (now {image.IsEnabled})";
};
Content = new StackLayout
{
Padding = new Thickness(0, 20, 0, 0),
Children =
{
instructions, resultLabel,
image, button
}
};
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += delegate
{
resultLabel.Text = Success;
};
image.GestureRecognizers.Add(tapGestureRecognizer);
}
#if UITEST
[Test]
public void _36703Test()
{
RunningApp.WaitForElement(TestImage);
RunningApp.Tap(TestImage);
RunningApp.WaitForElement(Testing);
RunningApp.Tap(Toggle);
RunningApp.Tap(TestImage);
RunningApp.WaitForElement(Success);
}
#endif
}
}
|