summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2414.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2414.cs')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2414.cs97
1 files changed, 97 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2414.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2414.cs
new file mode 100644
index 00000000..894d0d6c
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2414.cs
@@ -0,0 +1,97 @@
+using System;
+
+using Xamarin.Forms;
+using Xamarin.Forms.CustomAttributes;
+
+#if UITEST
+using NUnit.Framework;
+using Xamarin.UITest.iOS;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [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 ()
+ {
+ var screenBounds = RunningApp.Query (q => q.Raw ("* index:0"))[0].Rect;
+
+ var cell = RunningApp.Query (c => c.Marked ("Swipe ME")) [0];
+ if (RunningApp is iOSApp) {
+ 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"));
+ }
+ RunningApp.Screenshot ("Didn't crash");
+ RunningApp.TapCoordinates (screenBounds.CenterX, screenBounds.CenterY);
+ }
+
+ [Test]
+ public void TestShowContextMenuItemsInTheRightOrder ()
+ {
+ var screenBounds = RunningApp.Query (q => q.Raw ("* index:0"))[0].Rect;
+
+ var cell = RunningApp.Query (c => c.Marked ("Swipe ME")) [0];
+ if (RunningApp is iOSApp)
+ RunningApp.DragCoordinates (screenBounds.Width -10, cell.Rect.CenterY, 0, cell.Rect.CenterY);
+ else
+ RunningApp.TouchAndHoldCoordinates (cell.Rect.CenterX, cell.Rect.CenterY);
+ RunningApp.WaitForElement (c => c.Marked ("Text0"));
+ RunningApp.Screenshot ("Are the menuitems in the right order?");
+
+ }
+#endif
+
+ }
+}
+
+