|
@@ -18,7 +18,7 @@ namespace UnitTests {
|
|
|
[Fact, AutoInitShutdown]
|
|
|
public void TestSplitContainer_Vertical ()
|
|
|
{
|
|
|
- var splitContainer = Get11By3SplitContainer ();
|
|
|
+ var splitContainer = Get11By3SplitContainer (out var line);
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
|
|
|
string looksLike =
|
|
@@ -29,7 +29,7 @@ namespace UnitTests {
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
|
|
|
// Keyboard movement on splitter should have no effect if it is not focused
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
|
|
splitContainer.SetNeedsDisplay ();
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
@@ -38,7 +38,7 @@ namespace UnitTests {
|
|
|
[Fact, AutoInitShutdown]
|
|
|
public void TestSplitContainer_Vertical_WithBorder ()
|
|
|
{
|
|
|
- var splitContainer = Get11By3SplitContainer (true);
|
|
|
+ var splitContainer = Get11By3SplitContainer (out var line, true);
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
|
|
|
string looksLike =
|
|
@@ -49,7 +49,7 @@ namespace UnitTests {
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
|
|
|
// Keyboard movement on splitter should have no effect if it is not focused
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
|
|
splitContainer.SetNeedsDisplay ();
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
@@ -58,7 +58,7 @@ namespace UnitTests {
|
|
|
[Fact, AutoInitShutdown]
|
|
|
public void TestSplitContainer_Vertical_Focused ()
|
|
|
{
|
|
|
- var splitContainer = Get11By3SplitContainer ();
|
|
|
+ var splitContainer = Get11By3SplitContainer (out var line);
|
|
|
SetInputFocusLine (splitContainer);
|
|
|
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
@@ -71,7 +71,7 @@ namespace UnitTests {
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
|
|
|
// Now while focused move the splitter 1 unit right
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
|
|
|
looksLike =
|
|
@@ -83,8 +83,8 @@ namespace UnitTests {
|
|
|
|
|
|
|
|
|
// and 2 to the left
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
|
|
|
looksLike =
|
|
@@ -98,7 +98,7 @@ namespace UnitTests {
|
|
|
[Fact, AutoInitShutdown]
|
|
|
public void TestSplitContainer_Vertical_Focused_WithBorder ()
|
|
|
{
|
|
|
- var splitContainer = Get11By3SplitContainer (true);
|
|
|
+ var splitContainer = Get11By3SplitContainer (out var line, true);
|
|
|
SetInputFocusLine (splitContainer);
|
|
|
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
@@ -111,7 +111,7 @@ namespace UnitTests {
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
|
|
|
// Now while focused move the splitter 1 unit right
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
|
|
|
looksLike =
|
|
@@ -123,8 +123,8 @@ namespace UnitTests {
|
|
|
|
|
|
|
|
|
// and 2 to the left
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
|
|
|
looksLike =
|
|
@@ -139,7 +139,7 @@ namespace UnitTests {
|
|
|
[Fact, AutoInitShutdown]
|
|
|
public void TestSplitContainer_Vertical_Focused_50PercentSplit ()
|
|
|
{
|
|
|
- var splitContainer = Get11By3SplitContainer ();
|
|
|
+ var splitContainer = Get11By3SplitContainer (out var line);
|
|
|
SetInputFocusLine (splitContainer);
|
|
|
splitContainer.SplitterDistance = Pos.Percent (50);
|
|
|
Assert.IsType<Pos.PosFactor> (splitContainer.SplitterDistance);
|
|
@@ -153,7 +153,7 @@ namespace UnitTests {
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
|
|
|
// Now while focused move the splitter 1 unit right
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
|
|
|
looksLike =
|
|
@@ -168,8 +168,8 @@ namespace UnitTests {
|
|
|
|
|
|
|
|
|
// and 2 to the left
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
|
|
|
looksLike =
|
|
@@ -185,7 +185,7 @@ namespace UnitTests {
|
|
|
[Fact, AutoInitShutdown]
|
|
|
public void TestSplitContainer_Horizontal ()
|
|
|
{
|
|
|
- var splitContainer = Get11By3SplitContainer ();
|
|
|
+ var splitContainer = Get11By3SplitContainer (out var line);
|
|
|
splitContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
|
|
@@ -197,7 +197,7 @@ namespace UnitTests {
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
|
|
|
// Keyboard movement on splitter should have no effect if it is not focused
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
|
|
|
splitContainer.SetNeedsDisplay ();
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
@@ -207,7 +207,7 @@ namespace UnitTests {
|
|
|
[Fact, AutoInitShutdown]
|
|
|
public void TestSplitContainer_Vertical_Panel1MinSize_Absolute ()
|
|
|
{
|
|
|
- var splitContainer = Get11By3SplitContainer ();
|
|
|
+ var splitContainer = Get11By3SplitContainer (out var line);
|
|
|
SetInputFocusLine (splitContainer);
|
|
|
splitContainer.Panels [0].MinSize = 6;
|
|
|
|
|
@@ -229,13 +229,13 @@ namespace UnitTests {
|
|
|
|
|
|
// Keyboard movement on splitter should have no effect because it
|
|
|
// would take us below the minimum splitter size
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
|
|
|
splitContainer.SetNeedsDisplay ();
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
|
|
|
// but we can continue to move the splitter right if we want
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
|
|
|
splitContainer.SetNeedsDisplay ();
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
|
|
@@ -251,7 +251,7 @@ namespace UnitTests {
|
|
|
[Fact, AutoInitShutdown]
|
|
|
public void TestSplitContainer_Horizontal_Focused ()
|
|
|
{
|
|
|
- var splitContainer = Get11By3SplitContainer ();
|
|
|
+ var splitContainer = Get11By3SplitContainer (out var line);
|
|
|
|
|
|
splitContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
|
|
|
SetInputFocusLine (splitContainer);
|
|
@@ -266,7 +266,7 @@ namespace UnitTests {
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
|
|
|
// Now move splitter line down
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
looksLike =
|
|
|
@"
|
|
@@ -276,8 +276,8 @@ namespace UnitTests {
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
|
|
|
// And 2 up
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
looksLike =
|
|
|
@"
|
|
@@ -290,7 +290,7 @@ namespace UnitTests {
|
|
|
[Fact, AutoInitShutdown]
|
|
|
public void TestSplitContainer_Horizontal_Panel1MinSize_Absolute ()
|
|
|
{
|
|
|
- var splitContainer = Get11By3SplitContainer ();
|
|
|
+ var splitContainer = Get11By3SplitContainer (out var line);
|
|
|
|
|
|
splitContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
|
|
|
SetInputFocusLine (splitContainer);
|
|
@@ -310,7 +310,7 @@ namespace UnitTests {
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
|
|
|
// Now move splitter line down (allowed
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
looksLike =
|
|
|
@"
|
|
@@ -320,8 +320,8 @@ namespace UnitTests {
|
|
|
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
|
|
|
|
|
// And up 2 (only 1 is allowed because of minimum size of 1 on panel1)
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
|
|
|
- splitContainer.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
|
|
|
+ line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
|
|
|
splitContainer.Redraw (splitContainer.Bounds);
|
|
|
looksLike =
|
|
|
@"
|
|
@@ -348,13 +348,26 @@ namespace UnitTests {
|
|
|
Assert.Equal ("Only Percent and Absolute values are supported for SplitterDistance property. Passed value was PosCombine", ex.Message);
|
|
|
}
|
|
|
|
|
|
+ private LineView GetSplitContainerLineView (SplitContainer splitContainer)
|
|
|
+ {
|
|
|
+ return splitContainer.Subviews [0].Subviews.OfType<LineView> ().Single ();
|
|
|
+ }
|
|
|
+
|
|
|
private void SetInputFocusLine (SplitContainer splitContainer)
|
|
|
{
|
|
|
- var line = splitContainer.Subviews [0].Subviews.OfType<LineView> ().Single ();
|
|
|
+ var line = GetSplitContainerLineView (splitContainer);
|
|
|
line.SetFocus ();
|
|
|
Assert.True (line.HasFocus);
|
|
|
}
|
|
|
|
|
|
+ private SplitContainer Get11By3SplitContainer(out LineView line, bool withBorder = false)
|
|
|
+ {
|
|
|
+ var split = Get11By3SplitContainer (withBorder);
|
|
|
+ line = GetSplitContainerLineView (split);
|
|
|
+
|
|
|
+ return split;
|
|
|
+ }
|
|
|
+
|
|
|
private SplitContainer Get11By3SplitContainer (bool withBorder = false)
|
|
|
{
|
|
|
var container = new SplitContainer () {
|