Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ run-ji-tests:
TEST_APK_PROJECTS = \
src/Mono.Android/Test/Mono.Android-Tests.csproj \
tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj \
tests/locales/Xamarin.Android.Locale-Tests/Xamarin.Android.Locale-Tests.csproj
tests/locales/Xamarin.Android.Locale-Tests/Xamarin.Android.Locale-Tests.csproj \
tests/Xamarin.Android.Bcl-Tests/Xamarin.Android.Bcl-Tests.csproj

TEST_APK_PROJECTS_RELEASE = \
src/Mono.Android/Test/Mono.Android-Tests.csproj \
Expand Down
14 changes: 10 additions & 4 deletions Xamarin.Android-Tests.sln
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Xamarin.Forms.Performance.I
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Forms.Performance.Integration.Droid", "tests\Xamarin.Forms-Performance-Integration\Droid\Xamarin.Forms.Performance.Integration.Droid.csproj", "{576312CC-83FF-48B1-A473-488CDC7121AD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Bcl-Tests", "tests\Xamarin.Android.Bcl-Tests\Xamarin.Android.Bcl-Tests.csproj", "{E865C28E-32AF-4210-A41D-5791C39A9D85}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -119,10 +121,14 @@ Global
{B297008B-C313-455E-B230-E119589D2D79}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B297008B-C313-455E-B230-E119589D2D79}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B297008B-C313-455E-B230-E119589D2D79}.Release|Any CPU.Build.0 = Release|Any CPU
{576312CC-83FF-48B1-A473-488CDC7121AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{576312CC-83FF-48B1-A473-488CDC7121AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{576312CC-83FF-48B1-A473-488CDC7121AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{576312CC-83FF-48B1-A473-488CDC7121AD}.Release|Any CPU.Build.0 = Release|Any CPU
{576312CC-83FF-48B1-A473-488CDC7121AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{576312CC-83FF-48B1-A473-488CDC7121AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{576312CC-83FF-48B1-A473-488CDC7121AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{576312CC-83FF-48B1-A473-488CDC7121AD}.Release|Any CPU.Build.0 = Release|Any CPU
{E865C28E-32AF-4210-A41D-5791C39A9D85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E865C28E-32AF-4210-A41D-5791C39A9D85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E865C28E-32AF-4210-A41D-5791C39A9D85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E865C28E-32AF-4210-A41D-5791C39A9D85}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2305B00D-DE81-4744-B0DA-357835CAFE5A} = {43A4FB09-279A-4138-8027-EC1E1CED2E8A}
Expand Down
1 change: 1 addition & 0 deletions build-tools/bundle/bundle-path.targets
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<!-- Files which contribute to the bundle "version" -->
<ItemGroup>
<VersionFile Include="..\mono-runtimes\mono-runtimes.*" />
<VersionFile Include="..\mono-runtimes\ProfileAssemblies.projitems" />
<VersionFile Include="..\scripts\BuildEverything.mk" />
</ItemGroup>
<HashFileContents
Expand Down
68 changes: 68 additions & 0 deletions build-tools/mono-runtimes/ProfileAssemblies.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,72 @@
<MonoProfileAssembly Include="System.Xml.Linq.dll" />
<MonoProfileAssembly Include="System.Xml.Serialization.dll" />
</ItemGroup>
<ItemGroup>
<MonoTestAssembly Include="monodroid_corlib_test.dll">
<SourcePath>corlib</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_I18N.CJK_test.dll">
<SourcePath>I18N/CJK</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_I18N.MidEast_test.dll">
<SourcePath>I18N/MidEast</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_I18N.West_test.dll">
<SourcePath>I18N/West</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_Mono.CSharp_test.dll">
<SourcePath>Mono.CSharp</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_Mono.Data.Sqlite_test.dll">
<SourcePath>Mono.Data.Sqlite</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_Mono.Data.Tds_test.dll">
<SourcePath>Mono.Data.Tds</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_Mono.Security_test.dll">
<SourcePath>Mono.Security</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System_test.dll">
<SourcePath>System</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System.Core_test.dll">
<SourcePath>System.Core</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System.Data_test.dll">
<SourcePath>System.Data</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System.IO.Compression.FileSystem_test.dll">
<SourcePath>System.IO.Compression.FileSystem</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System.IO.Compression_test.dll">
<SourcePath>System.IO.Compression</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System.Json_test.dll">
<SourcePath>System.Json</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System.Net.Http_test.dll">
<SourcePath>System.Net.Http</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System.Numerics_test.dll">
<SourcePath>System.Numerics</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System.Runtime.Serialization_test.dll">
<SourcePath>System.Runtime.Serialization</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System.ServiceModel.Web_test.dll">
<SourcePath>System.ServiceModel.Web</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System.Transactions_test.dll">
<SourcePath>System.Transactions</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System.Xml_test.dll">
<SourcePath>System.XML</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="monodroid_System.Xml.Linq_test.dll">
<SourcePath>System.Xml.Linq</SourcePath>
</MonoTestAssembly>
<MonoTestAssembly Include="nunitlite.dll">
<SourcePath>lib/monodroid</SourcePath>
</MonoTestAssembly>
</ItemGroup>
</Project>
56 changes: 55 additions & 1 deletion build-tools/mono-runtimes/mono-runtimes.targets
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@
<_BclAssembly Include="@(MonoProfileAssembly)" />
<_BclExcludeDebugSymbols Include="System.Windows.dll" />
<_BclExcludeDebugSymbols Include="System.Xml.Serialization.dll" />
<_BclTestAssemblySource Include="@(MonoTestAssembly->'$(MonoSourceFullPath)\mcs\class\%(SourcePath)\%(Identity)')" />
<_BclTestAssemblySource Include="@(MonoTestAssembly->'$(MonoSourceFullPath)\mcs\class\%(SourcePath)\%(Filename).pdb')" />
<_BclTestAssemblyDestination Include="@(MonoTestAssembly->'$(XAInstallPrefix)\..\..\bcl-tests\%(Identity)')" />
<_BclTestAssemblyDestination Include="@(MonoTestAssembly->'$(XAInstallPrefix)\..\..\bcl-tests\%(Filename).pdb')" />
</ItemGroup>
<ItemGroup>
<_BclTestOutput Include="@(_BclTestAssemblyDestination)" />
<_BclTestOutput Include="$(XAInstallPrefix)\..\..\bcl-tests\bcl-tests.zip" />
</ItemGroup>
<ItemGroup>
<_BclProfileItems Include="@(_BclAssembly->'$(_MonoProfileDir)\%(Identity)')" />
Expand Down Expand Up @@ -286,7 +294,7 @@
<Target Name="_BuildRuntimes"
DependsOnTargets="_GetRuntimesOutputItems;_ConfigureRuntimes"
Inputs="@(_RuntimeBuildStamp)"
Outputs="@(_RuntimeSource);@(_ProfilerSource);@(_MonoPosixHelperSource);@(_BclProfileItems);@(_MonoBtlsSource)">
Outputs="@(_RuntimeSource);@(_ProfilerSource);@(_MonoPosixHelperSource);@(_BclProfileItems);@(_MonoBtlsSource);@(_BclTestOutput)">
<Exec
Condition=" '%(_MonoRuntime.DoBuild)' == 'true' "
Command="make $(MakeConcurrency) # %(_MonoRuntime.Identity)"
Expand All @@ -296,6 +304,51 @@
<Touch
Files="@(_RuntimeSource);@(_ProfilerSource);@(_MonoPosixHelperSource);@(_BclProfileItems);@(_MonoBtlsSource)"
/>
<Exec
Command="make $(MakeConcurrency) -i test # %(_MonoRuntime.Identity)"
IgnoreStandardErrorWarningFormat="True"
WorkingDirectory="$(IntermediateOutputPath)\%(_MonoRuntime.Identity)\runtime"
/>
<Copy
SourceFiles="@(_BclTestAssemblySource)"
DestinationFiles="@(_BclTestAssemblyDestination)"
/>
<Touch
Files="@(_BclTestAssemblyDestination)"
/>
<ItemGroup>
<_BclTestContent Include="$(MonoSourceFullPath)\mcs\class\%(MonoTestAssembly.SourcePath)\Test\**\*.*" />
<_BclTestContent Remove="$(MonoSourceFullPath)\mcs\class\%(MonoTestAssembly.SourcePath)\Test\**\*.cs" />
<_BclTestContent Remove="$(MonoSourceFullPath)\mcs\class\%(MonoTestAssembly.SourcePath)\Test\**\.gitattributes" />
<_BclTestContentDest Include="@(_BclTestContent->'$(XAInstallPrefix)\..\..\bcl-tests\Test\%(RecursiveDir)%(Filename)%(Extension)')" />
</ItemGroup>
<ItemGroup>
<_BclTestContent Include="$(MonoSourceFullPath)\mcs\class\System.IO.Compression\test.nupkg" />
<_BclTestContentDest Include="$(XAInstallPrefix)\..\..\bcl-tests\test.nupkg" />
<_BclTestContent Include="$(MonoSourceFullPath)\mcs\class\System.IO.Compression\archive.zip" />
<_BclTestContentDest Include="$(XAInstallPrefix)\..\..\bcl-tests\archive.zip" />
</ItemGroup>
<ItemGroup>
<_ZipTestContent Include="$(MonoSourceFullPath)\mcs\class\System.IO.Compression.FileSystem\foo\**\*.*" />
<_ZipTestContentDest Include="@(_ZipTestContent->'$(XAInstallPrefix)\..\..\bcl-tests\foo\%(RecursiveDir)%(Filename)%(Extension)')" />
<_BclTestContent Include="@(_ZipTestContent)" />
<_BclTestContentDest Include="@(_ZipTestContentDest)" />
</ItemGroup>
<Copy
SourceFiles="@(_BclTestContent)"
DestinationFiles="@(_BclTestContentDest)"
/>
<Exec
Condition="!Exists('$(XAInstallPrefix)\..\..\bcl-tests\Test\test.db')"
Command="sqlite3 &quot;$(XAInstallPrefix)\..\..\bcl-tests\Test\test.db&quot; &lt; &quot;$(MonoSourceFullPath)\mcs\class\Mono.Data.Sqlite\Test\test.sql&quot;"
/>
<Exec
Command="zip -r bcl-tests.zip ."
WorkingDirectory="$(XAInstallPrefix)\..\..\bcl-tests"
/>
<Touch
Files="$(XAInstallPrefix)\..\..\bcl-tests\bcl-tests.zip"
/>
</Target>
<Target Name="_InstallRuntimes"
DependsOnTargets="_GetRuntimesOutputItems"
Expand Down Expand Up @@ -577,6 +630,7 @@
<BundleItem Include="$(_MSBuildDir)\%(_MonoCrossRuntime.InstallPath)%(_MonoCrossRuntime.CrossMonoName)%(_MonoCrossRuntime.ExeSuffix)"
Condition=" '@(_MonoCrossRuntime)' != '' "
/>
<BundleItem Include="@(_BclTestOutput)" />
</ItemGroup>
</Target>
<Target Name="ForceBuild"
Expand Down
13 changes: 13 additions & 0 deletions src/Xamarin.Android.NUnitLite/Gui/Activities/TestSuiteActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ protected bool GCAfterEachFixture {
set { AndroidRunner.Runner.GCAfterEachFixture = value; }
}

protected ITestFilter Filter {
get { return AndroidRunner.Runner.Filter; }
set { AndroidRunner.Runner.Filter = value; }
}

protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
Expand All @@ -49,6 +54,8 @@ protected override void OnCreate (Bundle bundle)
}
AndroidRunner.Runner.AddTestFilters (GetIncludedCategories (), GetExcludedCategories ());

UpdateFilter ();

FindViewById<TextView> (Resource.Id.RunTestsButton).Click += (o, e) => {
AndroidRunner.Runner.Run (current_test, this);
UpdateData (data, lv);
Expand Down Expand Up @@ -104,6 +111,12 @@ protected override void OnResume ()
return null;
}

// Subclasses can override this method to update the test filtering that the runner will use.
// Subclasses should set the `Filter` property to their new filter value
protected virtual void UpdateFilter ()
{
}

public void AddTest (Assembly assembly)
{
AndroidRunner.Runner.AddTest (assembly);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Android.Util;

using NUnitLite.Runner;
using NUnit.Framework.Api;
using NUnit.Framework.Internal;

namespace Xamarin.Android.NUnitLite {
Expand All @@ -22,6 +23,11 @@ protected bool GCAfterEachFixture {
set { AndroidRunner.Runner.GCAfterEachFixture = value; }
}

protected ITestFilter Filter {
get { return AndroidRunner.Runner.Filter; }
set { AndroidRunner.Runner.Filter = value; }
}

protected TestSuiteInstrumentation (IntPtr handle, JniHandleOwnership transfer)
: base (handle, transfer)
{
Expand All @@ -45,6 +51,8 @@ public override void OnStart ()
AndroidRunner.Runner.Options.LoadFromBundle (arguments);
AndroidRunner.Runner.AddTestFilters (GetIncludedCategories (), GetExcludedCategories ());

UpdateFilter ();

AndroidRunner.Runner.Initialized = true;
var results = new Bundle ();
int failed = 0;
Expand Down Expand Up @@ -145,5 +153,9 @@ protected void AddTest (Assembly assembly)
{
return null;
}

protected virtual void UpdateFilter ()
{
}
}
}
1 change: 1 addition & 0 deletions tests/RunApkTests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
in the toplevel Makefile so that the `.apk` is built.
-->
<Import Project="..\src\Mono.Android\Test\Mono.Android-Tests.projitems" />
<Import Project="..\tests\Xamarin.Android.Bcl-Tests\Xamarin.Android.Bcl-Tests.projitems" />
<Import Project="..\tests\CodeGen-Binding\Xamarin.Android.JcwGen-Tests\Xamarin.Android.JcwGen-Tests.projitems" Condition=" '$(Configuration)' == 'Debug' " />
<Import Project="..\tests\locales\Xamarin.Android.Locale-Tests\Xamarin.Android.Locale-Tests.projitems" Condition=" '$(Configuration)' == 'Debug' " />
<Import Project="..\tests\Xamarin.Forms-Performance-Integration\Droid\Xamarin.Forms.Performance.Integration.Droid.projitems" Condition=" '$(Configuration)' == 'Release' And '$(AotAssemblies)' != 'true' " />
Expand Down
83 changes: 83 additions & 0 deletions tests/Xamarin.Android.Bcl-Tests/App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;

using NUnit.Framework.Api;
using NUnit.Framework.Internal.Filters;

namespace Xamarin.Android.BclTests
{
static partial class App
{
internal static string[] ExcludeAssemblyNames = {
// Not needed; distributed only for "sanity"/consistency
"nunitlite.dll",
};

internal static IEnumerable<Assembly> GetTestAssemblies ()
{
yield return typeof (App).Assembly;

var names = TestAssemblyNames.Except (ExcludeAssemblyNames);
foreach (var name in names) {
var a = Assembly.Load (name);
if (a == null) {
Console.WriteLine ($"# WARNING: Unable to load assembly: {name}");
continue;
}
yield return a;
}
}

internal static IEnumerable<string> GetExcludedCategories ()
{
var excluded = new List<string> {
"AndroidNotWorking",
"CAS",
"InetAccess",
"MobileNotWorking",
"NotWorking",
};

if (!System.Environment.Is64BitOperatingSystem) {
excluded.Add ("LargeFileSupport");
}

return excluded;
}

internal static void ExtractBclTestFiles ()
{
var cachePath = global::Android.App.Application.Context.CacheDir.AbsolutePath;
if (Directory.Exists (Path.Combine (cachePath, "Test")))
return;

using (var files = typeof (App).Assembly.GetManifestResourceStream ("bcl-tests.zip"))
using (var zip = new ZipArchive (files, ZipArchiveMode.Read)) {
zip.ExtractToDirectory (cachePath);
}
}

static string[] ExcludeTestNames = new string[]{
// https://jenkins.mono-project.com/job/xamarin-android-pr-builder/1720/testReport/(root)/AssemblyTest/GetReferencedAssemblies/
// https://bugzilla.xamarin.com/show_bug.cgi?id=59908
// AssemblyName.Flags == AssemblyNameFlags.PublicKey; expected AssemblyNameFlags.None
"MonoTests.System.Reflection.AssemblyTest.GetReferencedAssemblies",
// https://jenkins.mono-project.com/job/xamarin-android-pr-builder/1720/testReport/(root)/WebInvokeAttributeTest/RejectTwoParametersWhenNotWrapped/
// https://bugzilla.xamarin.com/show_bug.cgi?id=59909
// InvalidOperationException wasn't thrown when it was expected
"MonoTests.System.ServiceModel.Description.WebInvokeAttributeTest.RejectTwoParametersWhenNotWrapped",
};

internal static ITestFilter UpdateFilter (ITestFilter filter)
{
if (ExcludeTestNames?.Length == 0)
return filter;
var excludeTestNamesFilter = new SimpleNameFilter (ExcludeTestNames);
return new AndFilter (filter, new NotFilter (excludeTestNamesFilter));
}
}
}
7 changes: 7 additions & 0 deletions tests/Xamarin.Android.Bcl-Tests/App.cs.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Xamarin.Android.BclTests {
partial class App {
public static string[] TestAssemblyNames = {
@ASSEMBLIES@
};
}
}
19 changes: 19 additions & 0 deletions tests/Xamarin.Android.Bcl-Tests/Assets/AboutAssets.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Any raw assets you want to be deployed with your application can be placed in
this directory (and child directories) and given a Build Action of "AndroidAsset".

These files will be deployed with your package and will be accessible using Android's
AssetManager, like this:

public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

InputStream input = Assets.Open ("my_asset.txt");
}
}

Additionally, some Android functions will automatically load asset files:

Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
Loading