Skip to content

Commit 33615ec

Browse files
ghuntleyglennawatson
authored andcommitted
feature: add integration tests (#1598)
1 parent 0bd4205 commit 33615ec

File tree

231 files changed

+19928
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+19928
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27604.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTests.Android", "IntegrationTests.Android\IntegrationTests.Android.csproj", "{3BC0AC7E-3B3B-4D3F-9CC0-B2BDECC460A6}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests.Shared", "IntegrationTests.Shared\IntegrationTests.Shared.csproj", "{92988CE1-EA84-4A3A-8921-D3474CC0C87B}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{3BC0AC7E-3B3B-4D3F-9CC0-B2BDECC460A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{3BC0AC7E-3B3B-4D3F-9CC0-B2BDECC460A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{3BC0AC7E-3B3B-4D3F-9CC0-B2BDECC460A6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
19+
{3BC0AC7E-3B3B-4D3F-9CC0-B2BDECC460A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{3BC0AC7E-3B3B-4D3F-9CC0-B2BDECC460A6}.Release|Any CPU.Build.0 = Release|Any CPU
21+
{3BC0AC7E-3B3B-4D3F-9CC0-B2BDECC460A6}.Release|Any CPU.Deploy.0 = Release|Any CPU
22+
{92988CE1-EA84-4A3A-8921-D3474CC0C87B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{92988CE1-EA84-4A3A-8921-D3474CC0C87B}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{92988CE1-EA84-4A3A-8921-D3474CC0C87B}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{92988CE1-EA84-4A3A-8921-D3474CC0C87B}.Release|Any CPU.Build.0 = Release|Any CPU
26+
EndGlobalSection
27+
GlobalSection(SolutionProperties) = preSolution
28+
HideSolutionNode = FALSE
29+
EndGlobalSection
30+
GlobalSection(ExtensibilityGlobals) = postSolution
31+
SolutionGuid = {98CE2128-E3D7-4F18-A7F7-46C95788C011}
32+
EndGlobalSection
33+
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Any raw assets you want to be deployed with your application can be placed in
2+
this directory (and child directories) and given a Build Action of "AndroidAsset".
3+
4+
These files will be deployed with you package and will be accessible using Android's
5+
AssetManager, like this:
6+
7+
public class ReadAsset : Activity
8+
{
9+
protected override void OnCreate (Bundle bundle)
10+
{
11+
base.OnCreate (bundle);
12+
13+
InputStream input = Assets.Open ("my_asset.txt");
14+
}
15+
}
16+
17+
Additionally, some Android functions will automatically load asset files:
18+
19+
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{3BC0AC7E-3B3B-4D3F-9CC0-B2BDECC460A6}</ProjectGuid>
9+
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
10+
<TemplateGuid>{84dd83c5-0fe3-4294-9419-09e7c8ba324f}</TemplateGuid>
11+
<OutputType>Library</OutputType>
12+
<AppDesignerFolder>Properties</AppDesignerFolder>
13+
<RootNamespace>IntegrationTests.Android</RootNamespace>
14+
<AssemblyName>IntegrationTests.Android</AssemblyName>
15+
<FileAlignment>512</FileAlignment>
16+
<AndroidApplication>True</AndroidApplication>
17+
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
18+
<AndroidResgenClass>Resource</AndroidResgenClass>
19+
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
20+
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
21+
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
22+
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
23+
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
24+
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
27+
<DebugSymbols>True</DebugSymbols>
28+
<DebugType>Full</DebugType>
29+
<Optimize>False</Optimize>
30+
<OutputPath>bin\Debug\</OutputPath>
31+
<DefineConstants>DEBUG;TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
35+
<AndroidLinkMode>None</AndroidLinkMode>
36+
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
37+
</PropertyGroup>
38+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
39+
<DebugType>PdbOnly</DebugType>
40+
<DebugSymbols>True</DebugSymbols>
41+
<Optimize>True</Optimize>
42+
<OutputPath>bin\Release\</OutputPath>
43+
<DefineConstants>TRACE</DefineConstants>
44+
<ErrorReport>prompt</ErrorReport>
45+
<WarningLevel>4</WarningLevel>
46+
<AndroidManagedSymbols>true</AndroidManagedSymbols>
47+
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
48+
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
49+
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
50+
</PropertyGroup>
51+
<ItemGroup>
52+
<Reference Include="System" />
53+
<Reference Include="System.Xml" />
54+
<Reference Include="System.Core" />
55+
<Reference Include="Mono.Android" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<Compile Include="MainActivity.cs" />
59+
<Compile Include="Resources\Resource.Designer.cs" />
60+
<Compile Include="Properties\AssemblyInfo.cs" />
61+
</ItemGroup>
62+
<ItemGroup>
63+
<None Include="Resources\AboutResources.txt" />
64+
<None Include="Properties\AndroidManifest.xml" />
65+
<None Include="Assets\AboutAssets.txt" />
66+
</ItemGroup>
67+
<ItemGroup>
68+
<AndroidResource Include="Resources\layout\activity_main.axml">
69+
<SubType>Designer</SubType>
70+
</AndroidResource>
71+
<AndroidResource Include="Resources\layout\content_main.axml">
72+
<SubType>Designer</SubType>
73+
</AndroidResource>
74+
<AndroidResource Include="Resources\values\colors.xml" />
75+
<AndroidResource Include="Resources\values\dimens.xml" />
76+
<AndroidResource Include="Resources\values\ic_launcher_background.xml" />
77+
<AndroidResource Include="Resources\values\strings.xml" />
78+
<AndroidResource Include="Resources\values\styles.xml" />
79+
<AndroidResource Include="Resources\menu\menu_main.xml" />
80+
<AndroidResource Include="Resources\mipmap-anydpi-v26\ic_launcher.xml" />
81+
<AndroidResource Include="Resources\mipmap-anydpi-v26\ic_launcher_round.xml" />
82+
<AndroidResource Include="Resources\mipmap-hdpi\ic_launcher.png" />
83+
<AndroidResource Include="Resources\mipmap-hdpi\ic_launcher_foreground.png" />
84+
<AndroidResource Include="Resources\mipmap-hdpi\ic_launcher_round.png" />
85+
<AndroidResource Include="Resources\mipmap-mdpi\ic_launcher.png" />
86+
<AndroidResource Include="Resources\mipmap-mdpi\ic_launcher_foreground.png" />
87+
<AndroidResource Include="Resources\mipmap-mdpi\ic_launcher_round.png" />
88+
<AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher.png" />
89+
<AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher_foreground.png" />
90+
<AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher_round.png" />
91+
<AndroidResource Include="Resources\mipmap-xxhdpi\ic_launcher.png" />
92+
<AndroidResource Include="Resources\mipmap-xxhdpi\ic_launcher_foreground.png" />
93+
<AndroidResource Include="Resources\mipmap-xxhdpi\ic_launcher_round.png" />
94+
<AndroidResource Include="Resources\mipmap-xxxhdpi\ic_launcher.png" />
95+
<AndroidResource Include="Resources\mipmap-xxxhdpi\ic_launcher_foreground.png" />
96+
<AndroidResource Include="Resources\mipmap-xxxhdpi\ic_launcher_round.png" />
97+
</ItemGroup>
98+
<ItemGroup>
99+
<PackageReference Include="ReactiveUI">
100+
<Version>8.0.0-alpha0136</Version>
101+
</PackageReference>
102+
<PackageReference Include="Xamarin.Android.Support.Design" Version="27.0.2" />
103+
</ItemGroup>
104+
<ItemGroup>
105+
<ProjectReference Include="..\IntegrationTests.Shared\IntegrationTests.Shared.csproj">
106+
<Project>{92988ce1-ea84-4a3a-8921-d3474cc0c87b}</Project>
107+
<Name>IntegrationTests.Shared</Name>
108+
</ProjectReference>
109+
</ItemGroup>
110+
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
111+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
112+
Other similar extension points exist, see Microsoft.Common.targets.
113+
<Target Name="BeforeBuild">
114+
</Target>
115+
<Target Name="AfterBuild">
116+
</Target>
117+
-->
118+
</Project>
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
using System;
2+
using System.Reactive;
3+
using System.Reactive.Disposables;
4+
using System.Reactive.Linq;
5+
using Android.App;
6+
using Android.OS;
7+
using Android.Views;
8+
using Android.Widget;
9+
using IntegrationTests.Shared;
10+
using ReactiveUI;
11+
12+
namespace IntegrationTests.Android
13+
{
14+
[Activity(Label = "@string/app_name", Theme = "@style/AppTheme.NoActionBar", MainLauncher = true)]
15+
public class MainActivity : ReactiveActivity<LoginViewModel>
16+
{
17+
public EditText Username { get; set; }
18+
19+
public EditText Password { get; set; }
20+
21+
public Button Login { get; set; }
22+
23+
public Button Cancel { get; set; }
24+
25+
protected override void OnCreate(Bundle savedInstanceState)
26+
{
27+
base.OnCreate(savedInstanceState);
28+
29+
SetContentView(Resource.Layout.activity_main);
30+
31+
var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
32+
SetActionBar(toolbar);
33+
34+
Username = FindViewById<EditText>(Resource.Id.Username);
35+
Password = FindViewById<EditText>(Resource.Id.Password);
36+
Login = FindViewById<Button>(Resource.Id.Login);
37+
Cancel = FindViewById<Button>(Resource.Id.Cancel);
38+
39+
ViewModel = new LoginViewModel(RxApp.MainThreadScheduler);
40+
41+
this
42+
.WhenActivated(
43+
disposables =>
44+
{
45+
this
46+
.Bind(ViewModel, vm => vm.UserName, v => v.Username.Text)
47+
.DisposeWith(disposables);
48+
this
49+
.Bind(ViewModel, vm => vm.Password, v => v.Password.Text)
50+
.DisposeWith(disposables);
51+
this
52+
.BindCommand(ViewModel, vm => vm.Login, v => v.Login)
53+
.DisposeWith(disposables);
54+
this
55+
.BindCommand(ViewModel, vm => vm.Cancel, v => v.Cancel)
56+
.DisposeWith(disposables);
57+
58+
this
59+
.ViewModel
60+
.Login
61+
.SelectMany(
62+
result =>
63+
{
64+
if(!result.HasValue)
65+
{
66+
return Observable.Empty<Unit>();
67+
}
68+
69+
if(result.Value)
70+
{
71+
new AlertDialog.Builder(this)
72+
.SetTitle("Login Successful")
73+
.SetMessage("Welcome!")
74+
.Show();
75+
}
76+
else
77+
{
78+
new AlertDialog.Builder(this)
79+
.SetTitle("Login Failed")
80+
.SetMessage("Ah, ah, ah, you didn't say the magic word!")
81+
.Show();
82+
}
83+
84+
return Observable.Return(Unit.Default);
85+
})
86+
.Subscribe()
87+
.DisposeWith(disposables);
88+
});
89+
}
90+
91+
public override bool OnCreateOptionsMenu(IMenu menu)
92+
{
93+
MenuInflater.Inflate(Resource.Menu.menu_main, menu);
94+
return true;
95+
}
96+
97+
public override bool OnOptionsItemSelected(IMenuItem item)
98+
{
99+
int id = item.ItemId;
100+
if (id == Resource.Id.action_settings)
101+
{
102+
return true;
103+
}
104+
105+
return base.OnOptionsItemSelected(item);
106+
}
107+
}
108+
}
109+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="IntegrationTests.Android.IntegrationTests.Android" android:installLocation="auto">
3+
<uses-sdk android:minSdkVersion="23" />
4+
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"></application>
5+
</manifest>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
using Android.App;
5+
6+
// General Information about an assembly is controlled through the following
7+
// set of attributes. Change these attribute values to modify the information
8+
// associated with an assembly.
9+
[assembly: AssemblyTitle("IntegrationTests.Android")]
10+
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyConfiguration("")]
12+
[assembly: AssemblyCompany("")]
13+
[assembly: AssemblyProduct("IntegrationTests.Android")]
14+
[assembly: AssemblyCopyright("Copyright © 2018")]
15+
[assembly: AssemblyTrademark("")]
16+
[assembly: AssemblyCulture("")]
17+
[assembly: ComVisible(false)]
18+
19+
// Version information for an assembly consists of the following four values:
20+
//
21+
// Major Version
22+
// Minor Version
23+
// Build Number
24+
// Revision
25+
//
26+
// You can specify all the values or you can default the Build and Revision Numbers
27+
// by using the '*' as shown below:
28+
// [assembly: AssemblyVersion("1.0.*")]
29+
[assembly: AssemblyVersion("1.0.0.0")]
30+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Images, layout descriptions, binary blobs and string dictionaries can be included
2+
in your application as resource files. Various Android APIs are designed to
3+
operate on the resource IDs instead of dealing with images, strings or binary blobs
4+
directly.
5+
6+
For example, a sample Android app that contains a user interface layout (main.axml),
7+
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8+
would keep its resources in the "Resources" directory of the application:
9+
10+
Resources/
11+
drawable/
12+
icon.png
13+
14+
layout/
15+
main.axml
16+
17+
values/
18+
strings.xml
19+
20+
In order to get the build system to recognize Android resources, set the build action to
21+
"AndroidResource". The native Android APIs do not operate directly with filenames, but
22+
instead operate on resource IDs. When you compile an Android application that uses resources,
23+
the build system will package the resources for distribution and generate a class called "R"
24+
(this is an Android convention) that contains the tokens for each one of the resources
25+
included. For example, for the above Resources layout, this is what the R class would expose:
26+
27+
public class R {
28+
public class drawable {
29+
public const int icon = 0x123;
30+
}
31+
32+
public class layout {
33+
public const int main = 0x456;
34+
}
35+
36+
public class strings {
37+
public const int first_string = 0xabc;
38+
public const int second_string = 0xbcd;
39+
}
40+
}
41+
42+
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43+
to reference the layout/main.axml file, or R.strings.first_string to reference the first
44+
string in the dictionary file values/strings.xml.

0 commit comments

Comments
 (0)