Browse Source

Merge branch 'master' into feature/ApplicationOnStartup

pull/2442/head
Benedikt Schroeder 8 years ago
committed by GitHub
parent
commit
d282ae2fbb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      nukebuild/Numerge
  2. 5
      src/Avalonia.Controls/Platform/InProcessDragSource.cs
  3. 11
      src/Avalonia.Controls/Window.cs
  4. 45
      tests/Avalonia.Controls.UnitTests/WindowTests.cs

2
nukebuild/Numerge

@ -1 +1 @@
Subproject commit 4464343aef5c8ab7a42fcb20a483a6058199f8b8
Subproject commit aef10ae67dc55c95f49b52a505a0be33bfa297a5

5
src/Avalonia.Controls/Platform/InProcessDragSource.cs

@ -147,7 +147,10 @@ namespace Avalonia.Platform
e.Handled = true;
}
else if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl || e.Key == Key.LeftAlt || e.Key == Key.RightAlt)
RaiseEventAndUpdateCursor(RawDragEventType.DragOver, _lastRoot, _lastPosition, e.Modifiers);
{
if (_lastRoot != null)
RaiseEventAndUpdateCursor(RawDragEventType.DragOver, _lastRoot, _lastPosition, e.Modifiers);
}
}
private void ProcessMouseEvents(RawMouseEventArgs e)

11
src/Avalonia.Controls/Window.cs

@ -371,8 +371,16 @@ namespace Avalonia.Controls
/// <summary>
/// Shows the window.
/// </summary>
/// <exception cref="InvalidOperationException">
/// The window has already been closed.
/// </exception>
public override void Show()
{
if (PlatformImpl == null)
{
throw new InvalidOperationException("Cannot re-show a closed window.");
}
if (IsVisible)
{
return;
@ -397,6 +405,9 @@ namespace Avalonia.Controls
/// Shows the window as a dialog.
/// </summary>
/// <param name="owner">The dialog's owner window.</param>
/// <exception cref="InvalidOperationException">
/// The window has already been closed.
/// </exception>
/// <returns>
/// A task that can be used to track the lifetime of the dialog.
/// </returns>

45
tests/Avalonia.Controls.UnitTests/WindowTests.cs

@ -292,6 +292,51 @@ namespace Avalonia.Controls.UnitTests
}
}
[Fact]
public void Calling_Show_On_Closed_Window_Should_Throw()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var windowImpl = Mock.Of<IWindowImpl>(x => x.Scaling == 1);
var target = new Window(windowImpl);
target.Show();
target.Close();
var openedRaised = false;
target.Opened += (s, e) => openedRaised = true;
var ex = Assert.Throws<InvalidOperationException>(() => target.Show());
Assert.Equal("Cannot re-show a closed window.", ex.Message);
Assert.False(openedRaised);
}
}
[Fact]
public async Task Calling_ShowDialog_On_Closed_Window_Should_Throw()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var parent = new Mock<IWindowImpl>();
var windowImpl = new Mock<IWindowImpl>();
windowImpl.SetupProperty(x => x.Closed);
windowImpl.Setup(x => x.Scaling).Returns(1);
var target = new Window(windowImpl.Object);
var task = target.ShowDialog<bool>(parent.Object);
windowImpl.Object.Closed();
await task;
var openedRaised = false;
target.Opened += (s, e) => openedRaised = true;
var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => target.ShowDialog<bool>(parent.Object));
Assert.Equal("Cannot re-show a closed window.", ex.Message);
Assert.False(openedRaised);
}
}
[Fact]
public void Window_Should_Be_Centered_When_WindowStartupLocation_Is_CenterScreen()
{

Loading…
Cancel
Save