|
@@ -16,14 +16,14 @@ public class FindDeepestViewTests (ITestOutputHelper output)
|
|
[InlineData (2, 2)]
|
|
[InlineData (2, 2)]
|
|
public void Returns_Start_If_No_SubViews (int testX, int testY)
|
|
public void Returns_Start_If_No_SubViews (int testX, int testY)
|
|
{
|
|
{
|
|
- var view = new View ()
|
|
|
|
|
|
+ var start = new View ()
|
|
{
|
|
{
|
|
Width = 10, Height = 10,
|
|
Width = 10, Height = 10,
|
|
};
|
|
};
|
|
|
|
|
|
- Assert.Same (view, View.FindDeepestView (view, testX, testY));
|
|
|
|
|
|
+ Assert.Same (start, View.FindDeepestView (start, testX, testY));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Test that FindDeepestView returns null if the start view has no subviews and coords are outside the view
|
|
// Test that FindDeepestView returns null if the start view has no subviews and coords are outside the view
|
|
[Theory]
|
|
[Theory]
|
|
[InlineData (0, 0)]
|
|
[InlineData (0, 0)]
|
|
@@ -31,13 +31,29 @@ public class FindDeepestViewTests (ITestOutputHelper output)
|
|
[InlineData (20, 20)]
|
|
[InlineData (20, 20)]
|
|
public void Returns_Null_If_No_SubViews_Coords_Outside (int testX, int testY)
|
|
public void Returns_Null_If_No_SubViews_Coords_Outside (int testX, int testY)
|
|
{
|
|
{
|
|
- var view = new View ()
|
|
|
|
|
|
+ var start = new View ()
|
|
|
|
+ {
|
|
|
|
+ X = 1, Y = 2,
|
|
|
|
+ Width = 10, Height = 10,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Assert.Null(View.FindDeepestView (start, testX, testY));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [Theory]
|
|
|
|
+ [InlineData (0, 0)]
|
|
|
|
+ [InlineData (2, 1)]
|
|
|
|
+ [InlineData (20, 20)]
|
|
|
|
+ public void Returns_Null_If_Start_Not_Visible (int testX, int testY)
|
|
|
|
+ {
|
|
|
|
+ var start = new View ()
|
|
{
|
|
{
|
|
X = 1, Y = 2,
|
|
X = 1, Y = 2,
|
|
Width = 10, Height = 10,
|
|
Width = 10, Height = 10,
|
|
|
|
+ Visible = false,
|
|
};
|
|
};
|
|
|
|
|
|
- Assert.Null(View.FindDeepestView (view, testX, testY));
|
|
|
|
|
|
+ Assert.Null (View.FindDeepestView (start, testX, testY));
|
|
}
|
|
}
|
|
|
|
|
|
// Test that FindDeepestView returns the correct view if the start view has subviews
|
|
// Test that FindDeepestView returns the correct view if the start view has subviews
|
|
@@ -52,7 +68,7 @@ public class FindDeepestViewTests (ITestOutputHelper output)
|
|
[InlineData (5, 6, true)]
|
|
[InlineData (5, 6, true)]
|
|
public void Returns_Correct_If_SubViews (int testX, int testY, bool expectedSubViewFound)
|
|
public void Returns_Correct_If_SubViews (int testX, int testY, bool expectedSubViewFound)
|
|
{
|
|
{
|
|
- var view = new View ()
|
|
|
|
|
|
+ var start = new View ()
|
|
{
|
|
{
|
|
Width = 10, Height = 10,
|
|
Width = 10, Height = 10,
|
|
};
|
|
};
|
|
@@ -62,13 +78,73 @@ public class FindDeepestViewTests (ITestOutputHelper output)
|
|
X = 1, Y = 2,
|
|
X = 1, Y = 2,
|
|
Width = 5, Height = 5,
|
|
Width = 5, Height = 5,
|
|
};
|
|
};
|
|
- view.Add (subview);
|
|
|
|
|
|
+ start.Add (subview);
|
|
|
|
|
|
- var found = View.FindDeepestView (view, testX, testY);
|
|
|
|
|
|
+ var found = View.FindDeepestView (start, testX, testY);
|
|
|
|
|
|
Assert.Equal (expectedSubViewFound, found == subview);
|
|
Assert.Equal (expectedSubViewFound, found == subview);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [Theory]
|
|
|
|
+ [InlineData (0, 0, false)]
|
|
|
|
+ [InlineData (1, 1, false)]
|
|
|
|
+ [InlineData (9, 9, false)]
|
|
|
|
+ [InlineData (10, 10, false)]
|
|
|
|
+ [InlineData (6, 7, false)]
|
|
|
|
+ [InlineData (1, 2, false)]
|
|
|
|
+ [InlineData (5, 6, false)]
|
|
|
|
+ public void Returns_Null_If_SubView_NotVisible (int testX, int testY, bool expectedSubViewFound)
|
|
|
|
+ {
|
|
|
|
+ var start = new View ()
|
|
|
|
+ {
|
|
|
|
+ Width = 10, Height = 10,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ var subview = new View ()
|
|
|
|
+ {
|
|
|
|
+ X = 1, Y = 2,
|
|
|
|
+ Width = 5, Height = 5,
|
|
|
|
+ Visible = false
|
|
|
|
+ };
|
|
|
|
+ start.Add (subview);
|
|
|
|
+
|
|
|
|
+ var found = View.FindDeepestView (start, testX, testY);
|
|
|
|
+
|
|
|
|
+ Assert.Equal (expectedSubViewFound, found == subview);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ [Theory]
|
|
|
|
+ [InlineData (0, 0, false)]
|
|
|
|
+ [InlineData (1, 1, false)]
|
|
|
|
+ [InlineData (9, 9, false)]
|
|
|
|
+ [InlineData (10, 10, false)]
|
|
|
|
+ [InlineData (6, 7, false)]
|
|
|
|
+ [InlineData (1, 2, false)]
|
|
|
|
+ [InlineData (5, 6, false)]
|
|
|
|
+ public void Returns_Null_If_Not_Visible_And_SubView_Visible (int testX, int testY, bool expectedSubViewFound)
|
|
|
|
+ {
|
|
|
|
+ var start = new View ()
|
|
|
|
+ {
|
|
|
|
+ Width = 10, Height = 10,
|
|
|
|
+ Visible = false
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ var subview = new View ()
|
|
|
|
+ {
|
|
|
|
+ X = 1, Y = 2,
|
|
|
|
+ Width = 5, Height = 5,
|
|
|
|
+ };
|
|
|
|
+ start.Add (subview);
|
|
|
|
+ subview.Visible = true;
|
|
|
|
+ Assert.True (subview.Visible);
|
|
|
|
+ Assert.False (start.Visible);
|
|
|
|
+ var found = View.FindDeepestView (start, testX, testY);
|
|
|
|
+
|
|
|
|
+ Assert.Equal (expectedSubViewFound, found == subview);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
// Test that FindDeepestView works if the start view has positive Adornments
|
|
// Test that FindDeepestView works if the start view has positive Adornments
|
|
[Theory]
|
|
[Theory]
|
|
[InlineData (0, 0, false)]
|
|
[InlineData (0, 0, false)]
|
|
@@ -84,20 +160,20 @@ public class FindDeepestViewTests (ITestOutputHelper output)
|
|
[InlineData (6, 7, true)]
|
|
[InlineData (6, 7, true)]
|
|
public void Returns_Correct_If_Start_Has_Adornments (int testX, int testY, bool expectedSubViewFound)
|
|
public void Returns_Correct_If_Start_Has_Adornments (int testX, int testY, bool expectedSubViewFound)
|
|
{
|
|
{
|
|
- var view = new View ()
|
|
|
|
|
|
+ var start = new View ()
|
|
{
|
|
{
|
|
Width = 10, Height = 10,
|
|
Width = 10, Height = 10,
|
|
};
|
|
};
|
|
- view.Margin.Thickness = new Thickness (1);
|
|
|
|
|
|
+ start.Margin.Thickness = new Thickness (1);
|
|
|
|
|
|
var subview = new View ()
|
|
var subview = new View ()
|
|
{
|
|
{
|
|
X = 1, Y = 2,
|
|
X = 1, Y = 2,
|
|
Width = 5, Height = 5,
|
|
Width = 5, Height = 5,
|
|
};
|
|
};
|
|
- view.Add (subview);
|
|
|
|
|
|
+ start.Add (subview);
|
|
|
|
|
|
- var found = View.FindDeepestView (view, testX, testY);
|
|
|
|
|
|
+ var found = View.FindDeepestView (start, testX, testY);
|
|
|
|
|
|
Assert.Equal (expectedSubViewFound, found == subview);
|
|
Assert.Equal (expectedSubViewFound, found == subview);
|
|
}
|
|
}
|
|
@@ -117,7 +193,7 @@ public class FindDeepestViewTests (ITestOutputHelper output)
|
|
[InlineData (2, 3, true)]
|
|
[InlineData (2, 3, true)]
|
|
public void Returns_Correct_If_SubView_Has_Adornments (int testX, int testY, bool expectedSubViewFound)
|
|
public void Returns_Correct_If_SubView_Has_Adornments (int testX, int testY, bool expectedSubViewFound)
|
|
{
|
|
{
|
|
- var view = new View ()
|
|
|
|
|
|
+ var start = new View ()
|
|
{
|
|
{
|
|
Width = 10, Height = 10,
|
|
Width = 10, Height = 10,
|
|
};
|
|
};
|
|
@@ -128,9 +204,9 @@ public class FindDeepestViewTests (ITestOutputHelper output)
|
|
Width = 5, Height = 5,
|
|
Width = 5, Height = 5,
|
|
};
|
|
};
|
|
subview.Margin.Thickness = new Thickness (1);
|
|
subview.Margin.Thickness = new Thickness (1);
|
|
- view.Add (subview);
|
|
|
|
|
|
+ start.Add (subview);
|
|
|
|
|
|
- var found = View.FindDeepestView (view, testX, testY);
|
|
|
|
|
|
+ var found = View.FindDeepestView (start, testX, testY);
|
|
|
|
|
|
Assert.Equal (expectedSubViewFound, found == subview);
|
|
Assert.Equal (expectedSubViewFound, found == subview);
|
|
}
|
|
}
|