mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Adds TreeView MaxDepth (#2651)
This commit is contained in:
@@ -131,7 +131,7 @@ namespace Terminal.Gui.ViewsTests {
|
||||
{
|
||||
var tree = CreateTree (out Factory f, out Car car1, out Car car2);
|
||||
tree.BeginInit (); tree.EndInit ();
|
||||
|
||||
|
||||
// control only allows 1 row to be viewed at once
|
||||
tree.Bounds = new Rect (0, 0, 20, 1);
|
||||
|
||||
@@ -902,6 +902,99 @@ namespace Terminal.Gui.ViewsTests {
|
||||
new [] { tv.ColorScheme.Normal, pink });
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestBottomlessTreeView_MaxDepth_5 ()
|
||||
{
|
||||
var tv = new TreeView<string> () { Width = 20, Height = 10 };
|
||||
|
||||
tv.TreeBuilder = new DelegateTreeBuilder<string> (
|
||||
(s) => new [] { (int.Parse (s) + 1).ToString () }
|
||||
);
|
||||
|
||||
tv.AddObject ("1");
|
||||
tv.ColorScheme = new ColorScheme ();
|
||||
|
||||
tv.LayoutSubviews ();
|
||||
tv.Draw ();
|
||||
|
||||
// Nothing expanded
|
||||
TestHelpers.AssertDriverContentsAre (
|
||||
@"└+1
|
||||
", output);
|
||||
tv.MaxDepth = 5;
|
||||
tv.ExpandAll ();
|
||||
|
||||
tv.Draw ();
|
||||
|
||||
// Normal drawing of the tree view
|
||||
TestHelpers.AssertDriverContentsAre (
|
||||
@"
|
||||
└-1
|
||||
└-2
|
||||
└-3
|
||||
└-4
|
||||
└-5
|
||||
└─6
|
||||
", output);
|
||||
Assert.False (tv.CanExpand ("6"));
|
||||
Assert.False (tv.IsExpanded ("6"));
|
||||
|
||||
tv.Collapse("6");
|
||||
|
||||
Assert.False (tv.CanExpand ("6"));
|
||||
Assert.False (tv.IsExpanded ("6"));
|
||||
|
||||
tv.Collapse ("5");
|
||||
|
||||
Assert.True (tv.CanExpand ("5"));
|
||||
Assert.False (tv.IsExpanded ("5"));
|
||||
|
||||
tv.Draw ();
|
||||
|
||||
// Normal drawing of the tree view
|
||||
TestHelpers.AssertDriverContentsAre (
|
||||
@"
|
||||
└-1
|
||||
└-2
|
||||
└-3
|
||||
└-4
|
||||
└+5
|
||||
", output);
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestBottomlessTreeView_MaxDepth_3 ()
|
||||
{
|
||||
var tv = new TreeView<string> () { Width = 20, Height = 10 };
|
||||
|
||||
tv.TreeBuilder = new DelegateTreeBuilder<string> (
|
||||
(s) => new [] { (int.Parse (s) + 1).ToString () }
|
||||
);
|
||||
|
||||
tv.AddObject ("1");
|
||||
tv.ColorScheme = new ColorScheme ();
|
||||
|
||||
tv.LayoutSubviews ();
|
||||
tv.Draw ();
|
||||
|
||||
// Nothing expanded
|
||||
TestHelpers.AssertDriverContentsAre (
|
||||
@"└+1
|
||||
", output);
|
||||
tv.MaxDepth = 3;
|
||||
tv.ExpandAll ();
|
||||
tv.Draw ();
|
||||
|
||||
// Normal drawing of the tree view
|
||||
TestHelpers.AssertDriverContentsAre (
|
||||
@"
|
||||
└-1
|
||||
└-2
|
||||
└-3
|
||||
└─4
|
||||
", output);
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void TestTreeView_Filter ()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user