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
86
|
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using NUnit.Framework;
using Xamarin.UITest.Queries;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve (AllMembers = true)]
[Issue (IssueTracker.Bugzilla, 39530, "Frames do not handle pan or pinch gestures under AppCompat", PlatformAffected.Android)]
public class Bugzilla39530 : TestContentPage
{
protected override void Init ()
{
var taps = new Label { Text = "Taps: 0" };
var pans = new Label ();
var pinches = new Label ();
var pangr = new PanGestureRecognizer ();
var tapgr = new TapGestureRecognizer ();
var pinchgr = new PinchGestureRecognizer ();
var frame = new Frame {
HasShadow = false,
HorizontalOptions = LayoutOptions.Fill,
VerticalOptions = LayoutOptions.Fill,
BackgroundColor = Color.White,
Padding = new Thickness (5),
HeightRequest = 300,
WidthRequest = 300,
AutomationId = "frame"
};
var tapCount = 0;
tapgr.Command = new Command (() => {
tapCount += 1;
taps.Text = $"Taps: {tapCount}";
});
pangr.PanUpdated += (sender, args) => pans.Text = $"Panning: {args.StatusType}";
pinchgr.PinchUpdated += (sender, args) => pinches.Text = $"Pinching: {args.Status}";
frame.GestureRecognizers.Add (tapgr);
frame.GestureRecognizers.Add (pangr);
frame.GestureRecognizers.Add(pinchgr);
Content = new StackLayout {
BackgroundColor = Color.Olive,
Children = { taps, pans, pinches, frame }
};
}
#if UITEST
[Test]
public void Bugzilla39530PanTest()
{
AppRect frameBounds = RunningApp.Query (q => q.Marked ("frame"))[0].Rect;
RunningApp.Pan (new Drag (frameBounds, frameBounds.X + 10, frameBounds.Y + 10, frameBounds.X + 100, frameBounds.Y + 100, Drag.Direction.LeftToRight));
RunningApp.WaitForElement (q => q.Marked ("Panning: Completed"));
}
[Test]
public void Bugzilla39530PinchTest()
{
RunningApp.PinchToZoomIn ("frame");
RunningApp.WaitForElement(q => q.Marked("Pinching: Completed"));
}
[Test]
public void Bugzilla39530TapTest()
{
RunningApp.WaitForElement (q => q.Marked ("frame"));
RunningApp.Tap ("frame");
RunningApp.WaitForElement (q => q.Marked ("Taps: 1"));
RunningApp.Tap ("frame");
RunningApp.WaitForElement (q => q.Marked ("Taps: 2"));
}
#endif
}
}
|