[Xamarin.Android.Bcl-Tests] Add BCL test project. (#872)

What do we want? (with apologies to 48e3fc26)
**MOAR** Unit tests!

Specifically, we want to run the BCL unit tests which mono generates:

	$ cd external/mono/mcs/class/corlib
	$ make PROFILE=monodroid test
	# creates `monodroid_corlib_test.dll`

Creation of `monodroid_*_test.dll` assemblies and the
`make PROFILE=monodroid test` target is a relatively recent
development, for which I need to buy the #runtime team some beers.

In terms of `mono-runtimes.targets`, we can build *all* of the BCL
unit test assemblies with:

	$ cd external/mono/mcs/class
	$ make -i do-test PROFILE=monodroid

Now that we can create them, how do we *use* them? That's the trickier
bit: they need to be built within mono, as part of the existing BCL
build process. This in turn means that the BCL unit test assemblies
need to be distributed as part of the mono bundle, as we don't want to
rebuild the mono repo "from scratch" just for the unit tests.

Update `build-tools/mono-runtimes/ProfileAssemblies.projitems` to
include a new `@(MonoTestAssembly)` item group which contains all of
the BCL unit test assemblies and related files which should be
included into `bundle-*.zip`. Additionally, add
`ProfileAssemblies.projitems` to `@(VersionFile)` witihin
`bundle-path.targets`, so that if anything within
`ProfileAssemblies.projitems` changes, we rebuild the bundle.

Once we *have* the BCL unit test assemblies, and their dependencies,
we need to *run* them. The new `Xamarin.Android.Bcl-Tests.csproj`
project is a Xamarin.Android application project which will execute
the unit tests.

There's just one small problem: Xamarin.Android apps want to use
`Xamarin.Android.NUnitLite.dll`. The BCL unit test assemblies instead
build against their own `nunitlite.dll`, which has no Xamarin.Android
integration or support. How do we use the new test assemblies?

*Force* a fix by using `remap-assembly-ref` to "rename" the
`nunitlite` assembly reference to `Xamarin.Android.NUnitLite.dll`.
This *cannot* be done as part of the `mono-runtimes.mdproj` build, as
`Xamarin.Android.NUnitLite.dll` won't yet exist. Instead, remap the
assemblies within `Xamarin.Android.Bcl-Tests.targets`, and distribute
the remapped assemblies with the application.

Finally, address one other "small" problem: not all of the unit tests
pass! Some of these are for reasons we don't know, and others will
require changes to `mono`.

Update `Xamarin.Android.NUnitLite` to allow *filtering* of tests:

	namespace Xamarin.Android.NUnitLite {

	  partial class TestSuiteActivity {
	    public  ITestFilter   Filter          {get; set;}

	    public  virtual void  UpdateFilter ();
	  }

	  partial class TestSuiteInstrumentation {
	    public  ITestFilter   Filter          {get; set;}

	    public  virtual void  UpdateFilter ();
	  }
	}

`TestSuiteActivity.UpdateFilter()` is called by
`TestSuiteActivity.OnCreate()`, *after* `GetIncludedCategories()` and
`GetExcludedCategories()` are called, to allow subclasses to alter the
`ITestFilter` which is used to determine which tests are executed.

`TestSuiteInstrumentation.UpdateFilter()` is called by
`TestSuiteInstrumentation.OnStart()`, *after*
`GetIncludedCategories()` and `GetExcludedCategories()` are called, to
allow subclasses to alter the `ITestFilter` which is used to determine
which tests are executed.

`Xamarin.Android.Bcl_Tests` overrides both of these and updates the
`Filter` property so that "known failing" tests are excluded. This
allows us to skip failing tests, giving us time to properly fix them
in time while allowing the rest of this PR to be merged.

The skipped tests include:

  * MonoTests.System.Reflection.AssemblyTest.GetReferencedAssemblies
  * MonoTests.System.ServiceModel.Description.WebInvokeAttributeTest.RejectTwoParametersWhenNotWrapped
This commit is contained in:
Jonathan Pryor 2017-10-03 15:48:08 -04:00 коммит произвёл Marek Habersack
Родитель daa05732d3
Коммит e9daf5ea35
29 изменённых файлов: 700 добавлений и 6 удалений

Просмотреть файл

@ -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 \

Просмотреть файл

@ -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
@ -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}

