Skip to content

Commit

Permalink
Initial refactoring of uitests
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanis committed Mar 18, 2016
1 parent db7e651 commit 4a1d26f
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 38 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,5 @@ FakesAssemblies/
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml

.DS_Store
2 changes: 1 addition & 1 deletion XamarinApp/MyTrips/MyTrips.Android/MyTrips.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<OutputPath>bin\XTC</OutputPath>
<DefineConstants>XTC</DefineConstants>
<WarningLevel>4</WarningLevel>
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>
<AndroidSupportedAbis>armeabi-v7a;x86;armeabi;arm64-v8a;x86_64</AndroidSupportedAbis>
<EmbedAssembliesIntoApk></EmbedAssembliesIntoApk>
<AndroidFastDeploymentType></AndroidFastDeploymentType>
<AssemblyName>MyTrips.Android</AssemblyName>
Expand Down
4 changes: 2 additions & 2 deletions XamarinApp/MyTrips/MyTrips.UITests/AbstractSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

namespace MyTrips.UITests
{
[TestFixture(Platform.iOS)]
[TestFixture(Platform.Android)]
//[TestFixture(Platform.iOS)]
public abstract class AbstractSetup
{
protected IApp app;
Expand Down
2 changes: 1 addition & 1 deletion XamarinApp/MyTrips/MyTrips.UITests/AppInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static IApp StartApp(Platform platform)
string dir = fi.Directory.Parent.Parent.Parent.FullName;

// PathToAPK is a property or an instance variable in the test class
var PathToAPK = Path.Combine(dir, "MyTrips.Android", "bin", "Release", "com.microsoft.mytrips.apk");
var PathToAPK = Path.Combine(dir, "MyTrips.Android", "bin", "XTC", "com.microsoft.mytrips-Signed.apk");

Console.WriteLine (PathToAPK);

Expand Down
41 changes: 27 additions & 14 deletions XamarinApp/MyTrips/MyTrips.UITests/Pages/CurrentTripPage.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
using System;
using Xamarin.UITest;
using Query = System.Func<Xamarin.UITest.Queries.AppQuery, Xamarin.UITest.Queries.AppQuery>;

namespace MyTrips.UITests
{
public class CurrentTripPage : BasePage
{
readonly Query RecordingButton;
readonly string UseSimulatorButton = "Use Simulator";
readonly Query TripTitleField;
readonly Query SaveTripButton;

public CurrentTripPage ()
: base("Current Trip", "Current Trip")
{
app.Screenshot ("Current Trip");
if (OnAndroid)
{
RecordingButton = x => x.Id("fab");
TripTitleField = x => x.Class("EditText");
SaveTripButton = x => x.Id("button1");
}
if (OniOS)
{
RecordingButton = x => x.Class("UIButton");
}
}

public CurrentTripPage NavigateToCurrentTripPage ()
Expand All @@ -19,36 +35,33 @@ public CurrentTripPage NavigateToCurrentTripPage ()

public CurrentTripPage StartRecordingTrip ()
{
app.Tap (c => c.Class ("UIButton"));
app.Tap (RecordingButton);
app.Screenshot ("Started recording trip");

app.Tap("Use Simulator");
app.Tap(UseSimulatorButton);

return this;
}

public CurrentTripPage StopRecordingTrip ()
{
System.Threading.Thread.Sleep (2500);
app.Tap (c => c.Class ("UIButton"));
app.Tap (RecordingButton);

return this;
}

public CurrentTripPage EnterTripName ()
public CurrentTripPage SaveTrip (string title)
{
app.EnterText (c => c.Class ("UITextField"), "Trip Name");
app.ClearText (TripTitleField);
app.EnterText (TripTitleField, title);
app.DismissKeyboard ();
app.Screenshot ("Trip summary");

return this;
}
app.Screenshot ("Trip title entered");

public CurrentTripPage DismissTripSummary ()
{
app.Tap ("Done");
app.Tap(SaveTripButton);
app.Screenshot("Trip Saved!");

return this;
return this;
}
}
}
4 changes: 2 additions & 2 deletions XamarinApp/MyTrips/MyTrips.UITests/Pages/LoginPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace MyTrips.UITests
public class LoginPage : BasePage
{
string LoginWithFacebookItem = "LoginWithFacebook";
string SkipAuthenticationItem = "SkipAuthentication";
string SkipAuthenticationItem = "button_skip";

public LoginPage ()
: base (c => c.Marked ("LoginWithTwitter"), c => c.Marked ("LoginWithTwitter"))
: base (c => c.Marked ("button_twitter"), c => c.Marked ("LoginWithTwitter"))
{
if (OnAndroid) {

Expand Down
6 changes: 2 additions & 4 deletions XamarinApp/MyTrips/MyTrips.UITests/Tests/CurrentTripTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace MyTrips.UITests
{
[TestFixture(Platform.Android)]
public class CurrentTripTests : AbstractSetup
{
public CurrentTripTests (Platform platform) : base (platform)
Expand All @@ -17,9 +16,8 @@ public void RecordTripTest ()
new CurrentTripPage()
.NavigateToCurrentTripPage()
.StartRecordingTrip()
.StopRecordingTrip();
//.DismissTripSummary ()
//.EnterTripName();
.StopRecordingTrip()
.SaveTrip("Test Cloud Test Drive");
}
}
}
Expand Down
1 change: 0 additions & 1 deletion XamarinApp/MyTrips/MyTrips.UITests/Tests/LoginTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace MyTrips.UITests
{
[TestFixture(Platform.Android)]
public class LoginTests : AbstractSetup
{
public LoginTests (Platform platform) : base (platform)
Expand Down
1 change: 0 additions & 1 deletion XamarinApp/MyTrips/MyTrips.UITests/Tests/PastTripsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace MyTrips.UITests
{
[TestFixture(Platform.Android)]
public class PastTripsTests : AbstractSetup
{
public PastTripsTests (Platform platform) : base (platform)
Expand Down
19 changes: 7 additions & 12 deletions XamarinApp/MyTrips/MyTrips.iOS/MyTrips.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@
<MtouchArch>ARMv7, ARM64</MtouchArch>
<ConsolePause>false</ConsolePause>
<CodesignKey>iPhone Distribution</CodesignKey>
<CodesignProvision>
</CodesignProvision>
<CodesignExtraArgs>
</CodesignExtraArgs>
<CodesignProvision></CodesignProvision>
<CodesignExtraArgs></CodesignExtraArgs>
<BuildIpa>true</BuildIpa>
<CodesignResourceRules />
</PropertyGroup>
Expand Down Expand Up @@ -89,21 +87,18 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'XTC|iPhone'">
<DefineConstants>__UNIFIED__;__MOBILE__;__IOS__;XTC</DefineConstants>
<DebugType>
</DebugType>
<DebugType></DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\XTC</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchArch>ARMv7, ARM64</MtouchArch>
<ConsolePause>false</ConsolePause>
<CodesignKey>iPhone Distribution</CodesignKey>
<CodesignProvision>
</CodesignProvision>
<CodesignExtraArgs>
</CodesignExtraArgs>
<CodesignResourceRules />
<CodesignKey>iPhone Developer</CodesignKey>
<CodesignProvision></CodesignProvision>
<CodesignExtraArgs></CodesignExtraArgs>
<CodesignResourceRules></CodesignResourceRules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'XTC|iPhoneSimulator'">
<DefineConstants>__UNIFIED__;__MOBILE__;__IOS__;XTC</DefineConstants>
Expand Down

0 comments on commit 4a1d26f

Please sign in to comment.