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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
using System;
using Xamarin.Forms;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using NUnit.Framework;
using Xamarin.UITest.iOS;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve (AllMembers = true)]
[Issue (IssueTracker.Github, 2414, "NullReferenceException when swiping over Context Actions", PlatformAffected.WinPhone)]
public class Issue2414 : TestContentPage
{
protected override void Init ()
{
var tableView = new TableView
{
Intent = TableIntent.Settings,
Root = new TableRoot("TableView Title")
{
new TableSection("Table Section 2")
{
new TextCell
{
Text = "Swipe ME",
Detail = "And I will crash!",
ContextActions = {
new MenuItem
{
Text = "Text0"
},new MenuItem
{
Text = "Text1"
},
new MenuItem
{
Text = "Text2"
},
new MenuItem
{
Text = "Text3"
},
new MenuItem
{
Text = "Text4",
IsDestructive = true,
}}
},
}
}
};
Content = tableView;
}
#if UITEST
[Test]
public void TestDoesntCrashShowingContextMenu ()
{
RunningApp.WaitForElement(c => c.Marked("Swipe ME"));
var screenBounds = RunningApp.Query (q => q.Raw ("* index:0"))[0].Rect;
var cell = RunningApp.Query(c => c.Marked("Swipe ME")) [0];
#if __IOS__
RunningApp.DragCoordinates (screenBounds.Width - 10, cell.Rect.CenterY, 0, cell.Rect.CenterY);
//TODO: fix this when context menu bug is fixed
RunningApp.WaitForElement (c => c.Marked ("Text4"));
#else
RunningApp.TouchAndHoldCoordinates (cell.Rect.CenterX, cell.Rect.CenterY);
RunningApp.WaitForElement (c => c.Marked ("Text0"));
#endif
RunningApp.Screenshot ("Didn't crash");
RunningApp.TapCoordinates (screenBounds.CenterX, screenBounds.CenterY);
#if __ANDROID__
RunningApp.Tap(c => c.Marked("Text0"));
#endif
}
[Test]
public void TestShowContextMenuItemsInTheRightOrder ()
{
RunningApp.WaitForElement(c => c.Marked("Swipe ME"));
var screenBounds = RunningApp.Query (q => q.Raw ("* index:0"))[0].Rect;
var cell = RunningApp.Query (c => c.Marked ("Swipe ME")) [0];
#if __IOS__
RunningApp.DragCoordinates (screenBounds.Width -10, cell.Rect.CenterY, 0, cell.Rect.CenterY);
#else
RunningApp.TouchAndHoldCoordinates (cell.Rect.CenterX, cell.Rect.CenterY);
#endif
RunningApp.WaitForElement (c => c.Marked ("Text0"));
RunningApp.Screenshot ("Are the menuitems in the right order?");
#if __ANDROID__
RunningApp.Tap(c => c.Marked("Text0"));
#endif
}
#endif
}
}
|