diff options
author | Stephane Delcroix <stephane@delcroix.org> | 2017-04-06 23:13:49 +0200 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2017-04-06 14:13:49 -0700 |
commit | 0ee636003b6d1083ea4caeed85ef3efbc815ed06 (patch) | |
tree | 861ba1a66b1b72be663719437ace87179cd3c03d /Xamarin.Forms.Core.UnitTests | |
parent | eb3db860e47da2974bddf6f0f959799f12e962c5 (diff) | |
download | xamarin-forms-0ee636003b6d1083ea4caeed85ef3efbc815ed06.tar.gz xamarin-forms-0ee636003b6d1083ea4caeed85ef3efbc815ed06.tar.bz2 xamarin-forms-0ee636003b6d1083ea4caeed85ef3efbc815ed06.zip |
Fix 54334 (#855)
* [C] unset the FromStyle flag on manual setting
* [C] Do not reset overriden values to default
* complete the fix
Diffstat (limited to 'Xamarin.Forms.Core.UnitTests')
-rw-r--r-- | Xamarin.Forms.Core.UnitTests/StyleTests.cs | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/Xamarin.Forms.Core.UnitTests/StyleTests.cs b/Xamarin.Forms.Core.UnitTests/StyleTests.cs index d6927e5c..8caac97a 100644 --- a/Xamarin.Forms.Core.UnitTests/StyleTests.cs +++ b/Xamarin.Forms.Core.UnitTests/StyleTests.cs @@ -8,12 +8,19 @@ namespace Xamarin.Forms.Core.UnitTests public class StyleTests : BaseTestFixture { [SetUp] - public void Setup () + public override void Setup () { base.Setup (); Device.PlatformServices = new MockPlatformServices (); } + [TearDown] + public override void TearDown() + { + base.TearDown(); + Application.Current = null; + } + [Test] public void ApplyUnapplyStyle () { @@ -703,5 +710,54 @@ namespace Xamarin.Forms.Core.UnitTests Assert.AreEqual (Color.Pink, button.TextColor); Assert.AreEqual (20d, button.FontSize); } + + [Test] + public void ReplacingResourcesDoesNotOverrideManuallySetProperties() + { + var label0 = new Label { + TextColor = Color.Pink + }; + var label1 = new Label(); + + Assume.That(label0.TextColor, Is.EqualTo(Color.Pink)); + Assume.That(label1.TextColor, Is.EqualTo(Color.Default)); + + var rd0 = new ResourceDictionary { + new Style (typeof(Label)) { + Setters = { + new Setter {Property = Label.TextColorProperty, Value = Color.Olive} + } + } + }; + var rd1 = new ResourceDictionary { + new Style (typeof(Label)) { + Setters = { + new Setter {Property = Label.TextColorProperty, Value = Color.Lavender} + } + } + }; + + var mockApp = new MockApplication(); + Application.Current = mockApp; + mockApp.Resources = rd0; + + var layout = new StackLayout { + Children = { + label0, + label1, + } + }; + + mockApp.MainPage = new ContentPage { Content = layout}; + //Assert.That(label0.TextColor, Is.EqualTo(Color.Pink)); + //Assert.That(label1.TextColor, Is.EqualTo(Color.Default)); + + Assert.That(label0.TextColor, Is.EqualTo(Color.Pink)); + Assert.That(label1.TextColor, Is.EqualTo(Color.Olive)); + + mockApp.Resources = rd1; + Assert.That(label0.TextColor, Is.EqualTo(Color.Pink)); + Assert.That(label1.TextColor, Is.EqualTo(Color.Lavender)); + } } }
\ No newline at end of file |