From dd6c6a70a3d16a6a13b572b80f9a41c8a721ed1c Mon Sep 17 00:00:00 2001 From: Tig Date: Sat, 5 Apr 2025 08:11:41 -0600 Subject: [PATCH] FixedCM issues --- Tests/UnitTests/Dialogs/DialogTests.cs | 64 ++++++----------- Tests/UnitTests/Dialogs/MessageBoxTests.cs | 81 ++++++++++++++++++---- 2 files changed, 87 insertions(+), 58 deletions(-) diff --git a/Tests/UnitTests/Dialogs/DialogTests.cs b/Tests/UnitTests/Dialogs/DialogTests.cs index 47e843e18..6ba59a008 100644 --- a/Tests/UnitTests/Dialogs/DialogTests.cs +++ b/Tests/UnitTests/Dialogs/DialogTests.cs @@ -14,6 +14,24 @@ public class DialogTests View.DebugIDisposable = true; #endif _output = output; + + // Override CM + ConfigurationManager.RuntimeConfig = """ + { + "Themes": [ + { + "Default": { + "Dialog.DefaultButtonAlignment" : "Center", + "Dialog.DefaultBorderStyle" : "Single", + "Dialog.DefaultShadow" : "None", + "Button.DefaultShadow" : "None" + } + } + ] + } + """; + ConfigurationManager.Locations = ConfigLocations.Runtime; + ConfigurationManager.Load (); } [Fact] @@ -34,12 +52,6 @@ public class DialogTests int width = $@"{Glyphs.VLine} {btn1} {btn2} {Glyphs.VLine}".Length; d.SetBufferSize (width, 1); - // Override CM - Dialog.DefaultButtonAlignment = Alignment.Center; - Dialog.DefaultBorderStyle = LineStyle.Single; - Dialog.DefaultShadow = ShadowStyle.None; - Button.DefaultShadow = ShadowStyle.None; - // Default (center) var dlg = new Dialog { @@ -914,13 +926,6 @@ public class DialogTests { ((FakeDriver)Driver).SetBufferSize (20, 5); - // Override CM - Window.DefaultBorderStyle = LineStyle.Single; - Dialog.DefaultButtonAlignment = Alignment.Center; - Dialog.DefaultBorderStyle = LineStyle.Single; - Dialog.DefaultShadow = ShadowStyle.None; - Button.DefaultShadow = ShadowStyle.None; - var win = new Window (); var iterations = 0; @@ -1021,13 +1026,7 @@ public class DialogTests var win = new Window (); int iterations = -1; - - // Override CM - Dialog.DefaultButtonAlignment = Alignment.Center; - Dialog.DefaultBorderStyle = LineStyle.Single; - Dialog.DefaultShadow = ShadowStyle.None; - Button.DefaultShadow = ShadowStyle.None; - + Iteration += (s, a) => { iterations++; @@ -1065,13 +1064,7 @@ public class DialogTests public void Dialog_Opened_From_Another_Dialog () { ((FakeDriver)Driver).SetBufferSize (30, 10); - - // Override CM - Dialog.DefaultButtonAlignment = Alignment.Center; - Dialog.DefaultBorderStyle = LineStyle.Single; - Dialog.DefaultShadow = ShadowStyle.None; - Button.DefaultShadow = ShadowStyle.None; - + var btn1 = new Button { Text = "press me 1" }; Button btn2 = null; Button btn3 = null; @@ -1233,12 +1226,6 @@ public class DialogTests [AutoInitShutdown] public void Location_When_Application_Top_Not_Default () { - // Override CM - Window.DefaultBorderStyle = LineStyle.Single; - Dialog.DefaultButtonAlignment = Alignment.Center; - Dialog.DefaultBorderStyle = LineStyle.Single; - Dialog.DefaultShadow = ShadowStyle.None; - Button.DefaultShadow = ShadowStyle.None; var expected = 5; var d = new Dialog { X = expected, Y = expected, Height = 5, Width = 5 }; @@ -1268,8 +1255,6 @@ public class DialogTests var d = (FakeDriver)Driver; - Button.DefaultShadow = ShadowStyle.None; - var title = ""; var btnText = "ok"; @@ -1312,8 +1297,6 @@ public class DialogTests [AutoInitShutdown] public void Size_Not_Default () { - Dialog.DefaultShadow = ShadowStyle.None; - Button.DefaultShadow = ShadowStyle.None; var d = new Dialog { Width = 50, Height = 50 }; Begin (d); @@ -1325,7 +1308,7 @@ public class DialogTests } [Fact] - [SetupFakeDriver] + [AutoInitShutdown] public void Zero_Buttons_Works () { RunState runstate = null; @@ -1353,11 +1336,6 @@ public class DialogTests params Button [] btns ) { - // Override CM - Dialog.DefaultButtonAlignment = Alignment.Center; - Dialog.DefaultBorderStyle = LineStyle.Single; - Dialog.DefaultShadow = ShadowStyle.None; - Button.DefaultShadow = ShadowStyle.None; var dlg = new Dialog { diff --git a/Tests/UnitTests/Dialogs/MessageBoxTests.cs b/Tests/UnitTests/Dialogs/MessageBoxTests.cs index 7777806a8..c67f22670 100644 --- a/Tests/UnitTests/Dialogs/MessageBoxTests.cs +++ b/Tests/UnitTests/Dialogs/MessageBoxTests.cs @@ -156,8 +156,23 @@ public class MessageBoxTests int iterations = -1; ((FakeDriver)Application.Driver!).SetBufferSize (15, 15); // 15 x 15 gives us enough room for a button with one char (9x1) - Dialog.DefaultShadow = ShadowStyle.None; - Button.DefaultShadow = ShadowStyle.None; + + + // Override CM + ConfigurationManager.RuntimeConfig = """ + { + "Themes": [ + { + "Default": { + "Dialog.DefaultShadow": "None", + "Button.DefaultShadow": "None" + } + } + ] + } + """; + ConfigurationManager.Locations = ConfigLocations.Runtime; + ConfigurationManager.Load (); var mbFrame = Rectangle.Empty; @@ -195,10 +210,22 @@ public class MessageBoxTests $"{Glyphs.LeftBracket}{Glyphs.LeftDefaultIndicator} btn {Glyphs.RightDefaultIndicator}{Glyphs.RightBracket}"; // Override CM - MessageBox.DefaultButtonAlignment = Alignment.End; - MessageBox.DefaultBorderStyle = LineStyle.Double; - Dialog.DefaultShadow = ShadowStyle.None; - Button.DefaultShadow = ShadowStyle.None; + ConfigurationManager.RuntimeConfig = """ + { + "Themes": [ + { + "Default": { + "Dialog.DefaultShadow": "None", + "MessageBox.DefaultButtonAlignment": "End", + "MessageBox.DefaultBorderStyle": "Double", + "Button.DefaultShadow": "None" + } + } + ] + } + """; + ConfigurationManager.Locations = ConfigLocations.Runtime; + ConfigurationManager.Load (); Application.Iteration += (s, a) => { @@ -267,10 +294,22 @@ public class MessageBoxTests $"{Glyphs.LeftBracket}{Glyphs.LeftDefaultIndicator} btn {Glyphs.RightDefaultIndicator}{Glyphs.RightBracket}"; // Override CM - MessageBox.DefaultButtonAlignment = Alignment.End; - MessageBox.DefaultBorderStyle = LineStyle.Double; - Dialog.DefaultShadow = ShadowStyle.None; - Button.DefaultShadow = ShadowStyle.None; + ConfigurationManager.RuntimeConfig = """ + { + "Themes": [ + { + "Default": { + "Dialog.DefaultShadow": "None", + "MessageBox.DefaultButtonAlignment": "End", + "MessageBox.DefaultBorderStyle": "Double", + "Button.DefaultShadow": "None" + } + } + ] + } + """; + ConfigurationManager.Locations = ConfigLocations.Runtime; + ConfigurationManager.Load (); Application.Iteration += (s, a) => { @@ -449,10 +488,22 @@ public class MessageBoxTests ((FakeDriver)Application.Driver).SetBufferSize (70, 15); // Override CM - MessageBox.DefaultButtonAlignment = Alignment.End; - MessageBox.DefaultBorderStyle = LineStyle.Double; - Dialog.DefaultShadow = ShadowStyle.None; - Button.DefaultShadow = ShadowStyle.None; + ConfigurationManager.RuntimeConfig = """ + { + "Themes": [ + { + "Default": { + "Dialog.DefaultShadow": "None", + "MessageBox.DefaultButtonAlignment": "End", + "MessageBox.DefaultBorderStyle": "Double", + "Button.DefaultShadow": "None" + } + } + ] + } + """; + ConfigurationManager.Locations = ConfigLocations.Runtime; + ConfigurationManager.Load (); Application.Iteration += (s, a) => { @@ -462,7 +513,7 @@ public class MessageBoxTests { MessageBox.Query ( "", - UICatalog.UICatalogTop.GetAboutBoxMessage (), + UICatalogTop.GetAboutBoxMessage (), wrapMessage: false, buttons: "_Ok" );