From 81b62e948b597ef78fec4cb3277be31cb9378272 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 14 Sep 2017 14:36:02 -0400 Subject: [PATCH] [Xamarin.Android.Bcl-Tests] Add BCL test project. 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 --- Makefile | 3 +- Xamarin.Android-Tests.sln | 14 ++- build-tools/bundle/bundle-path.targets | 1 + .../mono-runtimes/ProfileAssemblies.projitems | 68 ++++++++++++ .../mono-runtimes/mono-runtimes.targets | 56 +++++++++- .../Gui/Activities/TestSuiteActivity.cs | 13 +++ .../TestSuiteInstrumentation.cs | 12 +++ tests/RunApkTests.targets | 1 + tests/Xamarin.Android.Bcl-Tests/App.cs | 83 +++++++++++++++ tests/Xamarin.Android.Bcl-Tests/App.cs.in | 7 ++ .../Assets/AboutAssets.txt | 19 ++++ .../Xamarin.Android.Bcl-Tests/Environment.txt | 4 + .../Xamarin.Android.Bcl-Tests/MainActivity.cs | 46 ++++++++ .../Properties/AndroidManifest.xml | 12 +++ .../Properties/AssemblyInfo.cs | 27 +++++ .../Resources/AboutResources.txt | 44 ++++++++ .../Resources/layout/Main.axml | 4 + .../Resources/mipmap-hdpi/Icon.png | Bin 0 -> 2201 bytes .../Resources/mipmap-mdpi/Icon.png | Bin 0 -> 1410 bytes .../Resources/mipmap-xhdpi/Icon.png | Bin 0 -> 3237 bytes .../Resources/mipmap-xxhdpi/Icon.png | Bin 0 -> 5414 bytes .../Resources/mipmap-xxxhdpi/Icon.png | Bin 0 -> 7825 bytes .../Resources/values/Strings.xml | 5 + .../System.Net.Http/HttpClientTest.cs | 30 ++++++ .../System.Net/NetworkChangeTest.cs | 23 ++++ .../TestInstrumentation.cs | 41 +++++++ .../Xamarin.Android.Bcl-Tests.csproj | 100 ++++++++++++++++++ .../Xamarin.Android.Bcl-Tests.projitems | 11 ++ .../Xamarin.Android.Bcl-Tests.targets | 82 ++++++++++++++ 29 files changed, 700 insertions(+), 6 deletions(-) create mode 100644 tests/Xamarin.Android.Bcl-Tests/App.cs create mode 100644 tests/Xamarin.Android.Bcl-Tests/App.cs.in create mode 100644 tests/Xamarin.Android.Bcl-Tests/Assets/AboutAssets.txt create mode 100644 tests/Xamarin.Android.Bcl-Tests/Environment.txt create mode 100644 tests/Xamarin.Android.Bcl-Tests/MainActivity.cs create mode 100644 tests/Xamarin.Android.Bcl-Tests/Properties/AndroidManifest.xml create mode 100644 tests/Xamarin.Android.Bcl-Tests/Properties/AssemblyInfo.cs create mode 100644 tests/Xamarin.Android.Bcl-Tests/Resources/AboutResources.txt create mode 100644 tests/Xamarin.Android.Bcl-Tests/Resources/layout/Main.axml create mode 100644 tests/Xamarin.Android.Bcl-Tests/Resources/mipmap-hdpi/Icon.png create mode 100644 tests/Xamarin.Android.Bcl-Tests/Resources/mipmap-mdpi/Icon.png create mode 100644 tests/Xamarin.Android.Bcl-Tests/Resources/mipmap-xhdpi/Icon.png create mode 100644 tests/Xamarin.Android.Bcl-Tests/Resources/mipmap-xxhdpi/Icon.png create mode 100644 tests/Xamarin.Android.Bcl-Tests/Resources/mipmap-xxxhdpi/Icon.png create mode 100644 tests/Xamarin.Android.Bcl-Tests/Resources/values/Strings.xml create mode 100644 tests/Xamarin.Android.Bcl-Tests/System.Net.Http/HttpClientTest.cs create mode 100644 tests/Xamarin.Android.Bcl-Tests/System.Net/NetworkChangeTest.cs create mode 100644 tests/Xamarin.Android.Bcl-Tests/TestInstrumentation.cs create mode 100644 tests/Xamarin.Android.Bcl-Tests/Xamarin.Android.Bcl-Tests.csproj create mode 100644 tests/Xamarin.Android.Bcl-Tests/Xamarin.Android.Bcl-Tests.projitems create mode 100644 tests/Xamarin.Android.Bcl-Tests/Xamarin.Android.Bcl-Tests.targets diff --git a/Makefile b/Makefile index 2d40597c888..a43837d4e50 100644 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/Xamarin.Android-Tests.sln b/Xamarin.Android-Tests.sln index 0c5521095a8..f709c02f587 100644 --- a/Xamarin.Android-Tests.sln +++ b/Xamarin.Android-Tests.sln @@ -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} diff --git a/build-tools/bundle/bundle-path.targets b/build-tools/bundle/bundle-path.targets index 209be9e50e0..eba0aefbaba 100644 --- a/build-tools/bundle/bundle-path.targets +++ b/build-tools/bundle/bundle-path.targets @@ -24,6 +24,7 @@ + + + + corlib + + + I18N/CJK + + + I18N/MidEast + + + I18N/West + + + Mono.CSharp + + + Mono.Data.Sqlite + + + Mono.Data.Tds + + + Mono.Security + + + System + + + System.Core + + + System.Data + + + System.IO.Compression.FileSystem + + + System.IO.Compression + + + System.Json + + + System.Net.Http + + + System.Numerics + + + System.Runtime.Serialization + + + System.ServiceModel.Web + + + System.Transactions + + + System.XML + + + System.Xml.Linq + + + lib/monodroid + + diff --git a/build-tools/mono-runtimes/mono-runtimes.targets b/build-tools/mono-runtimes/mono-runtimes.targets index 0e3e633ae6b..7636ae52b36 100644 --- a/build-tools/mono-runtimes/mono-runtimes.targets +++ b/build-tools/mono-runtimes/mono-runtimes.targets @@ -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')" /> + + + <_BclTestOutput Include="@(_BclTestAssemblyDestination)" /> + <_BclTestOutput Include="$(XAInstallPrefix)\..\..\bcl-tests\bcl-tests.zip" /> <_BclProfileItems Include="@(_BclAssembly->'$(_MonoProfileDir)\%(Identity)')" /> @@ -286,7 +294,7 @@ + Outputs="@(_RuntimeSource);@(_ProfilerSource);@(_MonoPosixHelperSource);@(_BclProfileItems);@(_MonoBtlsSource);@(_BclTestOutput)"> + + + + + <_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)')" /> + + + <_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" /> + + + <_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)" /> + + + + + + (Resource.Id.RunTestsButton).Click += (o, e) => { AndroidRunner.Runner.Run (current_test, this); UpdateData (data, lv); @@ -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); diff --git a/src/Xamarin.Android.NUnitLite/Gui/Instrumentations/TestSuiteInstrumentation.cs b/src/Xamarin.Android.NUnitLite/Gui/Instrumentations/TestSuiteInstrumentation.cs index c9b0954d416..f46a06205e7 100644 --- a/src/Xamarin.Android.NUnitLite/Gui/Instrumentations/TestSuiteInstrumentation.cs +++ b/src/Xamarin.Android.NUnitLite/Gui/Instrumentations/TestSuiteInstrumentation.cs @@ -10,6 +10,7 @@ using Android.Util; using NUnitLite.Runner; +using NUnit.Framework.Api; using NUnit.Framework.Internal; namespace Xamarin.Android.NUnitLite { @@ -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) { @@ -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; @@ -145,5 +153,9 @@ protected void AddTest (Assembly assembly) { return null; } + + protected virtual void UpdateFilter () + { + } } } diff --git a/tests/RunApkTests.targets b/tests/RunApkTests.targets index 8a4df87c79f..fdbbb165973 100644 --- a/tests/RunApkTests.targets +++ b/tests/RunApkTests.targets @@ -14,6 +14,7 @@ in the toplevel Makefile so that the `.apk` is built. --> + diff --git a/tests/Xamarin.Android.Bcl-Tests/App.cs b/tests/Xamarin.Android.Bcl-Tests/App.cs new file mode 100644 index 00000000000..bc7d60db485 --- /dev/null +++ b/tests/Xamarin.Android.Bcl-Tests/App.cs @@ -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 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 GetExcludedCategories () + { + var excluded = new List { + "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)); + } + } +} diff --git a/tests/Xamarin.Android.Bcl-Tests/App.cs.in b/tests/Xamarin.Android.Bcl-Tests/App.cs.in new file mode 100644 index 00000000000..d7cf58dbdda --- /dev/null +++ b/tests/Xamarin.Android.Bcl-Tests/App.cs.in @@ -0,0 +1,7 @@ +namespace Xamarin.Android.BclTests { + partial class App { + public static string[] TestAssemblyNames = { + @ASSEMBLIES@ + }; + } +} \ No newline at end of file diff --git a/tests/Xamarin.Android.Bcl-Tests/Assets/AboutAssets.txt b/tests/Xamarin.Android.Bcl-Tests/Assets/AboutAssets.txt new file mode 100644 index 00000000000..a9b0638eb1b --- /dev/null +++ b/tests/Xamarin.Android.Bcl-Tests/Assets/AboutAssets.txt @@ -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"); diff --git a/tests/Xamarin.Android.Bcl-Tests/Environment.txt b/tests/Xamarin.Android.Bcl-Tests/Environment.txt new file mode 100644 index 00000000000..ba117b60829 --- /dev/null +++ b/tests/Xamarin.Android.Bcl-Tests/Environment.txt @@ -0,0 +1,4 @@ +debug.mono.debug=1 +MONO_LOG_LEVEL=debug +MONO_LOG_MASK=asm +MONO_XDEBUG=1 diff --git a/tests/Xamarin.Android.Bcl-Tests/MainActivity.cs b/tests/Xamarin.Android.Bcl-Tests/MainActivity.cs new file mode 100644 index 00000000000..4954f1f3411 --- /dev/null +++ b/tests/Xamarin.Android.Bcl-Tests/MainActivity.cs @@ -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 GetExcludedCategories () + { + return App.GetExcludedCategories (); + } + + protected override void UpdateFilter () + { + Filter = App.UpdateFilter (Filter); + } + } +} + diff --git a/tests/Xamarin.Android.Bcl-Tests/Properties/AndroidManifest.xml b/tests/Xamarin.Android.Bcl-Tests/Properties/AndroidManifest.xml new file mode 100644 index 00000000000..347358c0b4d --- /dev/null +++ b/tests/Xamarin.Android.Bcl-Tests/Properties/AndroidManifest.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/Xamarin.Android.Bcl-Tests/Properties/AssemblyInfo.cs b/tests/Xamarin.Android.Bcl-Tests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..22e438562d2 --- /dev/null +++ b/tests/Xamarin.Android.Bcl-Tests/Properties/AssemblyInfo.cs @@ -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("")] diff --git a/tests/Xamarin.Android.Bcl-Tests/Resources/AboutResources.txt b/tests/Xamarin.Android.Bcl-Tests/Resources/AboutResources.txt new file mode 100644 index 00000000000..10f52d46021 --- /dev/null +++ b/tests/Xamarin.Android.Bcl-Tests/Resources/AboutResources.txt @@ -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. diff --git a/tests/Xamarin.Android.Bcl-Tests/Resources/layout/Main.axml b/tests/Xamarin.Android.Bcl-Tests/Resources/layout/Main.axml new file mode 100644 index 00000000000..15eab28b4d0 --- /dev/null +++ b/tests/Xamarin.Android.Bcl-Tests/Resources/layout/Main.axml @@ -0,0 +1,4 @@ + + +