mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Consider width2 chars that are not IsBmp
* Apply same fix in WindowsDriver
* Explicitly use type of local variable
* Revert changes to WindowsDriver
* Assume we are running in a terminal that supports true color by default unless user explicitly forces 16
* Switch to SetAttribute and WriteConsole instead of WriteConsoleOutput for 16 color mode
* Fix some cursor issues (WIP)
* Remove concept of 'dirty rows' from v2 as its never actually used
* Remove damageRegion as it does nothing
* Make string builder to console writing simpler
* Radically simplify Write method
* Simplify conditional logic
* Simplify restoring cursor position
* Reference local variable for console buffer
* Reduce calls to ConsoleWrite by accumulating till attribute changes
* When resizing v2 16 color mode on windows, recreate the back buffer to match its size
* Fixes for VTS enabled
* Fix _lastSize never being assigned
* Fixes VTS for Force16Colors
* Fixes force16Colors in VTS
* Fixes escape sequences always echoing in non-VTS
* Force Force16Colors in non-VTS. It have a bug in adding a newline in the last line
* WIP Add base class for NetOutput
* Abstract away how we change attribute
* WIP - Make WindowsOutput use base class
* WIP working to fix set cursor position
* Remove commented out code
* Fixes legacy output mode
* Fixes size with no alt buffer supported on VTS and size restore after maximized.
* Fix set cursor which also fixes the broken surrogate pairs
* Add force parameter
* Fixes an issue that only happens with Windows Terminal when paste surrogate pairs by press Ctrl+V
* In Windows escape sequences must be sent during the lifetime of the console which is created in input handle
* Ensure flush the input buffer before reset the console
* Flush input buffer before reset console in v2win
* Fixes issue in v2net not being refreshing the menu bar at start
* Only force layout and draw on size changed.
* Fix v2net issue not draw first line by forcing set cursor position
* Set _lastCursorPosition nullable and remove bool force from set cursor position
* Remove force parameter
* Add v2 version of fake driver attribute
* Make direct replacement and wire up window resizing events
* Update casts to use V2 fake driver instead
* Adjust interfaces to expose less internals
* Fix not raising iteration event in v2
* WIP investigate what it takes to do resize and redraw using TextAlignment_Centered as example
* Sketch adding component factory
* Create relevant fake component factories
* Add window size monitor into factory
* Fake size monitor injecting
* Add helper for faking console resize in AutoInitShutdown tests
* Fix size setting in FakeDriverV2
* Switch to new method
* Fix IsLegacy becoming false when using blank constructor
* Fix for Ready not being raised when showing same top twice also fixes garbage collection issue if running millions of top levels
* Fix tests
* Remove auto init
* Restore conditional compilation stuff
* Restore 'if running unit tests' logic
* Check only for the output being specific classes for the suppression
* Fix ShadowView blowing up with index out of bounds error
* Fix resize in fluent tests
* Fix for people using Iteration call directly
* Fix more calls to iteration to use
AutoInitShutdownAttribute.RunIteration ();
* Add comment
* Remove assumption that Run with prior view not disposed should throw
* Fix timings in Dialog_Opened_From_Another_Dialog
* Fix Zero_Buttons_Works
* Standardize and fix Button_IsDefault_True_Return_His_Index_On_Accepting
* Fix iteration counts on MessageBoxTests
* Fix WizartTests and DrawTests_Ruler
* Implement SendKeys into ConsoleDriverFacade
* Fix SendKeys in console driver facade such that FileDialogTests works
Fix when Clip is null in popover
* Add missing dispose call to test
* Fix support for Esc in facade SendKeys
* Fix AutocompleteTests
* Fix various tests
* Replace LayoutAndDraw with run iteration
* Fix draw issues
* fix draw order
* Fix run iteration calls
* Fix unit tests
* Fix SendKeys in facade.
* Manipulate upper and lower cases.
* Add IsValidInput method to the interface.
* Fix SendKeys scenario
* Fixes surrogate pairs in the label
* Make tests more sensible - they are testing draw functionality. Callbacks do not need to happen in Iteration method
* Fix tests and harden cleanup in AutoInitShutdownAttribute v2 lifecycle dispose
* Delete extra create input call
* Fix mocks and order of exceptions thrown in Run when things are not initialized
* Revert use of `MapConsoleKeyInfoToKeyCode`
* Ignore casing as it is not what test is really about
* Clear application top and top levels before each auto init shutdown test
* Fix for unstable tests
* Restore actually working SendKeys code
* option to pass logger in fluent ctor
* restore ToArray
* Fix SendKeys method and add extension to unit test
* Leverage the EscSeqUtils.MapConsoleKeyInfo method to avoid duplicate code
* Remove unnecessary hack
* Using only KeyCode for rKeys
* Recover modifier keys in surrogate pairs
* Reformat
* Remove iteration limit for benchmarking in v2
* remove iteration delay to identify bugs
* Remove nudge to unique key and make Then run on UI thread
* fix fluid assertions
* Ensure UI operations all happen on UI thread
* Add explicit error for WaitIteration during an invoke
* Remove timeout added for debug
* Catch failing asserts better
* Fix screenshot
* Fix null ref
* Fix race condition in processing input
* Test fixing
* Standardize asserts
* Remove calls to layout and draw, remove pointless lock and enable reading Cancelled from Dialog even if it is disposed
* fix bad merge
* Make logs access threadsafe
* add extra wait to remove race between iteration end and assert
* Code cleanup
* Remove test for crash on access Cancelled after dispose as this is no longer a restriction
* Change resize console to run on UI thread - fixing race condition with redrawing
* Restore original frame rate after test
* Restore nudge to unique key
* Code Cleanup
* Fix for cascading failures when an assert fails in a specific test
* fix for bad merge
* Address PR feedback
* Move classes to seperate files and add xmldoc
* xml doc warnings
* More xml comments docs
* Fix spelling
---------
Co-authored-by: BDisp <bd.bdisp@gmail.com>
This commit is contained in:
@@ -13,8 +13,6 @@ public class DialogTests (ITestOutputHelper output)
|
||||
{
|
||||
RunState? runState = null;
|
||||
|
||||
var d = (FakeDriver)Driver!;
|
||||
|
||||
var title = "1234";
|
||||
var btn1Text = "yes";
|
||||
var btn1 = $"{Glyphs.LeftBracket} {btn1Text} {Glyphs.RightBracket}";
|
||||
@@ -23,7 +21,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
|
||||
// We test with one button first, but do this to get the width right for 2
|
||||
int width = $@"{Glyphs.VLine} {btn1} {btn2} {Glyphs.VLine}".Length;
|
||||
d.SetBufferSize (width, 1);
|
||||
AutoInitShutdownAttribute.FakeResize(new(width, 1));
|
||||
|
||||
// Override CM
|
||||
Dialog.DefaultButtonAlignment = Alignment.Center;
|
||||
@@ -46,7 +44,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
runState = Begin (dlg);
|
||||
var buttonRow = $"{Glyphs.VLine} {btn1} {Glyphs.VLine}";
|
||||
|
||||
RunIteration (ref runState);
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
|
||||
@@ -54,7 +52,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
buttonRow = $"{Glyphs.VLine} {btn1} {btn2} {Glyphs.VLine}";
|
||||
dlg.AddButton (new () { Text = btn2Text });
|
||||
|
||||
RunIteration (ref runState);
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
End (runState);
|
||||
dlg.Dispose ();
|
||||
@@ -73,7 +71,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
dlg.Border!.Thickness = new (1, 0, 1, 0);
|
||||
runState = Begin (dlg);
|
||||
|
||||
RunIteration (ref runState);
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
|
||||
buttonRow = $"{Glyphs.VLine}{btn1} {Glyphs.VLine}";
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
@@ -81,7 +79,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
// Now add a second button
|
||||
buttonRow = $"{Glyphs.VLine}{btn1} {btn2}{Glyphs.VLine}";
|
||||
dlg.AddButton (new () { Text = btn2Text });
|
||||
RunIteration (ref runState);
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
End (runState);
|
||||
dlg.Dispose ();
|
||||
@@ -100,7 +98,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
dlg.Border!.Thickness = new (1, 0, 1, 0);
|
||||
runState = Begin (dlg);
|
||||
|
||||
RunIteration (ref runState);
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
|
||||
buttonRow = $"{Glyphs.VLine}{new (' ', width - btn1.Length - 2)}{btn1}{Glyphs.VLine}";
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
@@ -109,7 +107,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
buttonRow = $"{Glyphs.VLine} {btn1} {btn2}{Glyphs.VLine}";
|
||||
dlg.AddButton (new () { Text = btn2Text });
|
||||
|
||||
RunIteration (ref runState);
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
End (runState);
|
||||
dlg.Dispose ();
|
||||
@@ -127,7 +125,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
|
||||
dlg.Border!.Thickness = new (1, 0, 1, 0);
|
||||
runState = Begin (dlg);
|
||||
RunIteration (ref runState);
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
|
||||
buttonRow = $"{Glyphs.VLine}{btn1}{new (' ', width - btn1.Length - 2)}{Glyphs.VLine}";
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
@@ -136,7 +134,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
buttonRow = $"{Glyphs.VLine}{btn1} {btn2} {Glyphs.VLine}";
|
||||
dlg.AddButton (new () { Text = btn2Text });
|
||||
|
||||
RunIteration (ref runState);
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
End (runState);
|
||||
dlg.Dispose ();
|
||||
@@ -148,7 +146,6 @@ public class DialogTests (ITestOutputHelper output)
|
||||
{
|
||||
RunState? runState = null;
|
||||
|
||||
var d = (FakeDriver)Driver!;
|
||||
Dialog.DefaultShadow = ShadowStyle.None;
|
||||
Button.DefaultShadow = ShadowStyle.None;
|
||||
|
||||
@@ -166,7 +163,8 @@ public class DialogTests (ITestOutputHelper output)
|
||||
|
||||
var buttonRow = $"{Glyphs.VLine} {btn1} {btn2} {btn3} {btn4} {Glyphs.VLine}";
|
||||
int width = buttonRow.Length;
|
||||
d.SetBufferSize (buttonRow.Length, 3);
|
||||
|
||||
AutoInitShutdownAttribute.FakeResize(new (buttonRow.Length, 3));
|
||||
|
||||
// Default - Center
|
||||
(runState, Dialog dlg) = BeginButtonTestDialog (
|
||||
@@ -195,6 +193,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
new Button { Text = btn3Text },
|
||||
new Button { Text = btn4Text }
|
||||
);
|
||||
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
End (runState);
|
||||
dlg.Dispose ();
|
||||
@@ -240,7 +239,6 @@ public class DialogTests (ITestOutputHelper output)
|
||||
{
|
||||
RunState? runState = null;
|
||||
|
||||
var d = (FakeDriver)Driver!;
|
||||
Dialog.DefaultShadow = ShadowStyle.None;
|
||||
Button.DefaultShadow = ShadowStyle.None;
|
||||
|
||||
@@ -258,7 +256,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
var buttonRow = string.Empty;
|
||||
|
||||
var width = 30;
|
||||
d.SetBufferSize (width, 1);
|
||||
AutoInitShutdownAttribute.FakeResize(new(width, 1));
|
||||
|
||||
// Default - Center
|
||||
buttonRow =
|
||||
@@ -335,7 +333,6 @@ public class DialogTests (ITestOutputHelper output)
|
||||
{
|
||||
RunState? runState = null;
|
||||
|
||||
var d = (FakeDriver)Driver!;
|
||||
Dialog.DefaultShadow = ShadowStyle.None;
|
||||
Button.DefaultShadow = ShadowStyle.None;
|
||||
|
||||
@@ -355,7 +352,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
// 123456 1234567
|
||||
var buttonRow = $"{Glyphs.VLine} {btn1} {btn2} {btn3} {btn4} {Glyphs.VLine}";
|
||||
int width = buttonRow.Length;
|
||||
d.SetBufferSize (buttonRow.Length, 1);
|
||||
AutoInitShutdownAttribute.FakeResize (new (buttonRow.Length, 1));
|
||||
|
||||
// Default - Center
|
||||
(runState, Dialog dlg) = BeginButtonTestDialog (
|
||||
@@ -429,7 +426,6 @@ public class DialogTests (ITestOutputHelper output)
|
||||
{
|
||||
RunState? runState = null;
|
||||
|
||||
var d = (FakeDriver)Driver!;
|
||||
Dialog.DefaultShadow = ShadowStyle.None;
|
||||
Button.DefaultShadow = ShadowStyle.None;
|
||||
|
||||
@@ -451,7 +447,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
// 123456 123456
|
||||
var buttonRow = $"{Glyphs.VLine} {btn1} {btn2} {btn3} {btn4} {Glyphs.VLine}";
|
||||
int width = buttonRow.GetColumns ();
|
||||
d.SetBufferSize (width, 3);
|
||||
AutoInitShutdownAttribute.FakeResize(new(width, 3));
|
||||
|
||||
// Default - Center
|
||||
(runState, Dialog dlg) = BeginButtonTestDialog (
|
||||
@@ -523,7 +519,6 @@ public class DialogTests (ITestOutputHelper output)
|
||||
[AutoInitShutdown]
|
||||
public void ButtonAlignment_One ()
|
||||
{
|
||||
var d = (FakeDriver)Driver!;
|
||||
RunState? runState = null;
|
||||
Dialog.DefaultShadow = ShadowStyle.None;
|
||||
Button.DefaultShadow = ShadowStyle.None;
|
||||
@@ -537,7 +532,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
$"{Glyphs.VLine} {Glyphs.LeftBracket} {btnText} {Glyphs.RightBracket} {Glyphs.VLine}";
|
||||
int width = buttonRow.Length;
|
||||
|
||||
d.SetBufferSize (width, 1);
|
||||
AutoInitShutdownAttribute.FakeResize(new(width, 1));
|
||||
|
||||
(runState, Dialog dlg) = BeginButtonTestDialog (
|
||||
title,
|
||||
@@ -601,7 +596,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
$"{Glyphs.VLine} {Glyphs.LeftBracket} {btnText} {Glyphs.RightBracket} {Glyphs.VLine}";
|
||||
width = buttonRow.Length;
|
||||
|
||||
d.SetBufferSize (width, 1);
|
||||
AutoInitShutdownAttribute.FakeResize(new(width, 1));
|
||||
|
||||
(runState, dlg) = BeginButtonTestDialog (
|
||||
title,
|
||||
@@ -665,7 +660,6 @@ public class DialogTests (ITestOutputHelper output)
|
||||
{
|
||||
RunState? runState = null;
|
||||
|
||||
var d = (FakeDriver)Driver!;
|
||||
Dialog.DefaultShadow = ShadowStyle.None;
|
||||
Button.DefaultShadow = ShadowStyle.None;
|
||||
|
||||
@@ -682,7 +676,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
var buttonRow = $@"{Glyphs.VLine} {btn1} {btn2} {btn3} {Glyphs.VLine}";
|
||||
int width = buttonRow.Length;
|
||||
|
||||
d.SetBufferSize (buttonRow.Length, 3);
|
||||
AutoInitShutdownAttribute.FakeResize(new(buttonRow.Length, 3));
|
||||
|
||||
(runState, Dialog dlg) = BeginButtonTestDialog (
|
||||
title,
|
||||
@@ -751,7 +745,6 @@ public class DialogTests (ITestOutputHelper output)
|
||||
{
|
||||
RunState? runState = null;
|
||||
|
||||
var d = (FakeDriver)Driver!;
|
||||
Dialog.DefaultShadow = ShadowStyle.None;
|
||||
Button.DefaultShadow = ShadowStyle.None;
|
||||
|
||||
@@ -766,7 +759,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
var buttonRow = $@"{Glyphs.VLine} {btn1} {btn2} {Glyphs.VLine}";
|
||||
int width = buttonRow.Length;
|
||||
|
||||
d.SetBufferSize (buttonRow.Length, 3);
|
||||
AutoInitShutdownAttribute.FakeResize(new(buttonRow.Length, 3));
|
||||
|
||||
(runState, Dialog dlg) = BeginButtonTestDialog (
|
||||
title,
|
||||
@@ -832,7 +825,6 @@ public class DialogTests (ITestOutputHelper output)
|
||||
RunState? runState = null;
|
||||
var firstIteration = false;
|
||||
|
||||
var d = (FakeDriver)Driver!;
|
||||
Dialog.DefaultShadow = ShadowStyle.None;
|
||||
Button.DefaultShadow = ShadowStyle.None;
|
||||
|
||||
@@ -847,7 +839,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
var buttonRow = $@"{Glyphs.VLine} {btn1} {btn2} {Glyphs.VLine}";
|
||||
int width = buttonRow.Length;
|
||||
|
||||
d.SetBufferSize (buttonRow.Length, 3);
|
||||
AutoInitShutdownAttribute.FakeResize(new(buttonRow.Length, 3));
|
||||
|
||||
Dialog dlg = null;
|
||||
Button button1, button2;
|
||||
@@ -857,8 +849,10 @@ public class DialogTests (ITestOutputHelper output)
|
||||
button2 = new () { Text = btn2Text };
|
||||
(runState, dlg) = BeginButtonTestDialog (title, width, Alignment.Center, button1, button2);
|
||||
button1.Visible = false;
|
||||
RunIteration (ref runState, firstIteration);
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
|
||||
buttonRow = $@"{Glyphs.VLine} {btn2} {Glyphs.VLine}";
|
||||
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
End (runState);
|
||||
dlg.Dispose ();
|
||||
@@ -869,7 +863,8 @@ public class DialogTests (ITestOutputHelper output)
|
||||
button2 = new () { Text = btn2Text };
|
||||
(runState, dlg) = BeginButtonTestDialog (title, width, Alignment.Fill, button1, button2);
|
||||
button1.Visible = false;
|
||||
RunIteration (ref runState, firstIteration);
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
|
||||
buttonRow = $@"{Glyphs.VLine} {btn2}{Glyphs.VLine}";
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
End (runState);
|
||||
@@ -881,7 +876,8 @@ public class DialogTests (ITestOutputHelper output)
|
||||
button2 = new () { Text = btn2Text };
|
||||
(runState, dlg) = BeginButtonTestDialog (title, width, Alignment.End, button1, button2);
|
||||
button1.Visible = false;
|
||||
RunIteration (ref runState, firstIteration);
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
End (runState);
|
||||
dlg.Dispose ();
|
||||
@@ -892,7 +888,8 @@ public class DialogTests (ITestOutputHelper output)
|
||||
button2 = new () { Text = btn2Text };
|
||||
(runState, dlg) = BeginButtonTestDialog (title, width, Alignment.Start, button1, button2);
|
||||
button1.Visible = false;
|
||||
RunIteration (ref runState, firstIteration);
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
|
||||
buttonRow = $@"{Glyphs.VLine} {btn2} {Glyphs.VLine}";
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
|
||||
End (runState);
|
||||
@@ -903,7 +900,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
[AutoInitShutdown]
|
||||
public void Dialog_In_Window_With_Size_One_Button_Aligns ()
|
||||
{
|
||||
((FakeDriver)Driver!).SetBufferSize (20, 5);
|
||||
AutoInitShutdownAttribute.FakeResize(new(20, 5));
|
||||
|
||||
// Override CM
|
||||
Window.DefaultBorderStyle = LineStyle.Single;
|
||||
@@ -931,7 +928,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
|
||||
dlg.Loaded += (s, a) =>
|
||||
{
|
||||
LayoutAndDraw ();
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
|
||||
var expected = @$"
|
||||
┌──────────────────┐
|
||||
@@ -1008,7 +1005,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
)]
|
||||
public void Dialog_In_Window_Without_Size_One_Button_Aligns (int height, string expected)
|
||||
{
|
||||
((FakeDriver)Driver!).SetBufferSize (20, height);
|
||||
AutoInitShutdownAttribute.FakeResize(new (20, height));
|
||||
var win = new Window ();
|
||||
|
||||
int iterations = -1;
|
||||
@@ -1036,7 +1033,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
}
|
||||
else if (iterations == 1)
|
||||
{
|
||||
LayoutAndDraw ();
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
|
||||
// BUGBUG: This seems wrong; is it a bug in Dim.Percent(85)?? No
|
||||
_ = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
|
||||
@@ -1055,7 +1052,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
[AutoInitShutdown]
|
||||
public void Dialog_Opened_From_Another_Dialog ()
|
||||
{
|
||||
((FakeDriver)Driver!).SetBufferSize (30, 10);
|
||||
AutoInitShutdownAttribute.FakeResize(new (30, 10));
|
||||
|
||||
// Override CM
|
||||
Dialog.DefaultButtonAlignment = Alignment.Center;
|
||||
@@ -1108,7 +1105,6 @@ public class DialogTests (ITestOutputHelper output)
|
||||
case 0:
|
||||
Top!.SetNeedsLayout ();
|
||||
Top.SetNeedsDraw ();
|
||||
LayoutAndDraw ();
|
||||
|
||||
break;
|
||||
|
||||
@@ -1116,8 +1112,10 @@ public class DialogTests (ITestOutputHelper output)
|
||||
Assert.False (btn1.NewKeyDownEvent (Key.Space));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
LayoutAndDraw ();
|
||||
|
||||
// Now this happens on iteration 3 because Space triggers Run on the new dialog which itself causes another iteration
|
||||
// as it starts. Meaning we haven't exited case 1 when we enter case 2 from next Run stack frame.
|
||||
case 3:
|
||||
|
||||
expected = @$"
|
||||
┌───────────────────────┐
|
||||
@@ -1133,8 +1131,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
Assert.False (btn2!.NewKeyDownEvent (Key.Space));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
LayoutAndDraw ();
|
||||
case 5:
|
||||
|
||||
DriverAssert.AssertDriverContentsWithFrameAre (
|
||||
@$"
|
||||
@@ -1152,15 +1149,14 @@ public class DialogTests (ITestOutputHelper output)
|
||||
Assert.False (Top!.NewKeyDownEvent (Key.Enter));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
LayoutAndDraw ();
|
||||
case 7:
|
||||
|
||||
DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
|
||||
|
||||
Assert.False (btn3!.NewKeyDownEvent (Key.Space));
|
||||
|
||||
break;
|
||||
case 5:
|
||||
case 9:
|
||||
DriverAssert.AssertDriverContentsWithFrameAre ("", output);
|
||||
|
||||
RequestStop ();
|
||||
@@ -1172,7 +1168,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
Run ().Dispose ();
|
||||
Shutdown ();
|
||||
|
||||
Assert.Equal (5, iterations);
|
||||
Assert.Equal (9, iterations);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1198,7 +1194,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
Height = Dim.Percent (85)
|
||||
};
|
||||
Begin (d);
|
||||
((FakeDriver)Driver!).SetBufferSize (100, 100);
|
||||
AutoInitShutdownAttribute.FakeResize(new(100, 100));
|
||||
|
||||
// Default location is centered, so 100 / 2 - 85 / 2 = 7
|
||||
var expected = 7;
|
||||
@@ -1212,7 +1208,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
{
|
||||
var d = new Dialog { X = 1, Y = 1 };
|
||||
Begin (d);
|
||||
((FakeDriver)Driver!).SetBufferSize (100, 100);
|
||||
AutoInitShutdownAttribute.FakeResize(new(100, 100));
|
||||
|
||||
// Default location is centered, so 100 / 2 - 85 / 2 = 7
|
||||
var expected = 1;
|
||||
@@ -1234,7 +1230,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
var expected = 5;
|
||||
var d = new Dialog { X = expected, Y = expected, Height = 5, Width = 5 };
|
||||
Begin (d);
|
||||
((FakeDriver)Driver!).SetBufferSize (20, 10);
|
||||
AutoInitShutdownAttribute.FakeResize(new(20, 10));
|
||||
|
||||
// Default location is centered, so 100 / 2 - 85 / 2 = 7
|
||||
Assert.Equal (new (expected, expected), d.Frame.Location);
|
||||
@@ -1256,9 +1252,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
public void One_Button_Works ()
|
||||
{
|
||||
RunState? runState = null;
|
||||
|
||||
var d = (FakeDriver)Driver!;
|
||||
|
||||
|
||||
Button.DefaultShadow = ShadowStyle.None;
|
||||
|
||||
var title = "";
|
||||
@@ -1268,7 +1262,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
$"{Glyphs.VLine} {Glyphs.LeftBracket} {btnText} {Glyphs.RightBracket} {Glyphs.VLine}";
|
||||
|
||||
int width = buttonRow.Length;
|
||||
d.SetBufferSize (buttonRow.Length, 10);
|
||||
AutoInitShutdownAttribute.FakeResize(new(buttonRow.Length, 10));
|
||||
|
||||
(runState, Dialog dlg) = BeginButtonTestDialog (
|
||||
title,
|
||||
@@ -1292,7 +1286,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
};
|
||||
|
||||
Begin (d);
|
||||
((FakeDriver)Driver!).SetBufferSize (100, 100);
|
||||
AutoInitShutdownAttribute.FakeResize(new(100, 100));
|
||||
|
||||
// Default size is Percent(85)
|
||||
Assert.Equal (new ((int)(100 * .85), (int)(100 * .85)), d.Frame.Size);
|
||||
@@ -1308,7 +1302,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
var d = new Dialog { Width = 50, Height = 50 };
|
||||
|
||||
Begin (d);
|
||||
((FakeDriver)Driver!).SetBufferSize (100, 100);
|
||||
AutoInitShutdownAttribute.FakeResize(new(100, 100));
|
||||
|
||||
// Default size is Percent(85)
|
||||
Assert.Equal (new (50, 50), d.Frame.Size);
|
||||
@@ -1316,18 +1310,16 @@ public class DialogTests (ITestOutputHelper output)
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SetupFakeDriver]
|
||||
[AutoInitShutdown]
|
||||
public void Zero_Buttons_Works ()
|
||||
{
|
||||
RunState? runState = null;
|
||||
|
||||
var d = (FakeDriver)Driver!;
|
||||
|
||||
var title = "1234";
|
||||
|
||||
var buttonRow = $"{Glyphs.VLine} {Glyphs.VLine}";
|
||||
int width = buttonRow.Length;
|
||||
d.SetBufferSize (buttonRow.Length, 3);
|
||||
AutoInitShutdownAttribute.FakeResize(new(buttonRow.Length, 3));
|
||||
|
||||
(runState, Dialog dlg) = BeginButtonTestDialog (title, width, Alignment.Center, null);
|
||||
|
||||
@@ -1368,8 +1360,8 @@ public class DialogTests (ITestOutputHelper output)
|
||||
|
||||
dlg.SetNeedsDraw ();
|
||||
dlg.SetNeedsLayout ();
|
||||
dlg.Layout ();
|
||||
dlg.Draw ();
|
||||
|
||||
AutoInitShutdownAttribute.RunIteration ();
|
||||
|
||||
return (runState, dlg);
|
||||
}
|
||||
@@ -1439,9 +1431,9 @@ public class DialogTests (ITestOutputHelper output)
|
||||
// Run another view without dispose the prior will throw an assertion
|
||||
#if DEBUG_IDISPOSABLE
|
||||
Dialog dlg2 = new ();
|
||||
dlg2.Ready += Dlg_Ready;
|
||||
Exception exception = Record.Exception (() => Run (dlg2));
|
||||
Assert.NotNull (exception);
|
||||
dlg2.Ready += Dlg_Ready;
|
||||
// Exception exception = Record.Exception (() => Run (dlg2));
|
||||
// Assert.NotNull (exception);
|
||||
|
||||
dlg.Dispose ();
|
||||
|
||||
@@ -1455,9 +1447,12 @@ public class DialogTests (ITestOutputHelper output)
|
||||
|
||||
dlg2.Dispose ();
|
||||
|
||||
// tznind REMOVED: Why wouldn't you be able to read cancelled after dispose - that makes no sense
|
||||
// Now an assertion will throw accessing the Canceled property
|
||||
exception = Record.Exception (() => Assert.True (dlg.Canceled))!;
|
||||
Assert.NotNull (exception);
|
||||
//var exception = Record.Exception (() => Assert.True (dlg.Canceled))!;
|
||||
//Assert.NotNull (exception);
|
||||
//Assert.StartsWith ("Cannot access a disposed object.", exception.Message);
|
||||
|
||||
Assert.True (Top.WasDisposed);
|
||||
Shutdown ();
|
||||
Assert.True (dlg2.WasDisposed);
|
||||
@@ -1491,7 +1486,7 @@ public class DialogTests (ITestOutputHelper output)
|
||||
Y = 1
|
||||
};
|
||||
|
||||
((FakeDriver)Driver!).SetBufferSize (20, 20);
|
||||
AutoInitShutdownAttribute.FakeResize(new(20, 20));
|
||||
|
||||
int iterations = 0;
|
||||
Iteration += (s, a) =>
|
||||
|
||||
Reference in New Issue
Block a user