Fixed. With more unit tests.

This commit is contained in:
Tig
2024-09-20 17:17:21 -06:00
parent 8dbdccd77f
commit ed921edda9
8 changed files with 246 additions and 85 deletions

View File

@@ -12,7 +12,7 @@ public class AdornmentSubViewTests (ITestOutputHelper output)
[InlineData (1, 0, true)]
[InlineData (1, 1, true)]
[InlineData (2, 1, true)]
public void Adornment_WithSubView_FindDeepestView_Finds (int viewMargin, int subViewMargin, bool expectedFound)
public void Adornment_WithSubView_GetViewsUnderMouse_Finds (int viewMargin, int subViewMargin, bool expectedFound)
{
Application.Top = new Toplevel()
{
@@ -31,7 +31,7 @@ public class AdornmentSubViewTests (ITestOutputHelper output)
subView.Margin.Thickness = new Thickness (subViewMargin);
Application.Top.Margin.Add (subView);
var foundView = View.FindDeepestView (new (0, 0));
var foundView = View.GetViewsUnderMouse (new Point(0, 0)).LastOrDefault ();
bool found = foundView == subView || foundView == subView.Margin;
Assert.Equal (expectedFound, found);
@@ -40,7 +40,7 @@ public class AdornmentSubViewTests (ITestOutputHelper output)
}
[Fact]
public void Adornment_WithNonVisibleSubView_FindDeepestView_Finds_Adornment ()
public void Adornment_WithNonVisibleSubView_GetViewsUnderMouse_Finds_Adornment ()
{
Application.Top = new Toplevel ()
{
@@ -59,7 +59,7 @@ public class AdornmentSubViewTests (ITestOutputHelper output)
};
Application.Top.Padding.Add (subView);
Assert.Equal (Application.Top.Padding, View.FindDeepestView (new (0, 0)));
Assert.Equal (Application.Top.Padding, View.GetViewsUnderMouse (new Point(0, 0)).LastOrDefault ());
Application.Top?.Dispose ();
Application.ResetState (ignoreDisposed: true);
}

View File

@@ -1,18 +1,200 @@

#nullable enable
using Microsoft.VisualStudio.TestPlatform.Utilities;
using Xunit.Abstractions;
#nullable enable
namespace Terminal.Gui.ViewTests;
/// <summary>
/// Tests View.FindDeepestView
/// </summary>
/// <param name="output"></param>
public class FindDeepestViewTests ()
public class GetViewsUnderMouseTests
{
[Theory]
[InlineData (0, 0, 0, 0, 0, -1, -1, null)]
[InlineData (0, 0, 0, 0, 0, 0, 0, typeof (Toplevel))]
[InlineData (0, 0, 0, 0, 0, 1, 1, typeof (Toplevel))]
[InlineData (0, 0, 0, 0, 0, 4, 4, typeof (Toplevel))]
[InlineData (0, 0, 0, 0, 0, 9, 9, typeof (Toplevel))]
[InlineData (0, 0, 0, 0, 0, 10, 10, null)]
[InlineData (1, 1, 0, 0, 0, -1, -1, null)]
[InlineData (1, 1, 0, 0, 0, 0, 0, null)]
[InlineData (1, 1, 0, 0, 0, 1, 1, typeof (Toplevel))]
[InlineData (1, 1, 0, 0, 0, 4, 4, typeof (Toplevel))]
[InlineData (1, 1, 0, 0, 0, 9, 9, typeof (Toplevel))]
[InlineData (1, 1, 0, 0, 0, 10, 10, typeof (Toplevel))]
[InlineData (0, 0, 1, 0, 0, -1, -1, null)]
[InlineData (0, 0, 1, 0, 0, 0, 0, typeof (Margin))]
[InlineData (0, 0, 1, 0, 0, 1, 1, typeof (Toplevel))]
[InlineData (0, 0, 1, 0, 0, 4, 4, typeof (Toplevel))]
[InlineData (0, 0, 1, 0, 0, 9, 9, typeof (Margin))]
[InlineData (0, 0, 1, 0, 0, 10, 10, null)]
[InlineData (0, 0, 1, 1, 0, -1, -1, null)]
[InlineData (0, 0, 1, 1, 0, 0, 0, typeof (Margin))]
[InlineData (0, 0, 1, 1, 0, 1, 1, typeof (Border))]
[InlineData (0, 0, 1, 1, 0, 4, 4, typeof (Toplevel))]
[InlineData (0, 0, 1, 1, 0, 9, 9, typeof (Margin))]
[InlineData (0, 0, 1, 1, 0, 10, 10, null)]
[InlineData (0, 0, 1, 1, 1, -1, -1, null)]
[InlineData (0, 0, 1, 1, 1, 0, 0, typeof (Margin))]
[InlineData (0, 0, 1, 1, 1, 1, 1, typeof (Border))]
[InlineData (0, 0, 1, 1, 1, 2, 2, typeof (Padding))]
[InlineData (0, 0, 1, 1, 1, 4, 4, typeof (Toplevel))]
[InlineData (0, 0, 1, 1, 1, 9, 9, typeof (Margin))]
[InlineData (0, 0, 1, 1, 1, 10, 10, null)]
[InlineData (1, 1, 1, 0, 0, -1, -1, null)]
[InlineData (1, 1, 1, 0, 0, 0, 0, null)]
[InlineData (1, 1, 1, 0, 0, 1, 1, typeof (Margin))]
[InlineData (1, 1, 1, 0, 0, 4, 4, typeof (Toplevel))]
[InlineData (1, 1, 1, 0, 0, 9, 9, typeof (Toplevel))]
[InlineData (1, 1, 1, 0, 0, 10, 10, typeof (Margin))]
[InlineData (1, 1, 1, 1, 0, -1, -1, null)]
[InlineData (1, 1, 1, 1, 0, 0, 0, null)]
[InlineData (1, 1, 1, 1, 0, 1, 1, typeof (Margin))]
[InlineData (1, 1, 1, 1, 0, 4, 4, typeof (Toplevel))]
[InlineData (1, 1, 1, 1, 0, 9, 9, typeof (Border))]
[InlineData (1, 1, 1, 1, 0, 10, 10, typeof (Margin))]
[InlineData (1, 1, 1, 1, 1, -1, -1, null)]
[InlineData (1, 1, 1, 1, 1, 0, 0, null)]
[InlineData (1, 1, 1, 1, 1, 1, 1, typeof (Margin))]
[InlineData (1, 1, 1, 1, 1, 2, 2, typeof (Border))]
[InlineData (1, 1, 1, 1, 1, 3, 3, typeof (Padding))]
[InlineData (1, 1, 1, 1, 1, 4, 4, typeof (Toplevel))]
[InlineData (1, 1, 1, 1, 1, 8, 8, typeof (Padding))]
[InlineData (1, 1, 1, 1, 1, 9, 9, typeof (Border))]
[InlineData (1, 1, 1, 1, 1, 10, 10, typeof (Margin))]
public void GetViewsUnderMouse_Top_Adornments_Returns_Correct_View (int frameX, int frameY, int marginThickness, int borderThickness, int paddingThickness, int testX, int testY, Type? expectedViewType)
{
// Arrange
Application.Top = new ()
{
Frame = new Rectangle (frameX, frameY, 10, 10),
};
Application.Top.Margin.Thickness = new Thickness (marginThickness);
Application.Top.Border.Thickness = new Thickness (borderThickness);
Application.Top.Padding.Thickness = new Thickness (paddingThickness);
var location = new Point (testX, testY);
// Act
var viewsUnderMouse = View.GetViewsUnderMouse (location);
// Assert
if (expectedViewType == null)
{
Assert.Empty (viewsUnderMouse);
}
else
{
Assert.Contains (viewsUnderMouse, v => v?.GetType () == expectedViewType);
}
Application.Top.Dispose ();
Application.ResetState (ignoreDisposed: true);
}
[Theory]
[InlineData (0, 0)]
[InlineData (1, 1)]
[InlineData (2, 2)]
public void GetViewsUnderMouse_Returns_Top_If_No_SubViews (int testX, int testY)
{
// Arrange
Application.Top = new ()
{
Frame = new Rectangle (0, 0, 10, 10)
};
var location = new Point (testX, testY);
// Act
var viewsUnderMouse = View.GetViewsUnderMouse (location);
// Assert
Assert.Contains (viewsUnderMouse, v => v == Application.Top);
Application.Top.Dispose ();
Application.ResetState (ignoreDisposed: true);
}
[Theory]
[InlineData (0, 0)]
[InlineData (2, 1)]
[InlineData (20, 20)]
public void GetViewsUnderMouse_Returns_Null_If_No_SubViews_Coords_Outside (int testX, int testY)
{
// Arrange
var view = new View
{
Frame = new Rectangle (0, 0, 10, 10)
};
var location = new Point (testX, testY);
// Act
var viewsUnderMouse = View.GetViewsUnderMouse (location);
// Assert
Assert.Empty (viewsUnderMouse);
}
[Theory]
[InlineData (0, 0)]
[InlineData (2, 1)]
[InlineData (20, 20)]
public void GetViewsUnderMouse_Returns_Null_If_Start_Not_Visible (int testX, int testY)
{
// Arrange
var view = new View
{
Frame = new Rectangle (0, 0, 10, 10),
Visible = false
};
var location = new Point (testX, testY);
// Act
var viewsUnderMouse = View.GetViewsUnderMouse (location);
// Assert
Assert.Empty (viewsUnderMouse);
}
[Theory]
[InlineData (0, 0, false)]
[InlineData (1, 1, true)]
[InlineData (9, 9, false)]
[InlineData (10, 10, false)]
[InlineData (6, 7, true)]
[InlineData (1, 2, true)]
[InlineData (5, 6, true)]
public void GetViewsUnderMouse_Returns_Correct_If_SubViews (int testX, int testY, bool expected)
{
// Arrange
Application.Top = new ()
{
Frame = new Rectangle (0, 0, 10, 10)
};
var subView = new View
{
Frame = new Rectangle (1, 1, 8, 8)
};
Application.Top.Add (subView);
var location = new Point (testX, testY);
// Act
var viewsUnderMouse = View.GetViewsUnderMouse (location);
// Assert
if (expected)
{
Assert.Contains (viewsUnderMouse, v => v == subView);
}
else
{
Assert.DoesNotContain (viewsUnderMouse, v => v == subView);
}
Application.Top.Dispose ();
Application.ResetState (ignoreDisposed: true);
}
[Theory]
[InlineData (0, 0, 0, 0, 0, -1, -1, null)]
[InlineData (0, 0, 0, 0, 0, 0, 0, typeof (View))]
[InlineData (0, 0, 0, 0, 0, 1, 1, typeof (View))]
[InlineData (0, 0, 0, 0, 0, 4, 4, typeof (View))]
@@ -104,7 +286,7 @@ public class FindDeepestViewTests ()
}
// Test that FindDeepestView returns the correct view if the start view has no subviews
// Test that GetViewsUnderMouse returns the correct view if the start view has no subviews
[Theory]
[InlineData (0, 0)]
[InlineData (1, 1)]
@@ -116,12 +298,12 @@ public class FindDeepestViewTests ()
Width = 10, Height = 10,
};
Assert.Same (Application.Top, View.FindDeepestView (new (testX, testY)));
Assert.Same (Application.Top, View.GetViewsUnderMouse(new Point(testX, testY)).LastOrDefault());
Application.Top.Dispose ();
Application.ResetState (ignoreDisposed: true);
}
// Test that FindDeepestView returns null if the start view has no subviews and coords are outside the view
// Test that GetViewsUnderMouse returns null if the start view has no subviews and coords are outside the view
[Theory]
[InlineData (0, 0)]
[InlineData (2, 1)]
@@ -134,7 +316,7 @@ public class FindDeepestViewTests ()
Width = 10, Height = 10,
};
Assert.Null (View.FindDeepestView (new (testX, testY)));
Assert.Null (View.GetViewsUnderMouse(new Point(testX, testY)).LastOrDefault());
Application.Top.Dispose ();
Application.ResetState (ignoreDisposed: true);
}
@@ -152,12 +334,12 @@ public class FindDeepestViewTests ()
Visible = false,
};
Assert.Null (View.FindDeepestView (new (testX, testY)));
Assert.Null (View.GetViewsUnderMouse(new Point(testX, testY)).LastOrDefault());
Application.Top.Dispose ();
Application.ResetState (ignoreDisposed: true);
}
// Test that FindDeepestView returns the correct view if the start view has subviews
// Test that GetViewsUnderMouse returns the correct view if the start view has subviews
[Theory]
[InlineData (0, 0, false)]
[InlineData (1, 1, false)]
@@ -181,7 +363,7 @@ public class FindDeepestViewTests ()
};
Application.Top.Add (subview);
var found = View.FindDeepestView (new (testX, testY));
var found = View.GetViewsUnderMouse(new Point(testX, testY)).LastOrDefault();
Assert.Equal (expectedSubViewFound, found == subview);
Application.Top.Dispose ();
@@ -211,7 +393,7 @@ public class FindDeepestViewTests ()
};
Application.Top.Add (subview);
var found = View.FindDeepestView (new (testX, testY));
var found = View.GetViewsUnderMouse(new Point(testX, testY)).LastOrDefault();
Assert.Equal (expectedSubViewFound, found == subview);
Application.Top.Dispose ();
@@ -244,14 +426,14 @@ public class FindDeepestViewTests ()
subview.Visible = true;
Assert.True (subview.Visible);
Assert.False (Application.Top.Visible);
var found = View.FindDeepestView (new (testX, testY));
var found = View.GetViewsUnderMouse(new Point(testX, testY)).LastOrDefault();
Assert.Equal (expectedSubViewFound, found == subview);
Application.Top.Dispose ();
Application.ResetState (ignoreDisposed: true);
}
// Test that FindDeepestView works if the start view has positive Adornments
// Test that GetViewsUnderMouse works if the start view has positive Adornments
[Theory]
[InlineData (0, 0, false)]
[InlineData (1, 1, false)]
@@ -278,14 +460,14 @@ public class FindDeepestViewTests ()
};
Application.Top.Add (subview);
var found = View.FindDeepestView (new (testX, testY));
var found = View.GetViewsUnderMouse(new Point(testX, testY)).LastOrDefault();
Assert.Equal (expectedSubViewFound, found == subview);
Application.Top.Dispose ();
Application.ResetState (ignoreDisposed: true);
}
// Test that FindDeepestView works if the start view has offset Viewport location
// Test that GetViewsUnderMouse works if the start view has offset Viewport location
[Theory]
[InlineData (1, 0, 0, true)]
[InlineData (1, 1, 1, true)]
@@ -311,7 +493,7 @@ public class FindDeepestViewTests ()
};
Application.Top.Add (subview);
var found = View.FindDeepestView (new (testX, testY));
var found = View.GetViewsUnderMouse(new Point(testX, testY)).LastOrDefault();
Assert.Equal (expectedSubViewFound, found == subview);
Application.Top.Dispose ();
@@ -338,14 +520,14 @@ public class FindDeepestViewTests ()
var subview = new View ()
{
X = Pos.AnchorEnd(1), Y = Pos.AnchorEnd(1),
X = Pos.AnchorEnd (1), Y = Pos.AnchorEnd (1),
Width = 1, Height = 1,
};
Application.Top.Padding.Add (subview);
Application.Top.BeginInit();
Application.Top.EndInit();
Application.Top.BeginInit ();
Application.Top.EndInit ();
var found = View.FindDeepestView (new (testX, testY));
var found = View.GetViewsUnderMouse(new Point(testX, testY)).LastOrDefault();
Assert.Equal (expectedSubViewFound, found == subview);
Application.Top.Dispose ();
@@ -381,13 +563,13 @@ public class FindDeepestViewTests ()
};
Application.Top.Add (subview);
var found = View.FindDeepestView (new (testX, testY));
var found = View.GetViewsUnderMouse(new Point(testX, testY)).LastOrDefault();
Assert.Equal (expectedAdornmentType, found!.GetType ());
Application.Top.Dispose ();
Application.ResetState (ignoreDisposed: true);
}
// Test that FindDeepestView works if the subview has positive Adornments
// Test that GetViewsUnderMouse works if the subview has positive Adornments
[Theory]
[InlineData (0, 0, false)]
[InlineData (1, 1, false)]
@@ -414,7 +596,7 @@ public class FindDeepestViewTests ()
subview.Margin.Thickness = new Thickness (1);
Application.Top.Add (subview);
var found = View.FindDeepestView (new (testX, testY));
var found = View.GetViewsUnderMouse(new Point(testX, testY)).LastOrDefault();
Assert.Equal (expectedSubViewFound, found == subview);
Application.Top.Dispose ();
@@ -458,10 +640,10 @@ public class FindDeepestViewTests ()
};
subview.Padding.Add (paddingSubview);
Application.Top.Add (subview);
Application.Top.BeginInit();
Application.Top.EndInit();
Application.Top.BeginInit ();
Application.Top.EndInit ();
var found = View.FindDeepestView (new (testX, testY));
var found = View.GetViewsUnderMouse(new Point(testX, testY)).LastOrDefault();
Assert.Equal (expectedSubViewFound, found == paddingSubview);
Application.Top.Dispose ();
@@ -512,14 +694,14 @@ public class FindDeepestViewTests ()
Application.Top.BeginInit ();
Application.Top.EndInit ();
var found = View.FindDeepestView (new (testX, testY));
var found = View.GetViewsUnderMouse(new (testX, testY)).LastOrDefault();
Assert.Equal (expectedSubViewFound, found == paddingSubview);
Application.Top.Dispose ();
Application.ResetState (ignoreDisposed: true);
}
// Test that FindDeepestView works with nested subviews
// Test that GetViewsUnderMouse works with nested subviews
[Theory]
[InlineData (0, 0, -1)]
[InlineData (9, 9, -1)]
@@ -556,7 +738,7 @@ public class FindDeepestViewTests ()
Application.Top.Add (subviews [0]);
var found = View.FindDeepestView (new (testX, testY));
var found = View.GetViewsUnderMouse(new (testX, testY)).LastOrDefault();
Assert.Equal (expectedSubViewFound, subviews.IndexOf (found!));
Application.Top.Dispose ();
Application.ResetState (ignoreDisposed: true);

