summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.UITests.Shared/Tests/RootGalleryUITests.cs
blob: b55fc23ef6378779f03ce9e2fa84ae311c017f58 (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
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;

namespace Xamarin.Forms.Core.UITests
{
	internal sealed class RootPageModel
	{
		public string ButtonId { get; private set; }

		public string PageId { get; private set; }

		public bool IsModal { get; private set; }

		public RootPageModel(string buttonId, string pageId, bool isModal = false)
		{
			ButtonId = buttonId;
			PageId = pageId;
			IsModal = isModal;
		}
	}

	[TestFixture]
	[Category(UITestCategories.RootGallery)]
	internal class RootGalleryUITests : BaseTestFixture
	{
		readonly IEnumerable<RootPageModel> rootPages;

		public RootGalleryUITests()
		{
			string[] ids =
			{
				"Content",
				"Nav->Content",
				"MDP->Nav->Content",
				"Tab->Content",
				"Tab->MDP->Nav->Content",
				"Tab->Nav->Content",
				"Tab(Many)->Nav->Content",
				"Nav->Tab->Content(BAD IDEA)",
				"Nav->Tab(Many)->Content(BAD IDEA)",
				"MDP->Nav->Tab->Content(BAD IDEA)"
			};
			string[] modalIds =
			{
				"(Modal)Content",
				"(Modal)Nav->Content",
				"(Modal)MDP->Nav->Content",
				"(Modal)Tab->Content",
				"(Modal)Tab->MDP->Nav->Content",
				"(Modal)Tab->Nav->Content",
				"(Modal)Tab(Many)->Nav->Content",
				"(Modal)Nav->Tab->Content(BAD IDEA)",
				"(Modal)Nav->Tab(Many)->Content(BAD IDEA)",
				"(Modal)MDP->Nav->Tab->Content(BAD IDEA)",
			};

			rootPages =
			(from id in ids
				select new RootPageModel(id + "ButtonId", id + "PageId")).Union(
				from id in modalIds
				select new RootPageModel(id + "ButtonId", id + "PageId", true));
		}

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

		[Test]
		[Ignore("Ignore while we dont't have a response from XTC team why this fails some times")]
		public void VisitEachPage()
		{
			foreach (var page in rootPages)
			{
				var scrollViewArea = App.Query(q => q.Marked("ChoosePageScrollView")).First().Rect;
				App.ScrollForElement(string.Format("* marked:'{0}'", page.ButtonId),
					new Drag(scrollViewArea, Drag.Direction.BottomToTop, Drag.DragLength.Long));
				App.Tap(q => q.Marked(page.ButtonId));

				bool ios = false;
#if __IOS__
				ios = true;
#endif

				if (!page.IsModal || ios)
					App.WaitForElement(q => q.Marked(page.PageId));

				App.Screenshot("Page: " + page.PageId);
			}
		}
	}
}