summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.iOS.UITests/Tests/RootGalleryUITests.cs
blob: 764c3a69c45b517d0a11dae475f5023a2ee9328d (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
using NUnit.Framework;
using Xamarin.UITest;

using System;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using Xamarin.UITest.Queries;
using Xamarin.UITest.iOS;

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 ("RootGallery")]
	internal class RootGalleryUITests : BaseTestFixture
	{
		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));
				if(!page.IsModal || App is iOSApp)
					App.WaitForElement (q => q.Marked (page.PageId));
				App.Screenshot ("Page: " + page.PageId);
			}
		}
	}
}