View File

@@ -95,7 +95,7 @@ public class PosCombineTests (ITestOutputHelper output)
Assert.Equal (new Rectangle (0, 2, 10, 3), win2.Frame);
Assert.Equal (new Rectangle (0, 0, 8, 1), view2.Frame);
Assert.Equal (new Rectangle (0, 0, 7, 1), view3.Frame);
var foundView = View.FindDeepestView (new (9, 4));
var foundView = View.GetViewsUnderMouse (new Point(9, 4)).LastOrDefault ();
Assert.Equal (foundView, view2);
Application.Top.Dispose ();
Application.ResetState (ignoreDisposed: true);

View File

@@ -945,7 +945,7 @@ public class ToScreenTests (ITestOutputHelper output)
[Fact]
[AutoInitShutdown]
public void ScreenToView_ViewToScreen_FindDeepestView_Full_Top ()
public void ScreenToView_ViewToScreen_GetViewsUnderMouse_Full_Top ()
{
Application.Top = new ();
Application.Top.BorderStyle = LineStyle.Single;
@@ -1003,7 +1003,7 @@ public class ToScreenTests (ITestOutputHelper output)
screen = Application.Top.ViewportToScreen (new Point (-1, -1));
Assert.Equal (0, screen.X);
Assert.Equal (0, screen.Y);
var found = View.FindDeepestView (new (0, 0));
var found = View.GetViewsUnderMouse (new Point(0, 0)).LastOrDefault ();
Assert.Equal (Application.Top.Border, found);
Assert.Equal (0, found.Frame.X);
@@ -1012,12 +1012,12 @@ public class ToScreenTests (ITestOutputHelper output)
screen = Application.Top.ViewportToScreen (new Point (3, 2));
Assert.Equal (4, screen.X);
Assert.Equal (3, screen.Y);
found = View.FindDeepestView (new (screen.X, screen.Y));
found = View.GetViewsUnderMouse (new Point(screen.X, screen.Y)).LastOrDefault ();
Assert.Equal (view, found);
//Assert.Equal (0, found.FrameToScreen ().X);
//Assert.Equal (0, found.FrameToScreen ().Y);
found = View.FindDeepestView (new (3, 2));
found = View.GetViewsUnderMouse (new Point(3, 2)).LastOrDefault ();
Assert.Equal (Application.Top, found);
//Assert.Equal (3, found.FrameToScreen ().X);
@@ -1026,7 +1026,7 @@ public class ToScreenTests (ITestOutputHelper output)
screen = Application.Top.ViewportToScreen (new Point (12, 2));
Assert.Equal (13, screen.X);
Assert.Equal (3, screen.Y);
found = View.FindDeepestView (new (screen.X, screen.Y));
found = View.GetViewsUnderMouse (new Point(screen.X, screen.Y)).LastOrDefault ();
Assert.Equal (view, found);
//Assert.Equal (9, found.FrameToScreen ().X);
@@ -1034,7 +1034,7 @@ public class ToScreenTests (ITestOutputHelper output)
screen = Application.Top.ViewportToScreen (new Point (13, 2));
Assert.Equal (14, screen.X);
Assert.Equal (3, screen.Y);
found = View.FindDeepestView (new (13, 2));
found = View.GetViewsUnderMouse (new Point(13, 2)).LastOrDefault ();
Assert.Equal (Application.Top, found);
//Assert.Equal (13, found.FrameToScreen ().X);
@@ -1043,7 +1043,7 @@ public class ToScreenTests (ITestOutputHelper output)
screen = Application.Top.ViewportToScreen (new Point (14, 3));
Assert.Equal (15, screen.X);
Assert.Equal (4, screen.Y);
found = View.FindDeepestView (new (14, 3));
found = View.GetViewsUnderMouse (new Point(14, 3)).LastOrDefault ();
Assert.Equal (Application.Top, found);
//Assert.Equal (14, found.FrameToScreen ().X);
@@ -1066,28 +1066,28 @@ public class ToScreenTests (ITestOutputHelper output)
screen = view.ViewportToScreen (new Point (-4, -3));
Assert.Equal (0, screen.X);
Assert.Equal (0, screen.Y);
found = View.FindDeepestView (new (0, 0));
found = View.GetViewsUnderMouse (new Point(0, 0)).LastOrDefault ();
Assert.Equal (Application.Top.Border, found);
Assert.Equal (new (-1, -1), view.ScreenToFrame (new (3, 2)));
screen = view.ViewportToScreen (new Point (0, 0));
Assert.Equal (4, screen.X);
Assert.Equal (3, screen.Y);
found = View.FindDeepestView (new (4, 3));
found = View.GetViewsUnderMouse (new Point(4, 3)).LastOrDefault ();
Assert.Equal (view, found);
Assert.Equal (new (9, -1), view.ScreenToFrame (new (13, 2)));
screen = view.ViewportToScreen (new Point (10, 0));
Assert.Equal (14, screen.X);
Assert.Equal (3, screen.Y);
found = View.FindDeepestView (new (14, 3));
found = View.GetViewsUnderMouse (new Point(14, 3)).LastOrDefault ();
Assert.Equal (Application.Top, found);
Assert.Equal (new (10, 0), view.ScreenToFrame (new (14, 3)));
screen = view.ViewportToScreen (new Point (11, 1));
Assert.Equal (15, screen.X);
Assert.Equal (4, screen.Y);
found = View.FindDeepestView (new (15, 4));
found = View.GetViewsUnderMouse (new Point(15, 4)).LastOrDefault ();
Assert.Equal (Application.Top, found);
Application.Top.Dispose ();
@@ -1096,7 +1096,7 @@ public class ToScreenTests (ITestOutputHelper output)
[Fact]
[AutoInitShutdown]
public void ScreenToView_ViewToScreen_FindDeepestView_Smaller_Top ()
public void ScreenToView_ViewToScreen_GetViewsUnderMouse_Smaller_Top ()
{
Application.Top = new ()
{
@@ -1165,13 +1165,13 @@ public class ToScreenTests (ITestOutputHelper output)
screen = Application.Top.ViewportToScreen (new Point (-4, -3));
Assert.Equal (0, screen.X);
Assert.Equal (0, screen.Y);
var found = View.FindDeepestView (new (-4, -3));
var found = View.GetViewsUnderMouse (new Point(-4, -3)).LastOrDefault ();
Assert.Null (found);
Assert.Equal (Point.Empty, Application.Top.ScreenToFrame (new (3, 2)));
screen = Application.Top.ViewportToScreen (new Point (0, 0));
Assert.Equal (4, screen.X);
Assert.Equal (3, screen.Y);
Assert.Equal (Application.Top.Border, View.FindDeepestView (new (3, 2)));
Assert.Equal (Application.Top.Border, View.GetViewsUnderMouse (new Point(3, 2)).LastOrDefault ());
//Assert.Equal (0, found.FrameToScreen ().X);
//Assert.Equal (0, found.FrameToScreen ().Y);
@@ -1179,7 +1179,7 @@ public class ToScreenTests (ITestOutputHelper output)
screen = Application.Top.ViewportToScreen (new Point (10, 0));
Assert.Equal (14, screen.X);
Assert.Equal (3, screen.Y);
Assert.Equal (Application.Top.Border, View.FindDeepestView (new (13, 2)));
Assert.Equal (Application.Top.Border, View.GetViewsUnderMouse (new Point(13, 2)).LastOrDefault ());
//Assert.Equal (10, found.FrameToScreen ().X);
//Assert.Equal (0, found.FrameToScreen ().Y);
@@ -1187,7 +1187,7 @@ public class ToScreenTests (ITestOutputHelper output)
screen = Application.Top.ViewportToScreen (new Point (11, 1));
Assert.Equal (15, screen.X);
Assert.Equal (4, screen.Y);
Assert.Equal (Application.Top, View.FindDeepestView (new (14, 3)));
Assert.Equal (Application.Top, View.GetViewsUnderMouse (new Point(14, 3)).LastOrDefault ());
// view
Assert.Equal (new (-7, -5), view.ScreenToFrame (new (0, 0)));
@@ -1203,32 +1203,32 @@ public class ToScreenTests (ITestOutputHelper output)
screen = view.ViewportToScreen (new Point (-6, -4));
Assert.Equal (1, screen.X);
Assert.Equal (1, screen.Y);
Assert.Null (View.FindDeepestView (new (1, 1)));
Assert.Null (View.GetViewsUnderMouse (new Point(1, 1)).LastOrDefault ());
Assert.Equal (new (-4, -3), view.ScreenToFrame (new (3, 2)));
screen = view.ViewportToScreen (new Point (-3, -2));
Assert.Equal (4, screen.X);
Assert.Equal (3, screen.Y);
Assert.Equal (Application.Top, View.FindDeepestView (new (4, 3)));
Assert.Equal (Application.Top, View.GetViewsUnderMouse (new Point(4, 3)).LastOrDefault ());
Assert.Equal (new (-1, -1), view.ScreenToFrame (new (6, 4)));
screen = view.ViewportToScreen (new Point (0, 0));
Assert.Equal (7, screen.X);
Assert.Equal (5, screen.Y);
Assert.Equal (view, View.FindDeepestView (new (7, 5)));
Assert.Equal (view, View.GetViewsUnderMouse (new Point(7, 5)).LastOrDefault ());
Assert.Equal (new (6, -1), view.ScreenToFrame (new (13, 4)));
screen = view.ViewportToScreen (new Point (7, 0));
Assert.Equal (14, screen.X);
Assert.Equal (5, screen.Y);
Assert.Equal (view, View.FindDeepestView (new (14, 5)));
Assert.Equal (view, View.GetViewsUnderMouse (new Point(14, 5)).LastOrDefault ());
Assert.Equal (new (7, -2), view.ScreenToFrame (new (14, 3)));
screen = view.ViewportToScreen (new Point (8, -1));
Assert.Equal (15, screen.X);
Assert.Equal (4, screen.Y);
Assert.Equal (Application.Top, View.FindDeepestView (new (15, 4)));
Assert.Equal (Application.Top, View.GetViewsUnderMouse (new Point(15, 4)).LastOrDefault ());
Assert.Equal (new (16, -2), view.ScreenToFrame (new (23, 3)));
screen = view.ViewportToScreen (new Point (17, -1));
Assert.Equal (24, screen.X);
Assert.Equal (4, screen.Y);
Assert.Null (View.FindDeepestView (new (24, 4)));
Assert.Null (View.GetViewsUnderMouse (new Point(24, 4)).LastOrDefault ());
Application.Top.Dispose ();
}
}