From 4fd939799b03ea2228a3d82a317c715850604619 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Wed, 29 Mar 2017 15:37:27 +0100 Subject: [PATCH 1/5] [Mono.Android] Add a Test for reading 9 Patch files at runtime. Context https://bugzilla.xamarin.com/show_bug.cgi?id=46807 --- .../Test/Android.Graphics/GraphicsTest.cs | 20 ++ .../Test/Mono.Android-Tests.csproj | 6 +- .../Test/Resources/Resource.designer.cs | 206 ++++++++++++++++++ 3 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs create mode 100644 src/Mono.Android/Test/Resources/Resource.designer.cs diff --git a/src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs b/src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs new file mode 100644 index 00000000000..322724c1e51 --- /dev/null +++ b/src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs @@ -0,0 +1,20 @@ +using System; + +using Android.Content; + +using NUnit.Framework; + +namespace Android.GraphicsTests +{ + [TestFixture] + public class GraphicTest + { + [Test] + public void NinePatch () + { + var d = Android.App.Application.Context.Resources.GetDrawable (Xamarin.Android.RuntimeTests.Resource.Drawable.Image); + Assert.IsNotNull (d); + Assert.IsNotNull (d as Android.Graphics.Drawables.NinePatchDrawable); + } + } +} diff --git a/src/Mono.Android/Test/Mono.Android-Tests.csproj b/src/Mono.Android/Test/Mono.Android-Tests.csproj index e6e36efd7e7..8a9fca980bc 100644 --- a/src/Mono.Android/Test/Mono.Android-Tests.csproj +++ b/src/Mono.Android/Test/Mono.Android-Tests.csproj @@ -57,6 +57,7 @@ + @@ -101,6 +102,9 @@ + + Resources\Drawable\Image.png + @@ -126,4 +130,4 @@ False - \ No newline at end of file + diff --git a/src/Mono.Android/Test/Resources/Resource.designer.cs b/src/Mono.Android/Test/Resources/Resource.designer.cs new file mode 100644 index 00000000000..92b7a1b0183 --- /dev/null +++ b/src/Mono.Android/Test/Resources/Resource.designer.cs @@ -0,0 +1,206 @@ +#pragma warning disable 1591 +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Mono Runtime Version: 4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ + +[assembly: Android.Runtime.ResourceDesignerAttribute("Xamarin.Android.RuntimeTests.Resource", IsApplication=true)] + +namespace Xamarin.Android.RuntimeTests +{ + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")] + public partial class Resource + { + + static Resource() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + public static void UpdateIdValues() + { + global::Xamarin.Android.NUnitLite.Resource.Id.OptionHostName = global::Xamarin.Android.RuntimeTests.Resource.Id.OptionHostName; + global::Xamarin.Android.NUnitLite.Resource.Id.OptionPort = global::Xamarin.Android.RuntimeTests.Resource.Id.OptionPort; + global::Xamarin.Android.NUnitLite.Resource.Id.OptionRemoteServer = global::Xamarin.Android.RuntimeTests.Resource.Id.OptionRemoteServer; + global::Xamarin.Android.NUnitLite.Resource.Id.OptionsButton = global::Xamarin.Android.RuntimeTests.Resource.Id.OptionsButton; + global::Xamarin.Android.NUnitLite.Resource.Id.ResultFullName = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultFullName; + global::Xamarin.Android.NUnitLite.Resource.Id.ResultMessage = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultMessage; + global::Xamarin.Android.NUnitLite.Resource.Id.ResultResultState = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultResultState; + global::Xamarin.Android.NUnitLite.Resource.Id.ResultRunSingleMethodTest = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultRunSingleMethodTest; + global::Xamarin.Android.NUnitLite.Resource.Id.ResultStackTrace = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultStackTrace; + global::Xamarin.Android.NUnitLite.Resource.Id.ResultsFailed = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsFailed; + global::Xamarin.Android.NUnitLite.Resource.Id.ResultsId = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsId; + global::Xamarin.Android.NUnitLite.Resource.Id.ResultsIgnored = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsIgnored; + global::Xamarin.Android.NUnitLite.Resource.Id.ResultsInconclusive = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsInconclusive; + global::Xamarin.Android.NUnitLite.Resource.Id.ResultsMessage = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsMessage; + global::Xamarin.Android.NUnitLite.Resource.Id.ResultsPassed = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsPassed; + global::Xamarin.Android.NUnitLite.Resource.Id.ResultsResult = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsResult; + global::Xamarin.Android.NUnitLite.Resource.Id.RunTestsButton = global::Xamarin.Android.RuntimeTests.Resource.Id.RunTestsButton; + global::Xamarin.Android.NUnitLite.Resource.Id.TestSuiteListView = global::Xamarin.Android.RuntimeTests.Resource.Id.TestSuiteListView; + global::Xamarin.Android.NUnitLite.Resource.Layout.options = global::Xamarin.Android.RuntimeTests.Resource.Layout.options; + global::Xamarin.Android.NUnitLite.Resource.Layout.results = global::Xamarin.Android.RuntimeTests.Resource.Layout.results; + global::Xamarin.Android.NUnitLite.Resource.Layout.test_result = global::Xamarin.Android.RuntimeTests.Resource.Layout.test_result; + global::Xamarin.Android.NUnitLite.Resource.Layout.test_suite = global::Xamarin.Android.RuntimeTests.Resource.Layout.test_suite; + } + + public partial class Attribute + { + + static Attribute() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Attribute() + { + } + } + + public partial class Drawable + { + + // aapt resource value: 0x7f020000 + public const int android_button = 2130837504; + + // aapt resource value: 0x7f020001 + public const int android_focused = 2130837505; + + // aapt resource value: 0x7f020002 + public const int android_normal = 2130837506; + + // aapt resource value: 0x7f020003 + public const int AndroidPressed = 2130837507; + + // aapt resource value: 0x7f020004 + public const int Icon = 2130837508; + + // aapt resource value: 0x7f020005 + public const int Image = 2130837509; + + static Drawable() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Drawable() + { + } + } + + public partial class Id + { + + // aapt resource value: 0x7f050001 + public const int OptionHostName = 2131034113; + + // aapt resource value: 0x7f050002 + public const int OptionPort = 2131034114; + + // aapt resource value: 0x7f050000 + public const int OptionRemoteServer = 2131034112; + + // aapt resource value: 0x7f050010 + public const int OptionsButton = 2131034128; + + // aapt resource value: 0x7f05000b + public const int ResultFullName = 2131034123; + + // aapt resource value: 0x7f05000d + public const int ResultMessage = 2131034125; + + // aapt resource value: 0x7f05000c + public const int ResultResultState = 2131034124; + + // aapt resource value: 0x7f05000a + public const int ResultRunSingleMethodTest = 2131034122; + + // aapt resource value: 0x7f05000e + public const int ResultStackTrace = 2131034126; + + // aapt resource value: 0x7f050006 + public const int ResultsFailed = 2131034118; + + // aapt resource value: 0x7f050003 + public const int ResultsId = 2131034115; + + // aapt resource value: 0x7f050007 + public const int ResultsIgnored = 2131034119; + + // aapt resource value: 0x7f050008 + public const int ResultsInconclusive = 2131034120; + + // aapt resource value: 0x7f050009 + public const int ResultsMessage = 2131034121; + + // aapt resource value: 0x7f050005 + public const int ResultsPassed = 2131034117; + + // aapt resource value: 0x7f050004 + public const int ResultsResult = 2131034116; + + // aapt resource value: 0x7f05000f + public const int RunTestsButton = 2131034127; + + // aapt resource value: 0x7f050011 + public const int TestSuiteListView = 2131034129; + + static Id() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Id() + { + } + } + + public partial class Layout + { + + // aapt resource value: 0x7f030000 + public const int options = 2130903040; + + // aapt resource value: 0x7f030001 + public const int results = 2130903041; + + // aapt resource value: 0x7f030002 + public const int test_result = 2130903042; + + // aapt resource value: 0x7f030003 + public const int test_suite = 2130903043; + + static Layout() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Layout() + { + } + } + + public partial class Xml + { + + // aapt resource value: 0x7f040000 + public const int XmlReaderResourceParser = 2130968576; + + static Xml() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Xml() + { + } + } + } +} +#pragma warning restore 1591 From 2e0fa5452ffaf1728d11b4e7de9577b5ffc2b3cc Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Mon, 19 Mar 2018 13:10:19 +0000 Subject: [PATCH 2/5] ff --- .../Test/Resources/Resource.designer.cs | 206 ------------------ 1 file changed, 206 deletions(-) delete mode 100644 src/Mono.Android/Test/Resources/Resource.designer.cs diff --git a/src/Mono.Android/Test/Resources/Resource.designer.cs b/src/Mono.Android/Test/Resources/Resource.designer.cs deleted file mode 100644 index 92b7a1b0183..00000000000 --- a/src/Mono.Android/Test/Resources/Resource.designer.cs +++ /dev/null @@ -1,206 +0,0 @@ -#pragma warning disable 1591 -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -[assembly: Android.Runtime.ResourceDesignerAttribute("Xamarin.Android.RuntimeTests.Resource", IsApplication=true)] - -namespace Xamarin.Android.RuntimeTests -{ - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")] - public partial class Resource - { - - static Resource() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - public static void UpdateIdValues() - { - global::Xamarin.Android.NUnitLite.Resource.Id.OptionHostName = global::Xamarin.Android.RuntimeTests.Resource.Id.OptionHostName; - global::Xamarin.Android.NUnitLite.Resource.Id.OptionPort = global::Xamarin.Android.RuntimeTests.Resource.Id.OptionPort; - global::Xamarin.Android.NUnitLite.Resource.Id.OptionRemoteServer = global::Xamarin.Android.RuntimeTests.Resource.Id.OptionRemoteServer; - global::Xamarin.Android.NUnitLite.Resource.Id.OptionsButton = global::Xamarin.Android.RuntimeTests.Resource.Id.OptionsButton; - global::Xamarin.Android.NUnitLite.Resource.Id.ResultFullName = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultFullName; - global::Xamarin.Android.NUnitLite.Resource.Id.ResultMessage = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultMessage; - global::Xamarin.Android.NUnitLite.Resource.Id.ResultResultState = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultResultState; - global::Xamarin.Android.NUnitLite.Resource.Id.ResultRunSingleMethodTest = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultRunSingleMethodTest; - global::Xamarin.Android.NUnitLite.Resource.Id.ResultStackTrace = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultStackTrace; - global::Xamarin.Android.NUnitLite.Resource.Id.ResultsFailed = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsFailed; - global::Xamarin.Android.NUnitLite.Resource.Id.ResultsId = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsId; - global::Xamarin.Android.NUnitLite.Resource.Id.ResultsIgnored = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsIgnored; - global::Xamarin.Android.NUnitLite.Resource.Id.ResultsInconclusive = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsInconclusive; - global::Xamarin.Android.NUnitLite.Resource.Id.ResultsMessage = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsMessage; - global::Xamarin.Android.NUnitLite.Resource.Id.ResultsPassed = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsPassed; - global::Xamarin.Android.NUnitLite.Resource.Id.ResultsResult = global::Xamarin.Android.RuntimeTests.Resource.Id.ResultsResult; - global::Xamarin.Android.NUnitLite.Resource.Id.RunTestsButton = global::Xamarin.Android.RuntimeTests.Resource.Id.RunTestsButton; - global::Xamarin.Android.NUnitLite.Resource.Id.TestSuiteListView = global::Xamarin.Android.RuntimeTests.Resource.Id.TestSuiteListView; - global::Xamarin.Android.NUnitLite.Resource.Layout.options = global::Xamarin.Android.RuntimeTests.Resource.Layout.options; - global::Xamarin.Android.NUnitLite.Resource.Layout.results = global::Xamarin.Android.RuntimeTests.Resource.Layout.results; - global::Xamarin.Android.NUnitLite.Resource.Layout.test_result = global::Xamarin.Android.RuntimeTests.Resource.Layout.test_result; - global::Xamarin.Android.NUnitLite.Resource.Layout.test_suite = global::Xamarin.Android.RuntimeTests.Resource.Layout.test_suite; - } - - public partial class Attribute - { - - static Attribute() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - private Attribute() - { - } - } - - public partial class Drawable - { - - // aapt resource value: 0x7f020000 - public const int android_button = 2130837504; - - // aapt resource value: 0x7f020001 - public const int android_focused = 2130837505; - - // aapt resource value: 0x7f020002 - public const int android_normal = 2130837506; - - // aapt resource value: 0x7f020003 - public const int AndroidPressed = 2130837507; - - // aapt resource value: 0x7f020004 - public const int Icon = 2130837508; - - // aapt resource value: 0x7f020005 - public const int Image = 2130837509; - - static Drawable() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - private Drawable() - { - } - } - - public partial class Id - { - - // aapt resource value: 0x7f050001 - public const int OptionHostName = 2131034113; - - // aapt resource value: 0x7f050002 - public const int OptionPort = 2131034114; - - // aapt resource value: 0x7f050000 - public const int OptionRemoteServer = 2131034112; - - // aapt resource value: 0x7f050010 - public const int OptionsButton = 2131034128; - - // aapt resource value: 0x7f05000b - public const int ResultFullName = 2131034123; - - // aapt resource value: 0x7f05000d - public const int ResultMessage = 2131034125; - - // aapt resource value: 0x7f05000c - public const int ResultResultState = 2131034124; - - // aapt resource value: 0x7f05000a - public const int ResultRunSingleMethodTest = 2131034122; - - // aapt resource value: 0x7f05000e - public const int ResultStackTrace = 2131034126; - - // aapt resource value: 0x7f050006 - public const int ResultsFailed = 2131034118; - - // aapt resource value: 0x7f050003 - public const int ResultsId = 2131034115; - - // aapt resource value: 0x7f050007 - public const int ResultsIgnored = 2131034119; - - // aapt resource value: 0x7f050008 - public const int ResultsInconclusive = 2131034120; - - // aapt resource value: 0x7f050009 - public const int ResultsMessage = 2131034121; - - // aapt resource value: 0x7f050005 - public const int ResultsPassed = 2131034117; - - // aapt resource value: 0x7f050004 - public const int ResultsResult = 2131034116; - - // aapt resource value: 0x7f05000f - public const int RunTestsButton = 2131034127; - - // aapt resource value: 0x7f050011 - public const int TestSuiteListView = 2131034129; - - static Id() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - private Id() - { - } - } - - public partial class Layout - { - - // aapt resource value: 0x7f030000 - public const int options = 2130903040; - - // aapt resource value: 0x7f030001 - public const int results = 2130903041; - - // aapt resource value: 0x7f030002 - public const int test_result = 2130903042; - - // aapt resource value: 0x7f030003 - public const int test_suite = 2130903043; - - static Layout() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - private Layout() - { - } - } - - public partial class Xml - { - - // aapt resource value: 0x7f040000 - public const int XmlReaderResourceParser = 2130968576; - - static Xml() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - private Xml() - { - } - } - } -} -#pragma warning restore 1591 From efc1bf15982e1e05e120fa3c38d63f2af2cf8467 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Tue, 27 Mar 2018 16:42:58 +0100 Subject: [PATCH 3/5] Fix Image name to be Image.9.png --- src/Mono.Android/Test/Mono.Android-Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mono.Android/Test/Mono.Android-Tests.csproj b/src/Mono.Android/Test/Mono.Android-Tests.csproj index 8a9fca980bc..f67d5626876 100644 --- a/src/Mono.Android/Test/Mono.Android-Tests.csproj +++ b/src/Mono.Android/Test/Mono.Android-Tests.csproj @@ -103,7 +103,7 @@ - Resources\Drawable\Image.png + Resources\Drawable\Image.9.png From 41a9c4f31bac54e08b1d3e4e71b70f6bd3d0af13 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Tue, 27 Mar 2018 16:56:34 +0100 Subject: [PATCH 4/5] Fixed compile error --- src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs b/src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs index 322724c1e51..dfe6ea049b5 100644 --- a/src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs +++ b/src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs @@ -12,7 +12,7 @@ public class GraphicTest [Test] public void NinePatch () { - var d = Android.App.Application.Context.Resources.GetDrawable (Xamarin.Android.RuntimeTests.Resource.Drawable.Image); + var d = Android.App.Application.Context.Resources.GetDrawable (Xamarin.Android.RuntimeTests.Resource.Drawable.image); Assert.IsNotNull (d); Assert.IsNotNull (d as Android.Graphics.Drawables.NinePatchDrawable); } From b430bf4407c24385dc9147692594cd1195adb75c Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Tue, 27 Mar 2018 17:14:02 +0100 Subject: [PATCH 5/5] Added Text for failures --- src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs b/src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs index dfe6ea049b5..e05720869af 100644 --- a/src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs +++ b/src/Mono.Android/Test/Android.Graphics/GraphicsTest.cs @@ -13,8 +13,8 @@ public class GraphicTest public void NinePatch () { var d = Android.App.Application.Context.Resources.GetDrawable (Xamarin.Android.RuntimeTests.Resource.Drawable.image); - Assert.IsNotNull (d); - Assert.IsNotNull (d as Android.Graphics.Drawables.NinePatchDrawable); + Assert.IsNotNull (d, "An image should have been retrieved."); + Assert.IsNotNull (d as Android.Graphics.Drawables.NinePatchDrawable, "The image should be a NinePatchDrawable."); } } }