|
@@ -271,6 +271,40 @@ public class FindDeepestViewTests (ITestOutputHelper output)
|
|
|
Assert.Equal (expectedSubViewFound, found == subview);
|
|
|
}
|
|
|
|
|
|
+ [Theory]
|
|
|
+ [InlineData (0, 0, false)]
|
|
|
+ [InlineData (1, 1, false)]
|
|
|
+ [InlineData (9, 9, true)]
|
|
|
+ [InlineData (10, 10, false)]
|
|
|
+ [InlineData (7, 8, false)]
|
|
|
+ [InlineData (1, 2, false)]
|
|
|
+ [InlineData (2, 3, false)]
|
|
|
+ [InlineData (5, 6, false)]
|
|
|
+ [InlineData (2, 3, false)]
|
|
|
+ [InlineData (6, 7, false)]
|
|
|
+ public void Returns_Correct_If_Start_Has_Adornment_WithSubview (int testX, int testY, bool expectedSubViewFound)
|
|
|
+ {
|
|
|
+ var start = new View ()
|
|
|
+ {
|
|
|
+ Width = 10, Height = 10,
|
|
|
+ };
|
|
|
+ start.Padding.Thickness = new Thickness (1);
|
|
|
+
|
|
|
+ var subview = new View ()
|
|
|
+ {
|
|
|
+ X = Pos.AnchorEnd(1), Y = Pos.AnchorEnd(1),
|
|
|
+ Width = 1, Height = 1,
|
|
|
+ };
|
|
|
+ start.Padding.Add (subview);
|
|
|
+ start.BeginInit();
|
|
|
+ start.EndInit();
|
|
|
+
|
|
|
+ var found = View.FindDeepestView (start, testX, testY);
|
|
|
+
|
|
|
+ Assert.Equal (expectedSubViewFound, found == subview);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
[Theory]
|
|
|
[InlineData (0, 0, typeof (Margin))]
|
|
|
[InlineData (9, 9, typeof (Margin))]
|
|
@@ -336,6 +370,99 @@ public class FindDeepestViewTests (ITestOutputHelper output)
|
|
|
Assert.Equal (expectedSubViewFound, found == subview);
|
|
|
}
|
|
|
|
|
|
+ [Theory]
|
|
|
+ [InlineData (0, 0, false)]
|
|
|
+ [InlineData (1, 1, false)]
|
|
|
+ [InlineData (9, 9, false)]
|
|
|
+ [InlineData (10, 10, false)]
|
|
|
+ [InlineData (7, 8, false)]
|
|
|
+ [InlineData (6, 7, false)]
|
|
|
+ [InlineData (1, 2, false)]
|
|
|
+ [InlineData (5, 6, false)]
|
|
|
+ [InlineData (6, 5, false)]
|
|
|
+ [InlineData (5, 5, true)]
|
|
|
+ public void Returns_Correct_If_SubView_Has_Adornment_WithSubview (int testX, int testY, bool expectedSubViewFound)
|
|
|
+ {
|
|
|
+ var start = new View ()
|
|
|
+ {
|
|
|
+ Width = 10, Height = 10,
|
|
|
+ };
|
|
|
+
|
|
|
+ // A subview with + Padding
|
|
|
+ var subview = new View ()
|
|
|
+ {
|
|
|
+ X = 1, Y = 1,
|
|
|
+ Width = 5, Height = 5,
|
|
|
+ };
|
|
|
+ subview.Padding.Thickness = new (1);
|
|
|
+
|
|
|
+ // This subview will be at the bottom-right-corner of subview
|
|
|
+ // So screen-relative location will be X + Width - 1 = 5
|
|
|
+ var paddingSubview = new View ()
|
|
|
+ {
|
|
|
+ X = Pos.AnchorEnd (1),
|
|
|
+ Y = Pos.AnchorEnd (1),
|
|
|
+ Width = 1,
|
|
|
+ Height = 1,
|
|
|
+ };
|
|
|
+ subview.Padding.Add (paddingSubview);
|
|
|
+ start.Add (subview);
|
|
|
+ start.BeginInit();
|
|
|
+ start.EndInit();
|
|
|
+
|
|
|
+ var found = View.FindDeepestView (start, testX, testY);
|
|
|
+
|
|
|
+ Assert.Equal (expectedSubViewFound, found == paddingSubview);
|
|
|
+ }
|
|
|
+
|
|
|
+ [Theory]
|
|
|
+ [InlineData (0, 0, false)]
|
|
|
+ [InlineData (1, 1, false)]
|
|
|
+ [InlineData (9, 9, false)]
|
|
|
+ [InlineData (10, 10, false)]
|
|
|
+ [InlineData (7, 8, false)]
|
|
|
+ [InlineData (6, 7, false)]
|
|
|
+ [InlineData (1, 2, false)]
|
|
|
+ [InlineData (5, 6, false)]
|
|
|
+ [InlineData (6, 5, false)]
|
|
|
+ [InlineData (5, 5, true)]
|
|
|
+ public void Returns_Correct_If_SubView_Is_Scrolled_And_Has_Adornment_WithSubview (int testX, int testY, bool expectedSubViewFound)
|
|
|
+ {
|
|
|
+ var start = new View ()
|
|
|
+ {
|
|
|
+ Width = 10, Height = 10,
|
|
|
+ };
|
|
|
+
|
|
|
+ // A subview with + Padding
|
|
|
+ var subview = new View ()
|
|
|
+ {
|
|
|
+ X = 1, Y = 1,
|
|
|
+ Width = 5, Height = 5,
|
|
|
+ };
|
|
|
+ subview.Padding.Thickness = new (1);
|
|
|
+
|
|
|
+ // Scroll the subview
|
|
|
+ subview.ContentSize = new Size (10, 10);
|
|
|
+ subview.Viewport = subview.Viewport with { Location = new (1, 1) };
|
|
|
+
|
|
|
+ // This subview will be at the bottom-right-corner of subview
|
|
|
+ // So screen-relative location will be X + Width - 1 = 5
|
|
|
+ var paddingSubview = new View ()
|
|
|
+ {
|
|
|
+ X = Pos.AnchorEnd (1),
|
|
|
+ Y = Pos.AnchorEnd (1),
|
|
|
+ Width = 1,
|
|
|
+ Height = 1,
|
|
|
+ };
|
|
|
+ subview.Padding.Add (paddingSubview);
|
|
|
+ start.Add (subview);
|
|
|
+ start.BeginInit ();
|
|
|
+ start.EndInit ();
|
|
|
+
|
|
|
+ var found = View.FindDeepestView (start, testX, testY);
|
|
|
+
|
|
|
+ Assert.Equal (expectedSubViewFound, found == paddingSubview);
|
|
|
+ }
|
|
|
// Test that FindDeepestView works with nested subviews
|
|
|
[Theory]
|
|
|
[InlineData (0, 0, -1)]
|