This repository has been archived by the owner on May 1, 2024. It is now read-only.
/
BaseTestFixture.cs
108 lines (84 loc) · 2.56 KB
/
BaseTestFixture.cs
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
using System;
using Xamarin.UITest;
using Xamarin.UITest.Android;
using Xamarin.UITest.Queries;
using NUnit.Framework;
using System.Threading;
namespace Xamarin.Forms.UITests
{
public class BaseTestFixture
{
string idiomEnvVar;
string IPEnvVar;
public AndroidApp 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)) {
// Use IDE Configuration
App = ConfigureApp
.Android
.Debug ()
.ApkFile ("../../../Xamarin.Forms.ControlGallery.Android/bin/Debug/AndroidControlGallery.AndroidControlGallery-Signed.apk")
.StartApp ();
} else {
// Use CI Configuration
App = ConfigureApp
.Android
.DeviceIp (Device.IP)
.ApkFile ("../../../Xamarin.Forms.ControlGallery.Android/bin/Debug/AndroidControlGallery.AndroidControlGallery-Signed.apk")
.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.1.161");
if (!string.IsNullOrEmpty (IPEnvVar))
device.IP = IPEnvVar;
} else if (idiomEnvVar == "TABLET") {
// default tablet
device = new Device (DeviceType.Tablet, "10.0.1.42");
if (!string.IsNullOrEmpty (IPEnvVar))
device.IP = IPEnvVar;
} else {
// default phone
device = new Device (DeviceType.Phone, "10.0.1.161");
}
return device;
}
}
public static class PlatformStrings
{
public static string Button = "Button";
public static string Cell = "xamarin.forms.platform.android.ViewCellRenderer_ViewCellContainer";
public static string HomePageTitle = "Android Controls";
public static string Label = "TextView";
public static string Entry = "EditText";
public static string Placeholder = "hint";
public static string Text = "text";
}
public static class PlatformValues
{
public static int BoxViewScreenNumber = 4;
public static int KeyboardDismissY = 500;
public static int OffsetForScrollView = -5;
}
}