summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-08-02 22:24:50 +0200
committerJason Smith <jason.smith@xamarin.com>2016-08-02 13:24:50 -0700
commit89199205e48fe3fdf4336fe7e0f8af7dc0b662de (patch)
tree42e4d3a8f53ecd45d95b290bcdedd809eb046e4c /Xamarin.Forms.Xaml.UnitTests
parentac44cf9dec53b3b8be1836f20479f01820f3667f (diff)
downloadxamarin-forms-89199205e48fe3fdf4336fe7e0f8af7dc0b662de.tar.gz
xamarin-forms-89199205e48fe3fdf4336fe7e0f8af7dc0b662de.tar.bz2
xamarin-forms-89199205e48fe3fdf4336fe7e0f8af7dc0b662de.zip
Xaml convert on add (#273)
* [Xaml] add test for conversion on Set and Add * [Xaml] Fix conversion on Add() * [XamlC] use op_implicit before Add()
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/BuiltInConversions.xaml (renamed from Xamarin.Forms.Xaml.UnitTests/ImplicitConversions.xaml)2
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/BuiltInConversions.xaml.cs (renamed from Xamarin.Forms.Xaml.UnitTests/ImplicitConversions.xaml.cs)11
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/FindByName.xaml (renamed from Xamarin.Forms.Xaml.UnitTests/Compiled/FindByName.xaml)2
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/FindByName.xaml.cs (renamed from Xamarin.Forms.Xaml.UnitTests/Compiled/FindByName.xaml.cs)2
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/SetValue.xaml (renamed from Xamarin.Forms.Xaml.UnitTests/Compiled/SetValue.xaml)9
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/SetValue.xaml.cs (renamed from Xamarin.Forms.Xaml.UnitTests/Compiled/SetValue.xaml.cs)29
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj30
7 files changed, 55 insertions, 30 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/ImplicitConversions.xaml b/Xamarin.Forms.Xaml.UnitTests/BuiltInConversions.xaml
index 38d20e3e..cb0aefb6 100644
--- a/Xamarin.Forms.Xaml.UnitTests/ImplicitConversions.xaml
+++ b/Xamarin.Forms.Xaml.UnitTests/BuiltInConversions.xaml
@@ -2,7 +2,7 @@
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- x:Class="Xamarin.Forms.Xaml.UnitTests.ImplicitConversions">
+ x:Class="Xamarin.Forms.Xaml.UnitTests.BuiltInConversions">
<StackLayout>
<DatePicker x:Name="datetime0" Date="2015-01-16"/>
<DatePicker x:Name="datetime1">
diff --git a/Xamarin.Forms.Xaml.UnitTests/ImplicitConversions.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/BuiltInConversions.xaml.cs
index 5eae0299..20d4afd2 100644
--- a/Xamarin.Forms.Xaml.UnitTests/ImplicitConversions.xaml.cs
+++ b/Xamarin.Forms.Xaml.UnitTests/BuiltInConversions.xaml.cs
@@ -1,15 +1,12 @@
´╗┐using System;
-using System.Collections.Generic;
-
-using Xamarin.Forms;
using NUnit.Framework;
namespace Xamarin.Forms.Xaml.UnitTests
{
- public partial class ImplicitConversions : ContentPage
+ public partial class BuiltInConversions : ContentPage
{
- public ImplicitConversions ()
+ public BuiltInConversions ()
{
InitializeComponent ();
}
@@ -20,7 +17,7 @@ namespace Xamarin.Forms.Xaml.UnitTests
[Test]
public void Datetime ()
{
- var layout = new ImplicitConversions ();
+ var layout = new BuiltInConversions ();
Assert.AreEqual (new DateTime (2015, 01, 16), layout.datetime0.Date);
Assert.AreEqual (new DateTime (2015, 01, 16), layout.datetime1.Date);
@@ -29,7 +26,7 @@ namespace Xamarin.Forms.Xaml.UnitTests
[Test]
public void String ()
{
- var layout = new ImplicitConversions ();
+ var layout = new BuiltInConversions ();
Assert.AreEqual ("foobar", layout.label0.Text);
Assert.AreEqual ("foobar", layout.label1.Text);
diff --git a/Xamarin.Forms.Xaml.UnitTests/Compiled/FindByName.xaml b/Xamarin.Forms.Xaml.UnitTests/FindByName.xaml
index c0b7afd7..f064e5b0 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Compiled/FindByName.xaml
+++ b/Xamarin.Forms.Xaml.UnitTests/FindByName.xaml
@@ -2,7 +2,7 @@
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- x:Class="Xamarin.Forms.Xaml.UnitTests.Compiled.FindByName"
+ x:Class="Xamarin.Forms.Xaml.UnitTests.FindByName"
x:Name="root">
<StackLayout>
<Label Text="Foo" x:Name="label0"/>
diff --git a/Xamarin.Forms.Xaml.UnitTests/Compiled/FindByName.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/FindByName.xaml.cs
index 0ec198e8..c80ca6a6 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Compiled/FindByName.xaml.cs
+++ b/Xamarin.Forms.Xaml.UnitTests/FindByName.xaml.cs
@@ -2,7 +2,7 @@
using Xamarin.Forms;
-namespace Xamarin.Forms.Xaml.UnitTests.Compiled
+namespace Xamarin.Forms.Xaml.UnitTests
{
public partial class FindByName : ContentPage
{
diff --git a/Xamarin.Forms.Xaml.UnitTests/Compiled/SetValue.xaml b/Xamarin.Forms.Xaml.UnitTests/SetValue.xaml
index e60cd6db..133e0e9b 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Compiled/SetValue.xaml
+++ b/Xamarin.Forms.Xaml.UnitTests/SetValue.xaml
@@ -2,7 +2,8 @@
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- x:Class="Xamarin.Forms.Xaml.UnitTests.Compiled.SetValue">
+ xmlns:local="clr-namespace:Xamarin.Forms.Xaml.UnitTests"
+ x:Class="Xamarin.Forms.Xaml.UnitTests.SetValue">
<ContentPage.Resources>
<ResourceDictionary>
<Color x:Key="purple">Purple</Color>
@@ -67,5 +68,11 @@
</Grid.ColumnDefinitions>
</Grid>
<Label x:Name="label14" AbsoluteLayout.LayoutFlags="PositionProportional,WidthProportional" />
+ <ContentView x:Name="content0">
+ <local:ConvertibleToView/>
+ </ContentView>
+ <StackLayout x:Name="stack4">
+ <local:ConvertibleToView/>
+ </StackLayout>
</StackLayout>
</ContentPage> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Compiled/SetValue.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/SetValue.xaml.cs
index f835d59f..ce377a71 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Compiled/SetValue.xaml.cs
+++ b/Xamarin.Forms.Xaml.UnitTests/SetValue.xaml.cs
@@ -1,13 +1,18 @@
´╗┐using System;
using System.Linq;
-using System.Collections.Generic;
-
-using Xamarin.Forms;
using NUnit.Framework;
-namespace Xamarin.Forms.Xaml.UnitTests.Compiled
+namespace Xamarin.Forms.Xaml.UnitTests
{
+ public class ConvertibleToView
+ {
+ public static implicit operator View(ConvertibleToView source)
+ {
+ return new Button();
+ }
+ }
+
public partial class SetValue : ContentPage
{
public SetValue ()
@@ -186,6 +191,22 @@ namespace Xamarin.Forms.Xaml.UnitTests.Compiled
var page = new SetValue (useCompiledXaml);
Assert.AreEqual (AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional, AbsoluteLayout.GetLayoutFlags (page.label14));
}
+
+ [TestCase(false)]
+ [TestCase(true)]
+ public void ConversionsAreAppliedOnSet(bool useCompiledXaml)
+ {
+ var page = new SetValue(useCompiledXaml);
+ Assert.That(page.content0.Content, Is.TypeOf<Button>());
+ }
+
+ [TestCase(false)]
+ [TestCase(true)]
+ public void ConversionsAreAppliedOnAdd(bool useCompiledXaml)
+ {
+ var page = new SetValue(useCompiledXaml);
+ Assert.That(page.stack4.Children[0], Is.TypeOf<Button>());
+ }
}
}
} \ 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 cf473ff8..577b68bb 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
+++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
@@ -121,9 +121,6 @@
<Compile Include="Issues\Issue2016.xaml.cs">
<DependentUpon>Issue2016.xaml</DependentUpon>
</Compile>
- <Compile Include="Compiled\FindByName.xaml.cs">
- <DependentUpon>FindByName.xaml</DependentUpon>
- </Compile>
<Compile Include="Validation\SetterOnNonBP.xaml.cs">
<DependentUpon>SetterOnNonBP.xaml</DependentUpon>
</Compile>
@@ -143,8 +140,8 @@
<Compile Include="Issues\Issue2152.xaml.cs">
<DependentUpon>Issue2152.xaml</DependentUpon>
</Compile>
- <Compile Include="ImplicitConversions.xaml.cs">
- <DependentUpon>ImplicitConversions.xaml</DependentUpon>
+ <Compile Include="BuiltInConversions.xaml.cs">
+ <DependentUpon>BuiltInConversions.xaml</DependentUpon>
</Compile>
<Compile Include="Issues\Issue2450.xaml.cs">
<DependentUpon>Issue2450.xaml</DependentUpon>
@@ -170,9 +167,6 @@
<Compile Include="Issues\Issue2742.xaml.cs">
<DependentUpon>Issue2742.xaml</DependentUpon>
</Compile>
- <Compile Include="Compiled\SetValue.xaml.cs">
- <DependentUpon>SetValue.xaml</DependentUpon>
- </Compile>
<Compile Include="X2009Primitives.xaml.cs">
<DependentUpon>X2009Primitives.xaml</DependentUpon>
</Compile>
@@ -353,6 +347,12 @@
<Compile Include="Issues\Unreported004.xaml.cs">
<DependentUpon>Unreported004.xaml</DependentUpon>
</Compile>
+ <Compile Include="FindByName.xaml.cs">
+ <DependentUpon>FindByName.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="SetValue.xaml.cs">
+ <DependentUpon>SetValue.xaml</DependentUpon>
+ </Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
@@ -422,7 +422,7 @@
<EmbeddedResource Include="Issues\Issue2152.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
- <EmbeddedResource Include="ImplicitConversions.xaml">
+ <EmbeddedResource Include="BuiltInConversions.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="Issues\Issue2450.xaml">
@@ -449,12 +449,6 @@
<EmbeddedResource Include="Issues\Issue2742.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
- <EmbeddedResource Include="Compiled\FindByName.xaml">
- <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
- </EmbeddedResource>
- <EmbeddedResource Include="Compiled\SetValue.xaml">
- <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
- </EmbeddedResource>
<EmbeddedResource Include="X2009Primitives.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
@@ -629,6 +623,12 @@
<EmbeddedResource Include="Issues\Unreported004.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
+ <EmbeddedResource Include="FindByName.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
+ <EmbeddedResource Include="SetValue.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />