summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-GridGalleryUITests.cs
blob: 04b59460b36d36737a81a5a5c4549c047f7d67e3 (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
125
126
127
128
129
130
131
132
using NUnit.Framework;

using Xamarin.Forms.CustomAttributes;
using Xamarin.UITest;
using Xamarin.UITest.Queries;
using System.Threading;

namespace Xamarin.Forms.Core.UITests
{
	[TestFixture]
	[Category ("GridLayout")]
	internal class GridLayoutGalleryTests : BaseTestFixture
	{
		// TODO - test Absolutes
		// TODO: Port to new conventions

		public GridLayoutGalleryTests ()
		{
			ShouldResetPerFixture = false;
		}

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

		//void AllElementsPresent ()
		//{
		//	App.ScrollForElement ("* marked:'Column Types:'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'Absolute Width'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'Auto Width'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'Star'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'*'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'**'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'***'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'Right'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'Center'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'Left'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'Fill'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'Spans:'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'Spanning 4 columns'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'Spanning 3 rows'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'Spanning 4 columns'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
		//	App.ScrollForElement ("* marked:'a block 3x3'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));

		//	App.Screenshot ("All elements present");
		//}


		[Test]
		[Category("ManualReview")]
		[Description ("Check Grid Star sizing")]
		[UiTest (typeof(Grid))]
		public void GridLayoutGalleryStarLayout ()
		{
		//	AllElementsPresent ();

		//	App.ScrollForElement ("* marked:'*'", new Drag (ScreenBounds, Drag.Direction.TopToBottom, Drag.DragLength.Medium));

		//	var oneStarWidth = App.Query (q => q.Marked ("*"))[0].Rect.Width;
		//	var twoStarWidth = App.Query (q => q.Marked ("**"))[0].Rect.Width;
		//	var threeStarWidth = App.Query (q => q.Marked ("***"))[0].Rect.Width;

		//	Assert.AreEqual (threeStarWidth, oneStarWidth * 3, 2.0);
		//	Assert.AreEqual (twoStarWidth, oneStarWidth * 2, 2.0);

		//	App.Screenshot ("Star layout correct");
		}

		// TODO port to new framework
		//[Test]
		//[UiTest (Test.Layouts.Grid)]
		//public void GridLayoutGallerySpanSizes ()
		//{
		//	AllElementsPresent ();

		//	var unitWidth = App.Query (q => q.Marked ("Unit"))[0].Rect.Width;
		//	var unitHeight = App.Query (q => q.Marked ("Unit"))[0].Rect.Height;

		//	var spanningFourColumnsWidth = App.Query (q => q.Marked ("Spanning 4 columns"))[0].Rect.Width; 
		//	var spanningFourColumnsHeight = App.Query (q => q.Marked ("Spanning 4 columns"))[0].Rect.Height; 

		//	// platform queries deal with label rendering differences
		//	var threeXThreeWidth = App.Query (PlatformQueries.ThreeXThreeGridCell) [0].Rect.Width;
		//	var threeXThreeHeight = App.Query (PlatformQueries.ThreeXThreeGridCell) [0].Rect.Height;

		//	var spanningThreeRowsWidth = App.Query (PlatformQueries.SpanningThreeRows)[0].Rect.Width; 
		//	var spanningThreeRowsHeight = App.Query (PlatformQueries.SpanningThreeRows)[0].Rect.Height;

		//	Assert.AreEqual (spanningFourColumnsWidth, unitWidth * 4, 2.0);
		//	Assert.AreEqual (spanningFourColumnsHeight, unitHeight, 2.0);

		//	Assert.AreEqual (threeXThreeWidth, unitWidth * 3, 2.0);
		//	Assert.AreEqual (threeXThreeHeight, unitHeight * 3, 2.0);

		//	Assert.AreEqual (spanningThreeRowsWidth, unitWidth, 2.0);
		//	Assert.AreEqual (spanningThreeRowsHeight, unitHeight * 3, 2.0);

		//	App.Screenshot ("Span sizes correct");
		//}

		// TODO port to new framework
		//[Test]
		//[UiTest (Test.Layouts.Grid)]
		//public void GridLayoutGalleryResizesProperlyAfterRotation ()
		//{
		//	// Displays GridLayout bug on rotation (Issue #854)
		//	AllElementsPresent ();

		//	AppRect detailBounds = App.DetailPage ().Rect;

		//	var oneStarWidth = App.Query (q => q.Marked ("*"))[0].Rect.Width;
		//	var twoStarWidth = App.Query (q => q.Marked ("**"))[0].Rect.Width;
		//	var threeStarWidth = App.Query (q => q.Marked ("***"))[0].Rect.Width;

		//	Assert.AreEqual (detailBounds.Width, oneStarWidth + twoStarWidth + threeStarWidth, 1.0);
		//	App.Screenshot ("All stars fill portrait screen width");

		//	App.SetOrientationLandscape ();

		//	AppRect detailBoundsAfterRotation = App.DetailPage ().Rect;
		//	var oneStarWidthAfterRotation = App.Query (q => q.Marked ("*"))[0].Rect.Width;
		//	var twoStarWidthAfterRotation = App.Query (q => q.Marked ("**"))[0].Rect.Width;
		//	var threeStarWidthAfterRotation = App.Query (q => q.Marked ("***"))[0].Rect.Width;

		//	Assert.AreEqual (detailBoundsAfterRotation.Width, oneStarWidthAfterRotation + twoStarWidthAfterRotation + threeStarWidthAfterRotation, 1.0);
		//	App.Screenshot ("Grid stars resized");

		//	App.SetOrientationPortrait ();
		//}
	}
}