|
|
|
@ -68,7 +68,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void IsVisible_Should_Be_False_Atfer_Hide() |
|
|
|
public void IsVisible_Should_Be_False_After_Hide() |
|
|
|
{ |
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
|
|
|
{ |
|
|
|
@ -82,7 +82,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void IsVisible_Should_Be_False_Atfer_Close() |
|
|
|
public void IsVisible_Should_Be_False_After_Close() |
|
|
|
{ |
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
|
|
|
{ |
|
|
|
@ -96,7 +96,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void IsVisible_Should_Be_False_Atfer_Impl_Signals_Close() |
|
|
|
public void IsVisible_Should_Be_False_After_Impl_Signals_Close() |
|
|
|
{ |
|
|
|
var windowImpl = new Mock<IWindowImpl>(); |
|
|
|
windowImpl.SetupProperty(x => x.Closed); |
|
|
|
@ -191,5 +191,76 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
// AvaloniaLocator scopes.
|
|
|
|
((IList<Window>)Window.OpenWindows).Clear(); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Window_Should_Be_Centered_When_Window_Startup_Location_Is_Center_Screen() |
|
|
|
{ |
|
|
|
var windowImpl = new Mock<IWindowImpl>(); |
|
|
|
windowImpl.SetupProperty(x => x.Position); |
|
|
|
windowImpl.Setup(x => x.ClientSize).Returns(new Size(800, 480)); |
|
|
|
windowImpl.Setup(x => x.MaxClientSize).Returns(new Size(1920, 1080)); |
|
|
|
windowImpl.Setup(x => x.Scaling).Returns(1); |
|
|
|
|
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
|
|
|
{ |
|
|
|
var window = new Window(); |
|
|
|
window.WindowStartupLocation = WindowStartupLocation.CenterScreen; |
|
|
|
window.Position = new Point(60, 40); |
|
|
|
|
|
|
|
window.Show(); |
|
|
|
|
|
|
|
var expectedPosition = new Point( |
|
|
|
window.PlatformImpl.MaxClientSize.Width / 2 - window.ClientSize.Width / 2, |
|
|
|
window.PlatformImpl.MaxClientSize.Height / 2 - window.ClientSize.Height / 2); |
|
|
|
|
|
|
|
Assert.Equal(window.Position, expectedPosition); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Window_Should_Be_Centered_Relative_To_Owner_When_Window_Startup_Location_Is_Center_Owner() |
|
|
|
{ |
|
|
|
var parentWindowImpl = new Mock<IWindowImpl>(); |
|
|
|
parentWindowImpl.SetupProperty(x => x.Position); |
|
|
|
parentWindowImpl.Setup(x => x.ClientSize).Returns(new Size(800, 480)); |
|
|
|
parentWindowImpl.Setup(x => x.MaxClientSize).Returns(new Size(1920, 1080)); |
|
|
|
parentWindowImpl.Setup(x => x.Scaling).Returns(1); |
|
|
|
|
|
|
|
var windowImpl = new Mock<IWindowImpl>(); |
|
|
|
windowImpl.SetupProperty(x => x.Position); |
|
|
|
windowImpl.Setup(x => x.ClientSize).Returns(new Size(320, 200)); |
|
|
|
windowImpl.Setup(x => x.MaxClientSize).Returns(new Size(1920, 1080)); |
|
|
|
windowImpl.Setup(x => x.Scaling).Returns(1); |
|
|
|
|
|
|
|
var parentWindowServices = TestServices.StyledWindow.With( |
|
|
|
windowingPlatform: new MockWindowingPlatform(() => parentWindowImpl.Object)); |
|
|
|
|
|
|
|
var windowServices = TestServices.StyledWindow.With( |
|
|
|
windowingPlatform: new MockWindowingPlatform(() => windowImpl.Object)); |
|
|
|
|
|
|
|
using (UnitTestApplication.Start(parentWindowServices)) |
|
|
|
{ |
|
|
|
var parentWindow = new Window(); |
|
|
|
parentWindow.Position = new Point(60, 40); |
|
|
|
|
|
|
|
parentWindow.Show(); |
|
|
|
|
|
|
|
using (UnitTestApplication.Start(windowServices)) |
|
|
|
{ |
|
|
|
var window = new Window(); |
|
|
|
window.WindowStartupLocation = WindowStartupLocation.CenterOwner; |
|
|
|
window.Position = new Point(60, 40); |
|
|
|
window.Owner = parentWindow; |
|
|
|
|
|
|
|
window.Show(); |
|
|
|
|
|
|
|
var expectedPosition = new Point( |
|
|
|
parentWindow.Position.X + parentWindow.ClientSize.Width / 2 - window.ClientSize.Width / 2, |
|
|
|
parentWindow.Position.Y + parentWindow.ClientSize.Height / 2 - window.ClientSize.Height / 2); |
|
|
|
|
|
|
|
Assert.Equal(window.Position, expectedPosition); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|