summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TemplatedTabPageUITests.cs
blob: 180c7bff755f55912fd8cbe19f27ee134a3ae70d (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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
using NUnit.Framework;
using Xamarin.UITest;
using Xamarin.UITest.Queries;
using System;

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

		public TemplatedTabPageGalleryTests ()
		{
			ShouldResetPerFixture = false;
		}

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

//		void AllElementsExist ()
//		{
//			var labels = new [] { 
//				"Lorem ipsum dolor sit amet #0",
//				"Page 0",
//				"Page 1",
//			};

//			foreach (var label in labels)
//				App.WaitForElement (q => q.Marked (label), "Timeout : " + label);
				
//			AllElementExistForPage (0);

//			App.Tap (q => q.Marked ("Page 1"));
//			AllElementExistForPage (1);

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

		[Test]
		[Description ("Insert tab")]
		public void TemplatedTabPageGalleryInsertTab () 
		{
//			AllElementsExist ();

//			App.Tap (q => q.Button ("Insert Tab: 1"));
//			App.WaitForElement (q => q.Marked ("Page 2"), "Timeout : Page 2");

//			App.Screenshot ("Page 2 added");

//			App.Tap (q => q.Marked ("Page 2"));
//			AllElementExistForPage (2);

//			App.Screenshot ("Page 2 selected");
		}

//		[Test]
//		[Description ("Insert tab crash reproduction")]
//		public void TemplatedTabPageGalleryInsertTabCrash ()
//		{
//			TemplatedTabPageGalleryInsertTab ();
//			App.Tap (q => q.Marked ("Page 1"));
//			AllElementExistForPage (1);

//			App.Tap (q => q.Marked ("Page 0"));
//			AllElementExistForPage (0);
//		}

//		[Test]
//		[Description ("Change tab Title")]
//		public void TemplatedTabPageGalleryChangeTitles () 
//		{
//			AllElementsExist ();
//			App.Tap (q => q.Marked ("Change title: 1"));
//			App.WaitForNoElement (q => q.Marked ("Page 1"), "Timeout : Page 1");

//			// Change Page 1 title
//			for (int i = 0; i < 3; i++) {
//				App.WaitForElement (q => q.Marked ("Title: " + i), "Timeout : Title " + i);
//				App.Tap (q => q.Marked ("Change title: 1"));
//			}

//			App.Screenshot ("Page 1 titles changed");

//			// Change Page 0 title
//			App.Tap (q => q.Marked ("Page 0"));
//			App.Tap (q => q.Button ("Change title: 0"));
//			App.WaitForNoElement (q => q.Marked ("Page 0"), "Timeout : Page 0");

//			for (int i = 0; i < 3; i++) {
//				App.WaitForElement (q => q.Marked ("Title: " + i), "Timeout : Title " + i);
//				App.Tap (q => q.Button ("Change title: 0"));
//			}

//			App.Screenshot ("Page 0 titles changed");
//		}

//		[Test]
//		[Description ("Move tabs")]
//		public void TemplatedTabPageGalleryMoveTabs () 
//		{
//			AllElementsExist ();

//			int pageZeroTabIndex = App.IndexForElementWithText (PlatformQueries.Labels, "Page 0");
//			int pageOneTabIndex = App.IndexForElementWithText (PlatformQueries.Labels, "Page 1");

//			// Elements found
//			Assert.AreNotEqual (-1, pageZeroTabIndex);
//			Assert.AreNotEqual (-1, pageOneTabIndex);

//			Assert.Greater (pageOneTabIndex, pageZeroTabIndex);

//			App.Screenshot ("Tabs before move");

//			App.Tap (q => q.Button ("Move Tab: 1"));

//			int pageZeroMovedTabIndex = App.IndexForElementWithText (PlatformQueries.Labels, "Page 0");
//			int pageOneMovedTabIndex = App.IndexForElementWithText (PlatformQueries.Labels, "Page 1");

//			// Elements found
//			Assert.AreNotEqual (-1, pageZeroMovedTabIndex);
//			Assert.AreNotEqual (-1, pageOneMovedTabIndex);

//			Assert.Greater (pageZeroMovedTabIndex, pageOneMovedTabIndex);

//			App.Screenshot ("Tabs after move");
//		}

//		[Test]
//		[Description ("Remove tabs")]
//		public void TemplatedTabPageGalleryRemoveTabs () 
//		{
//			AllElementsExist ();

//			App.Tap (q => q.Button ("Remove Tab: 1"));
//			App.WaitForNoElement (q => q.Marked ("Page 1"), "Timeout : Page 1");

//			App.Screenshot ("Remove Page 1");
//		}

//		[Test]
//		[Description ("Add / remove tabs")]
//		public void TemplatedTabPageGalleryAddRemoveTabs () 
//		{
//			TemplatedTabPageGalleryInsertTab ();

//			App.Tap (q => q.Button ("Remove Tab: 2"));
//			App.WaitForNoElement (q => q.Marked ("Page 2"), "Timeout : Page 2");

//			App.Screenshot ("Remove Page 2");

//			App.Tap (q => q.Button ("Remove Tab: 0"));
//			App.WaitForNoElement (q => q.Marked ("Page 0"), "Timeout : Page 0");

//			App.Screenshot ("Remove Page 0");

//			AllElementExistForPage (1);
//		}

//		[Test]
//		[Description ("Reset tabs")]
//		public void TemplatedTabPageGalleryResetAllTabs () 
//		{
//			TemplatedTabPageGalleryChangeTitles ();

//			App.Tap (q => q.Button ("Insert Tab: 0"));
//			App.WaitForElement (q => q.Marked ("Page 2"), "Timeout : Page 2");

//			App.Screenshot ("Page 2 added");

//			App.Tap (q => q.Marked ("Page 2"));
//			AllElementExistForPage (2);

//			App.Screenshot ("Page 2 selected");

//			App.ScrollDownForElement (q => q.Button ("Reset all tabs: 2"), 3);
//			App.Tap (q => q.Button ("Reset all tabs: 2"));
//			App.WaitForElement (q => q.Marked ("Page 0"), "Timeout : Page 0");
//			App.WaitForElement (q => q.Marked ("Page 1"), "Timeout : Page 1");

//			var numberOfTabs = App.Query (q => q.Raw (PlatformStrings.Label + " {text BEGINSWITH 'Page'}")).Length;
//			Assert.AreEqual (2, numberOfTabs);

//			App.Screenshot ("Tabs reset");
//		}

//		[Test]
//		[Description ("Go to next tabs")]
//		public void TemplatedTabPageGalleryNextPage () 
//		{
//			TemplatedTabPageGalleryInsertTab ();

//			ScrollDownForQuery (q => q.Button ("Next Page: 2"));
//			App.Tap (q => q.Button ("Next Page: 2"));
//			AllElementExistForPage (0);
//			App.Screenshot ("On Page 0");

//			ScrollDownForQuery (q => q.Button ("Next Page: 0"));
//			App.Tap (q => q.Button ("Next Page: 0"));
//			AllElementExistForPage (1);
//			App.Screenshot ("On Page 1");

//			ScrollDownForQuery (q => q.Button ("Next Page: 1"));
//			App.Tap (q => q.Button ("Next Page: 1"));
//			AllElementExistForPage (2);
//			App.Screenshot ("On Page 2");

//			ScrollDownForQuery (q => q.Button ("Next Page: 2"));
//			App.Tap (q => q.Button ("Next Page: 2"));
//			AllElementExistForPage (0);
//			App.Screenshot ("On Page 0");
//		}

//		void AllElementExistForPage (int index)
//		{
//			var title = "Lorem ipsum dolor sit amet #" + index;

//			ScrollUpForQuery (q => q.Marked (title));

//			var buttons = new [] { 
//				"Insert Tab: " + index,
//				"Change title: " + index,
//				"Move Tab: " + index,
//				"Remove Tab: " + index,
//				"Reset all tabs: " + index,
//				"Next Page: " + index,
//			};

//			App.WaitForElement (q => q.Marked (title));

//			foreach (var button in buttons)
//				ScrollDownForQuery (q => q.Button (button));

//			ScrollUpForQuery (q => q.Marked (title));
//		}

//		void ScrollDownForQuery (Func<AppQuery, AppQuery> query)
//		{
//			var screenBounds = App.MainScreenBounds ();
//			App.DragFromToForElement (2, query, screenBounds.Width - 10, (2 / 3.0f) * screenBounds.Height, screenBounds.Width - 10, screenBounds.Height / 3.0f);
//		}

//		void ScrollUpForQuery (Func<AppQuery, AppQuery> query)
//		{
//			var screenBounds = App.MainScreenBounds ();
//			App.DragFromToForElement (2, query, screenBounds.Width - 10, screenBounds.Height / 3.0f, screenBounds.Width - 10,  (2 / 3.0f) * screenBounds.Height);
//		}

///*******************************************************/
///**************** Landscape tests **********************/
///*******************************************************/

//		[Test]
//		[Description ("Insert tab - Landscape")]
//		public void TemplatedTabPageGalleryInsertTabLandscape () 
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			TemplatedTabPageGalleryInsertTab ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

//		[Test]
//		[Description ("Insert tab crash reproduction - Landscape")]
//		public void TemplatedTabPageGalleryInsertTabCrashLandscape ()
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			TemplatedTabPageGalleryInsertTabCrash ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

//		[Test]
//		[Description ("Change tab Title - Landscape")]
//		public void TemplatedTabPageGalleryChangeTitlesLandscape () 
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			TemplatedTabPageGalleryChangeTitles ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

//		[Test]
//		[Description ("Move tabs - Landscape")]
//		public void TemplatedTabPageGalleryMoveTabsLandscape () 
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			TemplatedTabPageGalleryMoveTabs ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

//		[Test]
//		[Description ("Remove tabs - Landscape")]
//		public void TemplatedTabPageGalleryRemoveTabLandscapes () 
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			TemplatedTabPageGalleryRemoveTabs ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

//		[Test]
//		[Description ("Add / remove tabs - Landscape")]
//		public void TemplatedTabPageGalleryAddRemoveTabsLandscape () 
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			TemplatedTabPageGalleryAddRemoveTabs ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

//		[Test]
//		[Description ("Reset tabs - Landscape")]
//		public void TemplatedTabPageGalleryResetAllTabsLandscape () 
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			TemplatedTabPageGalleryResetAllTabs ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

//		[Test]
//		[Description ("Go to next tabs - Landscape")]
//		public void TemplatedTabPageGalleryNextPageLandscape () 
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			TemplatedTabPageGalleryNextPage ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

	}
}