Просмотреть файл

@ -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

Просмотреть файл

@ -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>

Просмотреть файл

@ -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)')" />
@ -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)"
@ -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"
@ -577,6 +630,7 @@
<BundleItem Include="$(_MSBuildDir)\%(_MonoCrossRuntime.InstallPath)%(_MonoCrossRuntime.CrossMonoName)%(_MonoCrossRuntime.ExeSuffix)"
Condition=" '@(_MonoCrossRuntime)' != '' "
/>
<BundleItem Include="@(_BclTestOutput)" />
</ItemGroup>
</Target>
<Target Name="ForceBuild"

Просмотреть файл

@ -32,6 +32,11 @@ namespace Xamarin.Android.NUnitLite
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);
@ -49,6 +54,8 @@ namespace Xamarin.Android.NUnitLite
}
AndroidRunner.Runner.AddTestFilters (GetIncludedCategories (), GetExcludedCategories ());
UpdateFilter ();
FindViewById<TextView> (Resource.Id.RunTestsButton).Click += (o, e) => {
AndroidRunner.Runner.Run (current_test, this);
UpdateData (data, lv);
@ -104,6 +111,12 @@ namespace Xamarin.Android.NUnitLite
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);

Просмотреть файл

@ -10,6 +10,7 @@ using Android.Runtime;
using Android.Util;
using NUnitLite.Runner;
using NUnit.Framework.Api;
using NUnit.Framework.Internal;
namespace Xamarin.Android.NUnitLite {
@ -22,6 +23,11 @@ namespace Xamarin.Android.NUnitLite {
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)
{
@ -45,6 +51,8 @@ namespace Xamarin.Android.NUnitLite {
AndroidRunner.Runner.Options.LoadFromBundle (arguments);
AndroidRunner.Runner.AddTestFilters (GetIncludedCategories (), GetExcludedCategories ());
UpdateFilter ();
AndroidRunner.Runner.Initialized = true;
var results = new Bundle ();
int failed = 0;
@ -145,5 +153,9 @@ namespace Xamarin.Android.NUnitLite {
{
return null;
}
protected virtual void UpdateFilter ()
{
}
}
}

Просмотреть файл

@ -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' " />

Просмотреть файл

@ -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));
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
namespace Xamarin.Android.BclTests {
partial class App {
public static string[] TestAssemblyNames = {
@ASSEMBLIES@
};
}
}

Просмотреть файл

@ -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");

Просмотреть файл

@ -0,0 +1,4 @@
debug.mono.debug=1
MONO_LOG_LEVEL=debug
MONO_LOG_MASK=asm
MONO_XDEBUG=1

Просмотреть файл

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using Android.App;
using Android.Widget;
using Android.OS;
using Xamarin.Android.NUnitLite;
namespace Xamarin.Android.BclTests
{
[Activity (
Label = "Xamarin.Android BCL Tests",
MainLauncher = true,
Name = "xamarin.android.bcltests.MainActivity")]
public class MainActivity : TestSuiteActivity
{
public MainActivity ()
{
GCAfterEachFixture = true;
}
protected override void OnCreate (Bundle bundle)
{
App.ExtractBclTestFiles ();
foreach (var tests in App.GetTestAssemblies ()) {
AddTest (tests);
}
// Once you called base.OnCreate(), you cannot add more assemblies.
base.OnCreate (bundle);
}
protected override IEnumerable<string> GetExcludedCategories ()
{
return App.GetExcludedCategories ();
}
protected override void UpdateFilter ()
{
Filter = App.UpdateFilter (Filter);
}
}
}

