summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-AbsoluteLayoutGalleryTest.cs
blob: c23a0d276fa6e42adce145b883ba2d916976195c (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
using NUnit.Framework;
using Xamarin.UITest;
using System;
using System.Threading;
using Xamarin.UITest.Queries;
using System.Diagnostics;

namespace Xamarin.Forms.Core.UITests
{
	[TestFixture]
	[Category ("AbsoluteLayout")]
	internal class AbsoluteLayoutGalleryTests : BaseTestFixture
	{
		// TODO: Port to new conventions

		public AbsoluteLayoutGalleryTests ()
		{
			ShouldResetPerFixture = false;
		}

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

		[Test]
		public void AbsoluteLayoutGalleryMoveBox ()
		{
			App.Screenshot ("At Gallery");

			//	App.WaitForElement (q => q.Raw (Views.BoxView), "Timeout : Box Renderers");
			//	Assert.AreEqual (1, App.Query (q => q.Raw (Views.BoxView)).Length);

			//	App.WaitForElement (q => q.Raw (Views.Label), "Timeout : Labels");
			//	Assert.AreEqual (4, App.Query(q => q.Raw (Views.Label)).Length);

			//	App.WaitForElement (q => q.Raw (Views.Slider), "Timeout : Sliders");
			//	Assert.AreEqual (4, App.Query(q => q.Raw (Views.Slider)).Length);
			//	App.Screenshot ("All elements exist");

			//	App.WaitForElement (q => q.Raw (Views.Slider));
			//	// Move green box left
			//	var sliders = (App.Query (q => q.Raw (Views.Slider)));
			//	var sliderCenter = (sliders[0]).Rect.CenterX;
			//	var sliderLeft = (sliders[0]).Rect.X;
			//	var sliderRight = sliderLeft + (sliders[0]).Rect.Width;

			//	var xSlider = (sliders[0]).Rect.CenterY;
			//	var ySlider = (sliders[1]).Rect.CenterY;

			//var absoluteBounds = App.Query (PlatformQueries.AbsoluteGalleryBackground)[0].Rect;

			//// Move box left
			//App.DragFromTo (sliderCenter, xSlider, sliderLeft, xSlider, Speed.Slow);
			//Assert.AreEqual (absoluteBounds.X, (App.Query (PlatformQueries.BoxRendererQuery))[0].Rect.X, 2.0);
			//App.Screenshot ("Box moved to left bounds");

			//// Move box right
			//App.DragFromTo (sliderLeft, xSlider, sliderRight, xSlider, Speed.Slow);
			//Assert.AreEqual (absoluteBounds.X + absoluteBounds.Width, (App.Query (PlatformQueries.BoxRendererQuery))[0].Rect.X + (App.Query (PlatformQueries.BoxRendererQuery))[0].Rect.Width, 2.0);
			//App.Screenshot ("Box moved to right bounds");

			////Move box up
			//var boxContainer = App.Query (PlatformQueries.AbsoluteGalleryBackground)[0];
			//var boxContainerTop = boxContainer.Rect.Y;
			//var boxContainerBottom = boxContainer.Rect.Y + boxContainer.Rect.Height;

			//App.DragFromTo (sliderCenter, ySlider, sliderLeft, ySlider, Speed.Slow);
			//Assert.AreEqual (boxContainerTop, (App.Query (PlatformQueries.BoxRendererQuery))[0].Rect.Y);
			//App.Screenshot ("Box moved to top bounds");

			//// Move box down
			//App.DragFromTo (sliderLeft, ySlider, sliderRight, ySlider, Speed.Slow);
			//Assert.AreEqual (boxContainerBottom, (App.Query (PlatformQueries.BoxRendererQuery))[0].Rect.Y + (App.Query (PlatformQueries.BoxRendererQuery))[0].Rect.Height);
			//App.Screenshot ("Box moved to bottom bounds");
		}

		//[Test] 
		//[Description ("MaxWidth")]
		//public void AbsoluteLayoutGalleryResizeToMaximumWidth ()
		//{
			//App.WaitForElement (PlatformQueries.Sliders, "Timeout : Sliders");

			//AppRect widthSlider = (App.Query (PlatformQueries.Sliders))[2].Rect;
			//float sliderCenter = widthSlider.CenterX;
			//float sliderY = widthSlider.CenterY;
			//float sliderRight = widthSlider.X + widthSlider.Width;

			//App.DragFromTo (sliderCenter, sliderY, sliderRight, sliderY, Speed.Slow);

			//AppRect absoluteBounds = App.Query (PlatformQueries.AbsoluteGalleryBackground)[0].Rect;
			//AppRect boxBounds = App.Query (PlatformQueries.BoxRendererQuery)[0].Rect;

			//Assert.AreEqual (absoluteBounds.Width, boxBounds.Width, 2.0);
			//App.Screenshot ("Box at maximum width");
		//}

		//[Test] 
		//[Description ("MaxHeight")]
		//public void AbsoluteLayoutGalleryResizeToMaximumHeight ()
		//{
			//App.WaitForElement (PlatformQueries.Sliders, "Timeout : Sliders");

			//AppRect widthSlider = (App.Query (PlatformQueries.Sliders))[3].Rect;
			//float sliderCenter = widthSlider.CenterX;
			//float sliderY = widthSlider.CenterY;
			//float sliderRight = widthSlider.X + widthSlider.Width;

			//App.DragFromTo (sliderCenter, sliderY, sliderRight, sliderY, Speed.Slow);

			//AppRect absoluteBounds = App.Query (PlatformQueries.AbsoluteGalleryBackground)[0].Rect;
			//AppRect boxBounds = App.Query (PlatformQueries.BoxRendererQuery)[0].Rect;

			//Assert.AreEqual (absoluteBounds.Height, boxBounds.Height, 2.0);
			//App.Screenshot ("Box at maximum height");
		//}

		//[Test] 
		//[Description ("MinWidth")]
		//public void AbsoluteLayoutGalleryResizeToMinimumWidth ()
		//{
			//App.WaitForElement (PlatformQueries.Sliders, "Timeout : Sliders");

			//AppRect widthSlider = (App.Query (PlatformQueries.Sliders))[2].Rect;
			//float sliderCenter = widthSlider.CenterX;
			//float sliderY = widthSlider.CenterY;
			//float sliderLeft = widthSlider.X - 20;

			//App.DragFromTo (sliderCenter, sliderY, sliderLeft, sliderY, Speed.Slow);

			//bool isZeroed = false;
			//if (App.Query (PlatformQueries.BoxRendererQuery).Length == 0) {
			//	// Android removes 0 width BoxView
			//	isZeroed = true;
			//} else {
			//	if (App.Query (PlatformQueries.BoxRendererQuery)[0].Rect.Width <= 4.0)
			//		isZeroed = true;
			//}

			//Assert.IsTrue (isZeroed, "Box is minimum width");
			//App.Screenshot ("Box at minimum width");
		}

		//[Test] 
		//[Description ("MinHeight")]
		//public void AbsoluteLayoutGalleryResizeToMinimumHeight ()
		//{
			//App.WaitForElement (PlatformQueries.Sliders, "Timeout : Sliders");

			//AppRect widthSlider = (App.Query (PlatformQueries.Sliders))[3].Rect;
			//float sliderCenter = widthSlider.CenterX;
			//float sliderY = widthSlider.CenterY;
			//float sliderLeft = widthSlider.X - 20;

			//App.DragFromTo (sliderCenter, sliderY, sliderLeft, sliderY, Speed.Slow);

			//bool isZeroed = false;
			//if (App.Query (PlatformQueries.BoxRendererQuery).Length == 0) {
			//	// Android removes 0 height BoxView
			//	isZeroed = true;
			//} else {
			//	if (App.Query (PlatformQueries.BoxRendererQuery)[0].Rect.Height <= 4.0)
			//		isZeroed = true;
			//}

			//Assert.IsTrue (isZeroed, "Box is minimum height");
			//App.Screenshot ("Box at minimum height");
		//}
			
/*******************************************************/
/**************** Landscape tests **********************/
/*******************************************************/

		//[Test]
		//[Description ("Move box around with sliders - landscape")]
		//public void AbsoluteLayoutGalleryMoveBoxLandscape ()
		//{
		//	App.SetOrientationLandscape ();
		//	App.Screenshot ("Rotated to Landscape");
		//	AbsoluteLayoutGalleryMoveBox ();
		//	App.SetOrientationPortrait ();
		//	App.Screenshot ("Rotated to Portrait");
		//}

		//[Test]
		//[Description ("Resize to max width with sliders - landscape")]
		//public void AbsoluteLayoutGalleryResizeToMaximumWidthLandscape ()
		//{
		//	App.SetOrientationLandscape ();
		//	App.Screenshot ("Rotated to Landscape");
		//	AbsoluteLayoutGalleryResizeToMaximumWidth ();
		//	App.SetOrientationPortrait ();
		//	App.Screenshot ("Rotated to Portrait");
		//}

		//[Test]
		//[Description ("Resize to max height with sliders - landscape")]
		//public void AbsoluteLayoutGalleryResizeToMaximumHeightLandscape ()
		//{
		//	App.SetOrientationLandscape ();
		//	App.Screenshot ("Rotated to Landscape");
		//	AbsoluteLayoutGalleryResizeToMaximumHeight ();
		//	App.SetOrientationPortrait ();
		//	App.Screenshot ("Rotated to Portrait");
		//}

		//[Test]
		//[Description ("Resize to min height with sliders - landscape")]
		//public void AbsoluteLayoutGalleryResizeToMinimumWidthLandscape ()
		//{
		//	App.SetOrientationLandscape ();
		//	App.Screenshot ("Rotated to Landscape");
		//	AbsoluteLayoutGalleryResizeToMinimumWidth ();
		//	App.SetOrientationPortrait ();
		//	App.Screenshot ("Rotated to Portrait");
		//}

		//[Test]
		//[Description ("Resize to min height with sliders - landscape")]
		//public void AbsoluteLayoutGalleryResizeToMinimumHeightLandscape ()
		//{
		//	App.SetOrientationLandscape ();
		//	App.Screenshot ("Rotated to Landscape");
		//	AbsoluteLayoutGalleryResizeToMinimumHeight ();
		//	App.SetOrientationPortrait ();
		//	App.Screenshot ("Rotated to Portrait");
		//}
	//}
}