mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* touching publish.yml
* Fixed UICatalog bugs. Added fluent tests.
* marked v1 menu stuff as obsolte
* Tweaks.
Added View.GetSubMenus<type>().
* fixed unit tests
* general messing around
* general messing around
* Playing with Fluent
* ColorScheme tweaks
* WIP: ColorScheme tweaks
* Playing with Fluent
* Merged from laptop2
* Hacky-ish fixes to:
- #4016
- #4014
* Fixed Region bug preventing menus without borders from working
* Tweaks
* Fixed a bunch of CM issues
* Fixed OoptionSelector
* ip
* FixedCM issues
* Fixed CM issues2
* Revert "FixedCM issues"
This reverts commit dd6c6a70a3.
* Reverted stuff
* Found and fixed bug in AllViews_Center_Properly
* Fixed CM issues2
* removed menuv2 onapplied.
Changed how UICatalog Applys CM
* changed test time out to see if it helkps with ubuntu fails
* reset app on fail?
* back to 1500ms
* Made StatusBar nullable.
* Code Cleanup.
* HexEditor Code Cleanup.
* HexEditor Code Cleanup.
* Back to 3000ms. Sigh.
* Trying different logic
* Trying different logic2
* Fixed potential crash in runlop
* Fixed potential crash in runlop2
* Tweaked Spinner stuff
* Removed TabView from TextEffects scenario. Not needed and possible culprit.
* back to 2000ms
* WIP: Revamping menu scenarios
* Menu Scenario refinements.
Fixed a few bugs.
Code cleanup.
* fixed unit test
* Fixed warnings
* Fixed warnings2
* Fixed File.Exit
* WIP: Dealing with QuitKey struggles
* WIP: Dealing with QuitKey struggles 2
* WIP: Dealing with QuitKey struggles 3
* Fixed ListView collection nav bug
* Fixed a bunch of menu stuff.
Fixed Appv2 stuff.
* Lots of refactoring and fixing
* Lots of unit test issues
* Fixed DebugIDisposable issues
* Fixed release build issue
* Fixed release build issue 2
* DebugIDisposable -> EnableDebugIDisposableAsserts and more
* DebugIDisposable -> EnableDebugIDisposableAsserts and more 2
* Fixed Menus scenario - context menu
* Added @bdisp suggested assert. Commented it out as it breaks tests.
* Code cleanup
* Fixed disposed but
* Fixed UICatalog exit
* Fixed Unit test I broke.
Added 'Minimal' Theme that turns off all borders etc...
242 lines
5.6 KiB
C#
242 lines
5.6 KiB
C#
using UnitTests;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Terminal.Gui.ViewTests;
|
|
|
|
[Collection ("Global Test Setup")]
|
|
public class CanFocusTests () : TestsAllViews
|
|
{
|
|
[Fact]
|
|
public void CanFocus_False_Prevents_SubSubView_HasFocus ()
|
|
{
|
|
var view = new View { };
|
|
var subView = new View { };
|
|
var subSubView = new View { CanFocus = true };
|
|
|
|
subView.Add (subSubView);
|
|
view.Add (subView);
|
|
|
|
Assert.False (view.CanFocus);
|
|
Assert.False (subView.CanFocus);
|
|
Assert.True (subSubView.CanFocus);
|
|
|
|
view.SetFocus ();
|
|
Assert.False (view.HasFocus);
|
|
|
|
subView.SetFocus ();
|
|
Assert.False (subView.HasFocus);
|
|
|
|
subSubView.SetFocus ();
|
|
Assert.False (subSubView.HasFocus);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanFocus_False_Prevents_SubView_HasFocus ()
|
|
{
|
|
var view = new View { };
|
|
var subView = new View { CanFocus = true };
|
|
var subSubView = new View { };
|
|
|
|
subView.Add (subSubView);
|
|
view.Add (subView);
|
|
|
|
Assert.False (view.CanFocus);
|
|
Assert.True (subView.CanFocus);
|
|
Assert.False (subSubView.CanFocus);
|
|
|
|
view.SetFocus ();
|
|
Assert.False (view.HasFocus);
|
|
|
|
subView.SetFocus ();
|
|
Assert.False (subView.HasFocus);
|
|
|
|
subSubView.SetFocus ();
|
|
Assert.False (subSubView.HasFocus);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanFocus_Set_True_No_SuperView_Doesnt_Set_HasFocus ()
|
|
{
|
|
var view = new View { };
|
|
|
|
// Act
|
|
view.CanFocus = true;
|
|
Assert.False (view.HasFocus);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanFocus_Set_True_Sets_HasFocus_To_True ()
|
|
{
|
|
var view = new View { };
|
|
var subView = new View { };
|
|
view.Add (subView);
|
|
|
|
Assert.False (view.CanFocus);
|
|
Assert.False (subView.CanFocus);
|
|
|
|
view.SetFocus ();
|
|
Assert.False (view.HasFocus);
|
|
Assert.False (subView.HasFocus);
|
|
|
|
view.CanFocus = true;
|
|
view.SetFocus ();
|
|
Assert.True (view.HasFocus);
|
|
|
|
// Act
|
|
subView.CanFocus = true;
|
|
Assert.True (subView.HasFocus);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanFocus_Set_SubView_True_Sets_HasFocus_To_True ()
|
|
{
|
|
var view = new View
|
|
{
|
|
CanFocus = true
|
|
};
|
|
var subView = new View
|
|
{
|
|
CanFocus = false
|
|
};
|
|
var subSubView = new View
|
|
{
|
|
CanFocus = true
|
|
};
|
|
|
|
subView.Add (subSubView);
|
|
view.Add (subView);
|
|
|
|
view.SetFocus ();
|
|
Assert.True (view.HasFocus);
|
|
Assert.False (subView.HasFocus);
|
|
Assert.False (subSubView.HasFocus);
|
|
|
|
// Act
|
|
subView.CanFocus = true;
|
|
Assert.True (subView.HasFocus);
|
|
Assert.True (subSubView.HasFocus);
|
|
}
|
|
|
|
|
|
[Fact]
|
|
public void CanFocus_Set_SubView_True_Does_Not_Change_Focus_If_SuperView_Focused_Is_True ()
|
|
{
|
|
var top = new View
|
|
{
|
|
Id = "top",
|
|
CanFocus = true
|
|
};
|
|
var subView = new View
|
|
{
|
|
Id = "subView",
|
|
CanFocus = true
|
|
};
|
|
var subSubView = new View
|
|
{
|
|
Id = "subSubView",
|
|
CanFocus = true
|
|
};
|
|
|
|
subView.Add (subSubView);
|
|
|
|
var subView2 = new View
|
|
{
|
|
Id = "subView2",
|
|
CanFocus = false
|
|
};
|
|
|
|
top.Add (subView, subView2);
|
|
|
|
top.SetFocus ();
|
|
Assert.True (top.HasFocus);
|
|
Assert.Equal (subView, top.Focused);
|
|
Assert.True (subView.HasFocus);
|
|
Assert.True (subSubView.HasFocus);
|
|
|
|
// Act
|
|
subView2.CanFocus = true;
|
|
Assert.False (subView2.HasFocus);
|
|
Assert.True (subView.HasFocus);
|
|
Assert.True (subSubView.HasFocus);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanFocus_Set_False_Sets_HasFocus_To_False ()
|
|
{
|
|
var view = new View { CanFocus = true };
|
|
var view2 = new View { CanFocus = true };
|
|
view2.Add (view);
|
|
|
|
Assert.True (view.CanFocus);
|
|
|
|
view.SetFocus ();
|
|
Assert.True (view.HasFocus);
|
|
|
|
view.CanFocus = false;
|
|
Assert.False (view.CanFocus);
|
|
Assert.False (view.HasFocus);
|
|
}
|
|
|
|
// TODO: Figure out what this test is supposed to be testing
|
|
[Fact]
|
|
public void CanFocus_Faced_With_Container ()
|
|
{
|
|
var t = new Toplevel ();
|
|
var w = new Window ();
|
|
var f = new FrameView ();
|
|
var v = new View { CanFocus = true };
|
|
f.Add (v);
|
|
w.Add (f);
|
|
t.Add (w);
|
|
|
|
Assert.True (t.CanFocus);
|
|
Assert.True (w.CanFocus);
|
|
Assert.True (f.CanFocus);
|
|
Assert.True (v.CanFocus);
|
|
|
|
f.CanFocus = false;
|
|
Assert.False (f.CanFocus);
|
|
Assert.True (v.CanFocus);
|
|
|
|
v.CanFocus = false;
|
|
Assert.False (f.CanFocus);
|
|
Assert.False (v.CanFocus);
|
|
|
|
v.CanFocus = true;
|
|
Assert.False (f.CanFocus);
|
|
Assert.True (v.CanFocus);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanFocus_True_Focuses ()
|
|
{
|
|
View view = new ()
|
|
{
|
|
Id = "view"
|
|
};
|
|
|
|
View superView = new ()
|
|
{
|
|
Id = "superView",
|
|
CanFocus = true
|
|
};
|
|
|
|
superView.Add (view);
|
|
|
|
superView.SetFocus ();
|
|
Assert.True (superView.HasFocus);
|
|
Assert.NotEqual (view, superView.Focused);
|
|
|
|
view.CanFocus = true;
|
|
Assert.True (superView.HasFocus);
|
|
Assert.Equal (view, superView.Focused);
|
|
Assert.True (view.HasFocus);
|
|
|
|
view.CanFocus = false;
|
|
Assert.True (superView.HasFocus);
|
|
Assert.NotEqual (view, superView.Focused);
|
|
Assert.False (view.HasFocus);
|
|
}
|
|
|
|
}
|