summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.iOS.UITests/Legacy-BaseTestFixture.cs
blob: 07cbe93db8778425d2a1d1f97c368b9223b43d18 (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
´╗┐using System;
using Xamarin.UITest;
using Xamarin.UITest.iOS;
using Xamarin.UITest.Queries;
using NUnit.Framework;
using System.Threading;

namespace Xamarin.Forms.UITests
{

	public class BaseTestFixture
	{
		string idiomEnvVar;
		string IPEnvVar;

		public static iOSApp App { get; private set; }
		public Device Device { get; set; }

		public BaseTestFixture ()
		{
			idiomEnvVar = Environment.GetEnvironmentVariable ("DEVICE_IDIOM");
			IPEnvVar = Environment.GetEnvironmentVariable ("DEVICE_IP");

			Console.WriteLine (string.Format ("****** Connecting to {0} with IP: {1} ********", idiomEnvVar, IPEnvVar));

			Device = SetupDevice (idiomEnvVar, IPEnvVar);
		}

		[SetUp]
		public void Setup ()
		{

			if (string.IsNullOrEmpty (idiomEnvVar) &&
				string.IsNullOrEmpty (IPEnvVar)) { 
				// IDE Configuration
				// Use your own device information
				App = ConfigureApp
					.iOS
					.Debug ()
//					.DeviceIp ("10.0.1.159") // iPod iOS 7
					// .DeviceIp ("10.0.1.163") // iPhone iOS 7
					// .DeviceIp ("10.0.3.146") // iPod iOS 6
					.InstalledApp ("com.xamarin.quickui.controlgallery")
					.StartApp();
			} else {
				// CI Configuration
				App = ConfigureApp
					.iOS
					.DeviceIp (Device.IP)
					.InstalledApp ("com.xamarin.quickui.controlgallery")
					.StartApp();
			}
				
			FixtureSetup ();
		}

		protected virtual void FixtureSetup ()
		{
			App.SetOrientationPortrait ();
			App.Screenshot ("Begin test");
		}

		Device SetupDevice (string idiomEnvVar, string IPEnvVar)
		{
			Device device;

			if (idiomEnvVar == "PHONE") {

				// default phone
				device = new Device (DeviceType.Phone, "10.0.3.253");

				if (!string.IsNullOrEmpty (IPEnvVar)) 
					device.IP = IPEnvVar;

			} else if (idiomEnvVar == "TABLET") {

				// default tablet
				device = new Device (DeviceType.Tablet, "10.0.1.159");

				if (!string.IsNullOrEmpty (IPEnvVar)) 
					device.IP = IPEnvVar;

			} else {

				// default phone
				device = new Device (DeviceType.Phone, "10.0.3.253");

			}

			return device;
		}
	}

	public static class PlatformStrings
	{
		public static string Button = "Button";
		public static string Cell = "TableViewCell";
		public static string Entry = "TextField";
		public static string HomePageTitle = "iOS Controls";
		public static string Label = "Label";
		public static string MapPin = "view:'MKPinAnnotationView'";
		public static string Placeholder = "placeholder";
		public static string Text = "text";
	}

	public static class PlatformValues
	{
		public static int BoxViewScreenNumber = 3;
		public static int KeyboardDismissY = 200;
		public static int OffsetForScrollView = 5;
	}
}