diff options
author | Stephane Delcroix <stephane@delcroix.org> | 2017-01-25 14:47:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-25 14:47:27 +0100 |
commit | f30aa8ae2c54172df237a80dfff7a6eb0c679195 (patch) | |
tree | c0c0f3e0a9ed58972cf3a4277c29ef2e3da2dd1c /Xamarin.Forms.Xaml.UnitTests | |
parent | ebb24b7edd2b297f259eadfa4686e03c96504f1d (diff) | |
download | xamarin-forms-f30aa8ae2c54172df237a80dfff7a6eb0c679195.tar.gz xamarin-forms-f30aa8ae2c54172df237a80dfff7a6eb0c679195.tar.bz2 xamarin-forms-f30aa8ae2c54172df237a80dfff7a6eb0c679195.zip |
[Xaml[C]] Do not instantiate DataTemplate Content at parsing time (#683)
* [Xaml] rename VisitChildrenFirst
* [Xaml] rework SkipChildren in XamlNode
* [Xaml] fix 45179
* fix
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
5 files changed, 101 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27863.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27863.xaml.cs index 03ebaaf9..1120a033 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27863.xaml.cs +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27863.xaml.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using Xamarin.Forms; using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; namespace Xamarin.Forms.Xaml.UnitTests { @@ -22,6 +23,18 @@ namespace Xamarin.Forms.Xaml.UnitTests [TestFixture] class Tests { + [SetUp] + public void Setup() + { + Device.PlatformServices = new MockPlatformServices(); + } + + [TearDown] + public void TearDown() + { + Device.PlatformServices = null; + } + [TestCase(true)] [TestCase(false)] public void DataTemplateInResourceDictionaries (bool useCompiledXaml) diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27968.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27968.xaml.cs index 2482e9f0..507073d7 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27968.xaml.cs +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27968.xaml.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using Xamarin.Forms; using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; namespace Xamarin.Forms.Xaml.UnitTests { @@ -26,6 +27,18 @@ namespace Xamarin.Forms.Xaml.UnitTests [TestFixture] class Tests { + [SetUp] + public void Setup() + { + Device.PlatformServices = new MockPlatformServices(); + } + + [TearDown] + public void TearDown() + { + Device.PlatformServices = null; + } + [TestCase(true)] [TestCase(false)] public void BaseClassIdentifiersAreValidForResources (bool useCompiledXaml) diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45179.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45179.xaml new file mode 100644 index 00000000..a89aa295 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45179.xaml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage + xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + xmlns:local="clr-namespace:Xamarin.Forms.Xaml.UnitTests" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz45179"> + <ContentPage.Resources> + <ResourceDictionary> + <DataTemplate x:Key="dt0"> + <local:Bz45179_0/> + </DataTemplate> + </ResourceDictionary> + </ContentPage.Resources> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45179.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45179.xaml.cs new file mode 100644 index 00000000..1dbdb44d --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45179.xaml.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; +using Xamarin.Forms; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class Bz45179_0 : ContentView { + public static int creator_count; + public Bz45179_0() + { + creator_count++; + } + + } + public partial class Bz45179 : ContentPage + { + public Bz45179() + { + InitializeComponent(); + } + + public Bz45179(bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [SetUp] + public void Setup() + { + Device.PlatformServices = new MockPlatformServices(); + } + + [TearDown] + public void TearDown() + { + Device.PlatformServices = null; + } + + [TestCase(true)] + [TestCase(false)] + public void DTDoNotInstantiateTheirContent(bool useCompiledXaml) + { + Bz45179_0.creator_count = 0; + Assume.That(Bz45179_0.creator_count, Is.EqualTo(0)); + var page = new Bz45179(useCompiledXaml); + Assert.That(Bz45179_0.creator_count, Is.EqualTo(0)); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj index b66a0824..ae250cd1 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj +++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj @@ -406,6 +406,9 @@ <Compile Include="Issues\Unreported008.xaml.cs"> <DependentUpon>Unreported008.xaml</DependentUpon> </Compile> + <Compile Include="Issues\Bz45179.xaml.cs"> + <DependentUpon>Bz45179.xaml</DependentUpon> + </Compile> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" /> @@ -733,6 +736,9 @@ <EmbeddedResource Include="Issues\Unreported008.xaml"> <Generator>MSBuild:UpdateDesignTimeXaml</Generator> </EmbeddedResource> + <EmbeddedResource Include="Issues\Bz45179.xaml"> + <Generator>MSBuild:UpdateDesignTimeXaml</Generator> + </EmbeddedResource> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> |