summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-EntryUITests.cs
blob: e88ff6b668604fe074db1f52c69f644107762ddb (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
using System;
using NUnit.Framework;
using System.Collections.Generic;
using Xamarin.UITest.Queries;

namespace Xamarin.Forms.Core.UITests
{
	[TestFixture]
	[Category ("Entry")]
	internal class EntryGalleryTests : BaseTestFixture
	{
		// TODO: Get Toggle color tests for both iOS and Android, Keyboard dismisses for Enter
		// TODO: Port to new conventions

		public EntryGalleryTests ()
		{
			ShouldResetPerFixture = false;
		}

		protected override void NavigateToGallery ()
		{
			App.NavigateToGallery (GalleryQueries.EntryGalleryLegacy);
		}
		[Test]
		[Description ("All Entry Gallery elements are present")]
		public void EntryGalleryAllElementsPresent ()
		{

//			var entryElements = new [] {
//				q => q.Marked ("Enter something in Normal"),
//				q => q.Marked ("No typing has happened in Normal yet"),
//				PlatformQueries.EntryWithPlaceholder ("Normal"),
//				PlatformQueries.EntryWithPlaceholder ("Password"),
//				PlatformQueries.EntryWithPlaceholder ("Numeric Password"),
//				q => q.Marked ("Focus an Entry"),
//				PlatformQueries.EntryWithPlaceholder ("Disabled"),
//				PlatformQueries.EntryWithPlaceholder ("Activation"),
//				PlatformQueries.EntryWithPlaceholder ("Transparent"),
//				PlatformQueries.EntryWithPlaceholder ("Keyboard.Default")
//			};

//			foreach (var entry in entryElements)
//				App.ScrollDownForElement (entry, 10);

//			var buttons = new [] { 
//				"Toggle Text Color",
//				"Toggle Secure",
//				"Change Placeholder",
//				"Focus First"
//			};

//			foreach (var button in buttons)
//				App.ScrollDownForElement (q => q.Button (button), 10);

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

//		[Test]
//		[Category ("ManualReview")]
//		[Description ("Check that the keyboard shows for each Entry")]
//		public void EntryGalleryKeyboardDisplays ()
//		{
//			AppRect windowBounds = App.MainScreenBounds ();

//			var placeHolders = new [] { 
//				"Normal",
//				"Password",
//				"Numeric Password",
//				"Disabled",
//				"Activation",
//				"Transparent",
//				"Keyboard.Default"
//			};

//			foreach (var placeholder in placeHolders) {
//				App.ScrollDownForElement (PlatformQueries.EntryWithPlaceholder (placeholder), 3);
//				if (placeholder != "Disabled") {
//					App.Tap (PlatformQueries.EntryWithPlaceholder (placeholder));
//					//App.KeyboardIsPresent ();
//					App.Screenshot ("Keyboard shown: " + placeholder);
//					// Tap empty part of screen
//					App.TapCoordinates (10, windowBounds.Height / 3);
//				} else { // Disabled entry should not show keyboard 
//					App.Tap (PlatformQueries.EntryWithPlaceholder (placeholder));
//					//App.KeyboardIsDismissed ();
//					App.Screenshot ("Keyboard not shown: " + placeholder);
//				}
//			}

//			App.Screenshot ("Keyboard should be dismissed");
//		}

//		[Test]
//		[Category ("ManualReview")]
//		[Description ("Enter text in each entry")]
//		public void EntryGalleryEnterTextInEachFieldAndTapScreenDismiss ()
//		{
//			var entries = new [] { 
//				new { Placeholder = "Normal", LabelValue = "Normal Focused" },
//				new { Placeholder = "Password", LabelValue = "Password Focused" },
//				new { Placeholder = "Numeric Password", LabelValue = "Numeric Password Focused" },
//				new { Placeholder = "Disabled", LabelValue = "Disabled Focused" },
//				new { Placeholder = "Activation", LabelValue = "Activation Focused" },
//				new { Placeholder = "Transparent", LabelValue = "Transparent Focused" },
//				new { Placeholder = "Keyboard.Default", LabelValue = "Keyboard.Default Focused" },
//			};

//			AppRect windowBounds = App.MainScreenBounds ();
//			int helloNum = 0;

//			foreach (var entry in entries) {
//				App.ScrollDownForElement (PlatformQueries.EntryWithPlaceholder (entry.Placeholder), 3);
//				if (entry.Placeholder == "Disabled") {
//					App.Tap (PlatformQueries.EntryWithPlaceholder (entry.Placeholder));
//					// App.KeyboardIsDismissed ();
//				} else if (entry.Placeholder == "Numeric Password") {
//					App.Tap (PlatformQueries.EntryWithPlaceholder (entry.Placeholder));
//					// App.KeyboardIsPresent ();
//					App.EnterText (PlatformQueries.EntryWithPlaceholder (entry.Placeholder), "167728");
//					App.TapCoordinates (10, windowBounds.Height / 3);
//				} else {
//					App.Tap (PlatformQueries.EntryWithPlaceholder (entry.Placeholder));
//					// App.KeyboardIsPresent ();
//					App.EnterText (PlatformQueries.EntryWithPlaceholder (entry.Placeholder), "Hello " + helloNum);
//					App.TapCoordinates (10, windowBounds.Height / 3);
//					helloNum++;
//				} 
//			}

//			App.Screenshot ("Entered text in each entry, password should be hidden");
//			App.Tap (q => q.Button ("Toggle Secure"));
							
//			App.ScrollUpForElement (q => q.Marked ("Hello 0"), 5);
//			App.ScrollDownForElement (q => q.Marked ("Hello 1"), 5);
//			App.ScrollDownForElement (q => q.Marked ("167728"), 5);
//			App.ScrollDownForElement (q => q.Marked ("Hello 3"), 5);
//			App.ScrollDownForElement (q => q.Marked ("Hello 4"), 5);
//			App.ScrollDownForElement (q => q.Marked ("Hello 5"), 5);

//			App.Screenshot ("Entered text in each entry, password should be shown");
//		}

////		[Test]
////		public void ToggleTextColor ()
////		{
////			AllElementsPresent ();
////
////			var text = "hello";
////			App.EnterText (PlatformQueries.EntryWithPlaceholder ("Normal"), text);
////			var initialTextColor = App.Query (q => q.Raw (string.Format ("{0} {1}:'{2}', :getCurrentTextColor", PlatformStrings.Entry, PlatformStrings.Text, text)));
////			App.Tap (q => q.Button ("Toggle Text Color"));
////			var secondTextColor = App.Query (q => q.Raw (string.Format ("{0} {1}:'{2}', :getCurrentTextColor", PlatformStrings.Entry, PlatformStrings.Text, text)));
////			Assert.AreNotEqual (initialTextColor, secondTextColor);
////		} 

//		[Test]
//		[Description ("Change Placeholder in each entry")]
//		public void EntryGalleryChangePlaceholder ()
//		{
//			for (var i = 1; i <= 5; i++) {
//				App.ScrollDownForElement (q => q.Button ("Change Placeholder"), 5);
//				App.Tap (q => q.Button ("Change Placeholder"));
//				App.ScrollUpForElement (PlatformQueries.EntryWithPlaceholder ("Placeholder " + i), 5);
//			}

//			App.Screenshot ("Changed placeholder 5 times");
//		}

//		[Test]
//		[Category ("ManualReview")]
//		[Description ("Update Keyboard Type - #1307")]
//		public void EntryGalleryChangeKeyboardType ()
//		{
//			App.ScrollDownForElement (PlatformQueries.EntryWithPlaceholder ("Keyboard.Default"), 5);
//			App.Tap (PlatformQueries.EntryWithPlaceholder ("Keyboard.Default"));
//			App.Screenshot ("I should see the default keyboard");
//			App.PressEnter ();
//			App.Screenshot ("Keyboard should be dismissed");
//			App.Screenshot ("Manually check that keyboard type is switched");
////			App.WaitForElement (PlatformQueries.EntryWithPlaceholder ("Keyboard.Numeric"));
////			App.Tap (PlatformQueries.EntryWithPlaceholder ("Keyboard.Numeric"));
//			App.Screenshot ("I should see the numeric keyboard");
//		}

//		[Test]
//		[Category ("ManualReview")]
//		[Description ("Completed handler firing, keyboard dismissing - #1308")]
//		public void EntryGalleryCheckCompletedKeyboardDismissed ()
//		{
//			App.WaitForElement (q => q.Marked ("Enter something in Normal"));
//			App.ScrollDownForElement (PlatformQueries.EntryWithPlaceholder ("Normal"), 5);
//			App.Tap (PlatformQueries.EntryWithPlaceholder ("Normal"));
//			App.Screenshot ("Tapped Normal");
//			App.EnterText (PlatformQueries.EntryWithPlaceholder ("Normal"), "It has been entered");
//			App.Screenshot ("The keyboard should be shown");
//			// App.PressEnter ();
//			App.Screenshot ("Keyboard should be dismissed - Check manually");
//			//App.WaitForNoElement (q => q.Marked ("Enter something in Normal"));
//			//App.ScrollUpForElement (q => q.Marked ("It has been entered"), 5);
//			App.Screenshot ("Text should have changed");
//		}

//		[Test]
//		[Description ("Test the TextChanged event")]
//		public void EntryGalleryTextChangedEventTest ()
//		{
//			App.Screenshot ("Waiting for entry gallery");
//			App.WaitForElement (q => q.Marked ("No typing has happened in Normal yet"));
//			App.Screenshot ("Entering text in Normal");
//			App.EnterText (PlatformQueries.EntryWithPlaceholder ("Normal"), "a");
//			App.WaitForElement (q => q.Marked ("You typed in normal"));
//			App.Screenshot ("Text entered, TextChanged event should have fired");
//		}
			

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

//		[Test]
//		[Description ("All Entry Gallery elements are present - landscape")]
//		public void EntryGalleryAllElementsPresentLandscape ()
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			EntryGalleryAllElementsPresent ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}
			
//		[Test]
//		[Category ("ManualReview")]
//		[Description ("Check that the keyboard shows for each Entry - landscape")]
//		public void EntryGalleryKeyboardDisplaysLandscape ()
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			EntryGalleryKeyboardDisplays ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

//		[Test]
//		[Category ("ManualReview")]
//		[Description ("Enter text in each entry - landscape")]
//		public void EntryGalleryEnterTextInEachFieldAndTapScreenDismissLandscape ()
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			EntryGalleryEnterTextInEachFieldAndTapScreenDismiss ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

//		[Test]
//		[Description ("Change Placeholder in each entry - landscape")]
//		public void EntryGalleryChangePlaceholderLandscape ()
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			EntryGalleryChangePlaceholder ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

//		[Test]
//		[Category ("ManualReview")]
//		[Description ("Update Keyboard Type - #1307 - Landscape")]
//		public void EntryGalleryChangeKeyboardTypeLandscape ()
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			EntryGalleryChangeKeyboardType ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

//		[Test]
//		[Description ("Completed handler firing, keyboard dismissing - #1308 - Landscape")]
//		public void EntryGalleryCheckCompletedKeyboardDismissedLandscape ()
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			EntryGalleryCheckCompletedKeyboardDismissed ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

//		[Test]
//		[Description ("Test the TextChanged event - Landscape")]
//		public void EntryGalleryTextChangedEventTestLandscape ()
//		{
//			App.SetOrientationLandscape ();
//			App.Screenshot ("Rotated to Landscape");
//			EntryGalleryTextChangedEventTest ();
//			App.SetOrientationPortrait ();
//			App.Screenshot ("Rotated to Portrait");
//		}

	}
}