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
87
88
89
90
91
|
using System;
using Xamarin.Forms.CustomAttributes;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.UITest.iOS;
#endif
namespace Xamarin.Forms.Controls
{
[Preserve (AllMembers = true)]
[Issue (IssueTracker.Bugzilla, 34561, "[A] Navigation.PushAsync crashes when used in Context Actions (legacy)", PlatformAffected.Android)]
public class Bugzilla34561 : TestContentPage
{
protected override void Init ()
{
var listView = new ListView () {
ItemsSource = new List<string> { "item" },
ItemTemplate = new DataTemplate (typeof(ContextActionTemplate))
};
Content = listView;
}
[Preserve (AllMembers = true)]
public class NextPage : TestContentPage
{
protected override void Init ()
{
Content = new Label {
AutomationId = "NextPageLabel",
Text = "See if I'm here"
};
}
}
[Preserve (AllMembers = true)]
public class ContextActionTemplate : ViewCell
{
public ContextActionTemplate ()
{
MenuItem newMenuItem = new MenuItem { Text = "Click" };
newMenuItem.Clicked += NewMenuItem_Clicked;
ContextActions.Add (newMenuItem);
View = new StackLayout {
Children = {
new Label {
Text = "Click and hold",
AutomationId = "ListViewItem",
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center
}
}
};
}
void NewMenuItem_Clicked (object sender, EventArgs e)
{
#pragma warning disable 618
ParentView.Navigation.PushAsync (new NextPage (), false);
#pragma warning restore 618
}
}
#if UITEST
[Test]
public void Bugzilla34561Test ()
{
RunningApp.WaitForElement (q => q.Marked ("ListViewItem"));
if(RunningApp is iOSApp) {
var listItem = RunningApp.Query (q => q.Marked ("ListViewItem"))[0].Rect;
RunningApp.DragCoordinates(listItem.CenterX, listItem.CenterY, 0, listItem.CenterY);
} else {
RunningApp.TouchAndHold (q => q.Marked ("ListViewItem"));
}
RunningApp.WaitForElement (q => q.Marked ("Click"));
RunningApp.Tap (q => q.Marked ("Click"));
RunningApp.WaitForElement (q => q.Marked ("NextPageLabel"));
RunningApp.Screenshot ("I see the next page");
}
#endif
}
}
|