summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs
blob: fc80937fcdd265ddfbdd2392c39af6185a4aebf8 (plain)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
using NUnit.Framework;
using Xamarin.UITest;
using System;
using System.Threading;

using Xamarin.UITest.Android;
using Xamarin.UITest.iOS;
using Xamarin.UITest.Queries;

namespace Xamarin.Forms.Core.UITests
{
	[TestFixture]
	[Category ("Cells")]
	internal class ContextActionsListUITests : BaseTestFixture
	{

		public ContextActionsListUITests ()
		{
			ShouldResetPerFixture = false;
		}

		protected override void NavigateToGallery ()
		{
			App.NavigateToGallery (GalleryQueries.ContextActionsListGallery);
		}

		const string cell0 = "Subject Line 0";
		const string cell1 = "Subject Line 1";
		const string move = "Move";
		const string delete = "Delete";
		const string clear = "Clear Items";
		const string mark = "Mark";


#if __ANDROID__
		[Test]
		public void ContextActionsShow ()
		{
			// mark is an icon on android
			App.TouchAndHold (q => q.Marked (cell0));
			App.WaitForElement (q => q.Marked (delete));
			App.Screenshot ("I have actions!");
		}

		[Test]
		public void ContextActionsDelete ()
		{
			// mark is an icon on android
			App.TouchAndHold (q => q.Marked (cell0));
			App.WaitForElement (q => q.Marked (delete));
			App.Screenshot ("I have actions!");

			App.Tap (q => q.Marked (delete));
			App.WaitForNoElement (q => q.Marked (cell0));
			App.Screenshot ("Deleted cell 0");
		}
#endif

#if __IOS__
		[Test]
		public void PopoverDismiss()
		{
			var device = App.Device as iOSDevice;

			if (device == null)
			{
				return;
			}

			if (device.IsTablet) {
				var screenBounds = App.Query (PlatformQueries.Root)[0].Rect;
				var cellBounds = App.Query (q => q.Marked (cell0))[0].Rect;
				App.DragCoordinates (screenBounds.Width - 10, cellBounds.CenterY, 10, cellBounds.CenterY);
				App.Screenshot("I see context actions");
				App.Tap (q => q.Marked ("More"));
				App.Screenshot ("Should see Popover");
				App.TapCoordinates (50, 50);
				App.Screenshot ("I should not crash");
			} else {
				Assert.Inconclusive("Not testing iOS Phone");
			}
		}
#endif
	}

	[TestFixture]
	[Category ("Cells")]
	internal class ContextActionsTableUITests : BaseTestFixture
	{
		public ContextActionsTableUITests ()
		{
			ShouldResetPerFixture = false;
		}

		protected override void NavigateToGallery ()
		{
			App.NavigateToGallery (GalleryQueries.ContextActionsTableGallery);
		}

		const string cell0 = "Subject Line 0";
		const string cell1 = "Subject Line 1";
		const string move = "Move";
		const string delete = "Delete";
		const string clear = "Clear Items";
		const string mark = "Mark";
		const string cellWithNoContextActions = "I have no ContextActions";

#if __ANDROID__
		[Test]
		public void ContextActionsShowAndReset ()
		{
			// mark is an icon on android
			App.TouchAndHold (q => q.Marked (cell0));
			App.WaitForElement (q => q.Marked (delete));
			App.Screenshot ("I have actions!");
				
			App.Tap (q => q.Marked (cellWithNoContextActions));
			App.WaitForNoElement (q => q.Marked (delete));
			App.Screenshot ("Actions should be gone");
		}
#endif
	}
}