diff options
author | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 13:02:25 -0700 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 16:13:41 -0700 |
commit | 17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch) | |
tree | b5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Xaml.UnitTests/Issues | |
download | xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2 xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip |
Initial import
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests/Issues')
102 files changed, 3694 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/BPNotResolvedOnSubClass.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/BPNotResolvedOnSubClass.xaml new file mode 100644 index 00000000..ea5204a3 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/BPNotResolvedOnSubClass.xaml @@ -0,0 +1,15 @@ +<?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.BPNotResolvedOnSubClass"> + <ContentPage.Resources> + <ResourceDictionary> + <Style TargetType="Button"> + <Style.Setters> + <Setter Property="local:BPNotResolvedOnSubClass.ShadowColor" Value="#dddddd" /> + </Style.Setters> + </Style> + </ResourceDictionary> + </ContentPage.Resources> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/BPNotResolvedOnSubClass.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/BPNotResolvedOnSubClass.xaml.cs new file mode 100644 index 00000000..65bb73f1 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/BPNotResolvedOnSubClass.xaml.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class BPNotResolvedOnSubClass : ContentPage + { + public static readonly BindableProperty ShadowColorProperty = + BindableProperty.CreateAttached ("ShadowColor", typeof (Color), typeof (BPNotResolvedOnSubClass), Color.Default); + + public static Color GetShadowColor (Element bindable) // Change to Element instead of BindableObject o make fail + { + return (Color)bindable.GetValue (ShadowColorProperty); + } + + public BPNotResolvedOnSubClass () + { + InitializeComponent (); + } + + public BPNotResolvedOnSubClass (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void CorrectlyResolveBPOnSubClasses (bool useCompiledXaml) + { + var layout = new BPNotResolvedOnSubClass (useCompiledXaml); + var style = (Style)layout.Resources["Xamarin.Forms.Button"]; + Assert.NotNull (style); + + var button = new Button (); + button.Style = style; + + Assert.AreEqual (Color.FromHex ("#dddddd"), button.GetValue (ShadowColorProperty)); + } + } + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz24485.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz24485.xaml new file mode 100644 index 00000000..ed7ec074 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz24485.xaml @@ -0,0 +1,15 @@ +<?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.Bz24485"> + <ContentPage.Resources> + <ResourceDictionary> + <local:Bz24485Converter x:Key="ToBasicItem" /> + </ResourceDictionary> + </ContentPage.Resources> + <Grid BindingContext="{Binding Data1, Converter={StaticResource ToBasicItem}"> + <Label Text="{Binding FormattedDate}" /> + <Label Text="{Binding Date}" /> + </Grid> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz24485.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz24485.xaml.cs new file mode 100644 index 00000000..8165e8f4 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz24485.xaml.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class Bz24485Converter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + return null; + + return new { + Date = DateTime.Now.ToString("dd MMMM yyyy"), + Object = new object () + }; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + public partial class Bz24485 : ContentPage + { + public Bz24485 () + { + InitializeComponent (); + } + + public Bz24485 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void BindingContextWithConverter (bool useCompiledXaml) + { + var layout = new Bz24485 (useCompiledXaml); + layout.BindingContext = new { Data1 = new object ()}; + Assert.Pass (); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz24910.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz24910.xaml new file mode 100644 index 00000000..6031212c --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz24910.xaml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:local="clr-namespace:Xamarin.Forms.Xaml.UnitTests" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz24910" > + <StackLayout> + <local:Bz24910Control x:Name="control0" Text="CustomButton" NullableInt="1" NullableDouble="2.2" /> + <local:Bz24910Control x:Name="control1" Text="CustomButton" NullableDouble="2" /> + <local:Bz24910Control x:Name="control2" Text="CustomButton" NullableInt="{x:Null}" /> + <local:Bz24910Control x:Name="control3" Text="CustomButton" NullableInt="{Binding .}" /> + <Label x:Name="control4" local:Bz24910Control.AttachedNullableInt="3" /> + <local:Bz24910Control x:Name="control5" Text="CustomButton" NullableIntProp="5" /> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz24910.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz24910.xaml.cs new file mode 100644 index 00000000..50dad4f7 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz24910.xaml.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz24910 : ContentPage + { + public Bz24910 () + { + InitializeComponent (); + } + + public Bz24910 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true), TestCase(false)] + public void AllowNullableIntProperties (bool useCompiledXaml) + { + var page = new Bz24910 (useCompiledXaml); + var control = page.control0; + Assert.AreEqual (1, control.NullableInt); + } + + [TestCase(true), TestCase(false)] + public void AllowNullableDoubleProperties (bool useCompiledXaml) + { + var page = new Bz24910 (useCompiledXaml); + var control = page.control0; + Assert.AreEqual (2.2d, control.NullableDouble); + } + + [TestCase(true), TestCase(false)] + public void ConversionForNullable (bool useCompiledXaml) + { + var page = new Bz24910 (useCompiledXaml); + var control = page.control1; + Assert.AreEqual (2d, control.NullableDouble); + } + + [TestCase(true), TestCase(false)] + public void AllowNull (bool useCompiledXaml) + { + var page = new Bz24910 (useCompiledXaml); + var control = page.control2; + Assert.Null (control.NullableInt); + } + + [TestCase(true), TestCase(false)] + public void AllowBindingToNullable (bool useCompiledXaml) + { + var page = new Bz24910 (useCompiledXaml); + var control = page.control3; + Assert.Null (control.NullableInt); + + page.BindingContext = 2; + Assert.AreEqual (2, control.NullableInt); + } + + [TestCase(true), TestCase(false)] + public void NullableAttachedBPs (bool useCompiledXaml) + { + var page = new Bz24910 (useCompiledXaml); + var control = page.control4; + Assert.AreEqual (3, Bz24910Control.GetAttachedNullableInt (control)); + } + + [TestCase(true), TestCase(false)] + public void AllowNonBindableNullable (bool useCompiledXaml) + { + var page = new Bz24910 (useCompiledXaml); + var control = page.control5; + + Assert.AreEqual (5, control.NullableIntProp); + } + } + } + + public class Bz24910Control : Button + { + public static readonly BindableProperty NullableIntProperty = + BindableProperty.Create ("NullableInt", typeof(int?), typeof(Bz24910Control), default(int?)); + + public int? NullableInt { + get { return (int?)GetValue (NullableIntProperty); } + set { SetValue (NullableIntProperty, value); } + } + + public static readonly BindableProperty NullableDoubleProperty = + BindableProperty.Create ("NullableDouble", typeof(double?), typeof(Bz24910Control), default(double?)); + + public double? NullableDouble { + get { return (double?)GetValue (NullableDoubleProperty); } + set { SetValue (NullableDoubleProperty, value); } + } + + public static readonly BindableProperty AttachedNullableIntProperty = + BindableProperty.CreateAttached<Bz24910Control, int?> (bindable => GetAttachedNullableInt (bindable), default(int?)); + + public static int? GetAttachedNullableInt (BindableObject bindable) + { + return (int?)bindable.GetValue (AttachedNullableIntProperty); + } + + public static void SetAttachedNullableInt (BindableObject bindable, int? value) + { + bindable.SetValue (AttachedNullableIntProperty, value); + } + + public int? NullableIntProp { get; set; } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27299.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27299.xaml new file mode 100644 index 00000000..fd149013 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27299.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" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz27299" + xmlns:local="clr-namespace:Xamarin.Forms.Xaml.UnitTests" + BindingContext="{Binding Bz27299, Source={StaticResource ViewModelLocator}}"> + <ContentPage.Resources> + <ResourceDictionary> + <local:Bz27299ViewModelLocator x:Key="ViewModelLocator" /> + </ResourceDictionary> + </ContentPage.Resources> + <Label x:Name="label" + Text="{Binding Text}" /> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27299.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27299.xaml.cs new file mode 100644 index 00000000..35211a1b --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27299.xaml.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class Bz27299ViewModel + { + public string Text { + get { return "Foo"; } + } + } + public class Bz27299ViewModelLocator + { + public static int Count { get; set; } + public object Bz27299 { + get { + Count++; + return new Bz27299ViewModel (); + } + } + } + + public partial class Bz27299 : ContentPage + { + public Bz27299 () + { + InitializeComponent (); + } + public Bz27299 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [SetUp] + public void SetUp () + { + Bz27299ViewModelLocator.Count = 0; + } + + [TestCase(true)] + [TestCase(false)] + public void ViewModelLocatorOnlyCalledOnce (bool useCompiledXaml) + { + Assert.AreEqual (0, Bz27299ViewModelLocator.Count); + var layout = new Bz27299 (useCompiledXaml); + Assert.AreEqual (1, Bz27299ViewModelLocator.Count); + Assert.AreEqual ("Foo", layout.label.Text); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27863.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27863.xaml new file mode 100644 index 00000000..962ede6d --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27863.xaml @@ -0,0 +1,20 @@ +<?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.Bz27863"> + <ContentPage.Resources> + <ResourceDictionary> + <local:ReverseConverter x:Key="reverseConverter"/> + <DataTemplate x:Key="SimpleMessageTemplate"> + <ViewCell> + <StackLayout > + <Label Text="{Binding Converter={StaticResource reverseConverter}}" /> + </StackLayout> + </ViewCell> + </DataTemplate> + <ListView x:Key="listview" + ItemTemplate="{StaticResource SimpleMessageTemplate}" /> + </ResourceDictionary> + </ContentPage.Resources> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27863.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27863.xaml.cs new file mode 100644 index 00000000..03ebaaf9 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27863.xaml.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz27863 : ContentPage + { + public Bz27863 () + { + InitializeComponent (); + } + + public Bz27863 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void DataTemplateInResourceDictionaries (bool useCompiledXaml) + { + var layout = new Bz27863 (useCompiledXaml); + var listview = layout.Resources ["listview"] as ListView; + Assert.NotNull (listview.ItemTemplate); + var template = listview.ItemTemplate; + var cell = template.CreateContent () as ViewCell; + cell.BindingContext = "Foo"; + Assert.AreEqual ("ooF", ((Label)((StackLayout)cell.View).Children [0]).Text); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27968.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27968.xaml new file mode 100644 index 00000000..98121ab3 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27968.xaml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<local:Bz27968Page 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.Bz27968"> + <ContentPage.Resources> + <ResourceDictionary> + <DataTemplate x:Key="template"> + <ViewCell /> + </DataTemplate> + <ListView x:Key="listView" ItemTemplate="{StaticResource template}" /> + </ResourceDictionary> + </ContentPage.Resources> +</local:Bz27968Page>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27968.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27968.xaml.cs new file mode 100644 index 00000000..2482e9f0 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz27968.xaml.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class Bz27968Page : ContentPage + { + } + + public partial class Bz27968 : Bz27968Page + { + public Bz27968 () + { + InitializeComponent (); + } + + public Bz27968 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void BaseClassIdentifiersAreValidForResources (bool useCompiledXaml) + { + var layout = new Bz27968 (useCompiledXaml); + Assert.That (layout.Resources ["listView"], Is.TypeOf<ListView> ()); + } + } + } +} diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28545.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28545.xaml new file mode 100644 index 00000000..66664011 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28545.xaml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz28545"> + <ContentPage.Resources> + <ResourceDictionary> + <Style x:Key="TitleLabel" TargetType="Label"> + <Setter Property="AbsoluteLayout.LayoutBounds" Value="1,1,AutoSize,AutoSize" /> + <Setter Property="AbsoluteLayout.LayoutFlags" Value="PositionProportional" /> + <Setter Property="TextColor" Value="Pink" /> + </Style> + </ResourceDictionary> + </ContentPage.Resources> + <AbsoluteLayout> + <Label x:Name="label" + Style="{StaticResource TitleLabel}" /> + </AbsoluteLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28545.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28545.xaml.cs new file mode 100644 index 00000000..794e7ce1 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28545.xaml.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz28545 : ContentPage + { + public Bz28545 () + { + InitializeComponent (); + } + + public Bz28545 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void TypeConverterAreAppliedForSettersToAttachedBP (bool useCompiledXaml) + { + var layout = new Bz28545 (useCompiledXaml); + Assert.AreEqual (Color.Pink, layout.label.TextColor); + Assert.AreEqual (AbsoluteLayoutFlags.PositionProportional, AbsoluteLayout.GetLayoutFlags (layout.label)); + Assert.AreEqual (new Rectangle (1, 1, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize), AbsoluteLayout.GetLayoutBounds (layout.label)); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28556.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28556.xaml new file mode 100644 index 00000000..4780ee23 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28556.xaml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz28556"> + <ContentPage.Resources> + <ResourceDictionary> + <Style TargetType="Entry"> + <Setter Property="TextColor" Value="Yellow" /> + <Setter Property="BackgroundColor" Value="Green" /> + <Style.Triggers> + <Trigger TargetType="Entry" Property="IsEnabled" Value="False"> + <Setter Property="TextColor" Value="Red" /> + <Setter Property="BackgroundColor" Value="Purple" /> + </Trigger> +<!-- <Trigger TargetType="Entry" Property="IsEnabled" Value="True"> + <Setter Property="TextColor" Value="Yellow" /> + <Setter Property="BackgroundColor" Value="Green" /> + </Trigger>--> + </Style.Triggers> + </Style> + </ResourceDictionary> + </ContentPage.Resources> + <StackLayout> + <Entry x:Name="entry" Text="Sample Text" /> + <Entry x:Name="disableEntry" Text="Sample Text" IsEnabled="false" /> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28556.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28556.xaml.cs new file mode 100644 index 00000000..dd5bb317 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28556.xaml.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz28556 : ContentPage + { + public Bz28556 () + { + InitializeComponent (); + } + + public Bz28556 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void SettersAppliedBeforeTriggers (bool useCompiledXaml) + { + var layout = new Bz28556 (useCompiledXaml); + + Assert.AreEqual (Color.Yellow, layout.entry.TextColor); + Assert.AreEqual (Color.Green, layout.entry.BackgroundColor); + + Assert.AreEqual (Color.Red, layout.disableEntry.TextColor); + Assert.AreEqual (Color.Purple, layout.disableEntry.BackgroundColor); + + layout.entry.IsEnabled = false; + layout.disableEntry.IsEnabled = true; + + Assert.AreEqual (Color.Yellow, layout.disableEntry.TextColor); + Assert.AreEqual (Color.Green, layout.disableEntry.BackgroundColor); + + Assert.AreEqual (Color.Red, layout.entry.TextColor); + Assert.AreEqual (Color.Purple, layout.entry.BackgroundColor); + + layout.entry.IsEnabled = true; + layout.disableEntry.IsEnabled = false; + + Assert.AreEqual (Color.Yellow, layout.entry.TextColor); + Assert.AreEqual (Color.Green, layout.entry.BackgroundColor); + + Assert.AreEqual (Color.Red, layout.disableEntry.TextColor); + Assert.AreEqual (Color.Purple, layout.disableEntry.BackgroundColor); + } + } + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28689.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28689.xaml new file mode 100644 index 00000000..e2d10dab --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28689.xaml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz28689"> + <ContentPage.Resources> + <ResourceDictionary> + <x:Array x:Key="stringArray" Type="{x:Type x:String}"> + <x:String>Test1</x:String> + <x:String>Test2</x:String> + </x:Array> + </ResourceDictionary> + </ContentPage.Resources> +</ContentPage> diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28689.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28689.xaml.cs new file mode 100644 index 00000000..41a8280c --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28689.xaml.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz28689 : ContentPage + { + public Bz28689 () + { + InitializeComponent (); + } + + public Bz28689 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void XArrayInResources (bool useCompiledXaml) + { + var layout = new Bz28689 (useCompiledXaml); + var array = layout.Resources ["stringArray"]; + Assert.That (array, Is.TypeOf<string[]> ()); + var stringarray = (string[])array; + Assert.AreEqual (2, stringarray.Length); + Assert.AreEqual ("Test1", stringarray [0]); + Assert.AreEqual ("Test2", stringarray [1]); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28719.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28719.xaml new file mode 100644 index 00000000..54a8b9a0 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28719.xaml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz28719"> + <ListView x:Name="listView"> + <ListView.ItemTemplate> + <DataTemplate> + <ViewCell> + <Image Grid.Row="0" Grid.Column="0"> + <Image.Triggers> + <DataTrigger TargetType="Image" Binding="{Binding IsSelected}" Value="False"> + <Setter Property="Source" Value="Add.png" /> + </DataTrigger> + <DataTrigger TargetType="Image" Binding="{Binding IsSelected}" Value="True"> + <Setter Property="Source" Value="Remove.png" /> + </DataTrigger> + </Image.Triggers> + </Image> + </ViewCell> + </DataTemplate> + </ListView.ItemTemplate> + </ListView> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28719.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28719.xaml.cs new file mode 100644 index 00000000..5cd1f9cb --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz28719.xaml.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz28719 : ContentPage + { + public Bz28719 () + { + InitializeComponent (); + } + + public Bz28719 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void DataTriggerInTemplates (bool useCompiledXaml) + { + var layout = new Bz28719 (useCompiledXaml); + var template = layout.listView.ItemTemplate; + Assert.NotNull (template); + var cell0 = template.CreateContent () as ViewCell; + Assert.NotNull (cell0); + var image0 = cell0.View as Image; + Assert.NotNull (image0); + + cell0.BindingContext = new {IsSelected = true}; + Assert.AreEqual ("Remove.png", (image0.Source as FileImageSource).File); + + cell0.BindingContext = new {IsSelected = false}; + Assert.AreEqual ("Add.png", (image0.Source as FileImageSource).File); + + var cell1 = template.CreateContent () as ViewCell; + Assert.NotNull (cell1); + var image1 = cell1.View as Image; + Assert.NotNull (image1); + + cell1.BindingContext = new {IsSelected = true}; + Assert.AreEqual ("Remove.png", (image1.Source as FileImageSource).File); + + cell1.BindingContext = new {IsSelected = false}; + Assert.AreEqual ("Add.png", (image1.Source as FileImageSource).File); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz29300.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz29300.xaml new file mode 100644 index 00000000..39b961dc --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz29300.xaml @@ -0,0 +1,9 @@ +<?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.Bz29300"> + <local:Bz29300DummyView x:Name="dummy" + Text="Test" + NumOfRepeat="4" /> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz29300.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz29300.xaml.cs new file mode 100644 index 00000000..3548fc14 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz29300.xaml.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class Bz29300DummyView : StackLayout + { + public static readonly BindableProperty NumOfRepeatProperty = + BindableProperty.Create<Bz29300DummyView, int> (p => p.NumOfRepeat, 1, BindingMode.OneWay, null, UpdateTexts); + + public static readonly BindableProperty TextProperty = + BindableProperty.Create<Bz29300DummyView, string> (p => p.Text, string.Empty, BindingMode.OneWay, null, UpdateTexts); + + public int NumOfRepeat + { + get { return (int)GetValue(NumOfRepeatProperty); } + set { SetValue(NumOfRepeatProperty, value); } + } + + public string Text + { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + + public Bz29300DummyView() + { + } + + static void UpdateTexts(BindableObject bindable, string oldValue, string newValue) + { + var instance = bindable as Bz29300DummyView; + instance.Children.Clear(); + for (int i = 0; i < instance.NumOfRepeat; i++) + instance.Children.Add(new Label() {Text = newValue }); + } + + static void UpdateTexts(BindableObject bindable, int oldValue, int newValue) + { + var instance = bindable as Bz29300DummyView; + if (oldValue == newValue) + return; + if (oldValue > newValue) { + for (int i = newValue; i > oldValue; i--) + instance.Children.RemoveAt(0); + } else { + for (int i = oldValue; i < newValue; i++) + instance.Children.Add(new Label() { Text = instance.Text }); + } + } + } + + public partial class Bz29300 : ContentPage + { + public Bz29300 () + { + InitializeComponent (); + } + + public Bz29300 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void AccessUserDefinedBindableProperties (bool useCompiledXaml) + { + var layout = new Bz29300 (useCompiledXaml); + Assert.AreEqual (4, layout.dummy.NumOfRepeat); + Assert.AreEqual ("Test", layout.dummy.Text); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz30074.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz30074.xaml new file mode 100644 index 00000000..85604a82 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz30074.xaml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz30074"> + <Image x:Name="image"> + <Image.Triggers> + <DataTrigger TargetType="Image" Binding="{Binding IsSelected}" Value="True"> + <Setter Property="Source" Value="Add.png" /> + </DataTrigger> + </Image.Triggers> + </Image> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz30074.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz30074.xaml.cs new file mode 100644 index 00000000..e1c60feb --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz30074.xaml.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz30074 : ContentPage + { + public Bz30074 () + { + InitializeComponent (); + } + + public Bz30074 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void DataTriggerInTemplates (bool useCompiledXaml) + { + var layout = new Bz30074 (useCompiledXaml); + Assert.Null (layout.image.Source); + + layout.BindingContext = new {IsSelected = true}; + Assert.AreEqual ("Add.png", ((FileImageSource)layout.image.Source).File); + + layout.BindingContext = new {IsSelected = false}; + Assert.Null (layout.image.Source); + } + } + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz30684.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz30684.xaml new file mode 100644 index 00000000..0dff72c2 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz30684.xaml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz30684"> + <StackLayout> + <Label Text="Foo" x:Name="foo" /> + <ListView x:Name="listView"> + <ListView.ItemTemplate> + <DataTemplate> + <TextCell Text="{Binding Text, Source={x:Reference foo}}" /> + </DataTemplate> + </ListView.ItemTemplate> + </ListView> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz30684.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz30684.xaml.cs new file mode 100644 index 00000000..2b0ca827 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz30684.xaml.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz30684 : ContentPage + { + public Bz30684 () + { + InitializeComponent (); + } + + public Bz30684 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void XReferenceFindObjectsInParentNamescopes (bool useCompiledXaml) + { + var layout = new Bz30684 (useCompiledXaml); + var cell = (TextCell)layout.listView.TemplatedItems.GetOrCreateContent (0, null); + Assert.AreEqual ("Foo", cell.Text); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31234/A/Bz31234.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31234/A/Bz31234.xaml new file mode 100644 index 00000000..57f780a6 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31234/A/Bz31234.xaml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.A.Bz31234"> + <ContentPage.Content> + </ContentPage.Content> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31234/A/Bz31234.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31234/A/Bz31234.xaml.cs new file mode 100644 index 00000000..a2c1a62c --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31234/A/Bz31234.xaml.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests.A +{ + public partial class Bz31234 : ContentPage + { + public Bz31234 () + { + InitializeComponent (); + } + + public Bz31234 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase(true), TestCase(false)] + public void ShouldPass (bool useCompiledXaml) + { + new Bz31234 (useCompiledXaml); + Assert.Pass (); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31234/B/Bz31234.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31234/B/Bz31234.xaml new file mode 100644 index 00000000..4be6af22 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31234/B/Bz31234.xaml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.B.Bz31234"> + <ContentPage.Content> + </ContentPage.Content> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31234/B/Bz31234.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31234/B/Bz31234.xaml.cs new file mode 100644 index 00000000..b7b12be8 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31234/B/Bz31234.xaml.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +namespace Xamarin.Forms.Xaml.UnitTests.B +{ + public partial class Bz31234 : ContentPage + { + public Bz31234 () + { + InitializeComponent (); + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31529.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31529.xaml new file mode 100644 index 00000000..ebe69f8c --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31529.xaml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz31529"> + <StackLayout> + <Label x:Name="label" Text="Foo" /> + <Button x:Name="button" + CommandParameter = "{Binding Text, Source= {x:Reference label}}" /> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31529.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31529.xaml.cs new file mode 100644 index 00000000..7edf9ad2 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz31529.xaml.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz31529 : ContentPage + { + public Bz31529 () + { + InitializeComponent (); + } + public Bz31529 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void AllowWhiteSpacesInMarkups (bool useCompiledXaml) + { + var layout = new Bz31529 (useCompiledXaml); + Assert.AreEqual ("Foo", layout.button.CommandParameter); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz34037.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz34037.xaml new file mode 100644 index 00000000..b5c36482 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz34037.xaml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz34037" + xmlns:local="clr-namespace:Xamarin.Forms.Xaml.UnitTests" + x:Name="PageRoot"> + <ContentPage.Resources> + <ResourceDictionary> + <local:Bz34037Converter0 x:Key="MyConverter0" /> + <local:Bz34037Converter1 x:Key="MyConverter1" /> + </ResourceDictionary> + </ContentPage.Resources> + <StackLayout> + <Switch x:Name="s0"> + <Switch.Triggers> + <MultiTrigger TargetType="Switch"> + <MultiTrigger.Conditions> + <BindingCondition Value="True" + Binding="{Binding Property, Source={x:Reference PageRoot}, Converter={local:Bz34037Converter0}, ConverterParameter={x:Type x:String}}" /> + </MultiTrigger.Conditions> + <Setter Property="Switch.IsToggled" Value="True" /> + </MultiTrigger> + </Switch.Triggers> + </Switch> + <Switch x:Name="s1"> + <Switch.Triggers> + <MultiTrigger TargetType="Switch"> + <MultiTrigger.Conditions> + <BindingCondition Value="True" + Binding="{Binding Property, ConverterParameter={x:Type x:String}, Source={x:Reference PageRoot}, Converter={local:Bz34037Converter1}}" /> + </MultiTrigger.Conditions> + <Setter Property="Switch.IsToggled" Value="True" /> + </MultiTrigger> + </Switch.Triggers> + </Switch> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz34037.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz34037.xaml.cs new file mode 100644 index 00000000..ee300cb0 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz34037.xaml.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class Bz34037Converter0 : IValueConverter, IMarkupExtension + { + public static int Invoked { get; set; } + public static object Parameter { get; set; } + public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + Invoked++; + Parameter = parameter; + return true; + } + + public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException (); + } + + public object ProvideValue (IServiceProvider serviceProvider) + { + return new Bz34037Converter0 (); + } + } + + public class Bz34037Converter1 : IValueConverter, IMarkupExtension + { + public static int Invoked { get; set; } + public static object Parameter { get; set; } + public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + Invoked++; + Parameter = parameter; + return true; + } + + public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException (); + } + + public object ProvideValue (IServiceProvider serviceProvider) + { + return new Bz34037Converter1 (); + } + } + + public partial class Bz34037 : ContentPage + { + public Bz34037 () + { + InitializeComponent (); + } + + public string Property { + get { return "FooBar"; } + } + + public Bz34037 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [SetUp] + public void Setup () + { + Bz34037Converter0.Invoked = 0; + Bz34037Converter1.Invoked = 0; + } + + [TestCase(true)] + [TestCase(false)] + public void ConverterParameterOrderDoesNotMatters (bool useCompiledXaml) + { + var layout = new Bz34037 (useCompiledXaml); + Assert.AreEqual (2, Bz34037Converter0.Invoked); +// Assert.AreEqual (2, Bz34037Converter1.Invoked); + Assert.AreEqual (typeof(string), Bz34037Converter0.Parameter); +// Assert.AreEqual (typeof(string), Bz34037Converter1.Parameter); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz36422.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz36422.xaml new file mode 100644 index 00000000..4a467eab --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz36422.xaml @@ -0,0 +1,21 @@ +<?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.Bz36422"> + <local:Bz36422Control x:Name="control"> + <local:Bz36422Control.Views> + <x:Array Type="{x:Type ContentView}"> + <ContentView> + <Label Text="Page 1"/> + </ContentView> + <ContentView> + <Label Text="Page 2"/> + </ContentView> + <ContentView> + <Label Text="Page 3"/> + </ContentView> + </x:Array> + </local:Bz36422Control.Views> + </local:Bz36422Control> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz36422.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz36422.xaml.cs new file mode 100644 index 00000000..4728068f --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz36422.xaml.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class Bz36422Control : ContentView + { + public IList<ContentView> Views { get; set; } + } + + public partial class Bz36422 : ContentPage + { + public Bz36422 () + { + InitializeComponent (); + } + + public Bz36422 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void xArrayCanBeAssignedToIListT (bool useCompiledXaml) + { + var layout = new Bz36422 (useCompiledXaml); + Assert.AreEqual (3, layout.control.Views.Count); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz37306.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz37306.xaml new file mode 100644 index 00000000..bfd5b732 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz37306.xaml @@ -0,0 +1,12 @@ +<?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:sys="clr-namespace:System;assembly=mscorlib" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz37306"> + <ContentPage.Resources> + <ResourceDictionary> + <x:String x:Key="AppName">Mobile App</x:String> + <sys:String x:Key="ApplicationName">Mobile App</sys:String> + </ResourceDictionary> + </ContentPage.Resources> +</ContentPage> diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz37306.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz37306.xaml.cs new file mode 100644 index 00000000..6e0d39e2 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz37306.xaml.cs @@ -0,0 +1,31 @@ +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz37306 : ContentPage + { + public Bz37306 () + { + InitializeComponent (); + } + + public Bz37306 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void xStringInResourcesDictionaries (bool useCompiledXaml) + { + var layout = new Bz37306 (useCompiledXaml); + Assert.AreEqual ("Mobile App", layout.Resources ["AppName"]); + Assert.AreEqual ("Mobile App", layout.Resources ["ApplicationName"]); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz37524.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz37524.xaml new file mode 100644 index 00000000..df2736a8 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz37524.xaml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz37524"> + <StackLayout> + <Entry x:Name="TheEntry" + Text="This simulates an error" + TextColor="Red"/> + <Button x:Name="TheButton" + Text="Should be disabled"> + <Button.Triggers> + <MultiTrigger TargetType="Button"> + <MultiTrigger.Conditions> + <BindingCondition Binding="{Binding Source={x:Reference TheEntry}, Path=TextColor}" + Value="Red" /> + </MultiTrigger.Conditions> + <Setter Property="IsEnabled" Value="False" /> + </MultiTrigger> + </Button.Triggers> + </Button> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz37524.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz37524.xaml.cs new file mode 100644 index 00000000..d979755d --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz37524.xaml.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz37524 : ContentPage + { + public Bz37524 () + { + InitializeComponent (); + } + + public Bz37524 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void MultiTriggerConditionNotApplied (bool useCompiledXaml) + { + var layout = new Bz37524 (useCompiledXaml); + Assert.AreEqual (false, layout.TheButton.IsEnabled); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/GrialIssue01.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/GrialIssue01.xaml new file mode 100644 index 00000000..ea92c61e --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/GrialIssue01.xaml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.GrialIssue01"> + <ContentPage.Resources> + <ResourceDictionary> + <FileImageSource x:Key="image">path.png</FileImageSource> + </ResourceDictionary> + </ContentPage.Resources> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/GrialIssue01.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/GrialIssue01.xaml.cs new file mode 100644 index 00000000..7cf20f42 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/GrialIssue01.xaml.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class GrialIssue01 : ContentPage + { + public GrialIssue01 () + { + InitializeComponent (); + } + + public GrialIssue01 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void ImplicitCastIsUsedOnFileImageSource (bool useCompiledXaml) + { + var layout = new GrialIssue01 (useCompiledXaml); + var res = (FileImageSource)layout.Resources ["image"]; + + Assert.AreEqual ("path.png", res.File); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/GrialIssue02.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/GrialIssue02.xaml new file mode 100644 index 00000000..d623607b --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/GrialIssue02.xaml @@ -0,0 +1,18 @@ +<?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.GrialIssue02"> + <ContentPage.Resources> + <ResourceDictionary> + <local:GrialIssue02Converter x:Key="converter"> + <local:GrialIssue02Converter.TrueValue> + <FontAttributes>None</FontAttributes> + </local:GrialIssue02Converter.TrueValue> + <local:GrialIssue02Converter.FalseValue> + <FontAttributes>Bold</FontAttributes> + </local:GrialIssue02Converter.FalseValue> + </local:GrialIssue02Converter> + </ResourceDictionary> + </ContentPage.Resources> +</ContentPage> diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/GrialIssue02.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/GrialIssue02.xaml.cs new file mode 100644 index 00000000..ca239af7 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/GrialIssue02.xaml.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using System.Globalization; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class GrialIssue02Converter : IValueConverter + { + public object FalseValue { + get; + set; + } + + public object TrueValue { + get; + set; + } + + public object Convert (object value, Type targetType, object parameter, CultureInfo culture) + { + if (!(value is bool)) { + return null; + } + bool flag = (bool)value; + return (!flag) ? FalseValue : TrueValue; + } + + public object ConvertBack (object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException (); + } + } + + public partial class GrialIssue02 : ContentPage + { + public GrialIssue02 () + { + InitializeComponent (); + } + public GrialIssue02 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void BoxValueTypes (bool useCompiledXaml) + { + var layout = new GrialIssue02 (useCompiledXaml); + var res = (GrialIssue02Converter)layout.Resources ["converter"]; + + Assert.AreEqual (FontAttributes.None, res.TrueValue); + Assert.AreEqual (FontAttributes.Bold, res.FalseValue); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1199.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1199.xaml new file mode 100644 index 00000000..7d6abe90 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1199.xaml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue1199"> +<ContentPage.Resources> + <ResourceDictionary> + <Color x:Key="AlmostSilver">#FFCCCCCC</Color> + </ResourceDictionary> + </ContentPage.Resources> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1199.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1199.xaml.cs new file mode 100644 index 00000000..18ae8731 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1199.xaml.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue1199 : ContentPage + { + public Issue1199 () + { + InitializeComponent (); + } + + public Issue1199 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + public void AllowCreationOfTypesFromString (bool useCompiledXaml) + { + var layout = new Issue1199 (useCompiledXaml); + var res = (Color)layout.Resources ["AlmostSilver"]; + + Assert.AreEqual (Color.FromHex ("#FFCCCCCC"), res); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1213.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1213.xaml new file mode 100644 index 00000000..ec149423 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1213.xaml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue1213"> + <ContentPage Title="page 1"> + <Label Text="page 1" + VerticalOptions = "LayoutOptions.CenterAndExpand" + HorizontalOptions = "LayoutOptions.CenterAndExpand"/> + </ContentPage> + <ContentPage Title="page 2"> + <Label Text="page 2" + VerticalOptions = "LayoutOptions.CenterAndExpand" + HorizontalOptions = "LayoutOptions.CenterAndExpand"/> + </ContentPage> +</TabbedPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1213.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1213.xaml.cs new file mode 100644 index 00000000..d89203b7 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1213.xaml.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue1213 : TabbedPage + { + public Issue1213 () + { + InitializeComponent (); + } + + public Issue1213 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase(false)] + [TestCase(true)] + public void MultiPageAsContentPropertyAttribute (bool useCompiledXaml) + { + var page = new Issue1213 (useCompiledXaml); + Assert.AreEqual (2, page.Children.Count); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1250.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1250.xaml new file mode 100644 index 00000000..ad06901c --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1250.xaml @@ -0,0 +1,13 @@ +<?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;assembly=Xamarin.Forms.Xaml.UnitTests" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue1250"> + <StackLayout x:Name="stack"> + <Label Text="{Binding Header}" /> + <local:Issue1250AspectRatioContainer AspectRatio="0.5"> + <Image Source="{Binding Image}" Aspect="Fill" /> + </local:Issue1250AspectRatioContainer> + <Label Text="{Binding Footer}" /> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1250.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1250.xaml.cs new file mode 100644 index 00000000..8f4cdb7d --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1250.xaml.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class Issue1250AspectRatioContainer : ContentView + { + protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint) + { + return new SizeRequest(new Size(widthConstraint, widthConstraint * AspectRatio)); + } + + public double AspectRatio { get; set; } + } + + public partial class Issue1250 : ContentPage + { + public Issue1250 () + { + InitializeComponent (); + } + + public Issue1250 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase (false)] + [TestCase (true)] + public void AddCustomElementInCollection (bool useCompiledXaml) + { + var page = new Issue1250 (useCompiledXaml); + var stack = page.stack; + + Assert.AreEqual (3, stack.Children.Count); + Assert.That (stack.Children [0], Is.TypeOf<Label> ()); + Assert.That (stack.Children [1], Is.TypeOf<Issue1250AspectRatioContainer> ()); + Assert.That (stack.Children [2], Is.TypeOf<Label> ()); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1306.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1306.xaml new file mode 100644 index 00000000..e77a2d95 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1306.xaml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ListView xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue1306" + GroupDisplayBinding="{Binding Key}" + GroupShortNameBinding="{Binding Key}"/>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1306.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1306.xaml.cs new file mode 100644 index 00000000..582ce102 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1306.xaml.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue1306 : ListView + { + public Issue1306 () + { + InitializeComponent (); + } + + public Issue1306 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase (false)] + [TestCase (true)] + public void AssignBindingMarkupToBindingBase (bool useCompiledXaml) + { + var listView = new Issue1306 (useCompiledXaml); + + Assert.NotNull (listView.GroupDisplayBinding); + Assert.NotNull (listView.GroupShortNameBinding); + Assert.That (listView.GroupDisplayBinding, Is.TypeOf<Binding> ()); + Assert.That (listView.GroupShortNameBinding, Is.TypeOf<Binding> ()); + Assert.AreEqual ("Key", (listView.GroupDisplayBinding as Binding).Path); + Assert.AreEqual ("Key", (listView.GroupShortNameBinding as Binding).Path); + } + } + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1415.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1415.xaml new file mode 100644 index 00000000..148704ea --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1415.xaml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue1415" + xmlns:local="clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests"> + <Label x:Name="label" Text="{Binding Converter={x:Static local:ReverseConverter.Instance}, Mode=TwoWay}"/> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1415.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1415.xaml.cs new file mode 100644 index 00000000..b23fdb92 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1415.xaml.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue1415 : ContentPage + { + public Issue1415 () + { + InitializeComponent (); + } + + public Issue1415 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase (false)] + [TestCase (true)] + public void NestedMarkupExtension (bool useCompiledXaml) + { + var page = new Issue1415 (useCompiledXaml); + var label = page.FindByName<Label> ("label"); + Assert.NotNull (label); + label.BindingContext = "foo"; + Assert.AreEqual ("oof", label.Text); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1438.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1438.xaml new file mode 100644 index 00000000..f31c52ab --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1438.xaml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue1438"> + <StackLayout> + <Label BindingContext="{x:Reference slider}" + x:Name="label" + Text="{Binding Value, StringFormat='Slider value is {0:F3}'}" + Font="Large" + HorizontalOptions="Center" + VerticalOptions="CenterAndExpand" /> + <Slider x:Name="slider" + VerticalOptions="CenterAndExpand" /> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1438.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1438.xaml.cs new file mode 100644 index 00000000..26ee3d0b --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1438.xaml.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; +using System.Diagnostics; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue1438 : ContentPage + { + public Issue1438 () + { + InitializeComponent (); + } + + public Issue1438 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [SetUp] + public void Setup () + { + Device.PlatformServices = new MockPlatformServices (); + } + + [TestCase (false)] + [TestCase (true)] + public void XNameForwardDeclaration (bool useCompiledXaml) + { + var page = new Issue1438 (useCompiledXaml); + + var slider = page.FindByName<Slider> ("slider"); + var label = page.FindByName<Label> ("label"); + Assert.AreSame (slider, label.BindingContext); + Assert.That (slider.Parent, Is.TypeOf<StackLayout> ()); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1493.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1493.cs new file mode 100644 index 00000000..41f00ab8 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1493.cs @@ -0,0 +1,26 @@ +using System; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + [TestFixture] + public class Issue1493 + { + [Test] + //mostly happens in european cultures + [SetCulture ("fr-FR")] + public void CultureInvariantNumberParsing () + { + var xaml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> + <View + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" + RelativeLayout.HeightConstraint=""{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.25}"" + RelativeLayout.WidthConstraint=""{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.6}""/>"; + View view = new View (); + view.LoadFromXaml (xaml); + Assert.DoesNotThrow (() => view.LoadFromXaml (xaml)); + } + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1497.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1497.cs new file mode 100644 index 00000000..3813f73a --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1497.cs @@ -0,0 +1,27 @@ +using System; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + [TestFixture] + public class Issue1497 + { + [Test] + public void BPCollectionsWithSingleElement () + { + var xaml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> + <Grid + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""> + <Grid.ColumnDefinitions> + <ColumnDefinition Width=""*""/> + </Grid.ColumnDefinitions> + </Grid>"; + + var grid = new Grid ().LoadFromXaml (xaml); + Assert.AreEqual (1, grid.ColumnDefinitions.Count); + Assert.True (grid.ColumnDefinitions [0].Width.IsStar); + } + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1501.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1501.cs new file mode 100644 index 00000000..d4a5e761 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1501.cs @@ -0,0 +1,41 @@ +using System; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class BoxView1501 : BoxView + { + public bool Fired { get; set;} + + public void OnBoxViewTapped (object sender, EventArgs e) + { + Fired = true; + } + } + + [TestFixture] + public class Issue1501 + { + [Test] + public void ConnectEventsInGestureRecognizers () + { + var xaml = @" + <BoxView + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" + x:Class=""Xamarin.Forms.Xaml.UnitTests.BoxView1501"" > + <BoxView.GestureRecognizers> + <TapGestureRecognizer Tapped=""OnBoxViewTapped"" /> + </BoxView.GestureRecognizers> + </BoxView>"; + + BoxView1501 layout = null; + Assert.DoesNotThrow (() => {layout = new BoxView1501 ().LoadFromXaml (xaml);}); + + Assert.False (layout.Fired); + var tgr = layout.GestureRecognizers [0] as TapGestureRecognizer; + tgr.SendTapped (layout); + Assert.True (layout.Fired); + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1545.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1545.cs new file mode 100644 index 00000000..00747db4 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1545.cs @@ -0,0 +1,174 @@ +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + [TestFixture] + public class Issue1545 + { + [Test] + public void BindingCanNotBeReused() + { + string xaml = @"<ContentPage xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" + x:Class=""Xamarin.Forms.Controls.Issue1545""> + <ListView x:Name=""List"" ItemsSource=""{Binding}""> + <ListView.ItemTemplate> + <DataTemplate> + <TextCell Text=""{Binding}"" /> + </DataTemplate> + </ListView.ItemTemplate> + </ListView> + </ContentPage>"; + + ContentPage page = new ContentPage().LoadFromXaml (xaml); + + var items = new[] { "Fu", "Bar" }; + page.BindingContext = items; + + ListView lv = page.FindByName<ListView> ("List"); + + TextCell cell = (TextCell)lv.TemplatedItems.GetOrCreateContent (0, items[0]); + Assert.That (cell.Text, Is.EqualTo ("Fu")); + + cell = (TextCell)lv.TemplatedItems.GetOrCreateContent (1, items[1]); + Assert.That (cell.Text, Is.EqualTo ("Bar")); + } + + [Test] + public void ElementsCanNotBeReused() + { + string xaml = @"<ContentPage xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" + x:Class=""Xamarin.Forms.Controls.Issue1545""> + <ContentPage.Resources> + <ResourceDictionary> + <Color x:Key=""color"">#ff00aa</Color> + </ResourceDictionary> + </ContentPage.Resources> + + <ListView x:Name=""List"" ItemsSource=""{Binding}""> + <ListView.ItemTemplate> + <DataTemplate> + <ViewCell> + <StackLayout> + <Label Text=""{Binding}"" BackgroundColor=""{StaticResource color}""/> + </StackLayout> + </ViewCell> + </DataTemplate> + </ListView.ItemTemplate> + </ListView> + </ContentPage>"; + + ContentPage page = new ContentPage().LoadFromXaml (xaml); + + var items = new[] { "Fu", "Bar" }; + page.BindingContext = items; + + ListView lv = page.FindByName<ListView> ("List"); + + ViewCell cell0 = (ViewCell)lv.TemplatedItems.GetOrCreateContent (0, items[0]); + + + Assert.That (((Label)((StackLayout)cell0.View).Children[0]).Text, Is.EqualTo ("Fu")); + + ViewCell cell1 = (ViewCell)lv.TemplatedItems.GetOrCreateContent (1, items[1]); + Assert.That (((Label)((StackLayout)cell1.View).Children[0]).Text, Is.EqualTo ("Bar")); + + Assert.AreNotSame (cell0, cell1); + Assert.AreNotSame (cell0.View, cell1.View); + Assert.AreNotSame (((StackLayout)cell0.View).Children [0], ((StackLayout)cell1.View).Children [0]); + Assert.AreEqual (Color.FromHex ("ff00aa"), ((StackLayout)cell1.View).Children [0].BackgroundColor); + } + + [Test] + public void ElementsFromCollectionsAreNotReused () + { + var xaml = @"<ListView + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" + xmlns:local=""clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests"" + ItemsSource=""{Binding}""> + <ListView.ItemTemplate> + <DataTemplate> + <local:ViewCellWithCollection> + <local:ViewCellWithCollection.Children> + <local:ViewList> + <Label /> + <Label /> + </local:ViewList> + </local:ViewCellWithCollection.Children> + </local:ViewCellWithCollection> + </DataTemplate> + </ListView.ItemTemplate> + </ListView>"; + + var listview = new ListView (); + var items = new [] { "Foo", "Bar", "Baz" }; + listview.BindingContext = items; + listview.LoadFromXaml (xaml); + var cell0 = (ViewCellWithCollection)listview.TemplatedItems.GetOrCreateContent (0, items[0]); + var cell1 = (ViewCellWithCollection)listview.TemplatedItems.GetOrCreateContent (1, items[1]); + + Assert.AreNotSame (cell0, cell1); + Assert.AreNotSame (cell0.Children, cell1.Children); + Assert.AreNotSame (cell0.Children[0], cell1.Children[0]); + + } + + [Test] + public void ResourcesDeclaredInDataTemplatesAreNotShared () + { + var xaml = @"<ListView + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" + xmlns:sys=""clr-namespace:System;assembly=mscorlib"" + ItemsSource=""{Binding}""> + <ListView.ItemTemplate> + <DataTemplate> + <ViewCell> + <Label Text=""{Binding}""> + <Label.Resources> + <ResourceDictionary> + <sys:Object x:Key=""object""/> + </ResourceDictionary> + </Label.Resources> + </Label> + </ViewCell> + </DataTemplate> + </ListView.ItemTemplate> + </ListView>"; + + var listview = new ListView (); + var items = new [] { "Foo", "Bar", "Baz" }; + listview.BindingContext = items; + + listview.LoadFromXaml (xaml); + var cell0 = (ViewCell)listview.TemplatedItems.GetOrCreateContent (0, items[0]); + var cell1 = (ViewCell)listview.TemplatedItems.GetOrCreateContent (1, items[1]); + Assert.AreNotSame (cell0, cell1); + + var label0 = (Label)cell0.View; + var label1 = (Label)cell1.View; + Assert.AreNotSame (label0, label1); + Assert.AreEqual ("Foo", label0.Text); + Assert.AreEqual ("Bar", label1.Text); + + var res0 = label0.Resources; + var res1 = label1.Resources; + Assert.AreNotSame (res0, res1); + + var obj0 = res0 ["object"]; + var obj1 = res1 ["object"]; + + Assert.NotNull (obj0); + Assert.NotNull (obj1); + + Assert.AreNotSame (obj0, obj1); + } + } + + public class ViewCellWithCollection : ViewCell + { + public ViewList Children { get; set; } + } +} diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1549.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1549.cs new file mode 100644 index 00000000..c1253040 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1549.cs @@ -0,0 +1,166 @@ +using System; +using NUnit.Framework; +using System.Collections.ObjectModel; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + + public class SeverityColorConverter : IValueConverter + { + + public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + count++; + return Color.Blue; + } + + public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException (); + } + + + public static int count=0; + } + + public class InvertBoolenConverter : IValueConverter + { + public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + count++; + if (value is bool) { + + return !(bool)value; + } + return value; + } + + public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException (); + } + public static int count=0; + } + + public class Item + { + public bool IsLocked { + get; + set; + } + } + + [TestFixture] + public class Issue1549 + { + [SetUp] + public void Setup () + { + SeverityColorConverter.count = 0; + InvertBoolenConverter.count = 0; + } + + [Test] + public void ConverterIsInvoked () + { + var xaml = @" +<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;assembly=Xamarin.Forms.Xaml.UnitTests""> + +<ContentPage.Resources> +<ResourceDictionary> +<local:SeverityColorConverter x:Key=""SeverityColorConverter"" /> +</ResourceDictionary> +</ContentPage.Resources> + <Label Text=""{Binding value, StringFormat='{0}'}"" + WidthRequest=""50"" + TextColor=""Black"" + x:Name=""label"" + BackgroundColor=""{Binding Severity, Converter={StaticResource SeverityColorConverter}}"" + XAlign=""Center"" YAlign=""Center""/> +</ContentPage>"; + + var layout = new ContentPage ().LoadFromXaml (xaml); + layout.BindingContext = new {Value = "Foo", Severity = "Bar"}; + var label = layout.FindByName<Label> ("label"); + Assert.AreEqual (Color.Blue, label.BackgroundColor); + Assert.AreEqual (1, SeverityColorConverter.count); + } + + [Test] + public void ResourcesInNonXFBaseClassesAreFound () + { + var xaml = @"<local:BaseView + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" + xmlns:local=""clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests"" + Padding=""0,40,0,0""> + <local:BaseView.Resources> + <ResourceDictionary> + <local:InvertBoolenConverter x:Key=""cnvInvert""></local:InvertBoolenConverter> + </ResourceDictionary> + </local:BaseView.Resources> + <local:BaseView.Content> + <ListView x:Name=""lst"" VerticalOptions=""FillAndExpand"" + HorizontalOptions=""FillAndExpand"" + + ItemsSource=""{Binding Items}"" + + > + <ListView.ItemTemplate > + <DataTemplate> + <ViewCell > + <ViewCell.View> + <Grid VerticalOptions=""FillAndExpand"" HorizontalOptions=""FillAndExpand"" > + <Label IsVisible=""{Binding IsLocked}"" Text=""Show Is Locked"" /> + <Label IsVisible=""{Binding IsLocked, Converter={StaticResource cnvInvert}}"" Text=""Show Is Not locked"" /> + </Grid> + </ViewCell.View> + </ViewCell> + </DataTemplate> + </ListView.ItemTemplate> + </ListView> + </local:BaseView.Content> +</local:BaseView>"; + var page = new Issue1549Page ().LoadFromXaml (xaml); + var lst = page.FindByName<ListView> ("lst"); + ObservableCollection<Item> items; + lst.BindingContext = new { + Items = items = new ObservableCollection<Item> { + new Item { IsLocked = true}, + new Item { IsLocked = false}, + new Item { IsLocked = true}, + new Item { IsLocked = true}, + }, + }; + + var cell0 = (ViewCell)lst.TemplatedItems.GetOrCreateContent (0, items [0]); + var cell1 = (ViewCell)lst.TemplatedItems.GetOrCreateContent (1, items [1]); + var cell2 = (ViewCell)lst.TemplatedItems.GetOrCreateContent (2, items [2]); + var cell3 = (ViewCell)lst.TemplatedItems.GetOrCreateContent (3, items [3]); + + var label00 = (cell0.View as Grid).Children [0] as Label; + var label01 = (cell0.View as Grid).Children [1] as Label; + + Assert.AreEqual ("Show Is Locked", label00.Text); + Assert.AreEqual ("Show Is Not locked", label01.Text); + + Assert.AreEqual (true, label00.IsVisible); + Assert.AreEqual (false, label01.IsVisible); + + Assert.AreEqual (4, InvertBoolenConverter.count); + + } + } + + public class BaseView : ContentPage + { + } + + public partial class Issue1549Page : BaseView + { + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1554.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1554.cs new file mode 100644 index 00000000..2e7bfa91 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1554.cs @@ -0,0 +1,53 @@ +using System; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + [TestFixture] + public class Issue1554 + { + [Test] + public void CollectionItemsInDataTemplate () + { + var xaml = @"<?xml version=""1.0"" encoding=""UTF-8""?> + <ListView + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" + ItemsSource=""{Binding}""> + <ListView.ItemTemplate> + <DataTemplate> + <ViewCell> + <ViewCell.View> + <StackLayout> + <Label Text=""{Binding}""></Label> + <Label Text=""{Binding}""></Label> + </StackLayout> + </ViewCell.View> + </ViewCell> + </DataTemplate> + </ListView.ItemTemplate> + </ListView>"; + var listview = new ListView (); + var items = new [] { "Foo", "Bar", "Baz" }; + listview.BindingContext = items; + + listview.LoadFromXaml (xaml); + + ViewCell cell0 = null; + Assert.DoesNotThrow (() => { + cell0 = (ViewCell)listview.TemplatedItems.GetOrCreateContent (0, items [0]); + }); + ViewCell cell1 = null; + Assert.DoesNotThrow (() => { + cell1 = (ViewCell)listview.TemplatedItems.GetOrCreateContent (1, items [1]); + }); + + Assert.AreNotSame (cell0, cell1); + Assert.AreNotSame (cell0.View, cell1.View); + Assert.AreNotSame (((StackLayout)cell0.View).Children [0], ((StackLayout)cell1.View).Children [0]); + Assert.AreNotSame (((StackLayout)cell0.View).Children [1], ((StackLayout)cell1.View).Children [1]); + + } + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1564.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1564.cs new file mode 100644 index 00000000..895eb900 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1564.cs @@ -0,0 +1,29 @@ +using System; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + [TestFixture] + public class Issue1564 + { + [Test] + public void ViewCellAsXamlRoot () + { + var xaml = @"<?xml version=""1.0"" encoding=""UTF-8""?> + <ViewCell + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" + x:Class=""m.transport.VehicleCell""> + <ViewCell.View> + <StackLayout> + <Label Text=""This is my label""></Label> + </StackLayout> + </ViewCell.View> + </ViewCell>"; + var cell = new ViewCell ().LoadFromXaml (xaml); + Assert.NotNull (cell); + Assert.AreEqual ("This is my label", ((cell.View as StackLayout).Children [0] as Label).Text); + } + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1594.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1594.cs new file mode 100644 index 00000000..cd942319 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1594.cs @@ -0,0 +1,43 @@ +using System; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + [TestFixture] + public class Issue1594 + { + [Test] + public void OnPlatformForButtonHeight () + { + var xaml = @" + <Button + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" + xmlns:sys=""clr-namespace:System;assembly=mscorlib"" + x:Name=""activateButton"" Text=""ACTIVATE NOW"" TextColor=""White"" BackgroundColor=""#00A0FF""> + <Button.HeightRequest> + <OnPlatform x:TypeArguments=""sys:Double"" + iOS=""33"" + Android=""44"" + WinPhone=""44"" /> + </Button.HeightRequest> + </Button>"; + + Device.OS = TargetPlatform.iOS; + var button = new Button ().LoadFromXaml (xaml); + Assert.AreEqual (33, button.HeightRequest); + + Device.OS = TargetPlatform.Android; + button = new Button ().LoadFromXaml (xaml); + Assert.AreEqual (44, button.HeightRequest); + + Device.OS = TargetPlatform.WinPhone; + button = new Button ().LoadFromXaml (xaml); + Assert.AreEqual (44, button.HeightRequest); + + + } + + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1637.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1637.cs new file mode 100644 index 00000000..f6083fb1 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1637.cs @@ -0,0 +1,25 @@ +using System; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + [TestFixture] + public class Issue1637 + { + [Test] + public void ImplicitCollectionWithSingleElement () + { + var xaml = @" + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height=""*"" /> + </Grid.RowDefinitions> + </Grid>"; + var grid = new Grid (); + Assert.DoesNotThrow(()=> grid.LoadFromXaml<Grid> (xaml)); + Assert.AreEqual (1, grid.RowDefinitions.Count); + Assert.IsTrue (grid.RowDefinitions [0].Height.IsStar); + } + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1641.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1641.cs new file mode 100644 index 00000000..3809c16d --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1641.cs @@ -0,0 +1,38 @@ +using System; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + [TestFixture] + public class Issue1641 + { + [Test] + public void StaticResourceInTableView () + { + var xaml = @" + <ContentPage + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""> + <ContentPage.Resources> + <ResourceDictionary> + <x:String x:Key=""caption"" >Hello there!</x:String> + </ResourceDictionary> + </ContentPage.Resources> + + <TableView> + <TableRoot Title=""x""> + <TableSection Title=""y""> + <TextCell Text=""{StaticResource caption}"" /> + </TableSection> + </TableRoot> + </TableView> + </ContentPage>"; + var page = new ContentPage ().LoadFromXaml (xaml); + var table = page.Content as TableView; + Assert.AreEqual ("Hello there!", page.Resources ["caption"] as string); + Assert.AreEqual ("Hello there!", (table.Root [0] [0] as TextCell).Text); + + } + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1794.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1794.cs new file mode 100644 index 00000000..d0b6eb96 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1794.cs @@ -0,0 +1,58 @@ +using System; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + [TestFixture] + public class Issue1794 + { + [Test] + public void FindNameInDT () + { + var xaml = @"<?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:XamarinFormsXamlSample;assembly=XamarinFormsXamlSample"" + xmlns:constants=""clr-namespace:XamarinFormsSample;assembly=XamarinFormsXamlSample"" + x:Class=""UxDemoAppXF.Layouts.Menu"" + Title=""Employee List""> + + <ListView x:Name=""listView"" + IsVisible=""true"" + ItemsSource=""{Binding MenuItems}"" + SelectedItem=""{Binding ListItemSelected}""> + + <ListView.ItemTemplate> + <DataTemplate> + <ViewCell> + <RelativeLayout> + <Label x:Name=""LinkText"" + Text=""{Binding Name}"" + RelativeLayout.XConstraint= + ""{ConstraintExpression Type=RelativeToParent, + Property=Width, + Factor=0.5}""/> + <Image x:Name=""LinkImage"" + Source=""{Binding ImageSource}"" + RelativeLayout.XConstraint= + ""{ConstraintExpression Type=RelativeToView, + Property=Width, + ElementName=LinkText, + Constant=5}""/> + + + </RelativeLayout> + </ViewCell> + </DataTemplate> + </ListView.ItemTemplate> + </ListView> + </ContentPage>"; + var layout = new ContentPage ().LoadFromXaml (xaml); + var list = layout.FindByName<ListView> ("listView"); + var item0 = list.TemplatedItems.GetOrCreateContent (0, null); + var item1 = list.TemplatedItems.GetOrCreateContent (1, null); + Assert.Pass (); + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2016.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2016.xaml new file mode 100644 index 00000000..012427cd --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2016.xaml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Xamarin.Forms.Xaml.UnitTests.Issue2016"> + <StackLayout> + <Switch x:Name="a0" /> + <Switch x:Name="b0" /> + <Switch x:Name="s0"> + <Switch.Triggers> + <MultiTrigger TargetType="Switch"> + <MultiTrigger.Conditions> + <BindingCondition Binding="{Binding Source={x:Reference a0}, Path=IsToggled}" Value="True" /> + <BindingCondition Binding="{Binding Source={x:Reference b0}, Path=IsToggled}" Value="True" /> + </MultiTrigger.Conditions> + <Setter Property="Switch.IsToggled" Value="True" /> + </MultiTrigger> + </Switch.Triggers> + </Switch> + <Switch x:Name="t0"> + <Switch.Triggers> + <DataTrigger TargetType="Switch" Binding="{Binding Source={x:Reference a0}, Path=IsToggled}" Value="True"> + <Setter Property="Switch.IsToggled" Value="True" /> + </DataTrigger> + </Switch.Triggers> + </Switch> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2016.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2016.xaml.cs new file mode 100644 index 00000000..89c6964f --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2016.xaml.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue2016 : ContentPage + { + public Issue2016 () + { + InitializeComponent (); + } + + public Issue2016 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [SetUp] + public void Setup () + { + Device.PlatformServices = new MockPlatformServices (); + } + + [TestCase (false)] + [TestCase (true)] + public void TestSwitches (bool useCompiledXaml) + { + var page = new Issue2016 (useCompiledXaml); + Assert.AreEqual (false, page.a0.IsToggled); + Assert.AreEqual (false, page.b0.IsToggled); + Assert.AreEqual (false, page.s0.IsToggled); + Assert.AreEqual (false, page.t0.IsToggled); + + page.a0.IsToggled = true; + page.b0.IsToggled = true; + + Assert.AreEqual (true, page.s0.IsToggled); + Assert.AreEqual (true, page.t0.IsToggled); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2062.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2062.xaml new file mode 100644 index 00000000..e756d4a5 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2062.xaml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage + xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue2062"> + <StackLayout> + <Label x:Name="label1"> + <Label.Text>text explicitly set to Label.Text</Label.Text> + </Label> + <Label x:Name="label2">text implicitly set to Text property of Label</Label> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2062.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2062.xaml.cs new file mode 100644 index 00000000..ff756756 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2062.xaml.cs @@ -0,0 +1,32 @@ +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue2062 : ContentPage + { + public Issue2062 () + { + InitializeComponent (); + } + + public Issue2062 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase (false)] + [TestCase (true)] + public void LabelWithoutExplicitPropertyElement (bool useCompiledXaml) + { + var layout = new Issue2062 (useCompiledXaml); + Assert.AreEqual ("text explicitly set to Label.Text", layout.label1.Text); + Assert.AreEqual ("text implicitly set to Text property of Label", layout.label2.Text); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2114.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2114.xaml new file mode 100644 index 00000000..8a6917dc --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2114.xaml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Application + xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue2114" + > + <Application.Resources> + <ResourceDictionary> + <!-- buttons --> + <Style x:Key="ButtonStyle" TargetType="Button"> + <Setter Property="BorderRadius" Value="0"/> + <Setter Property="HeightRequest" Value="42"/> + </Style> + <Style x:Key="NavButtonBlueStyle" BasedOn="{StaticResource ButtonStyle}" TargetType="Button"> + </Style> + <Style x:Key="NavButtonGrayStyle" BasedOn="{StaticResource ButtonStyle}" TargetType="Button"> + </Style> + </ResourceDictionary> + </Application.Resources> +</Application>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2114.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2114.xaml.cs new file mode 100644 index 00000000..66aeac54 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2114.xaml.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using Xamarin.Forms; + +using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue2114 : Application + { + public Issue2114 () + { + InitializeComponent (); + } + + public Issue2114 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [SetUp] + public void SetUp () + { + Device.PlatformServices = new MockPlatformServices (); + + Current = null; + } + + [TestCase (false)] + [TestCase (true)] + public void StaticResourceOnApplication (bool useCompiledXaml) + { + Issue2114 app; + Assert.DoesNotThrow (() => app = new Issue2114 (useCompiledXaml)); + + Assert.True (Current.Resources.ContainsKey ("ButtonStyle")); + Assert.True (Current.Resources.ContainsKey ("NavButtonBlueStyle")); + Assert.True (Current.Resources.ContainsKey ("NavButtonGrayStyle")); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2125.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2125.xaml new file mode 100644 index 00000000..c2bc239c --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2125.xaml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Xamarin.Forms.Xaml.UnitTests.Issue2125"> + <StackLayout> + <Label x:Name="label"/> + <Label x:Name="label"/> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2125.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2125.xaml.cs new file mode 100644 index 00000000..8c4dcf80 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2125.xaml.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue2125 : ContentPage + { + public Issue2125 () + { + InitializeComponent (); + } + + public Issue2125 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase (false)] + [TestCase (true)] + public void DuplicatexName (bool useCompiledXaml) + { + Assert.Throws (new XamlParseExceptionConstraint (5, 10), () => new Issue2125 (useCompiledXaml)); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2152.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2152.xaml new file mode 100644 index 00000000..4614fafb --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2152.xaml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Xamarin.Forms.Xaml.UnitTests.Issue2152"> + <ListView ItemsSource="{Binding MyItems}" x:Name="listview"> + <ListView.ItemTemplate> + <DataTemplate> + <ViewCell> + <StackLayout Orientation="Horizontal"> + <Label Text="{Binding Reference}"/> + <Button Clicked="OnButtonClicked" Text=">>>" IsVisible="{Binding ShowButton}" x:Name="btn" /> + </StackLayout> + </ViewCell> + </DataTemplate> + </ListView.ItemTemplate> + </ListView> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2152.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2152.xaml.cs new file mode 100644 index 00000000..7062074a --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2152.xaml.cs @@ -0,0 +1,52 @@ +using System; + +using Xamarin.Forms; + +using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue2152 : ContentPage + { + public Issue2152 () + { + InitializeComponent (); + } + + public Issue2152 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + int clickcount; + public void OnButtonClicked(object sender, EventArgs e) + { + clickcount++; + } + + [TestFixture] + public class Tests + { + [SetUp] + public void Setup () + { + Device.PlatformServices = new MockPlatformServices (); + } + + [TestCase (false)] + [TestCase (true)] + public void TestEventConnection (bool useCompiledXaml) + { + Issue2152 layout = null; + Assert.DoesNotThrow (() => layout = new Issue2152 (useCompiledXaml)); + Cell cell = null; + Assert.DoesNotThrow (() => cell = layout.listview.TemplatedItems.GetOrCreateContent (0, null)); + var button = cell.FindByName<Button> ("btn") as IButtonController; + Assert.AreEqual (0, layout.clickcount); + button.SendClicked (); + Assert.AreEqual (1, layout.clickcount); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2450.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2450.xaml new file mode 100644 index 00000000..385619e5 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2450.xaml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage + xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue2450"> + <StackLayout> + <Label x:Name="label0"/> + <Label x:Name="label0"/> + </StackLayout> +</ContentPage> diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2450.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2450.xaml.cs new file mode 100644 index 00000000..0cf6f56c --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2450.xaml.cs @@ -0,0 +1,37 @@ +using Xamarin.Forms; + +using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue2450 : ContentPage + { + public Issue2450 () + { + InitializeComponent (); + } + + public Issue2450 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [SetUp] + public void Setup () + { + Device.PlatformServices = new MockPlatformServices (); + } + + [TestCase (false)] + [TestCase (true)] + public void ThrowMeaningfulExceptionOnDuplicateXName (bool useCompiledXaml) + { + Assert.Throws (new XamlParseExceptionConstraint (8, 10, m => m == "An element with the name \"label0\" already exists in this NameScope"), () => new Issue2450 (useCompiledXaml)); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2489.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2489.xaml new file mode 100644 index 00000000..58629e6e --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2489.xaml @@ -0,0 +1,17 @@ +<?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;assembly=Xamarin.Forms.Xaml.UnitTests" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue2489"> + <local:WImage Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" HeightRequest="150" x:Name="wimage"> + <local:WImage.Source> + <UriImageSource Uri="{Binding ImageUrl}" /> + </local:WImage.Source> + <local:WImage.Triggers> + <DataTrigger TargetType="{x:Type local:WImage}" Binding="{Binding ImageUrl}" Value="{x:Null}" > + <Setter Property="IsVisible" Value="False" /> + </DataTrigger> + </local:WImage.Triggers> + </local:WImage> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2489.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2489.xaml.cs new file mode 100644 index 00000000..ad79298e --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2489.xaml.cs @@ -0,0 +1,53 @@ +using System; +using System.Linq; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue2489 : ContentPage + { + public Issue2489 () + { + InitializeComponent (); + } + + public Issue2489 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [SetUp] + public void SetUp () + { + Device.PlatformServices = new MockPlatformServices (); + } + + [TestCase (false)] + [TestCase (true)] + public void DataTriggerTargetType (bool useCompiledXaml) + { + var layout = new Issue2489 (useCompiledXaml); + Assert.NotNull (layout.wimage); + Assert.NotNull (layout.wimage.Triggers); + Assert.True (layout.wimage.Triggers.Any ()); + Assert.That (layout.wimage.Triggers [0], Is.TypeOf<DataTrigger> ()); + var trigger = (DataTrigger)layout.wimage.Triggers [0]; + Assert.AreEqual (typeof(WImage), trigger.TargetType); + } + } + } + + public class WImage: View + { + public ImageSource Source { get; set; } + public Aspect Aspect { get; set; } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2578.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2578.xaml new file mode 100644 index 00000000..cedfbc83 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2578.xaml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage + xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue2578"> + <ContentPage.Resources> + <ResourceDictionary> + <Style x:Key="labelStyle" TargetType="Label"> + <Style.Triggers> + <Trigger Property="Text" TargetType="Label" Value="Foo"> + <Setter Property="BackgroundColor" Value="Red" /> + </Trigger> + <Trigger Property="Font" TargetType="Label" Value="Small"> + <Setter Property="TextColor" Value="Olive" /> + </Trigger> + </Style.Triggers> + </Style> + </ResourceDictionary> + </ContentPage.Resources> + <Label x:Name="label" Font="Small" Style="{StaticResource labelStyle}" /> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2578.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2578.xaml.cs new file mode 100644 index 00000000..62e54cd7 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2578.xaml.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue2578 : ContentPage + { + public Issue2578 () + { + InitializeComponent (); + } + + public Issue2578 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [SetUp] + public void Setup () + { + Device.PlatformServices = new MockPlatformServices (); + } + + [TestCase (false)] + [TestCase (true)] + public void MultipleTriggers (bool useCompiledXaml) + { + Issue2578 layout = null; + Assert.DoesNotThrow (() => layout = new Issue2578 (useCompiledXaml)); + + Assert.AreEqual (null, layout.label.Text); + Assert.AreEqual (Color.Default, layout.label.BackgroundColor); + Assert.AreEqual (Color.Olive, layout.label.TextColor); + layout.label.Text = "Foo"; + Assert.AreEqual (Color.Red, layout.label.BackgroundColor); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2659.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2659.xaml new file mode 100644 index 00000000..6e292469 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2659.xaml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue2659"> + <ContentPage.Resources> + <ResourceDictionary> + <Style x:Key="buttonStyle" TargetType="Button"> + <Setter Property="HorizontalOptions" Value="Center" /> + <Setter Property="VerticalOptions" Value="CenterAndExpand" /> + <Setter Property="FontSize" Value="Large" /> + <Setter Property="TextColor" Value="Blue" /> + <Setter Property="FontAttributes" Value="Italic" /> + </Style> + </ResourceDictionary> + </ContentPage.Resources> + + <StackLayout x:Name="stackLayout"> + <Button Text="Set Style from Resource" + Clicked="OnSetStyleButtonClicked" + x:Name="button0"/> + + <Button Text="Set Style to null" + Clicked="OnUnsetStyleButtonClicked" + x:Name="button1"/> + + <Button Text="Set Local Properties" + Clicked="OnSetLocalButtonClicked" + x:Name="button2"/> + + <Button Text="Clear Local Properties" + Clicked="OnClearLocalButtonClicked" + x:Name="button3"/> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2659.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2659.xaml.cs new file mode 100644 index 00000000..8372c50d --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2659.xaml.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue2659 : ContentPage + { + public Issue2659 () + { + InitializeComponent (); + } + + public Issue2659 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + void OnSetStyleButtonClicked(object sender, EventArgs args) + { + Style style = (Style)Resources["buttonStyle"]; + SetButtonStyle(style); + } + + void OnUnsetStyleButtonClicked(object sender, EventArgs args) + { + SetButtonStyle (null); + } + + void OnSetLocalButtonClicked(object sender, EventArgs args) + { + EnumerateButtons ((Button button) => { + button.TextColor = Color.Red; + button.FontAttributes = FontAttributes.Bold; + }); + } + + void OnClearLocalButtonClicked(object sender, EventArgs args) + { + EnumerateButtons ((Button button) => { + button.ClearValue (Button.TextColorProperty); + button.ClearValue (Button.FontAttributesProperty); + }); + } + + void SetButtonStyle(Style style) + { + EnumerateButtons (button => { + button.Style = style; + }); + } + + void EnumerateButtons(Action<Button> action) + { + foreach (View view in stackLayout.Children) + action ((Button)view); + } + + [TestFixture] + public class Tests + { + [SetUp] + public void SetUp () + { + Device.PlatformServices = new MockPlatformServices (); + } + + void AssertStyleApplied (Button button) + { + Assert.AreEqual (LayoutOptions.Center, button.HorizontalOptions); + Assert.AreEqual (LayoutOptions.CenterAndExpand, button.VerticalOptions); + Assert.AreEqual (16, button.FontSize); + Assert.AreEqual (Color.Blue, button.TextColor); + Assert.AreEqual (FontAttributes.Italic, button.FontAttributes); + } + + void AssertStyleUnApplied (Button button) + { + Assert.AreEqual (View.HorizontalOptionsProperty.DefaultValue, button.HorizontalOptions); + Assert.AreEqual (View.VerticalOptionsProperty.DefaultValue, button.VerticalOptions); + Assert.AreEqual (10, button.FontSize); + Assert.AreEqual (Button.TextColorProperty.DefaultValue, button.TextColor); + Assert.AreEqual (Button.FontAttributesProperty.DefaultValue, button.FontAttributes); + } + + [TestCase (false)] + [TestCase (true)] + public void SetUnsetStyleFromResource (bool useCompiledXaml) + { + var layout = new Issue2659 (useCompiledXaml); + layout.EnumerateButtons (AssertStyleUnApplied); + + ((IButtonController)layout.button0).SendClicked (); + layout.EnumerateButtons (AssertStyleApplied); + + ((IButtonController)layout.button1).SendClicked (); + layout.EnumerateButtons (AssertStyleUnApplied); + } + + void AssertPropertiesApplied (Button button) + { + Assert.AreEqual (Color.Red, button.TextColor); + Assert.AreEqual (FontAttributes.Bold, button.FontAttributes); + } + + void AssertPropertiesUnApplied (Button button) + { + Assert.AreEqual (Button.TextColorProperty.DefaultValue, button.TextColor); + Assert.AreEqual (Button.FontAttributesProperty.DefaultValue, button.FontAttributes); + } + + [TestCase (false)] + [TestCase (true)] + public void SetUnsetLocalProperties (bool useCompiledXaml) + { + var layout = new Issue2659 (useCompiledXaml); + layout.EnumerateButtons (AssertPropertiesUnApplied); + + ((IButtonController)layout.button2).SendClicked (); + layout.EnumerateButtons (AssertPropertiesApplied); + + ((IButtonController)layout.button3).SendClicked (); + layout.EnumerateButtons (AssertPropertiesUnApplied); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2742.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2742.xaml new file mode 100644 index 00000000..d4dc6fc6 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2742.xaml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<local:Issue2742BasePage 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.Issue2742"> + <ContentPage.ToolbarItems> + <ToolbarItem Name="One"></ToolbarItem> + <ToolbarItem Name="Two"></ToolbarItem> + </ContentPage.ToolbarItems> + <ContentPage.Content> + <Label Text="test"></Label> + </ContentPage.Content> +</local:Issue2742BasePage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2742.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2742.xaml.cs new file mode 100644 index 00000000..ba69280d --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue2742.xaml.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class Issue2742BasePage : ContentPage + { + + } + + public partial class Issue2742 : Issue2742BasePage + { + public Issue2742 () + { + InitializeComponent (); + } + + public Issue2742 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + + [TestFixture] + public class Tests + { + [TestCase (false)] + [TestCase (true)] + public void ToolBarItemsOnContentPageInheritors (bool useCompiledXaml) + { + var layout = new Issue2742 (useCompiledXaml); + Assert.That (layout.Content, Is.TypeOf<Label> ()); + Assert.AreEqual ("test", ((Label)layout.Content).Text); + + Assert.NotNull (layout.ToolbarItems); + Assert.AreEqual (2, layout.ToolbarItems.Count); + Assert.AreEqual ("One", layout.ToolbarItems [0].Name); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3076.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3076.xaml new file mode 100644 index 00000000..61e25f04 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3076.xaml @@ -0,0 +1,11 @@ +<?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" + xmlns:controls="clr-namespace:Xamarin.Forms.Controls;assembly=Xamarin.Forms.Controls" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue3076"> + <StackLayout> + <local:Issue3076Button VerticalContentAlignment="Start" x:Name="local"/> + <controls:Issue3076Button HorizontalContentAlignment="Start" x:Name="controls" /> + </StackLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3076.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3076.xaml.cs new file mode 100644 index 00000000..e44a1349 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3076.xaml.cs @@ -0,0 +1,55 @@ +using Xamarin.Forms; + +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class Issue3076Button : Button + { + public static readonly BindableProperty VerticalContentAlignmentProperty = + BindableProperty.Create ("VerticalContentAlignemnt", typeof(TextAlignment), typeof(Issue3076Button), TextAlignment.Center); + + public TextAlignment VerticalContentAlignment + { + get { return (TextAlignment)GetValue (VerticalContentAlignmentProperty); } + set { SetValue (VerticalContentAlignmentProperty, value); } + } + } + + public partial class Issue3076 : ContentPage + { + public Issue3076 () + { + InitializeComponent (); + } + + public Issue3076 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase (false)] + [TestCase (true)] + public void CanUseBindableObjectDefinedInThisAssembly (bool useCompiledXaml) + { + var layout = new Issue3076 (useCompiledXaml); + + Assert.That (layout.local, Is.TypeOf<Issue3076Button> ()); + Assert.AreEqual (TextAlignment.Start, layout.local.VerticalContentAlignment); + } + + [TestCase (false)] + [TestCase (true)] + public void CanUseBindableObjectDefinedInOtherAssembly (bool useCompiledXaml) + { + var layout = new Issue3076 (useCompiledXaml); + + Assert.That (layout.controls, Is.TypeOf<Controls.Issue3076Button> ()); + Assert.AreEqual (TextAlignment.Start, layout.controls.HorizontalContentAlignment); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3090.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3090.xaml new file mode 100644 index 00000000..4a171913 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3090.xaml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue3090"> + <AbsoluteLayout > + <Label AbsoluteLayout.LayoutBounds="0, 0, 1, 1" /> + </AbsoluteLayout> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3090.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3090.xaml.cs new file mode 100644 index 00000000..8fc37994 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3090.xaml.cs @@ -0,0 +1,30 @@ +using NUnit.Framework; + +using Xamarin.Forms; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue3090 : ContentPage + { + public Issue3090 () + { + InitializeComponent (); + } + + public Issue3090 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase (false)] + [TestCase (true)] + public void NewDoesNotThrow (bool useCompiledXaml) + { + var p = new Issue3090 (useCompiledXaml); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3106.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3106.xaml new file mode 100644 index 00000000..fe48c730 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3106.xaml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Issue3106"> + <ContentPage.Content> + <TableView HasUnevenRows="true"> + <TableView.Root> + <TableSection Title="TextCell Disable"> + <TextCell Text="txtCellDisable1" Detail="test" IsEnabled="false" /> + <TextCell Text="txtCellDisable2" Height="25" IsEnabled="false" /> + </TableSection> + <TableSection Title="TextCell Enable"> + <TextCell Text="txtCellEnable1" Detail="test" IsEnabled="true" /> + <TextCell Text="txtCellEnable2" Height="25" IsEnabled="true" /> + </TableSection> + <TableSection Title="TextCell ContextActions Disable"> + <TextCell Text="txtCellDisableContextActions1" Detail="test" IsEnabled="false"> + <TextCell.ContextActions> + <MenuItem Command="{Binding MoreCommand}" Text="More" /> + <MenuItem Command="{Binding DeleteCommand}" Text="Delete" /> + </TextCell.ContextActions> + </TextCell> + </TableSection> + <TableSection Title="TextCell ContextActions Enable"> + <TextCell Text="txtCellEnabledContextActions1" Detail="test" IsEnabled="true"> + <TextCell.ContextActions> + <MenuItem Command="{Binding MoreCommand}" Text="More" /> + <MenuItem Command="{Binding DeleteCommand}" Text="Delete" IsDestructive="true" /> + </TextCell.ContextActions> + </TextCell> + </TableSection> + </TableView.Root> + </TableView> + </ContentPage.Content> +</ContentPage> diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3106.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3106.xaml.cs new file mode 100644 index 00000000..f2e8a641 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue3106.xaml.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Issue3106 : ContentPage + { + public Issue3106 () + { + InitializeComponent (); + } + public Issue3106 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase (false)] + [TestCase (true)] + public void NewDoesNotThrow (bool useCompiledXaml) + { + var p = new Issue3106 (useCompiledXaml); + } + } + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Pr3384.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Pr3384.xaml new file mode 100644 index 00000000..24d0842b --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Pr3384.xaml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Pr3384"> + <ListView x:Name="listView" + CachingStrategy="RecycleElement" /> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Pr3384.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Pr3384.xaml.cs new file mode 100644 index 00000000..ebf3fe18 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Pr3384.xaml.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Pr3384 : ContentPage + { + public Pr3384 () + { + InitializeComponent (); + } + + public Pr3384 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [SetUp] + public void SetUp () + { + Device.OS = TargetPlatform.iOS; + } + + [TestCase (false)] + [TestCase (true)] + public void RecyclingStrategyIsHandled (bool useCompiledXaml) + { + var p = new Pr3384 (useCompiledXaml); + Assert.AreEqual (ListViewCachingStrategy.RecycleElement, p.listView.CachingStrategy); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/TestCases.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/TestCases.cs new file mode 100644 index 00000000..ba3c2c2f --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/TestCases.cs @@ -0,0 +1,212 @@ +using System; +using System.Linq; +using NUnit.Framework; +using System.Collections.Generic; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class BasePage : ContentPage + { + + } + + [TestFixture] + public class TestCases + { + [SetUp] + public void Setup () + { + Device.PlatformServices = new MockPlatformServices (); + } + + [TearDown] + public void Teardown () + { + Device.PlatformServices = null; + } + + public static readonly BindableProperty InnerViewProperty = + BindableProperty.CreateAttached<TestCases, View> (bindable => GetInnerView (bindable), default(View)); + + public static View GetInnerView (BindableObject bindable) + { + return (View)bindable.GetValue (InnerViewProperty); + } + + public static void SetInnerView (BindableObject bindable, View value) + { + bindable.SetValue (InnerViewProperty, value); + } + + [Test] + public void TestCase001 () + { + var xaml = @"<?xml version=""1.0"" encoding=""UTF-8"" ?> + <ContentPage + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" + xmlns:local=""clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests"" + Title=""Home""> + <local:TestCases.InnerView> + <Label x:Name=""innerView""/> + </local:TestCases.InnerView> + <ContentPage.Content> + <Grid RowSpacing=""9"" ColumnSpacing=""6"" Padding=""6,9"" VerticalOptions=""Fill"" HorizontalOptions=""Fill"" BackgroundColor=""Red""> + <Grid.Children> + <Label x:Name=""label0""/> + <Label x:Name=""label1""/> + <Label x:Name=""label2""/> + <Label x:Name=""label3""/> + </Grid.Children> + </Grid> + </ContentPage.Content> + </ContentPage>"; + var contentPage = new ContentPage ().LoadFromXaml (xaml); + var label0 = contentPage.FindByName<Label> ("label0"); + var label1 = contentPage.FindByName<Label> ("label1"); + + Assert.NotNull (GetInnerView (contentPage)); +// Assert.AreEqual ("innerView", GetInnerView (contentPage).Name); + Assert.AreEqual (GetInnerView (contentPage), ((Forms.Internals.INameScope)contentPage).FindByName ("innerView")); + Assert.NotNull (label0); + Assert.NotNull (label1); + Assert.AreEqual (4, contentPage.Content.Descendants ().Count ()); + } + + + [Test] + public void TestCase002 () + { + var xaml = @"<?xml version=""1.0"" encoding=""UTF-8"" ?> + <local:BasePage + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" + xmlns:local=""clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests"" + x:Class=""Tramchester.App.Views.HomeView""> + <local:BasePage.Content> + <Label Text=""Hi There!"" /> + </local:BasePage.Content> + </local:BasePage>"; + var contentPage = new ContentPage ().LoadFromXaml (xaml); + Assert.That (contentPage.Content, Is.InstanceOf<Label> ()); + } + + [Test] + public void TestCase003 () + { + var xaml = @"<?xml version=""1.0"" encoding=""UTF-8"" ?> + <ContentPage + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" + Title=""People""> + + <StackLayout Spacing=""0""> + <SearchBar x:Name=""searchBar""/> + <ListView ItemsSource=""{Binding Path=.}"" RowHeight=""42"" x:Name=""listview""> + <ListView.ItemTemplate> + <DataTemplate> + <ViewCell> + <ViewCell.View> + <StackLayout Orientation=""Horizontal"" HorizontalOptions=""FillAndExpand"" VerticalOptions=""CenterAndExpand"" BackgroundColor=""#fff4f4f4""> + <BoxView WidthRequest=""10""/> + <Grid WidthRequest=""42"" HeightRequest=""32"" VerticalOptions=""CenterAndExpand"" HorizontalOptions=""Start""> + <Image WidthRequest=""32"" HeightRequest=""32"" Aspect=""AspectFill"" HorizontalOptions=""FillAndExpand"" Source=""Images/icone_nopic_members_42.png""/> + <!--<Image WidthRequest=""32"" HeightRequest=""32"" Aspect=""AspectFill"" HorizontalOptions=""FillAndExpand""> + <Image.Source> + <UriImageSource Uri=""{Binding Picture}"" CacheValidity=""30""/> + </Image.Source> + </Image>--> + <Image Source=""Images/cropcircle.png"" HorizontalOptions=""FillAndExpand"" VerticalOptions=""FillAndExpand"" WidthRequest=""32"" HeightRequest=""32"" Aspect=""Fill""/> + </Grid> + <Label Text=""{Binding FirstName}"" VerticalOptions=""CenterAndExpand""/> + <Label Text=""{Binding LastName}"" Font=""HelveticaNeue-Bold, Medium"" VerticalOptions=""CenterAndExpand"" /> + </StackLayout> + </ViewCell.View> + </ViewCell> + </DataTemplate> + </ListView.ItemTemplate> + </ListView> + </StackLayout> + </ContentPage>"; + var page = new ContentPage ().LoadFromXaml (xaml); + var model = new List<object> { + new {FirstName = "John", LastName="Lennon", Picture="http://www.johnlennon.com/wp-content/themes/jl/images/home-gallery/2.jpg"}, + new {FirstName = "Paul", LastName="McCartney", Picture="http://t0.gstatic.com/images?q=tbn:ANd9GcRjNUGJ00Mt85n2XDu8CZM0w1em0Wv4ZaemLuIVmLCMwPMOLUO1SQ"}, + new {FirstName = "George", LastName="Harisson", Picture="http://cdn.riffraf.net/wp-content/uploads/2013/02/george-harrison-living.jpg"}, + new {FirstName = "Ringo", LastName="Starr", Picture="http://www.biography.com/imported/images/Biography/Images/Profiles/S/Ringo-Starr-306872-1-402.jpg"}, + }; + page.BindingContext = model; + + var listview = page.FindByName<ListView> ("listview"); + Cell cell = null; + Assert.DoesNotThrow(() => { cell = listview.TemplatedItems[0]; }); + Assert.NotNull (cell); + Assert.That (cell, Is.TypeOf<ViewCell> ()); + Assert.AreSame (model [0], cell.BindingContext); + } + + [Test] + public void TestCase004 () + { + var xaml = @"<?xml version=""1.0"" encoding=""UTF-8"" ?> + <ContentPage + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> + <ContentPage.Content> + <ScrollView Orientation=""Horizontal""> + <ScrollView.Content> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition /> + <ColumnDefinition /> + </Grid.ColumnDefinitions> + <Image Grid.Column=""0"" Grid.Row=""0"" Aspect=""AspectFill""> + <Image.Source> + <StreamImageSource Stream=""{Binding HeroPicture.Stream}"" /> + </Image.Source> + </Image> + </Grid> + </ScrollView.Content> + </ScrollView> + </ContentPage.Content> + </ContentPage>"; + + var page = new ContentPage (); + Assert.DoesNotThrow (()=> page.LoadFromXaml (xaml)); + } + + [Test] + public void Issue1415 () + { + var xaml = @"<?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;assembly=Xamarin.Forms.Xaml.UnitTests""> + <Label x:Name=""label"" Text=""{Binding Converter={x:Static local:ReverseConverter.Instance}, Mode=TwoWay}""/> + </ContentPage>"; + var page = new ContentPage ().LoadFromXaml (xaml); + var label = page.FindByName<Label> ("label"); + Assert.NotNull (label); + label.BindingContext = "foo"; + Assert.AreEqual ("oof", label.Text); + } + + [Test] + //only happens in european cultures + [SetCulture ("fr-FR")] + public void Issue1493 () + { + var xaml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> + <View + xmlns=""http://xamarin.com/schemas/2014/forms"" + xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" + RelativeLayout.HeightConstraint=""{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.25}"" + RelativeLayout.WidthConstraint=""{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.6}""/>"; + View view = new View (); + view.LoadFromXaml (xaml); + Assert.DoesNotThrow (() => view.LoadFromXaml (xaml)); + } + } +} diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported001.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported001.xaml new file mode 100644 index 00000000..a039f7f6 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported001.xaml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<TabbedPage 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.Unreported001"> + <NavigationPage Title="Test" x:Name="navpage"> + <x:Arguments> + <local:U001Page /> + </x:Arguments> + </NavigationPage> +</TabbedPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported001.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported001.xaml.cs new file mode 100644 index 00000000..d04ad467 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported001.xaml.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class U001Page : ContentPage + { + public U001Page () + { + ; + } + + } + + public partial class Unreported001 : TabbedPage + { + public Unreported001 () + { + InitializeComponent (); + } + + public Unreported001 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase (false)] + [TestCase (true)] + public void DoesNotThrow (bool useCompiledXaml) + { + var p = new Unreported001 (useCompiledXaml); + Assert.That (p.navpage.CurrentPage, Is.TypeOf<U001Page> ()); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported002.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported002.xaml new file mode 100644 index 00000000..7785ae8c --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported002.xaml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Unreported002"> + <Label x:Name="label" + AbsoluteLayout.LayoutBounds="0.5,0.5,1,AutoSize" /> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported002.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported002.xaml.cs new file mode 100644 index 00000000..23f24044 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported002.xaml.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Unreported002 : ContentPage + { + public Unreported002 () + { + InitializeComponent (); + } + + public Unreported002 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase (false)] + [TestCase (true)] + public void TypeConvertersOnAttachedBP (bool useCompiledXaml) + { + var p = new Unreported002 (useCompiledXaml); + Assert.AreEqual (new Rectangle (0.5, 0.5, 1, -1), AbsoluteLayout.GetLayoutBounds (p.label)); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported003.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported003.xaml new file mode 100644 index 00000000..b8db54b3 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported003.xaml @@ -0,0 +1,26 @@ +<?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:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps" + x:Class="Xamarin.Forms.Xaml.UnitTests.Unreported003" > + <maps:Map x:Name="map"> + <x:Arguments> + <maps:MapSpan> + <x:Arguments> + <!-- These coordinates land near Red Deer at a fairly high altitude (birds eye view). --> + <maps:Position> + <x:Arguments> + <!-- Latitude--> + <x:Double>52.325</x:Double> + <!-- Longitude--> + <x:Double>-113.9</x:Double> + </x:Arguments> + </maps:Position> + <!-- Elevation lat/long--> + <x:Double>.8</x:Double> + <x:Double>.8</x:Double> + </x:Arguments> + </maps:MapSpan> + </x:Arguments> + </maps:Map> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported003.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported003.xaml.cs new file mode 100644 index 00000000..ebe78bc4 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported003.xaml.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Unreported003 : ContentPage + { + public Unreported003 () + { + InitializeComponent (); + } + + public Unreported003 (bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true), TestCase(false)] + public void AllowCtorArgsForValueTypes (bool useCompiledXaml) + { + var page = new Unreported003 (useCompiledXaml); + } + } + } +}
\ No newline at end of file |