mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 00:46:39 +01:00
Fix up tests
This commit is contained in:
@@ -327,17 +327,20 @@ namespace Terminal.Gui {
|
||||
Height = Dim.Fill (),
|
||||
parentSplitPanel = this,
|
||||
};
|
||||
|
||||
// Take everything out of the Panel we are moving
|
||||
var childViews = toMove.Subviews.ToArray();
|
||||
toMove.RemoveAll ();
|
||||
|
||||
// Replace current child contents
|
||||
// Remove the panel itself and replace it with the new SplitContainer
|
||||
Remove (toMove);
|
||||
Add (newContainer);
|
||||
|
||||
// Set Panel (1 or 2) to the new container
|
||||
newSplitContainerSetter(newContainer);
|
||||
|
||||
// Set the original content into the first panel of the new container
|
||||
newContainer.Add (toMove);
|
||||
newContainer.Panel1 = toMove;
|
||||
// Add the original content into the first panel of the new container
|
||||
foreach(var childView in childViews) {
|
||||
newContainer.Panel1.Add (childView);
|
||||
}
|
||||
|
||||
result = newContainer;
|
||||
return true;
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Xml.Linq;
|
||||
using Terminal.Gui;
|
||||
using Terminal.Gui.Graphs;
|
||||
|
||||
@@ -17,6 +13,7 @@ namespace UICatalog.Scenarios {
|
||||
private CheckBox cbHorizontal;
|
||||
private CheckBox cbBorder;
|
||||
private CheckBox cbTitles;
|
||||
private CheckBox cbUseLabels;
|
||||
|
||||
bool loaded = false;
|
||||
int panelsCreated;
|
||||
@@ -56,6 +53,11 @@ namespace UICatalog.Scenarios {
|
||||
};
|
||||
cbTitles.Toggled += (s) => SetupSplitContainer ();
|
||||
|
||||
cbUseLabels = new CheckBox ("Use Labels") {
|
||||
X = Pos.Right (cbTitles) + 1
|
||||
};
|
||||
cbUseLabels.Toggled += (s) => SetupSplitContainer ();
|
||||
|
||||
workArea = new View {
|
||||
X = 0,
|
||||
Y = 1,
|
||||
@@ -73,6 +75,7 @@ namespace UICatalog.Scenarios {
|
||||
Win.Add (cbHorizontal);
|
||||
Win.Add (cbBorder);
|
||||
Win.Add (cbTitles);
|
||||
Win.Add (cbUseLabels);
|
||||
Win.Add (workArea);
|
||||
|
||||
SetupSplitContainer ();
|
||||
@@ -100,8 +103,8 @@ namespace UICatalog.Scenarios {
|
||||
Terminal.Gui.Graphs.Orientation.Horizontal :
|
||||
Terminal.Gui.Graphs.Orientation.Vertical);
|
||||
|
||||
root.Panel1.Add (CreateTextView (1));
|
||||
root.Panel2.Add (CreateTextView (2));
|
||||
root.Panel1.Add (CreateContentControl (1));
|
||||
root.Panel2.Add (CreateContentControl (2));
|
||||
|
||||
|
||||
root.IntegratedBorder = border ? BorderStyle.Rounded : BorderStyle.None;
|
||||
@@ -125,11 +128,26 @@ namespace UICatalog.Scenarios {
|
||||
}
|
||||
}
|
||||
|
||||
private View CreateContentControl (int number)
|
||||
{
|
||||
return cbUseLabels.Checked ?
|
||||
CreateLabelView (number) :
|
||||
CreateTextView (number);
|
||||
}
|
||||
|
||||
private View CreateLabelView (int number)
|
||||
{
|
||||
return new Label {
|
||||
Width = Dim.Fill (),
|
||||
Height = 1,
|
||||
Text = number.ToString ().Repeat (1000),
|
||||
};
|
||||
}
|
||||
private View CreateTextView (int number)
|
||||
{
|
||||
return new TextView {
|
||||
Width = Dim.Fill (),
|
||||
Height = Dim.Fill (),
|
||||
Height = Dim.Fill(),
|
||||
Text = number.ToString ().Repeat (1000),
|
||||
AllowsTab = false,
|
||||
//WordWrap = true, // TODO: This is very slow (like 10s to render with 45 panels)
|
||||
@@ -184,7 +202,7 @@ namespace UICatalog.Scenarios {
|
||||
Orientation.Horizontal :
|
||||
Orientation.Vertical;
|
||||
|
||||
newContainer.Panel2.Add (CreateTextView (panelsCreated));
|
||||
newContainer.Panel2.Add (CreateContentControl(panelsCreated));
|
||||
}
|
||||
|
||||
private SplitContainer CreateSplitContainer (int titleNumber, Orientation orientation)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace UnitTests {
|
||||
string looksLike =
|
||||
@"
|
||||
11111│22222
|
||||
│
|
||||
11111│22222
|
||||
│ ";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace UnitTests {
|
||||
string looksLike =
|
||||
@"
|
||||
11111│22222
|
||||
◊
|
||||
11111◊22222
|
||||
│ ";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace UnitTests {
|
||||
looksLike =
|
||||
@"
|
||||
111111│2222
|
||||
◊
|
||||
111111◊2222
|
||||
│ ";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace UnitTests {
|
||||
looksLike =
|
||||
@"
|
||||
1111│222222
|
||||
◊
|
||||
1111◊222222
|
||||
│ ";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
}
|
||||
@@ -148,7 +148,7 @@ namespace UnitTests {
|
||||
string looksLike =
|
||||
@"
|
||||
11111│22222
|
||||
◊
|
||||
11111◊22222
|
||||
│ ";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace UnitTests {
|
||||
looksLike =
|
||||
@"
|
||||
111111│2222
|
||||
◊
|
||||
111111◊2222
|
||||
│ ";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace UnitTests {
|
||||
looksLike =
|
||||
@"
|
||||
1111│222222
|
||||
◊
|
||||
1111◊222222
|
||||
│ ";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
// Even when moving the splitter location it should stay a Percentage based one
|
||||
@@ -223,7 +223,7 @@ namespace UnitTests {
|
||||
string looksLike =
|
||||
@"
|
||||
111111│2222
|
||||
◊
|
||||
111111◊2222
|
||||
│ ";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace UnitTests {
|
||||
looksLike =
|
||||
@"
|
||||
1111111│222
|
||||
◊
|
||||
1111111◊222
|
||||
│ ";
|
||||
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
@@ -312,7 +312,7 @@ namespace UnitTests {
|
||||
string looksLike =
|
||||
@"
|
||||
1111│222222
|
||||
◊
|
||||
1111◊222222
|
||||
│ ";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
@@ -331,7 +331,7 @@ namespace UnitTests {
|
||||
looksLike =
|
||||
@"
|
||||
111│2222222
|
||||
◊
|
||||
111◊2222222
|
||||
│ ";
|
||||
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
@@ -404,7 +404,7 @@ namespace UnitTests {
|
||||
looksLike =
|
||||
@"
|
||||
11111111111
|
||||
|
||||
11111111111
|
||||
─────◊─────";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
@@ -415,6 +415,7 @@ namespace UnitTests {
|
||||
looksLike =
|
||||
@"
|
||||
─────◊─────
|
||||
22222222222
|
||||
22222222222";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
}
|
||||
@@ -448,7 +449,7 @@ namespace UnitTests {
|
||||
looksLike =
|
||||
@"
|
||||
11111111111
|
||||
|
||||
11111111111
|
||||
─────◊─────";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
@@ -481,14 +482,57 @@ 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)
|
||||
[Fact,AutoInitShutdown]
|
||||
public void TestNestedContainer2LeftAnd1Right_RendersNicely()
|
||||
{
|
||||
var splitContainer = GetNestedContainer2Left1Right (false);
|
||||
splitContainer.Redraw (splitContainer.Bounds);
|
||||
|
||||
string looksLike =
|
||||
@"
|
||||
1111111111│22222222
|
||||
1111111111│22222222
|
||||
│
|
||||
│
|
||||
│
|
||||
──────────┤
|
||||
│
|
||||
│
|
||||
│
|
||||
│";
|
||||
TestHelpers.AssertDriverContentsAre (looksLike, output);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vertical orientation root container with left pane split into
|
||||
/// two (with horizontal splitter line).
|
||||
/// </summary>
|
||||
/// <param name="withBorder"></param>
|
||||
/// <returns></returns>
|
||||
private SplitContainer GetNestedContainer2Left1Right(bool withBorder)
|
||||
{
|
||||
var container = GetSplitContainer (20, 10,withBorder);
|
||||
Assert.True (container.TrySplitPanel1 (out var newContainer));
|
||||
|
||||
newContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
|
||||
newContainer.ColorScheme = new ColorScheme ();
|
||||
container.ColorScheme = new ColorScheme ();
|
||||
|
||||
container.LayoutSubviews ();
|
||||
return container;
|
||||
}
|
||||
|
||||
private LineView GetLine (SplitContainer splitContainer)
|
||||
{
|
||||
return splitContainer.Subviews.OfType<LineView> ().Single ();
|
||||
}
|
||||
|
||||
private void SetInputFocusLine (SplitContainer splitContainer)
|
||||
{
|
||||
var line = GetSplitContainerLineView (splitContainer);
|
||||
var line = GetLine (splitContainer);
|
||||
line.SetFocus ();
|
||||
Assert.True (line.HasFocus);
|
||||
}
|
||||
@@ -496,23 +540,28 @@ namespace UnitTests {
|
||||
private SplitContainer Get11By3SplitContainer(out LineView line, bool withBorder = false)
|
||||
{
|
||||
var split = Get11By3SplitContainer (withBorder);
|
||||
line = GetSplitContainerLineView (split);
|
||||
line = GetLine (split);
|
||||
|
||||
return split;
|
||||
}
|
||||
|
||||
private SplitContainer Get11By3SplitContainer (bool withBorder = false)
|
||||
{
|
||||
return GetSplitContainer (11, 3, withBorder);
|
||||
}
|
||||
private SplitContainer GetSplitContainer (int width, int height, bool withBorder = false)
|
||||
{
|
||||
var container = new SplitContainer () {
|
||||
Width = 11,
|
||||
Height = 3,
|
||||
Width = width,
|
||||
Height = height,
|
||||
};
|
||||
|
||||
container.IntegratedBorder = withBorder ? BorderStyle.Single : BorderStyle.None;
|
||||
|
||||
container.Panel1.Add (new Label (new string ('1', 100)));
|
||||
container.Panel1.Add (new Label (new string ('1', 100)) { Y = 1});
|
||||
container.Panel2.Add (new Label (new string ('2', 100)));
|
||||
|
||||
container.Panel2.Add (new Label (new string ('2', 100)) { Y = 1});
|
||||
|
||||
container.Panel1MinSize = 0;
|
||||
container.Panel2MinSize = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user