Просмотреть файл

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="Xamarin.Android.Bcl_Tests">
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SET_TIME" />
<uses-permission android:name="android.permission.SET_TIME_ZONE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:allowBackup="true" android:icon="@mipmap/icon" android:label="@string/app_name">
</application>
</manifest>

Просмотреть файл

@ -0,0 +1,27 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using Android.App;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle ("BCL")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("Microsoft Corporation")]
[assembly: AssemblyProduct ("")]
[assembly: AssemblyCopyright ("")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

Просмотреть файл

@ -0,0 +1,44 @@
Images, layout descriptions, binary blobs and string dictionaries can be included
in your application as resource files. Various Android APIs are designed to
operate on the resource IDs instead of dealing with images, strings or binary blobs
directly.
For example, a sample Android app that contains a user interface layout (main.axml),
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
would keep its resources in the "Resources" directory of the application:
Resources/
drawable/
icon.png
layout/
main.axml
values/
strings.xml
In order to get the build system to recognize Android resources, set the build action to
"AndroidResource". The native Android APIs do not operate directly with filenames, but
instead operate on resource IDs. When you compile an Android application that uses resources,
the build system will package the resources for distribution and generate a class called "R"
(this is an Android convention) that contains the tokens for each one of the resources
included. For example, for the above Resources layout, this is what the R class would expose:
public class R {
public class drawable {
public const int icon = 0x123;
}
public class layout {
public const int main = 0x456;
}
public class strings {
public const int first_string = 0xabc;
public const int second_string = 0xbcd;
}
}
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
to reference the layout/main.axml file, or R.strings.first_string to reference the first
string in the dictionary file values/strings.xml.

Просмотреть файл

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
<Button android:id="@+id/myButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hello" />
</LinearLayout>

Двоичные данные
tests/Xamarin.Android.Bcl-Tests/Resources/mipmap-hdpi/Icon.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.1 KiB

Двоичные данные
tests/Xamarin.Android.Bcl-Tests/Resources/mipmap-mdpi/Icon.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичные данные
tests/Xamarin.Android.Bcl-Tests/Resources/mipmap-xhdpi/Icon.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 3.2 KiB

Двоичные данные
tests/Xamarin.Android.Bcl-Tests/Resources/mipmap-xxhdpi/Icon.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 5.3 KiB

Двоичные данные
tests/Xamarin.Android.Bcl-Tests/Resources/mipmap-xxxhdpi/Icon.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.6 KiB

Просмотреть файл

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, Click Me!</string>
<string name="app_name">Bcl-Tests</string>
</resources>

Просмотреть файл

@ -0,0 +1,30 @@
using System;
using System.Net;
using System.Net.Http;
using NUnit.Framework;
namespace BclTests {
[TestFixture]
public class HttpClientTest
{
[Test] // Covers #26896
public void TestUnescapedURI ()
{
try
{
HttpClient client = new HttpClient();
var t = client.GetStringAsync("http://naver.com/t[e]st.txt");
t.Wait(1000);
Assert.IsNotNull(t.Result);
}
catch (AggregateException e)
{
Assert.AreEqual (1, e.InnerExceptions.Count);
Assert.AreEqual (typeof(HttpRequestException), e.InnerExceptions[0].GetType ());
}
}
}
}

Просмотреть файл

@ -0,0 +1,23 @@
using System;
using System.Net;
using System.Net.NetworkInformation;
using NUnit.Framework;
namespace BclTests {
[TestFixture]
public class NetworkChangeTest
{
[Test]
public void NetworkAvailabilityChanged ()
{
NetworkAvailabilityChangedEventHandler h = (o, e) => {
Console.WriteLine ("NetworkAvailabilityChanged called");
};
NetworkChange.NetworkAvailabilityChanged += h;
NetworkChange.NetworkAvailabilityChanged -= h;
}
}
}

Просмотреть файл

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using Android.App;
using Android.Content;
using Android.Runtime;
using Xamarin.Android.NUnitLite;
namespace Xamarin.Android.BclTests {
[Instrumentation (Name="xamarin.android.bcltests.TestInstrumentation")]
public class TestInstrumentation : TestSuiteInstrumentation {
public TestInstrumentation (IntPtr handle, JniHandleOwnership transfer)
: base (handle, transfer)
{
GCAfterEachFixture = true;
}
protected override void AddTests ()
{
App.ExtractBclTestFiles ();
foreach (var tests in App.GetTestAssemblies ()) {
AddTest (tests);
}
}
protected override IEnumerable<string> GetExcludedCategories ()
{
return App.GetExcludedCategories ();
}
protected override void UpdateFilter ()
{
Filter = App.UpdateFilter (Filter);
}
}
}

Просмотреть файл

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E865C28E-32AF-4210-A41D-5791C39A9D85}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>Xamarin.Android.BclTests</RootNamespace>
<AssemblyName>Xamarin.Android.Bcl_Tests</AssemblyName>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<MandroidI18n>All</MandroidI18n>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<PropertyGroup>
<TargetFrameworkVersion>$(AndroidFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\TestDebug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\TestRelease</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Mono.Android" />
<Reference Include="Mono.Data.Sqlite" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Xml" />
<Reference Include="System.Net.Http" />
<Reference Include="Xamarin.Android.NUnitLite" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.cs" />
<Compile Include="MainActivity.cs" />
<Compile Include="TestInstrumentation.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="System.Net\NetworkChangeTest.cs" />
<Compile Include="System.Net.Http\HttpClientTest.cs" />
<Compile Include="$(IntermediateOutputPath)\App.cs" Condition=" Exists('$(IntermediateOutputPath)\App.cs') "/>
</ItemGroup>
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
<None Include="Properties\AndroidManifest.xml" />
<None Include="Assets\AboutAssets.txt" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\..\bin\$(Configuration)\bcl-tests\Test\resources\Resources.resx">
<LogicalName>Resources.resources</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="..\..\bin\$(Configuration)\bcl-tests\bcl-tests.zip">
<LogicalName>bcl-tests.zip</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<AndroidEnvironment Include="Environment.txt" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\Main.axml" />
<AndroidResource Include="Resources\values\Strings.xml" />
<AndroidResource Include="Resources\mipmap-hdpi\Icon.png" />
<AndroidResource Include="Resources\mipmap-mdpi\Icon.png" />
<AndroidResource Include="Resources\mipmap-xhdpi\Icon.png" />
<AndroidResource Include="Resources\mipmap-xxhdpi\Icon.png" />
<AndroidResource Include="Resources\mipmap-xxxhdpi\Icon.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Import Project="Xamarin.Android.Bcl-Tests.targets" />
<PropertyGroup>
<BuildDependsOn>
_GenerateApp_cs;
$(BuildDependsOn)
</BuildDependsOn>
</PropertyGroup>
</Project>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<TestApk Include="$(OutputPath)Xamarin.Android.Bcl_Tests-Signed.apk">
<Package>Xamarin.Android.Bcl_Tests</Package>
<InstrumentationType>xamarin.android.bcltests.TestInstrumentation</InstrumentationType>
<ResultsPath>$(MSBuildThisFileDirectory)..\..\TestResult-Xamarin.Android.Bcl_Tests.xml</ResultsPath>
<TimingDefinitionsFilename>$(MSBuildThisFileDirectory)..\..\build-tools\scripts\TimingDefinitions.txt</TimingDefinitionsFilename>
</TestApk>
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.ReplaceFileContents" />
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.SystemUnzip" />
<Import Project="Xamarin.Android.Bcl-Tests.projitems" />
<Import Project="..\..\build-tools\scripts\TestApks.targets" />
<Import Project="..\..\build-tools\mono-runtimes\ProfileAssemblies.projitems" />
<Target Name="_AddTestAssemblies"
DependsOnTargets="_RemapAssemblies"
BeforeTargets="ResolveAssemblyReferences">
<ItemGroup>
<Reference Include="@(MonoTestAssembly->'$(IntermediateOutputPath)%(Identity)')" />
<Reference Remove="$(IntermediateOutputPath)nunitlite.dll" />
</ItemGroup>
</Target>
<Target Name="_RemapAssemblies"
Inputs="@(MonoTestAssembly->'..\..\bin\$(Configuration)\bcl-tests\%(Identity)')"
Outputs="@(MonoTestAssembly->'$(IntermediateOutputPath)%(Identity)')">
<MakeDir Directories="$(IntermediateOutputPath)" />
<ItemGroup>
<_Source Include="@(MonoTestAssembly->'..\..\bin\$(Configuration)\bcl-tests\%(Identity)')" />
</ItemGroup>
<PropertyGroup>
<_NUnit>$(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\Xamarin.Android.NUnitLite.dll</_NUnit>
</PropertyGroup>
<Exec
Command="$(RemapAssemblyRefTool) &quot;%(_Source.Identity)&quot; &quot;$(IntermediateOutputPath)%(_Source.Filename)%(_Source.Extension)&quot; nunitlite &quot;$(_NUnit)&quot;"
/>
<Copy
SourceFiles="..\..\bin\$(Configuration)\bcl-tests\%(MonoTestAssembly.Filename).pdb"
DestinationFolder="$(IntermediateOutputPath)"
/>
</Target>
<ItemGroup>
<_TestResource Include="..\..\bin\$(Configuration)\bcl-tests\Test\resources\Resources.es-ES.resources">
<Culture>es-ES</Culture>
<Name>monodroid_corlib_test.resources.dll</Name>
</_TestResource>
<_TestResource Include="..\..\bin\$(Configuration)\bcl-tests\Test\resources\Resources.nn-NO.resources">
<Culture>nn-NO</Culture>
<Name>monodroid_corlib_test.resources.dll</Name>
</_TestResource>
</ItemGroup>
<Target Name="_CreateTestResources"
BeforeTargets="ResolveAssemblyReferences"
DependsOnTargets="_ExtractTestResources"
Inputs="@(_TestResource)"
Outputs="$(IntermediateOutputPath)%(_TestResource.Culture)\%(_TestResource.Name)">
<MakeDir Directories="$(IntermediateOutputPath)%(_TestResource.Culture)" />
<AL
OutputAssembly="$(IntermediateOutputPath)%(Culture)\%(Name)"
Version="1.0.0.0"
Culture="%(Culture)"
EmbedResources="@(_TestResource)"
/>
</Target>
<Target Name="_ExtractTestResources"
Inputs="..\..\bin\$(Configuration)\bcl-tests\bcl-tests.zip"
Outputs="@(_TestResource)">
<SystemUnzip
SourceFiles="..\..\bin\$(Configuration)\bcl-tests\bcl-tests.zip"
HostOS="$(HostOS)"
DestinationFolder="..\..\bin\$(Configuration)\bcl-tests"
/>
</Target>
<Target Name="_GenerateApp_cs"
Inputs="@(MonoTestAssembly->'..\..\bin\$(Configuration)\bcl-tests\%(Identity)')"
Outputs="$(IntermediateOutputPath)\App.cs">
<MakeDir Directories="$(IntermediateOutputPath)" />
<ItemGroup>
<Compile Include="$(IntermediateOutputPath)\App.cs" />
</ItemGroup>
<PropertyGroup>
<_Assemblies>@(MonoTestAssembly->'"%(Identity)"', ', ')</_Assemblies>
</PropertyGroup>
<ReplaceFileContents
SourceFile="App.cs.in"
DestinationFile="$(IntermediateOutputPath)App.cs"
Replacements="@ASSEMBLIES@=$(_Assemblies)"
/>
</Target>
</Project>