|
|
|
@ -9,6 +9,8 @@ using Avalonia.Controls.Templates; |
|
|
|
using Avalonia.LogicalTree; |
|
|
|
using Avalonia.VisualTree; |
|
|
|
using Xunit; |
|
|
|
using System.Collections.ObjectModel; |
|
|
|
using Avalonia.UnitTests; |
|
|
|
|
|
|
|
namespace Avalonia.Controls.UnitTests |
|
|
|
{ |
|
|
|
@ -61,6 +63,32 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
Assert.Null(container.TemplatedParent); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Container_Child_Should_Have_LogicalParent_Set_To_Container() |
|
|
|
{ |
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
|
|
|
{ |
|
|
|
var root = new Window(); |
|
|
|
var target = new ItemsControl(); |
|
|
|
|
|
|
|
root.Content = target; |
|
|
|
|
|
|
|
var templatedParent = new Button(); |
|
|
|
target.TemplatedParent = templatedParent; |
|
|
|
target.Template = GetTemplate(); |
|
|
|
|
|
|
|
target.Items = new[] { "Foo" }; |
|
|
|
|
|
|
|
root.ApplyTemplate(); |
|
|
|
target.ApplyTemplate(); |
|
|
|
target.Presenter.ApplyTemplate(); |
|
|
|
|
|
|
|
var container = (ContentPresenter)target.Presenter.Panel.Children[0]; |
|
|
|
|
|
|
|
Assert.Equal(container.Child.Parent, container); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Control_Item_Should_Be_Logical_Child_Before_ApplyTemplate() |
|
|
|
{ |
|
|
|
@ -170,6 +198,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
|
|
|
|
Assert.Equal(new ILogical[0], target.GetLogicalChildren()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Setting_Items_Should_Fire_LogicalChildren_CollectionChanged() |
|
|
|
|