|
|
@ -8,7 +8,7 @@ using Avalonia.Data; |
|
|
using Avalonia.Input; |
|
|
using Avalonia.Input; |
|
|
using Avalonia.LogicalTree; |
|
|
using Avalonia.LogicalTree; |
|
|
using Avalonia.Media; |
|
|
using Avalonia.Media; |
|
|
using Avalonia.Threading; |
|
|
using Avalonia.VisualTree; |
|
|
using Avalonia.UnitTests; |
|
|
using Avalonia.UnitTests; |
|
|
using Xunit; |
|
|
using Xunit; |
|
|
|
|
|
|
|
|
@ -340,80 +340,77 @@ namespace Avalonia.Controls.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void FlowDirection_Of_RectangleContent_Shuold_Be_LeftToRight() |
|
|
public void FlowDirection_Of_RectangleContent_Shuold_Be_LeftToRight() |
|
|
{ |
|
|
{ |
|
|
using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface)) |
|
|
var items = new[] |
|
|
{ |
|
|
{ |
|
|
var items = new[] |
|
|
new ComboBoxItem() |
|
|
{ |
|
|
{ |
|
|
new ComboBoxItem() |
|
|
Content = new Control() |
|
|
{ |
|
|
} |
|
|
Content = new Control() |
|
|
}; |
|
|
} |
|
|
var target = new ComboBox |
|
|
}; |
|
|
{ |
|
|
var target = new ComboBox |
|
|
FlowDirection = FlowDirection.RightToLeft, |
|
|
{ |
|
|
Items = items, |
|
|
FlowDirection = FlowDirection.RightToLeft, |
|
|
Template = GetTemplate() |
|
|
Items = items, |
|
|
}; |
|
|
Template = GetTemplate() |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var root = new TestRoot(target); |
|
|
var root = new TestRoot(target); |
|
|
target.ApplyTemplate(); |
|
|
target.ApplyTemplate(); |
|
|
target.SelectedIndex = 0; |
|
|
target.SelectedIndex = 0; |
|
|
|
|
|
|
|
|
var rectangle = target.GetValue(ComboBox.SelectionBoxItemProperty) as Rectangle; |
|
|
var rectangle = target.GetValue(ComboBox.SelectionBoxItemProperty) as Rectangle; |
|
|
|
|
|
|
|
|
Assert.Equal(FlowDirection.LeftToRight, rectangle.FlowDirection); |
|
|
Assert.Equal(FlowDirection.LeftToRight, rectangle.FlowDirection); |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public void FlowDirection_Of_RectangleContent_Updated_After_Change_ComboBox() |
|
|
public void FlowDirection_Of_RectangleContent_Updated_After_InvalidateMirrorTransform() |
|
|
{ |
|
|
{ |
|
|
using (UnitTestApplication.Start(TestServices.RealStyler)) |
|
|
var parentContent = new Decorator() |
|
|
{ |
|
|
{ |
|
|
var items = new[] |
|
|
Child = new Control() |
|
|
{ |
|
|
}; |
|
|
new ComboBoxItem() |
|
|
var items = new[] |
|
|
{ |
|
|
{ |
|
|
Content = new Control() |
|
|
new ComboBoxItem() |
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
var target = new ComboBox |
|
|
|
|
|
{ |
|
|
{ |
|
|
FlowDirection = FlowDirection.RightToLeft, |
|
|
Content = parentContent.Child |
|
|
Items = items, |
|
|
} |
|
|
Template = GetTemplate() |
|
|
}; |
|
|
}; |
|
|
var target = new ComboBox |
|
|
|
|
|
{ |
|
|
var root = new TestRoot(target); |
|
|
FlowDirection = FlowDirection.RightToLeft, |
|
|
target.ApplyTemplate(); |
|
|
Items = items, |
|
|
target.Presenter.ApplyTemplate(); |
|
|
Template = GetTemplate() |
|
|
target.SelectedIndex = 0; |
|
|
}; |
|
|
((ContentPresenter)target.Presenter).UpdateChild(); |
|
|
|
|
|
|
|
|
|
|
|
var rectangle = target.GetValue(ComboBox.SelectionBoxItemProperty) as Rectangle; |
|
|
|
|
|
|
|
|
|
|
|
// need help here, the 'rectangle' isn't connected to visual tree for some reason
|
|
|
|
|
|
|
|
|
|
|
|
Assert.True(rectangle.HasMirrorTransform); |
|
|
var root = new TestRoot(target); |
|
|
|
|
|
target.ApplyTemplate(); |
|
|
|
|
|
target.SelectedIndex = 0; |
|
|
|
|
|
|
|
|
target.FlowDirection = FlowDirection.LeftToRight; |
|
|
var rectangle = target.GetValue(ComboBox.SelectionBoxItemProperty) as Rectangle; |
|
|
|
|
|
Assert.Equal(FlowDirection.LeftToRight, rectangle.FlowDirection); |
|
|
|
|
|
|
|
|
Assert.False(rectangle.HasMirrorTransform); |
|
|
parentContent.FlowDirection = FlowDirection.RightToLeft; |
|
|
} |
|
|
target.InvalidateMirrorTransform(); |
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(FlowDirection.RightToLeft, rectangle.FlowDirection); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public void FlowDirection_Of_RectangleContent_Updated_After_Content_In_VisualTree() |
|
|
public void FlowDirection_Of_RectangleContent_Updated_After_OpenPopup() |
|
|
{ |
|
|
{ |
|
|
using (UnitTestApplication.Start(TestServices.RealFocus)) |
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
|
|
{ |
|
|
{ |
|
|
Control content; |
|
|
var parentContent = new Decorator() |
|
|
var items = new[] |
|
|
|
|
|
{ |
|
|
{ |
|
|
|
|
|
Child = new Control() |
|
|
|
|
|
}; |
|
|
|
|
|
var items = new[] |
|
|
|
|
|
{ |
|
|
new ComboBoxItem() |
|
|
new ComboBoxItem() |
|
|
{ |
|
|
{ |
|
|
Content = content = new Control() |
|
|
Content = parentContent.Child |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
var target = new ComboBox |
|
|
var target = new ComboBox |
|
|
@ -425,14 +422,17 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
|
|
|
|
|
var root = new TestRoot(target); |
|
|
var root = new TestRoot(target); |
|
|
target.ApplyTemplate(); |
|
|
target.ApplyTemplate(); |
|
|
target.Presenter.ApplyTemplate(); |
|
|
|
|
|
target.SelectedIndex = 0; |
|
|
target.SelectedIndex = 0; |
|
|
|
|
|
|
|
|
// need help here how to connect 'content' to visual tree, or how to open popup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var rectangle = target.GetValue(ComboBox.SelectionBoxItemProperty) as Rectangle; |
|
|
var rectangle = target.GetValue(ComboBox.SelectionBoxItemProperty) as Rectangle; |
|
|
|
|
|
Assert.Equal(FlowDirection.LeftToRight, rectangle.FlowDirection); |
|
|
|
|
|
|
|
|
|
|
|
parentContent.FlowDirection = FlowDirection.RightToLeft; |
|
|
|
|
|
|
|
|
|
|
|
var popup = target.GetVisualDescendants().OfType<Popup>().First(); |
|
|
|
|
|
popup.PlacementTarget = new Window(); |
|
|
|
|
|
popup.Open(); |
|
|
|
|
|
|
|
|
Assert.Equal(FlowDirection.RightToLeft, rectangle.FlowDirection); |
|
|
Assert.Equal(FlowDirection.RightToLeft, rectangle.FlowDirection); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|