From 369279a3e081310430534b84a2bdc6a0da5a2de6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 12:45:03 +0000 Subject: [PATCH] Rename IApplication.Current to IApplication.Running Co-authored-by: tig <585482+tig@users.noreply.github.com> --- Examples/CommunityToolkitExample/Program.cs | 2 +- Examples/ReactiveExample/Program.cs | 2 +- Examples/UICatalog/Scenario.cs | 4 +- .../UICatalog/Scenarios/AllViewsTester.cs | 2 +- Examples/UICatalog/Scenarios/Bars.cs | 16 +- .../UICatalog/Scenarios/CombiningMarks.cs | 2 +- .../Scenarios/ConfigurationEditor.cs | 2 +- Examples/UICatalog/Scenarios/CsvEditor.cs | 2 +- Examples/UICatalog/Scenarios/Mazing.cs | 6 +- Examples/UICatalog/Scenarios/Shortcuts.cs | 54 ++--- .../Scenarios/SingleBackgroundWorker.cs | 4 +- Examples/UICatalog/Scenarios/Themes.cs | 2 +- Examples/UICatalog/Scenarios/TreeUseCases.cs | 12 +- .../Scenarios/WindowsAndFrameViews.cs | 2 +- Examples/UICatalog/UICatalog.cs | 4 +- Examples/UICatalog/UICatalogTop.cs | 2 +- ...tion.Current.cs => Application.Running.cs} | 12 +- Terminal.Gui/App/ApplicationImpl.Lifecycle.cs | 10 +- Terminal.Gui/App/ApplicationImpl.Run.cs | 64 +++--- Terminal.Gui/App/ApplicationImpl.cs | 12 +- Terminal.Gui/App/ApplicationNavigation.cs | 2 +- Terminal.Gui/App/ApplicationPopover.cs | 8 +- Terminal.Gui/App/IApplication.cs | 10 +- Terminal.Gui/App/IPopover.cs | 8 +- Terminal.Gui/App/Keyboard/KeyboardImpl.cs | 4 +- .../App/MainLoop/ApplicationMainLoop.cs | 8 +- Terminal.Gui/App/Mouse/MouseImpl.cs | 6 +- Terminal.Gui/App/PopoverBaseImpl.cs | 12 +- .../App/Toplevel/ToplevelTransitionManager.cs | 6 +- .../ViewBase/Adornment/Border.Arrangment.cs | 2 +- Terminal.Gui/ViewBase/View.Hierarchy.cs | 4 +- Terminal.Gui/ViewBase/View.Layout.cs | 26 +-- Terminal.Gui/ViewBase/View.Navigation.cs | 12 +- Terminal.Gui/Views/Dialog.cs | 2 +- Terminal.Gui/Views/Menuv1/Menu.cs | 12 +- Terminal.Gui/Views/Menuv1/MenuBar.cs | 8 +- Terminal.Gui/Views/Toplevel.cs | 6 +- Terminal.Gui/Views/Wizard/Wizard.cs | 2 +- .../GuiTestContextKeyEventTests.cs | 8 +- .../FluentTests/GuiTestContextTests.cs | 8 +- .../FluentTests/MenuBarv2Tests.cs | 46 ++--- .../FluentTests/NavigationTests.cs | 4 +- .../FluentTests/PopverMenuTests.cs | 32 +-- Tests/StressTests/ApplicationStressTests.cs | 4 +- Tests/StressTests/ScenariosStressTests.cs | 4 +- .../FakeDriver/FakeApplicationLifecycle.cs | 2 +- .../GuiTestContext.Navigation.cs | 4 +- .../GuiTestContext.ViewBase.cs | 8 +- .../Application.NavigationTests.cs | 24 +-- .../ApplicationImplBeginEndTests.cs | 28 +-- .../Application/ApplicationImplTests.cs | 62 +++--- .../Application/ApplicationPopoverTests.cs | 14 +- .../Application/ApplicationScreenTests.cs | 10 +- .../UnitTests/Application/ApplicationTests.cs | 110 +++++----- .../Mouse/ApplicationMouseEnterLeaveTests.cs | 78 +++---- .../Mouse/ApplicationMouseTests.cs | 16 +- .../Application/SessionTokenTests.cs | 2 +- .../Application/SynchronizatonContextTests.cs | 4 +- Tests/UnitTests/Dialogs/DialogTests.cs | 30 +-- Tests/UnitTests/Dialogs/MessageBoxTests.cs | 14 +- .../View/Adornment/AdornmentSubViewTests.cs | 26 +-- Tests/UnitTests/View/Adornment/MarginTests.cs | 32 +-- .../View/Keyboard/KeyBindingsTests.cs | 6 +- .../View/Layout/GetViewsUnderLocationTests.cs | 194 +++++++++--------- .../UnitTests/View/Layout/Pos.CombineTests.cs | 24 +-- Tests/UnitTests/View/Layout/SetLayoutTests.cs | 16 +- .../View/Navigation/CanFocusTests.cs | 8 +- .../View/Navigation/NavigationTests.cs | 10 +- Tests/UnitTests/View/TextTests.cs | 2 +- Tests/UnitTests/View/ViewCommandTests.cs | 8 +- .../ViewportSettings.TransparentMouseTests.cs | 6 +- .../Views/AppendAutocompleteTests.cs | 24 +-- Tests/UnitTests/Views/ButtonTests.cs | 2 +- Tests/UnitTests/Views/CheckBoxTests.cs | 8 +- Tests/UnitTests/Views/ColorPickerTests.cs | 10 +- Tests/UnitTests/Views/ComboBoxTests.cs | 4 +- Tests/UnitTests/Views/HexViewTests.cs | 58 +++--- Tests/UnitTests/Views/LabelTests.cs | 38 ++-- .../UnitTests/Views/Menuv1/MenuBarv1Tests.cs | 56 ++--- Tests/UnitTests/Views/ShortcutTests.cs | 76 +++---- Tests/UnitTests/Views/SpinnerViewTests.cs | 6 +- Tests/UnitTests/Views/TableViewTests.cs | 54 ++--- Tests/UnitTests/Views/TextFieldTests.cs | 16 +- Tests/UnitTests/Views/TextViewTests.cs | 2 +- Tests/UnitTests/Views/ToplevelTests.cs | 68 +++--- .../Application/ApplicationPopoverTests.cs | 2 +- .../Application/PopoverBaseImplTests.cs | 4 +- Tests/UnitTestsParallelizable/TestSetup.cs | 2 +- 88 files changed, 814 insertions(+), 814 deletions(-) rename Terminal.Gui/App/{Application.Current.cs => Application.Running.cs} (53%) diff --git a/Examples/CommunityToolkitExample/Program.cs b/Examples/CommunityToolkitExample/Program.cs index 74e45ce06..462b21399 100644 --- a/Examples/CommunityToolkitExample/Program.cs +++ b/Examples/CommunityToolkitExample/Program.cs @@ -16,7 +16,7 @@ public static class Program Services = ConfigureServices (); Application.Init (); Application.Run (Services.GetRequiredService ()); - Application.Current?.Dispose (); + Application.Running?.Dispose (); Application.Shutdown (); } diff --git a/Examples/ReactiveExample/Program.cs b/Examples/ReactiveExample/Program.cs index f73aa807d..fb4ac389a 100644 --- a/Examples/ReactiveExample/Program.cs +++ b/Examples/ReactiveExample/Program.cs @@ -16,7 +16,7 @@ public static class Program RxApp.MainThreadScheduler = TerminalScheduler.Default; RxApp.TaskpoolScheduler = TaskPoolScheduler.Default; Application.Run (new LoginView (new LoginViewModel ())); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.Shutdown (); } } diff --git a/Examples/UICatalog/Scenario.cs b/Examples/UICatalog/Scenario.cs index 0531d06c9..97b0e9fab 100644 --- a/Examples/UICatalog/Scenario.cs +++ b/Examples/UICatalog/Scenario.cs @@ -221,7 +221,7 @@ public class Scenario : IDisposable private void OnApplicationSessionBegun (object? sender, SessionTokenEventArgs e) { - SubscribeAllSubViews (Application.Current!); + SubscribeAllSubViews (Application.Running!); _demoKeys = GetDemoKeyStrokes (); @@ -241,7 +241,7 @@ public class Scenario : IDisposable return; - // Get a list of all subviews under Application.Current (and their subviews, etc.) + // Get a list of all subviews under Application.Running (and their subviews, etc.) // and subscribe to their DrawComplete event void SubscribeAllSubViews (View view) { diff --git a/Examples/UICatalog/Scenarios/AllViewsTester.cs b/Examples/UICatalog/Scenarios/AllViewsTester.cs index 5ac97bea9..18866983e 100644 --- a/Examples/UICatalog/Scenarios/AllViewsTester.cs +++ b/Examples/UICatalog/Scenarios/AllViewsTester.cs @@ -28,7 +28,7 @@ public class AllViewsTester : Scenario public override void Main () { - // Don't create a sub-win (Scenario.Win); just use Application.Current + // Don't create a sub-win (Scenario.Win); just use Application.Running Application.Init (); var app = new Window diff --git a/Examples/UICatalog/Scenarios/Bars.cs b/Examples/UICatalog/Scenarios/Bars.cs index 03f908611..b9272220c 100644 --- a/Examples/UICatalog/Scenarios/Bars.cs +++ b/Examples/UICatalog/Scenarios/Bars.cs @@ -28,7 +28,7 @@ public class Bars : Scenario // QuitKey and it only sticks if changed after init private void App_Loaded (object sender, EventArgs e) { - Application.Current!.Title = GetQuitKeyAndName (); + Application.Running!.Title = GetQuitKeyAndName (); ObservableCollection eventSource = new (); ListView eventLog = new ListView () @@ -41,7 +41,7 @@ public class Bars : Scenario Source = new ListWrapper (eventSource) }; eventLog.Border!.Thickness = new (0, 1, 0, 0); - Application.Current.Add (eventLog); + Application.Running.Add (eventLog); FrameView menuBarLikeExamples = new () { @@ -51,7 +51,7 @@ public class Bars : Scenario Width = Dim.Fill () - Dim.Width (eventLog), Height = Dim.Percent(33), }; - Application.Current.Add (menuBarLikeExamples); + Application.Running.Add (menuBarLikeExamples); Label label = new Label () { @@ -98,7 +98,7 @@ public class Bars : Scenario Width = Dim.Fill () - Dim.Width (eventLog), Height = Dim.Percent (33), }; - Application.Current.Add (menuLikeExamples); + Application.Running.Add (menuLikeExamples); label = new Label () { @@ -212,7 +212,7 @@ public class Bars : Scenario Width = Dim.Width (menuLikeExamples), Height = Dim.Percent (33), }; - Application.Current.Add (statusBarLikeExamples); + Application.Running.Add (statusBarLikeExamples); label = new Label () { @@ -249,7 +249,7 @@ public class Bars : Scenario ConfigStatusBar (bar); statusBarLikeExamples.Add (bar); - foreach (FrameView frameView in Application.Current.SubViews.Where (f => f is FrameView)!) + foreach (FrameView frameView in Application.Running.SubViews.Where (f => f is FrameView)!) { foreach (Bar barView in frameView.SubViews.Where (b => b is Bar)!) { @@ -269,8 +269,8 @@ public class Bars : Scenario //private void SetupContentMenu () //{ - // Application.Current.Add (new Label { Text = "Right Click for Context Menu", X = Pos.Center (), Y = 4 }); - // Application.Current.MouseClick += ShowContextMenu; + // Application.Running.Add (new Label { Text = "Right Click for Context Menu", X = Pos.Center (), Y = 4 }); + // Application.Running.MouseClick += ShowContextMenu; //} //private void ShowContextMenu (object s, MouseEventEventArgs e) diff --git a/Examples/UICatalog/Scenarios/CombiningMarks.cs b/Examples/UICatalog/Scenarios/CombiningMarks.cs index 47b8dfbc7..1fec15e21 100644 --- a/Examples/UICatalog/Scenarios/CombiningMarks.cs +++ b/Examples/UICatalog/Scenarios/CombiningMarks.cs @@ -13,7 +13,7 @@ public class CombiningMarks : Scenario top.DrawComplete += (s, e) => { // Forces reset _lineColsOffset because we're dealing with direct draw - Application.Current!.SetNeedsDraw (); + Application.Running!.SetNeedsDraw (); var i = -1; top.AddStr ("Terminal.Gui only supports combining marks that normalize. See Issue #2616."); diff --git a/Examples/UICatalog/Scenarios/ConfigurationEditor.cs b/Examples/UICatalog/Scenarios/ConfigurationEditor.cs index 36011a78c..e5f36e8ff 100644 --- a/Examples/UICatalog/Scenarios/ConfigurationEditor.cs +++ b/Examples/UICatalog/Scenarios/ConfigurationEditor.cs @@ -75,7 +75,7 @@ public class ConfigurationEditor : Scenario void ConfigurationManagerOnApplied (object? sender, ConfigurationManagerEventArgs e) { - Application.Current?.SetNeedsDraw (); + Application.Running?.SetNeedsDraw (); } } public void Save () diff --git a/Examples/UICatalog/Scenarios/CsvEditor.cs b/Examples/UICatalog/Scenarios/CsvEditor.cs index aca10fdac..923da6656 100644 --- a/Examples/UICatalog/Scenarios/CsvEditor.cs +++ b/Examples/UICatalog/Scenarios/CsvEditor.cs @@ -502,7 +502,7 @@ public class CsvEditor : Scenario // Only set the current filename if we successfully loaded the entire file _currentFile = filename; _selectedCellTextField.SuperView.Enabled = true; - Application.Current.Title = $"{GetName ()} - {Path.GetFileName (_currentFile)}"; + Application.Running.Title = $"{GetName ()} - {Path.GetFileName (_currentFile)}"; } catch (Exception ex) { diff --git a/Examples/UICatalog/Scenarios/Mazing.cs b/Examples/UICatalog/Scenarios/Mazing.cs index 935c72ae5..a4700bf21 100644 --- a/Examples/UICatalog/Scenarios/Mazing.cs +++ b/Examples/UICatalog/Scenarios/Mazing.cs @@ -171,7 +171,7 @@ public class Mazing : Scenario if (_m.PlayerHp <= 0) { _message = "You died!"; - Application.Current!.SetNeedsDraw (); // trigger redraw + Application.Running!.SetNeedsDraw (); // trigger redraw _dead = true; return; // Stop further action if dead @@ -190,7 +190,7 @@ public class Mazing : Scenario _message = string.Empty; } - Application.Current!.SetNeedsDraw (); // trigger redraw + Application.Running!.SetNeedsDraw (); // trigger redraw } // Optional win condition: @@ -200,7 +200,7 @@ public class Mazing : Scenario _m = new (); // Generate a new maze _m.PlayerHp = hp; GenerateNpcs (); - Application.Current!.SetNeedsDraw (); // trigger redraw + Application.Running!.SetNeedsDraw (); // trigger redraw } } } diff --git a/Examples/UICatalog/Scenarios/Shortcuts.cs b/Examples/UICatalog/Scenarios/Shortcuts.cs index 331ed0337..939a1eccb 100644 --- a/Examples/UICatalog/Scenarios/Shortcuts.cs +++ b/Examples/UICatalog/Scenarios/Shortcuts.cs @@ -28,7 +28,7 @@ public class Shortcuts : Scenario private void App_Loaded (object? sender, EventArgs e) { Application.QuitKey = Key.F4.WithCtrl; - Application.Current!.Title = GetQuitKeyAndName (); + Application.Running!.Title = GetQuitKeyAndName (); ObservableCollection eventSource = new (); @@ -46,14 +46,14 @@ public class Shortcuts : Scenario eventLog.Width = Dim.Func ( _ => Math.Min ( - Application.Current.Viewport.Width / 2, + Application.Running.Viewport.Width / 2, eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0)); eventLog.Width = Dim.Func ( _ => Math.Min ( eventLog.SuperView!.Viewport.Width / 2, eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0)); - Application.Current.Add (eventLog); + Application.Running.Add (eventLog); var alignKeysShortcut = new Shortcut { @@ -86,7 +86,7 @@ public class Shortcuts : Scenario }; - Application.Current.Add (alignKeysShortcut); + Application.Running.Add (alignKeysShortcut); var commandFirstShortcut = new Shortcut { @@ -115,7 +115,7 @@ public class Shortcuts : Scenario $"{commandFirstShortcut.Id}.CommandView.CheckedStateChanging: {cb.Text}"); eventLog.MoveDown (); - IEnumerable toAlign = Application.Current.SubViews.OfType (); + IEnumerable toAlign = Application.Running.SubViews.OfType (); IEnumerable enumerable = toAlign as View [] ?? toAlign.ToArray (); foreach (View view in enumerable) @@ -134,7 +134,7 @@ public class Shortcuts : Scenario } }; - Application.Current.Add (commandFirstShortcut); + Application.Running.Add (commandFirstShortcut); var canFocusShortcut = new Shortcut { @@ -159,7 +159,7 @@ public class Shortcuts : Scenario SetCanFocus (e.Result == CheckState.Checked); } }; - Application.Current.Add (canFocusShortcut); + Application.Running.Add (canFocusShortcut); var appShortcut = new Shortcut { @@ -173,7 +173,7 @@ public class Shortcuts : Scenario BindKeyToApplication = true }; - Application.Current.Add (appShortcut); + Application.Running.Add (appShortcut); var buttonShortcut = new Shortcut { @@ -193,7 +193,7 @@ public class Shortcuts : Scenario var button = (Button)buttonShortcut.CommandView; buttonShortcut.Accepting += Button_Clicked; - Application.Current.Add (buttonShortcut); + Application.Running.Add (buttonShortcut); var optionSelectorShortcut = new Shortcut { @@ -221,7 +221,7 @@ public class Shortcuts : Scenario } }; - Application.Current.Add (optionSelectorShortcut); + Application.Running.Add (optionSelectorShortcut); var sliderShortcut = new Shortcut { @@ -248,7 +248,7 @@ public class Shortcuts : Scenario eventLog.MoveDown (); }; - Application.Current.Add (sliderShortcut); + Application.Running.Add (sliderShortcut); ListView listView = new ListView () { @@ -270,7 +270,7 @@ public class Shortcuts : Scenario Key = Key.F5.WithCtrl, }; - Application.Current.Add (listViewShortcut); + Application.Running.Add (listViewShortcut); var noCommandShortcut = new Shortcut { @@ -282,7 +282,7 @@ public class Shortcuts : Scenario Key = Key.D0 }; - Application.Current.Add (noCommandShortcut); + Application.Running.Add (noCommandShortcut); var noKeyShortcut = new Shortcut { @@ -295,7 +295,7 @@ public class Shortcuts : Scenario HelpText = "Keyless" }; - Application.Current.Add (noKeyShortcut); + Application.Running.Add (noKeyShortcut); var noHelpShortcut = new Shortcut { @@ -308,7 +308,7 @@ public class Shortcuts : Scenario HelpText = "" }; - Application.Current.Add (noHelpShortcut); + Application.Running.Add (noHelpShortcut); noHelpShortcut.SetFocus (); var framedShortcut = new Shortcut @@ -340,7 +340,7 @@ public class Shortcuts : Scenario } framedShortcut.SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Toplevel); - Application.Current.Add (framedShortcut); + Application.Running.Add (framedShortcut); // Horizontal var progressShortcut = new Shortcut @@ -387,7 +387,7 @@ public class Shortcuts : Scenario }; timer.Start (); - Application.Current.Add (progressShortcut); + Application.Running.Add (progressShortcut); var textField = new TextField { @@ -408,7 +408,7 @@ public class Shortcuts : Scenario }; textField.CanFocus = true; - Application.Current.Add (textFieldShortcut); + Application.Running.Add (textFieldShortcut); var bgColorShortcut = new Shortcut { @@ -450,19 +450,19 @@ public class Shortcuts : Scenario eventSource.Add ($"ColorChanged: {o.GetType ().Name} - {args.Result}"); eventLog.MoveDown (); - Application.Current.SetScheme ( - new (Application.Current.GetScheme ()) + Application.Running.SetScheme ( + new (Application.Running.GetScheme ()) { Normal = new ( - Application.Current!.GetAttributeForRole (VisualRole.Normal).Foreground, + Application.Running!.GetAttributeForRole (VisualRole.Normal).Foreground, args.Result, - Application.Current!.GetAttributeForRole (VisualRole.Normal).Style) + Application.Running!.GetAttributeForRole (VisualRole.Normal).Style) }); } }; bgColorShortcut.CommandView = bgColor; - Application.Current.Add (bgColorShortcut); + Application.Running.Add (bgColorShortcut); var appQuitShortcut = new Shortcut { @@ -476,9 +476,9 @@ public class Shortcuts : Scenario }; appQuitShortcut.Accepting += (o, args) => { Application.RequestStop (); }; - Application.Current.Add (appQuitShortcut); + Application.Running.Add (appQuitShortcut); - foreach (Shortcut shortcut in Application.Current.SubViews.OfType ()) + foreach (Shortcut shortcut in Application.Running.SubViews.OfType ()) { shortcut.Selecting += (o, args) => { @@ -529,7 +529,7 @@ public class Shortcuts : Scenario void SetCanFocus (bool canFocus) { - foreach (Shortcut peer in Application.Current!.SubViews.OfType ()) + foreach (Shortcut peer in Application.Running!.SubViews.OfType ()) { if (peer.CanFocus) { @@ -542,7 +542,7 @@ public class Shortcuts : Scenario { var max = 0; - IEnumerable toAlign = Application.Current!.SubViews.OfType ().Where(s => !s.Y.Has(out _)).Cast(); + IEnumerable toAlign = Application.Running!.SubViews.OfType ().Where(s => !s.Y.Has(out _)).Cast(); IEnumerable enumerable = toAlign as Shortcut [] ?? toAlign.ToArray (); if (align) diff --git a/Examples/UICatalog/Scenarios/SingleBackgroundWorker.cs b/Examples/UICatalog/Scenarios/SingleBackgroundWorker.cs index 571597f8c..ad25f6dd1 100644 --- a/Examples/UICatalog/Scenarios/SingleBackgroundWorker.cs +++ b/Examples/UICatalog/Scenarios/SingleBackgroundWorker.cs @@ -179,9 +179,9 @@ public class SingleBackgroundWorker : Scenario var builderUI = new StagingUIController (_startStaging, e.Result as ObservableCollection); - Toplevel top = Application.Current; + Toplevel top = Application.Running; top.Visible = false; - Application.Current.Visible = false; + Application.Running.Visible = false; builderUI.Load (); builderUI.Dispose (); top.Visible = true; diff --git a/Examples/UICatalog/Scenarios/Themes.cs b/Examples/UICatalog/Scenarios/Themes.cs index d515b5ee0..926626cd5 100644 --- a/Examples/UICatalog/Scenarios/Themes.cs +++ b/Examples/UICatalog/Scenarios/Themes.cs @@ -129,7 +129,7 @@ public sealed class Themes : Scenario { if (_view is { }) { - Application.Current!.SchemeName = args.NewValue; + Application.Running!.SchemeName = args.NewValue; if (_view.HasScheme) { diff --git a/Examples/UICatalog/Scenarios/TreeUseCases.cs b/Examples/UICatalog/Scenarios/TreeUseCases.cs index d9ee48d15..0d8576473 100644 --- a/Examples/UICatalog/Scenarios/TreeUseCases.cs +++ b/Examples/UICatalog/Scenarios/TreeUseCases.cs @@ -77,7 +77,7 @@ public class TreeUseCases : Scenario if (_currentTree != null) { - Application.Current.Remove (_currentTree); + Application.Running.Remove (_currentTree); _currentTree.Dispose (); } @@ -97,7 +97,7 @@ public class TreeUseCases : Scenario tree.TreeBuilder = new GameObjectTreeBuilder (); } - Application.Current.Add (tree); + Application.Running.Add (tree); tree.AddObject (army1); @@ -117,13 +117,13 @@ public class TreeUseCases : Scenario if (_currentTree != null) { - Application.Current.Remove (_currentTree); + Application.Running.Remove (_currentTree); _currentTree.Dispose (); } var tree = new TreeView { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill (1) }; - Application.Current.Add (tree); + Application.Running.Add (tree); tree.AddObject (myHouse); @@ -134,13 +134,13 @@ public class TreeUseCases : Scenario { if (_currentTree != null) { - Application.Current.Remove (_currentTree); + Application.Running.Remove (_currentTree); _currentTree.Dispose (); } var tree = new TreeView { X = 0, Y = 1, Width = Dim.Fill (), Height = Dim.Fill (1) }; - Application.Current.Add (tree); + Application.Running.Add (tree); var root1 = new TreeNode ("Root1"); root1.Children.Add (new TreeNode ("Child1.1")); diff --git a/Examples/UICatalog/Scenarios/WindowsAndFrameViews.cs b/Examples/UICatalog/Scenarios/WindowsAndFrameViews.cs index afe039f1c..4ec8a1acd 100644 --- a/Examples/UICatalog/Scenarios/WindowsAndFrameViews.cs +++ b/Examples/UICatalog/Scenarios/WindowsAndFrameViews.cs @@ -69,7 +69,7 @@ public class WindowsAndFrameViews : Scenario // add it to our list listWin.Add (win); - // create 3 more Windows in a loop, adding them Application.Current + // create 3 more Windows in a loop, adding them Application.Running // Each with a // button // sub Window with diff --git a/Examples/UICatalog/UICatalog.cs b/Examples/UICatalog/UICatalog.cs index 8b8eeca71..d6d582a1f 100644 --- a/Examples/UICatalog/UICatalog.cs +++ b/Examples/UICatalog/UICatalog.cs @@ -246,7 +246,7 @@ public class UICatalog /// /// Shows the UI Catalog selection UI. When the user selects a Scenario to run, the UI Catalog main app UI is - /// killed and the Scenario is run as though it were Application.Current. When the Scenario exits, this function exits. + /// killed and the Scenario is run as though it were Application.Running. When the Scenario exits, this function exits. /// /// private static Scenario RunUICatalogTopLevel () @@ -347,7 +347,7 @@ public class UICatalog private static void ConfigFileChanged (object sender, FileSystemEventArgs e) { - if (Application.Current == null) + if (Application.Running == null) { return; } diff --git a/Examples/UICatalog/UICatalogTop.cs b/Examples/UICatalog/UICatalogTop.cs index 63c3eb528..d4f2d4b62 100644 --- a/Examples/UICatalog/UICatalogTop.cs +++ b/Examples/UICatalog/UICatalogTop.cs @@ -700,7 +700,7 @@ public class UICatalogTop : Toplevel _disableMouseCb!.CheckedState = Application.IsMouseDisabled ? CheckState.Checked : CheckState.UnChecked; _force16ColorsShortcutCb!.CheckedState = Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked; - Application.Current?.SetNeedsDraw (); + Application.Running?.SetNeedsDraw (); } private void ConfigAppliedHandler (object? sender, ConfigurationManagerEventArgs? a) { ConfigApplied (); } diff --git a/Terminal.Gui/App/Application.Current.cs b/Terminal.Gui/App/Application.Running.cs similarity index 53% rename from Terminal.Gui/App/Application.Current.cs rename to Terminal.Gui/App/Application.Running.cs index e94d074e7..fd94816d5 100644 --- a/Terminal.Gui/App/Application.Current.cs +++ b/Terminal.Gui/App/Application.Running.cs @@ -2,17 +2,17 @@ using System.Collections.Concurrent; namespace Terminal.Gui.App; -public static partial class Application // Current handling +public static partial class Application // Running handling { /// [Obsolete ("The legacy static Application object is going away.")] public static ConcurrentStack SessionStack => ApplicationImpl.Instance.SessionStack; - /// The that is currently active. - /// The current toplevel. + /// The that is currently running. + /// The running toplevel. [Obsolete ("The legacy static Application object is going away.")] - public static Toplevel? Current + public static Toplevel? Running { - get => ApplicationImpl.Instance.Current; - internal set => ApplicationImpl.Instance.Current = value; + get => ApplicationImpl.Instance.Running; + internal set => ApplicationImpl.Instance.Running = value; } } diff --git a/Terminal.Gui/App/ApplicationImpl.Lifecycle.cs b/Terminal.Gui/App/ApplicationImpl.Lifecycle.cs index 0d1b1011d..05d793740 100644 --- a/Terminal.Gui/App/ApplicationImpl.Lifecycle.cs +++ b/Terminal.Gui/App/ApplicationImpl.Lifecycle.cs @@ -182,21 +182,21 @@ public partial class ApplicationImpl #if DEBUG_IDISPOSABLE - // Don't dispose the Current. It's up to caller dispose it - if (View.EnableDebugIDisposableAsserts && !ignoreDisposed && Current is { }) + // Don't dispose the Running. It's up to caller dispose it + if (View.EnableDebugIDisposableAsserts && !ignoreDisposed && Running is { }) { - Debug.Assert (Current.WasDisposed, $"Title = {Current.Title}, Id = {Current.Id}"); + Debug.Assert (Running.WasDisposed, $"Title = {Running.Title}, Id = {Running.Id}"); // If End wasn't called _CachedSessionTokenToplevel may be null if (CachedSessionTokenToplevel is { }) { Debug.Assert (CachedSessionTokenToplevel.WasDisposed); - Debug.Assert (CachedSessionTokenToplevel == Current); + Debug.Assert (CachedSessionTokenToplevel == Running); } } #endif - Current = null; + Running = null; CachedSessionTokenToplevel = null; // === 4. Clean up driver === diff --git a/Terminal.Gui/App/ApplicationImpl.Run.cs b/Terminal.Gui/App/ApplicationImpl.Run.cs index eacb3fe45..5e1632a34 100644 --- a/Terminal.Gui/App/ApplicationImpl.Run.cs +++ b/Terminal.Gui/App/ApplicationImpl.Run.cs @@ -36,28 +36,28 @@ public partial class ApplicationImpl var rs = new SessionToken (toplevel); #if DEBUG_IDISPOSABLE - if (View.EnableDebugIDisposableAsserts && Current is { } && toplevel != Current && !SessionStack.Contains (Current)) + if (View.EnableDebugIDisposableAsserts && Running is { } && toplevel != Running && !SessionStack.Contains (Running)) { - // This assertion confirm if the Current was already disposed - Debug.Assert (Current.WasDisposed); - Debug.Assert (Current == CachedSessionTokenToplevel); + // This assertion confirm if the Running was already disposed + Debug.Assert (Running.WasDisposed); + Debug.Assert (Running == CachedSessionTokenToplevel); } #endif lock (SessionStack) { - if (Current is { } && toplevel != Current && !SessionStack.Contains (Current)) + if (Running is { } && toplevel != Running && !SessionStack.Contains (Running)) { - // If Current was already disposed and isn't on the Toplevels Stack, + // If Running was already disposed and isn't on the Toplevels Stack, // clean it up here if is the same as _CachedSessionTokenToplevel - if (Current == CachedSessionTokenToplevel) + if (Running == CachedSessionTokenToplevel) { - Current = null; + Running = null; } else { // Probably this will never hit - throw new ObjectDisposedException (Current.GetType ().FullName); + throw new ObjectDisposedException (Running.GetType ().FullName); } } @@ -89,35 +89,35 @@ public partial class ApplicationImpl } } - if (Current is null) + if (Running is null) { toplevel.App = this; - Current = toplevel; + Running = toplevel; } - if ((Current?.Modal == false && toplevel.Modal) - || (Current?.Modal == false && !toplevel.Modal) - || (Current?.Modal == true && toplevel.Modal)) + if ((Running?.Modal == false && toplevel.Modal) + || (Running?.Modal == false && !toplevel.Modal) + || (Running?.Modal == true && toplevel.Modal)) { if (toplevel.Visible) { - if (Current is { HasFocus: true }) + if (Running is { HasFocus: true }) { - Current.HasFocus = false; + Running.HasFocus = false; } - // Force leave events for any entered views in the old Current + // Force leave events for any entered views in the old Running if (Mouse.LastMousePosition is { }) { Mouse.RaiseMouseEnterLeaveEvents (Mouse.LastMousePosition!.Value, new ()); } - Current?.OnDeactivate (toplevel); - Toplevel previousTop = Current!; + Running?.OnDeactivate (toplevel); + Toplevel previousTop = Running!; - Current = toplevel; - Current.App = this; - Current.OnActivate (previousTop); + Running = toplevel; + Running.App = this; + Running.OnActivate (previousTop); } } @@ -194,11 +194,11 @@ public partial class ApplicationImpl throw new InvalidOperationException ("Driver was inexplicably null when trying to Run view"); } - Current = view; + Running = view; SessionToken rs = Begin (view); - Current.IsRunning = true; + Running.IsRunning = true; var firstIteration = true; @@ -254,8 +254,8 @@ public partial class ApplicationImpl if (SessionStack.TryPeek (out Toplevel? newTop)) { newTop.App = this; - Current = newTop; - Current?.SetNeedsDraw (); + Running = newTop; + Running?.SetNeedsDraw (); } if (sessionToken.Toplevel is { HasFocus: true }) @@ -263,9 +263,9 @@ public partial class ApplicationImpl sessionToken.Toplevel.HasFocus = false; } - if (Current is { HasFocus: false }) + if (Running is { HasFocus: false }) { - Current.SetFocus (); + Running.SetFocus (); } CachedSessionTokenToplevel = sessionToken.Toplevel; @@ -285,9 +285,9 @@ public partial class ApplicationImpl /// public void RequestStop (Toplevel? top) { - Logging.Trace ($"Current: '{(top is { } ? top : "null")}'"); + Logging.Trace ($"Running: '{(top is { } ? top : "null")}'"); - top ??= Current; + top ??= Running; if (top == null) { @@ -327,7 +327,7 @@ public partial class ApplicationImpl public void Invoke (Action? action) { // If we are already on the main UI thread - if (Current is { IsRunning: true } && MainThreadId == Thread.CurrentThread.ManagedThreadId) + if (Running is { IsRunning: true } && MainThreadId == Thread.CurrentThread.ManagedThreadId) { action?.Invoke (this); @@ -350,7 +350,7 @@ public partial class ApplicationImpl public void Invoke (Action action) { // If we are already on the main UI thread - if (Current is { IsRunning: true } && MainThreadId == Thread.CurrentThread.ManagedThreadId) + if (Running is { IsRunning: true } && MainThreadId == Thread.CurrentThread.ManagedThreadId) { action?.Invoke (); diff --git a/Terminal.Gui/App/ApplicationImpl.cs b/Terminal.Gui/App/ApplicationImpl.cs index bcedf0b14..b70ce1d95 100644 --- a/Terminal.Gui/App/ApplicationImpl.cs +++ b/Terminal.Gui/App/ApplicationImpl.cs @@ -121,19 +121,19 @@ public partial class ApplicationImpl : IApplication set => _navigation = value ?? throw new ArgumentNullException (nameof (value)); } - private Toplevel? _current; + private Toplevel? _running; /// - public Toplevel? Current + public Toplevel? Running { - get => _current; + get => _running; set { - _current = value; + _running = value; - if (_current is { }) + if (_running is { }) { - _current.App = this; + _running.App = this; } } } diff --git a/Terminal.Gui/App/ApplicationNavigation.cs b/Terminal.Gui/App/ApplicationNavigation.cs index d0ef40d9c..8888e8da8 100644 --- a/Terminal.Gui/App/ApplicationNavigation.cs +++ b/Terminal.Gui/App/ApplicationNavigation.cs @@ -113,6 +113,6 @@ public class ApplicationNavigation { return visiblePopover.AdvanceFocus (direction, behavior); } - return App?.Current is { } && App.Current.AdvanceFocus (direction, behavior); + return App?.Running is { } && App.Running.AdvanceFocus (direction, behavior); } } diff --git a/Terminal.Gui/App/ApplicationPopover.cs b/Terminal.Gui/App/ApplicationPopover.cs index 72f9957df..9e435f008 100644 --- a/Terminal.Gui/App/ApplicationPopover.cs +++ b/Terminal.Gui/App/ApplicationPopover.cs @@ -41,8 +41,8 @@ public sealed class ApplicationPopover : IDisposable { if (popover is { } && !IsRegistered (popover)) { - // When created, set IPopover.Toplevel to the current Application.Current - popover.Current ??= App?.Current; + // When created, set IPopover.Toplevel to the current Application.Running + popover.Toplevel ??= App?.Running; if (popover is View popoverView) { @@ -166,7 +166,7 @@ public sealed class ApplicationPopover : IDisposable { _activePopover = null; popoverView.Visible = false; - popoverView.App?.Current?.SetNeedsDraw (); + popoverView.App?.Running?.SetNeedsDraw (); } } @@ -215,7 +215,7 @@ public sealed class ApplicationPopover : IDisposable { if (popover == activePopover || popover is not View popoverView - || (popover.Current is { } && popover.Current != App?.Current)) + || (popover.Toplevel is { } && popover.Toplevel != App?.Running)) { continue; } diff --git a/Terminal.Gui/App/IApplication.cs b/Terminal.Gui/App/IApplication.cs index d1f2d6dfd..15ee80f1e 100644 --- a/Terminal.Gui/App/IApplication.cs +++ b/Terminal.Gui/App/IApplication.cs @@ -301,14 +301,14 @@ public interface IApplication /// /// This will cause to return. /// - /// This is equivalent to calling with as the parameter. + /// This is equivalent to calling with as the parameter. /// /// void RequestStop (); /// Requests that the currently running Session stop. The Session will stop after the current iteration completes. /// - /// The to stop. If , stops the currently running . + /// The to stop. If , stops the currently running . /// /// /// This will cause to return. @@ -356,13 +356,13 @@ public interface IApplication #region Toplevel Management - /// Gets or sets the currently active Toplevel. + /// Gets or sets the currently running Toplevel. /// /// /// This is set by and cleared by . /// /// - Toplevel? Current { get; set; } + Toplevel? Running { get; set; } /// Gets the stack of all active Toplevel sessions. /// @@ -433,7 +433,7 @@ public interface IApplication /// /// /// This is typically set to when a View's changes and that view - /// has no SuperView (e.g. when is moved or resized). + /// has no SuperView (e.g. when is moved or resized). /// /// /// Automatically reset to after processes it. diff --git a/Terminal.Gui/App/IPopover.cs b/Terminal.Gui/App/IPopover.cs index 87218d07a..e7f89fd03 100644 --- a/Terminal.Gui/App/IPopover.cs +++ b/Terminal.Gui/App/IPopover.cs @@ -50,12 +50,12 @@ namespace Terminal.Gui.App; public interface IPopover { /// - /// Gets or sets the that this Popover is associated with. If null, it is not associated with + /// Gets or sets the Toplevel that this Popover is associated with. If null, it is not associated with /// any Toplevel and will receive all keyboard /// events from the . If set, it will only receive keyboard events the Toplevel would normally /// receive. - /// When is called, the is set to the current - /// if not already set. + /// When is called, this property is set to the current + /// if not already set. /// - Toplevel? Current { get; set; } + Toplevel? Toplevel { get; set; } } diff --git a/Terminal.Gui/App/Keyboard/KeyboardImpl.cs b/Terminal.Gui/App/Keyboard/KeyboardImpl.cs index e1be672e5..58f2cbf04 100644 --- a/Terminal.Gui/App/Keyboard/KeyboardImpl.cs +++ b/Terminal.Gui/App/Keyboard/KeyboardImpl.cs @@ -138,7 +138,7 @@ internal class KeyboardImpl : IKeyboard return true; } - if (App?.Current is null) + if (App?.Running is null) { if (App?.SessionStack is { }) { @@ -158,7 +158,7 @@ internal class KeyboardImpl : IKeyboard } else { - if (App.Current.NewKeyDownEvent (key)) + if (App.Running.NewKeyDownEvent (key)) { return true; } diff --git a/Terminal.Gui/App/MainLoop/ApplicationMainLoop.cs b/Terminal.Gui/App/MainLoop/ApplicationMainLoop.cs index df03c3187..af014a6d3 100644 --- a/Terminal.Gui/App/MainLoop/ApplicationMainLoop.cs +++ b/Terminal.Gui/App/MainLoop/ApplicationMainLoop.cs @@ -82,7 +82,7 @@ public class ApplicationMainLoop : IApplicationMainLoop - /// Handles raising events and setting required draw status etc when changes + /// Handles raising events and setting required draw status etc when changes /// public IToplevelTransitionManager ToplevelTransitionManager = new ToplevelTransitionManager (); @@ -145,10 +145,10 @@ public class ApplicationMainLoop : IApplicationMainLoop : IApplicationMainLoop? currentViewsUnderMouse = App?.Current?.GetViewsUnderLocation (mouseEvent.ScreenPosition, ViewportSettingsFlags.TransparentMouse); + List? currentViewsUnderMouse = App?.Running?.GetViewsUnderLocation (mouseEvent.ScreenPosition, ViewportSettingsFlags.TransparentMouse); View? deepestViewUnderMouse = currentViewsUnderMouse?.LastOrDefault (); @@ -114,9 +114,9 @@ internal class MouseImpl : IMouse return; } - // if the mouse is outside the Application.Current or Popover hierarchy, we don't want to + // if the mouse is outside the Application.Running or Popover hierarchy, we don't want to // send the mouse event to the deepest view under the mouse. - if (!View.IsInHierarchy (App?.Current, deepestViewUnderMouse, true) && !View.IsInHierarchy (App?.Popover?.GetActivePopover () as View, deepestViewUnderMouse, true)) + if (!View.IsInHierarchy (App?.Running, deepestViewUnderMouse, true) && !View.IsInHierarchy (App?.Popover?.GetActivePopover () as View, deepestViewUnderMouse, true)) { return; } diff --git a/Terminal.Gui/App/PopoverBaseImpl.cs b/Terminal.Gui/App/PopoverBaseImpl.cs index 41258401f..a0873fb8b 100644 --- a/Terminal.Gui/App/PopoverBaseImpl.cs +++ b/Terminal.Gui/App/PopoverBaseImpl.cs @@ -73,16 +73,16 @@ public abstract class PopoverBaseImpl : View, IPopover } } - private Toplevel? _current; + private Toplevel? _toplevel; /// - public Toplevel? Current + public Toplevel? Toplevel { - get => _current; + get => _toplevel; set { - _current = value; - App ??= _current?.App; + _toplevel = value; + App ??= _toplevel?.App; } } @@ -119,7 +119,7 @@ public abstract class PopoverBaseImpl : View, IPopover // Whenever visible is changing to false, we need to reset the focus if (ApplicationNavigation.IsInHierarchy (this, App?.Navigation?.GetFocused ())) { - App?.Navigation?.SetFocused (App?.Current?.MostFocused); + App?.Navigation?.SetFocused (App?.Running?.MostFocused); } } diff --git a/Terminal.Gui/App/Toplevel/ToplevelTransitionManager.cs b/Terminal.Gui/App/Toplevel/ToplevelTransitionManager.cs index 10166b450..d40c4b544 100644 --- a/Terminal.Gui/App/Toplevel/ToplevelTransitionManager.cs +++ b/Terminal.Gui/App/Toplevel/ToplevelTransitionManager.cs @@ -13,7 +13,7 @@ public class ToplevelTransitionManager : IToplevelTransitionManager /// public void RaiseReadyEventIfNeeded (IApplication? app) { - Toplevel? top = app?.Current; + Toplevel? top = app?.Running; if (top != null && !_readiedTopLevels.Contains (top)) { @@ -29,13 +29,13 @@ public class ToplevelTransitionManager : IToplevelTransitionManager /// public void HandleTopMaybeChanging (IApplication? app) { - Toplevel? newTop = app?.Current; + Toplevel? newTop = app?.Running; if (_lastTop != null && _lastTop != newTop && newTop != null) { newTop.SetNeedsDraw (); } - _lastTop = app?.Current; + _lastTop = app?.Running; } } diff --git a/Terminal.Gui/ViewBase/Adornment/Border.Arrangment.cs b/Terminal.Gui/ViewBase/Adornment/Border.Arrangment.cs index f2e52fab8..1012a677c 100644 --- a/Terminal.Gui/ViewBase/Adornment/Border.Arrangment.cs +++ b/Terminal.Gui/ViewBase/Adornment/Border.Arrangment.cs @@ -657,7 +657,7 @@ public partial class Border if (Parent!.SuperView is null) { // Redraw the entire app window. - App?.Current?.SetNeedsDraw (); + App?.Running?.SetNeedsDraw (); } else { diff --git a/Terminal.Gui/ViewBase/View.Hierarchy.cs b/Terminal.Gui/ViewBase/View.Hierarchy.cs index b88a07199..8aa006b7f 100644 --- a/Terminal.Gui/ViewBase/View.Hierarchy.cs +++ b/Terminal.Gui/ViewBase/View.Hierarchy.cs @@ -362,12 +362,12 @@ public partial class View // SuperView/SubView hierarchy management (SuperView, #endregion AddRemove - // TODO: This drives a weird coupling of Application.Current and View. It's not clear why this is needed. + // TODO: This drives a weird coupling of Application.Running and View. It's not clear why this is needed. /// Get the top superview of a given . /// The superview view. internal View? GetTopSuperView (View? view = null, View? superview = null) { - View? top = superview ?? App?.Current; + View? top = superview ?? App?.Running; for (View? v = view?.SuperView ?? this?.SuperView; v != null; v = v.SuperView) { diff --git a/Terminal.Gui/ViewBase/View.Layout.cs b/Terminal.Gui/ViewBase/View.Layout.cs index ecd58e737..4d1d61212 100644 --- a/Terminal.Gui/ViewBase/View.Layout.cs +++ b/Terminal.Gui/ViewBase/View.Layout.cs @@ -437,7 +437,7 @@ public partial class View // Layout APIs private void NeedsClearScreenNextIteration () { - if (App is { Current: { } } && App.Current == this && App.SessionStack.Count == 1) + if (App is { Running: { } } && App.Running == this && App.SessionStack.Count == 1) { // If this is the only TopLevel, we need to redraw the screen App.ClearScreenNextIteration = true; @@ -1113,8 +1113,8 @@ public partial class View // Layout APIs { // TODO: Get rid of refs to Top Size superViewContentSize = SuperView?.GetContentSize () - ?? (App?.Current is { } && App?.Current != this && App!.Current.IsInitialized - ? App.Current.GetContentSize () + ?? (App?.Running is { } && App?.Running != this && App!.Running.IsInitialized + ? App.Running.GetContentSize () : App?.Screen.Size ?? new (2048, 2048)); return superViewContentSize; @@ -1130,7 +1130,7 @@ public partial class View // Layout APIs /// /// /// If does not have a or it's SuperView is not - /// the position will be bound by . + /// the position will be bound by . /// /// The View that is to be moved. /// The target x location. @@ -1138,7 +1138,7 @@ public partial class View // Layout APIs /// The new x location that will ensure will be fully visible. /// The new y location that will ensure will be fully visible. /// - /// Either (if does not have a Super View) or + /// Either (if does not have a Super View) or /// 's SuperView. This can be used to ensure LayoutSubViews is called on the correct View. /// internal static View? GetLocationEnsuringFullVisibility ( @@ -1154,10 +1154,10 @@ public partial class View // Layout APIs IApplication? app = viewToMove.App; - if (viewToMove?.SuperView is null || viewToMove == app?.Current || viewToMove?.SuperView == app?.Current) + if (viewToMove?.SuperView is null || viewToMove == app?.Running || viewToMove?.SuperView == app?.Running) { maxDimension = app?.Screen.Width ?? 0; - superView = app?.Current; + superView = app?.Running; } else { @@ -1190,9 +1190,9 @@ public partial class View // Layout APIs var menuVisible = false; var statusVisible = false; - if (viewToMove?.SuperView is null || viewToMove == app?.Current || viewToMove?.SuperView == app?.Current) + if (viewToMove?.SuperView is null || viewToMove == app?.Running || viewToMove?.SuperView == app?.Running) { - menuVisible = app?.Current?.MenuBar?.Visible == true; + menuVisible = app?.Running?.MenuBar?.Visible == true; } else { @@ -1209,7 +1209,7 @@ public partial class View // Layout APIs } } - if (viewToMove?.SuperView is null || viewToMove == app?.Current || viewToMove?.SuperView == app?.Current) + if (viewToMove?.SuperView is null || viewToMove == app?.Running || viewToMove?.SuperView == app?.Running) { maxDimension = menuVisible ? 1 : 0; } @@ -1220,7 +1220,7 @@ public partial class View // Layout APIs ny = Math.Max (targetY, maxDimension); - if (viewToMove?.SuperView is null || viewToMove == app?.Current || viewToMove?.SuperView == app?.Current) + if (viewToMove?.SuperView is null || viewToMove == app?.Running || viewToMove?.SuperView == app?.Running) { if (app is { }) { @@ -1310,7 +1310,7 @@ public partial class View // Layout APIs } } - if (toplevel == App.Current) + if (toplevel == App.Running) { checkedTop = true; } @@ -1318,7 +1318,7 @@ public partial class View // Layout APIs } // Fallback: If TopLevels is empty or Top is not in TopLevels, check Top directly (for test compatibility) - if (!checkedTop && App?.Current is { Visible: true } top) + if (!checkedTop && App?.Running is { Visible: true } top) { // For root toplevels, allow hit-testing even if location is outside bounds (for drag/move) List result = GetViewsUnderLocation (top, screenLocation, excludeViewportSettingsFlags); diff --git a/Terminal.Gui/ViewBase/View.Navigation.cs b/Terminal.Gui/ViewBase/View.Navigation.cs index 5ff60aa7e..8dde44103 100644 --- a/Terminal.Gui/ViewBase/View.Navigation.cs +++ b/Terminal.Gui/ViewBase/View.Navigation.cs @@ -395,7 +395,7 @@ public partial class View // Focus and cross-view navigation management (TabStop public event EventHandler? FocusedChanged; /// Returns a value indicating if this View is currently on Top (Active) - public bool IsCurrentTop => App?.Current == this; + public bool IsCurrentTop => App?.Running == this; /// /// Returns the most focused SubView down the subview-hierarchy. @@ -853,18 +853,18 @@ public partial class View // Focus and cross-view navigation management (TabStop } } - // Application.Current? - if (newFocusedView is null && App?.Current is { CanFocus: true, HasFocus: false }) + // Application.Running? + if (newFocusedView is null && App?.Running is { CanFocus: true, HasFocus: false }) { // Temporarily ensure this view can't get focus bool prevCanFocus = _canFocus; _canFocus = false; - bool restoredFocus = App?.Current.RestoreFocus () ?? false; + bool restoredFocus = App?.Running.RestoreFocus () ?? false; _canFocus = prevCanFocus; - if (App?.Current is { CanFocus: true, HasFocus: true }) + if (App?.Running is { CanFocus: true, HasFocus: true }) { - newFocusedView = App?.Current; + newFocusedView = App?.Running; } else if (restoredFocus) { diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index 4037d7312..d3d920f0c 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -21,7 +21,7 @@ public class Dialog : Window /// /// By default, , , , and are /// set - /// such that the will be centered in, and no larger than 90% of , if + /// such that the will be centered in, and no larger than 90% of , if /// there is one. Otherwise, /// it will be bound by the screen dimensions. /// diff --git a/Terminal.Gui/Views/Menuv1/Menu.cs b/Terminal.Gui/Views/Menuv1/Menu.cs index f538af7dd..7bb24bcf8 100644 --- a/Terminal.Gui/Views/Menuv1/Menu.cs +++ b/Terminal.Gui/Views/Menuv1/Menu.cs @@ -12,10 +12,10 @@ internal sealed class Menu : View { public Menu () { - if (Application.Current is { }) + if (Application.Running is { }) { - Application.Current.DrawComplete += Top_DrawComplete; - Application.Current.SizeChanging += Current_TerminalResized; + Application.Running.DrawComplete += Top_DrawComplete; + Application.Running.SizeChanging += Current_TerminalResized; } Application.MouseEvent += Application_RootMouseEvent; @@ -231,10 +231,10 @@ internal sealed class Menu : View { RemoveKeyBindingsHotKey (_barItems); - if (Application.Current is { }) + if (Application.Running is { }) { - Application.Current.DrawComplete -= Top_DrawComplete; - Application.Current.SizeChanging -= Current_TerminalResized; + Application.Running.DrawComplete -= Top_DrawComplete; + Application.Running.SizeChanging -= Current_TerminalResized; } Application.MouseEvent -= Application_RootMouseEvent; diff --git a/Terminal.Gui/Views/Menuv1/MenuBar.cs b/Terminal.Gui/Views/Menuv1/MenuBar.cs index 78d1c3a29..2730f0037 100644 --- a/Terminal.Gui/Views/Menuv1/MenuBar.cs +++ b/Terminal.Gui/Views/Menuv1/MenuBar.cs @@ -421,7 +421,7 @@ public class MenuBar : View, IDesignable _selected = 0; SetNeedsDraw (); - _previousFocused = (SuperView is null ? Application.Current?.Focused : SuperView.Focused)!; + _previousFocused = (SuperView is null ? Application.Running?.Focused : SuperView.Focused)!; OpenMenu (_selected); if (!SelectEnabledItem ( @@ -490,7 +490,7 @@ public class MenuBar : View, IDesignable if (_openMenu is null) { - _previousFocused = (SuperView is null ? Application.Current?.Focused ?? null : SuperView.Focused)!; + _previousFocused = (SuperView is null ? Application.Running?.Focused ?? null : SuperView.Focused)!; } OpenMenu (idx, sIdx, subMenu); @@ -702,7 +702,7 @@ public class MenuBar : View, IDesignable } Rectangle superViewFrame = SuperView?.Frame ?? Application.Screen; - View? sv = SuperView ?? Application.Current; + View? sv = SuperView ?? Application.Running; if (sv is null) { @@ -834,7 +834,7 @@ public class MenuBar : View, IDesignable { case null: // Open a submenu below a MenuBar - _lastFocused ??= SuperView is null ? Application.Current?.MostFocused : SuperView.MostFocused; + _lastFocused ??= SuperView is null ? Application.Running?.MostFocused : SuperView.MostFocused; if (_openSubMenu is { } && !CloseMenu (false, true)) { diff --git a/Terminal.Gui/Views/Toplevel.cs b/Terminal.Gui/Views/Toplevel.cs index 5d749f302..d1d78fe6e 100644 --- a/Terminal.Gui/Views/Toplevel.cs +++ b/Terminal.Gui/Views/Toplevel.cs @@ -13,7 +13,7 @@ namespace Terminal.Gui.Views; /// /// /// A Toplevel is created when an application initializes Terminal.Gui by calling . -/// The application Toplevel can be accessed via . Additional Toplevels can be created +/// The application Toplevel can be accessed via . Additional Toplevels can be created /// and run (e.g. s). To run a Toplevel, create the and call /// . /// @@ -152,7 +152,7 @@ public partial class Toplevel : View /// public virtual void RequestStop () { - App?.RequestStop (App?.Current); + App?.RequestStop (App?.Running); } /// @@ -244,7 +244,7 @@ public partial class Toplevel : View } // BUGBUG: The && true is a temp hack - if ((superView != top || top?.SuperView is { } || (top != App?.Current && top!.Modal) || (top == App?.Current && top?.SuperView is null)) + if ((superView != top || top?.SuperView is { } || (top != App?.Running && top!.Modal) || (top == App?.Running && top?.SuperView is null)) && (top!.Frame.X + top.Frame.Width > maxWidth || ny > top.Frame.Y)) { diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs index fe3cfcc63..78502e9cf 100644 --- a/Terminal.Gui/Views/Wizard/Wizard.cs +++ b/Terminal.Gui/Views/Wizard/Wizard.cs @@ -42,7 +42,7 @@ namespace Terminal.Gui.Views; /// Application.RequestStop(); /// }; /// -/// Application.Current.Add (wizard); +/// Application.Running.Add (wizard); /// Application.Run (); /// Application.Shutdown (); /// diff --git a/Tests/IntegrationTests/FluentTests/GuiTestContextKeyEventTests.cs b/Tests/IntegrationTests/FluentTests/GuiTestContextKeyEventTests.cs index dd26e1f09..16b4ec44a 100644 --- a/Tests/IntegrationTests/FluentTests/GuiTestContextKeyEventTests.cs +++ b/Tests/IntegrationTests/FluentTests/GuiTestContextKeyEventTests.cs @@ -16,9 +16,9 @@ public class GuiTestContextKeyEventTests (ITestOutputHelper outputHelper) public void QuitKey_ViaApplication_Stops (TestDriver d) { using GuiTestContext context = With.A (40, 10, d); - Assert.True (context.App?.Current!.IsRunning); + Assert.True (context.App?.Running!.IsRunning); - Toplevel? top = context.App?.Current; + Toplevel? top = context.App?.Running; context.Then ((_) => context!.App?.Keyboard.RaiseKeyDownEvent (Application.QuitKey)); Assert.False (top!.IsRunning); } @@ -28,9 +28,9 @@ public class GuiTestContextKeyEventTests (ITestOutputHelper outputHelper) public void QuitKey_ViaEnqueueKey_Stops (TestDriver d) { using GuiTestContext context = With.A (40, 10, d, _out); - Assert.True (context.App?.Current!.IsRunning); + Assert.True (context.App?.Running!.IsRunning); - Toplevel? top = context.App?.Current; + Toplevel? top = context.App?.Running; context.EnqueueKeyEvent (Application.QuitKey); Assert.False (top!.IsRunning); diff --git a/Tests/IntegrationTests/FluentTests/GuiTestContextTests.cs b/Tests/IntegrationTests/FluentTests/GuiTestContextTests.cs index 37439b28a..50dbda6f8 100644 --- a/Tests/IntegrationTests/FluentTests/GuiTestContextTests.cs +++ b/Tests/IntegrationTests/FluentTests/GuiTestContextTests.cs @@ -43,7 +43,7 @@ public class GuiTestContextTests (ITestOutputHelper outputHelper) public void With_New_A_Runs (TestDriver d) { using GuiTestContext context = With.A (40, 10, d, _out); - Assert.True (context.App!.Current!.IsRunning); + Assert.True (context.App!.Running!.IsRunning); Assert.NotEqual (Rectangle.Empty, context.App!.Screen); } @@ -54,9 +54,9 @@ public class GuiTestContextTests (ITestOutputHelper outputHelper) using GuiTestContext context = With.A (10, 3, d, _out) .Then ((app) => { - app.Current!.BorderStyle = LineStyle.None; - app.Current!.Border!.Thickness = Thickness.Empty; - app.Current.Text = "hello"; + app.Running!.BorderStyle = LineStyle.None; + app.Running!.Border!.Thickness = Thickness.Empty; + app.Running.Text = "hello"; }) .ScreenShot ("ScreenShot", _out) .AnsiScreenShot ("AnsiScreenShot", _out) diff --git a/Tests/IntegrationTests/FluentTests/MenuBarv2Tests.cs b/Tests/IntegrationTests/FluentTests/MenuBarv2Tests.cs index d3091f9aa..8acf7ab7a 100644 --- a/Tests/IntegrationTests/FluentTests/MenuBarv2Tests.cs +++ b/Tests/IntegrationTests/FluentTests/MenuBarv2Tests.cs @@ -143,7 +143,7 @@ public class MenuBarv2Tests .Then ((app) => { menuBar = new MenuBarv2 (); - top = app.Current!; + top = app.Running!; top.Add ( new View () @@ -153,7 +153,7 @@ public class MenuBarv2Tests }); menuBar.EnableForDesign (ref top); - app.Current!.Add (menuBar); + app.Running!.Add (menuBar); }) .WaitIteration () .AssertIsNotType (top?.App?.Navigation!.GetFocused ()) @@ -178,7 +178,7 @@ public class MenuBarv2Tests { app = a; menuBar = new MenuBarv2 (); - Toplevel top = app.Current!; + Toplevel top = app.Running!; top.Add ( new View () @@ -188,7 +188,7 @@ public class MenuBarv2Tests }); menuBar.EnableForDesign (ref top); - app.Current!.Add (menuBar); + app.Running!.Add (menuBar); }) .WaitIteration () .AssertIsNotType (app?.Navigation!.GetFocused ()) @@ -266,10 +266,10 @@ public class MenuBarv2Tests .Then ((app) => { var menuBar = new MenuBarv2 (); - app.Current!.Add (menuBar); + app.Running!.Add (menuBar); // Call EnableForDesign - Toplevel top = app.Current!; + Toplevel top = app.Running!; bool result = menuBar.EnableForDesign (ref top); // Should return true @@ -302,9 +302,9 @@ public class MenuBarv2Tests { app = a; menuBar = new MenuBarv2 (); - Toplevel top = app.Current!; + Toplevel top = app.Running!; menuBar.EnableForDesign (ref top); - app.Current!.Add (menuBar); + app.Running!.Add (menuBar); }) .WaitIteration () .ScreenShot ("MenuBar initial state", _out) @@ -342,7 +342,7 @@ public class MenuBarv2Tests { app = a; menuBar = new MenuBarv2 (); - Toplevel top = app.Current!; + Toplevel top = app.Running!; top.Add ( new View () @@ -352,7 +352,7 @@ public class MenuBarv2Tests }); menuBar.EnableForDesign (ref top); - app.Current!.Add (menuBar); + app.Running!.Add (menuBar); }) .AssertIsNotType (app!.Navigation!.GetFocused ()) .ScreenShot ("MenuBar initial state", _out) @@ -386,9 +386,9 @@ public class MenuBarv2Tests { app = a; menuBar = new MenuBarv2 (); - Toplevel? toplevel = app.Current; + Toplevel? toplevel = app.Running; menuBar.EnableForDesign (ref toplevel!); - app.Current!.Add (menuBar); + app.Running!.Add (menuBar); }) .WaitIteration () .AssertIsNotType (app?.Navigation!.GetFocused ()) @@ -417,7 +417,7 @@ public class MenuBarv2Tests { app = a; menuBar = new MenuBarv2 (); - Toplevel top = app.Current!; + Toplevel top = app.Running!; top.Add ( new View () @@ -427,18 +427,18 @@ public class MenuBarv2Tests }); menuBar.EnableForDesign (ref top); - app.Current!.Add (menuBar); + app.Running!.Add (menuBar); }) .WaitIteration () .AssertIsNotType (app!.Navigation!.GetFocused ()) .ScreenShot ("MenuBar initial state", _out) .EnqueueKeyEvent (MenuBarv2.DefaultKey) .AssertEqual ("_New file", app.Navigation!.GetFocused ()!.Title) - .AssertTrue (app?.Current!.IsRunning) + .AssertTrue (app?.Running!.IsRunning) .ScreenShot ($"After {MenuBarv2.DefaultKey}", _out) .EnqueueKeyEvent (Application.QuitKey) .AssertFalse (app?.Popover?.GetActivePopover () is PopoverMenu) - .AssertTrue (app!.Current!.IsRunning); + .AssertTrue (app!.Running!.IsRunning); } [Theory] @@ -453,7 +453,7 @@ public class MenuBarv2Tests { app = a; menuBar = new MenuBarv2 (); - Toplevel top = app.Current!; + Toplevel top = app.Running!; top.Add ( new View () @@ -470,7 +470,7 @@ public class MenuBarv2Tests item.Key = Key.Empty; } - app.Current!.Add (menuBar); + app.Running!.Add (menuBar); }) .WaitIteration () .AssertIsNotType (app?.Navigation!.GetFocused ()) @@ -480,7 +480,7 @@ public class MenuBarv2Tests .ScreenShot ($"After {MenuBarv2.DefaultKey}", _out) .EnqueueKeyEvent (Application.QuitKey) .AssertFalse (app?.Popover?.GetActivePopover () is PopoverMenu) - .AssertTrue (app?.Current!.IsRunning); + .AssertTrue (app?.Running!.IsRunning); } [Theory] @@ -506,9 +506,9 @@ public class MenuBarv2Tests .Then ((a) => { var menuBar = new MenuBarv2 (); - Toplevel top = a.Current!; + Toplevel top = a.Running!; menuBar.EnableForDesign (ref top); - a.Current!.Add (menuBar); + a.Running!.Add (menuBar); }) .Add (testView) .WaitIteration () @@ -540,9 +540,9 @@ public class MenuBarv2Tests .Then ((a) => { var menuBar = new MenuBarv2 (); - Toplevel top = a.Current!; + Toplevel top = a.Running!; menuBar.EnableForDesign (ref top); - a.Current!.Add (menuBar); + a.Running!.Add (menuBar); }) .Add (testView) .WaitIteration () diff --git a/Tests/IntegrationTests/FluentTests/NavigationTests.cs b/Tests/IntegrationTests/FluentTests/NavigationTests.cs index fe74c59ea..2eb6581c1 100644 --- a/Tests/IntegrationTests/FluentTests/NavigationTests.cs +++ b/Tests/IntegrationTests/FluentTests/NavigationTests.cs @@ -29,8 +29,8 @@ public class NavigationTests (ITestOutputHelper outputHelper) w2.Add (v3, v4); var w3 = new Window { Id = "w3" }; w3.Add (v5, v6); - Toplevel top = app?.Current!; - app?.Current!.Add (w1, w2, w3); + Toplevel top = app?.Running!; + app?.Running!.Add (w1, w2, w3); }) .AssertTrue (v5.HasFocus) .EnqueueKeyEvent (Key.F6) diff --git a/Tests/IntegrationTests/FluentTests/PopverMenuTests.cs b/Tests/IntegrationTests/FluentTests/PopverMenuTests.cs index 6efe81fe1..b7afdb2f5 100644 --- a/Tests/IntegrationTests/FluentTests/PopverMenuTests.cs +++ b/Tests/IntegrationTests/FluentTests/PopverMenuTests.cs @@ -26,10 +26,10 @@ public class PopoverMenuTests .Then ((app) => { PopoverMenu popoverMenu = new (); - app.Current!.Add (popoverMenu); + app.Running!.Add (popoverMenu); // Call EnableForDesign - Toplevel top = app.Current; + Toplevel top = app.Running; bool result = popoverMenu.EnableForDesign (ref top); // Should return true @@ -65,7 +65,7 @@ public class PopoverMenuTests }; // Call EnableForDesign - Toplevel top = app.Current!; + Toplevel top = app.Running!; popoverMenu.EnableForDesign (ref top); var view = new View @@ -76,7 +76,7 @@ public class PopoverMenuTests Id = "focusableView", Text = "View" }; - app.Current!.Add (view); + app.Running!.Add (view); // EnableForDesign sets to true; undo that popoverMenu.Visible = false; @@ -110,7 +110,7 @@ public class PopoverMenuTests }; // Call EnableForDesign - Toplevel top = app.Current!; + Toplevel top = app.Running!; bool result = popoverMenu.EnableForDesign (ref top); var view = new View @@ -121,7 +121,7 @@ public class PopoverMenuTests Id = "focusableView", Text = "View" }; - app.Current!.Add (view); + app.Running!.Add (view); // EnableForDesign sets to true; undo that popoverMenu.Visible = false; @@ -139,7 +139,7 @@ public class PopoverMenuTests .ScreenShot ($"After {Application.QuitKey}", _out) .AssertFalse (app?.Popover!.Popovers.Cast ().FirstOrDefault ()!.Visible) .AssertNull (app?.Popover!.GetActivePopover ()) - .AssertTrue (app?.Current!.IsRunning); + .AssertTrue (app?.Running!.IsRunning); } [Theory] @@ -157,7 +157,7 @@ public class PopoverMenuTests }; // Call EnableForDesign - Toplevel top = app.Current!; + Toplevel top = app.Running!; bool result = popoverMenu.EnableForDesign (ref top); var view = new View @@ -168,7 +168,7 @@ public class PopoverMenuTests Id = "focusableView", Text = "View" }; - app.Current!.Add (view); + app.Running!.Add (view); // EnableForDesign sets to true; undo that popoverMenu.Visible = false; @@ -206,7 +206,7 @@ public class PopoverMenuTests }; // Call EnableForDesign - Toplevel top = app.Current!; + Toplevel top = app.Running!; bool result = popoverMenu.EnableForDesign (ref top); var view = new View @@ -217,7 +217,7 @@ public class PopoverMenuTests Id = "focusableView", Text = "View" }; - app.Current!.Add (view); + app.Running!.Add (view); // EnableForDesign sets to true; undo that popoverMenu.Visible = false; @@ -231,11 +231,11 @@ public class PopoverMenuTests .Then ((_) => app?.Popover!.Show (app?.Popover.Popovers.First ())) .ScreenShot ("PopoverMenu after Show", _out) .AssertEqual ("Cu_t", app?.Navigation!.GetFocused ()!.Title) - .AssertTrue (app?.Current!.IsRunning) + .AssertTrue (app?.Running!.IsRunning) .EnqueueKeyEvent (Application.QuitKey) .ScreenShot ($"After {Application.QuitKey}", _out) .AssertFalse (app?.Popover?.GetActivePopover () is PopoverMenu) - .AssertTrue (app?.Current!.IsRunning); + .AssertTrue (app?.Running!.IsRunning); } [Theory] @@ -267,7 +267,7 @@ public class PopoverMenuTests { App = app }; - Toplevel top = app.Current!; + Toplevel top = app.Running!; popoverMenu.EnableForDesign (ref top); app?.Popover!.Register (popoverMenu); }) @@ -307,7 +307,7 @@ public class PopoverMenuTests { App = app }; - Toplevel top = app.Current!; + Toplevel top = app.Running!; popoverMenu.EnableForDesign (ref top); app?.Popover!.Register (popoverMenu); }) @@ -346,7 +346,7 @@ public class PopoverMenuTests { App = app }; - Toplevel top = app.Current!; + Toplevel top = app.Running!; popoverMenu.EnableForDesign (ref top); app?.Popover!.Register (popoverMenu); }) diff --git a/Tests/StressTests/ApplicationStressTests.cs b/Tests/StressTests/ApplicationStressTests.cs index c87927a45..08ee429a0 100644 --- a/Tests/StressTests/ApplicationStressTests.cs +++ b/Tests/StressTests/ApplicationStressTests.cs @@ -71,8 +71,8 @@ public class ApplicationStressTests { int tbNow = _tbCounter; - // Wait for Application.Current to be running to ensure timed events can be processed - while (Application.Current is null || Application.Current is { IsRunning: false }) + // Wait for Application.Running to be running to ensure timed events can be processed + while (Application.Running is null || Application.Running is { IsRunning: false }) { Thread.Sleep (1); } diff --git a/Tests/StressTests/ScenariosStressTests.cs b/Tests/StressTests/ScenariosStressTests.cs index fead31b84..4e10bc2e0 100644 --- a/Tests/StressTests/ScenariosStressTests.cs +++ b/Tests/StressTests/ScenariosStressTests.cs @@ -126,7 +126,7 @@ public class ScenariosStressTests void OnApplicationSessionBegun (object? sender, SessionTokenEventArgs e) { - // Get a list of all subviews under Application.Current (and their subviews, etc.) + // Get a list of all subviews under Application.Running (and their subviews, etc.) // and subscribe to their DrawComplete event void SubscribeAllSubViews (View view) { @@ -140,7 +140,7 @@ public class ScenariosStressTests } } - SubscribeAllSubViews (Application.Current!); + SubscribeAllSubViews (Application.Running!); } // If the scenario doesn't close within the abort time, this will force it to quit diff --git a/Tests/TerminalGuiFluentTesting/FakeDriver/FakeApplicationLifecycle.cs b/Tests/TerminalGuiFluentTesting/FakeDriver/FakeApplicationLifecycle.cs index 5fced9338..29b42e53c 100644 --- a/Tests/TerminalGuiFluentTesting/FakeDriver/FakeApplicationLifecycle.cs +++ b/Tests/TerminalGuiFluentTesting/FakeDriver/FakeApplicationLifecycle.cs @@ -13,7 +13,7 @@ internal class FakeApplicationLifecycle (CancellationTokenSource hardStop) : IDi { hardStop.Cancel (); - Application.Current?.Dispose (); + Application.Running?.Dispose (); Application.Shutdown (); } } diff --git a/Tests/TerminalGuiFluentTesting/GuiTestContext.Navigation.cs b/Tests/TerminalGuiFluentTesting/GuiTestContext.Navigation.cs index 9bd8f5bc9..05feaa74e 100644 --- a/Tests/TerminalGuiFluentTesting/GuiTestContext.Navigation.cs +++ b/Tests/TerminalGuiFluentTesting/GuiTestContext.Navigation.cs @@ -40,13 +40,13 @@ public partial class GuiTestContext public GuiTestContext Focus (Func? evaluator = null) where T : View { evaluator ??= _ => true; - Toplevel? t = App?.Current; + Toplevel? t = App?.Running; HashSet seen = new (); if (t == null) { - Fail ("Application.Current was null when trying to set focus"); + Fail ("Application.Running was null when trying to set focus"); return this; } diff --git a/Tests/TerminalGuiFluentTesting/GuiTestContext.ViewBase.cs b/Tests/TerminalGuiFluentTesting/GuiTestContext.ViewBase.cs index f96505840..e89357a17 100644 --- a/Tests/TerminalGuiFluentTesting/GuiTestContext.ViewBase.cs +++ b/Tests/TerminalGuiFluentTesting/GuiTestContext.ViewBase.cs @@ -14,7 +14,7 @@ public partial class GuiTestContext { WaitIteration ((app) => { - Toplevel top = app.Current ?? throw new ("Top was null so could not add view"); + Toplevel top = app.Running ?? throw new ("Top was null so could not add view"); top.Add (v); top.Layout (); _lastView = v; @@ -28,15 +28,15 @@ public partial class GuiTestContext /// /// The last view added (e.g. with ) or the root/current top. /// - public View LastView => _lastView ?? App?.Current ?? throw new ("Could not determine which view to add to"); + public View LastView => _lastView ?? App?.Running ?? throw new ("Could not determine which view to add to"); private T Find (Func evaluator) where T : View { - Toplevel? t = App?.Current; + Toplevel? t = App?.Running; if (t == null) { - Fail ("App.Current was null when attempting to find view"); + Fail ("App.Running was null when attempting to find view"); } T? f = FindRecursive (t!, evaluator); diff --git a/Tests/UnitTests/Application/Application.NavigationTests.cs b/Tests/UnitTests/Application/Application.NavigationTests.cs index 21cafa132..a1ac528b9 100644 --- a/Tests/UnitTests/Application/Application.NavigationTests.cs +++ b/Tests/UnitTests/Application/Application.NavigationTests.cs @@ -82,7 +82,7 @@ public class ApplicationNavigationTests (ITestOutputHelper output) { IApplication app = Application.Create (); - app.Current = new () + app.Running = new () { Id = "top", CanFocus = true, @@ -101,10 +101,10 @@ public class ApplicationNavigationTests (ITestOutputHelper output) CanFocus = true }; - app.Current?.Add (subView1, subView2); - Assert.False (app.Current?.HasFocus); + app.Running?.Add (subView1, subView2); + Assert.False (app.Running?.HasFocus); - app.Current?.SetFocus (); + app.Running?.SetFocus (); Assert.True (subView1.HasFocus); Assert.Equal (subView1, app.Navigation?.GetFocused ()); @@ -117,7 +117,7 @@ public class ApplicationNavigationTests (ITestOutputHelper output) { IApplication app = Application.Create (); - app.Current = new () + app.Running = new () { Id = "top", CanFocus = true, @@ -130,20 +130,20 @@ public class ApplicationNavigationTests (ITestOutputHelper output) CanFocus = true }; - app!.Current.Add (subView1); - Assert.False (app.Current.HasFocus); + app!.Running.Add (subView1); + Assert.False (app.Running.HasFocus); - app.Current.SetFocus (); + app.Running.SetFocus (); Assert.True (subView1.HasFocus); Assert.Equal (subView1, app.Navigation!.GetFocused ()); subView1.HasFocus = false; Assert.False (subView1.HasFocus); - Assert.True (app.Current.HasFocus); - Assert.Equal (app.Current, app.Navigation.GetFocused ()); + Assert.True (app.Running.HasFocus); + Assert.Equal (app.Running, app.Navigation.GetFocused ()); - app.Current.HasFocus = false; - Assert.False (app.Current.HasFocus); + app.Running.HasFocus = false; + Assert.False (app.Running.HasFocus); Assert.Null (app.Navigation.GetFocused ()); } diff --git a/Tests/UnitTests/Application/ApplicationImplBeginEndTests.cs b/Tests/UnitTests/Application/ApplicationImplBeginEndTests.cs index 9092200aa..017213fee 100644 --- a/Tests/UnitTests/Application/ApplicationImplBeginEndTests.cs +++ b/Tests/UnitTests/Application/ApplicationImplBeginEndTests.cs @@ -45,12 +45,12 @@ public class ApplicationImplBeginEndTests try { toplevel = new (); - Assert.Null (app.Current); + Assert.Null (app.Running); app.Begin (toplevel); - Assert.NotNull (app.Current); - Assert.Same (toplevel, app.Current); + Assert.NotNull (app.Running); + Assert.Same (toplevel, app.Running); Assert.Single (app.SessionStack); } finally @@ -74,11 +74,11 @@ public class ApplicationImplBeginEndTests app.Begin (toplevel1); Assert.Single (app.SessionStack); - Assert.Same (toplevel1, app.Current); + Assert.Same (toplevel1, app.Running); app.Begin (toplevel2); Assert.Equal (2, app.SessionStack.Count); - Assert.Same (toplevel2, app.Current); + Assert.Same (toplevel2, app.Running); } finally { @@ -163,7 +163,7 @@ public class ApplicationImplBeginEndTests app.End (token2); Assert.Single (app.SessionStack); - Assert.Same (toplevel1, app.Current); + Assert.Same (toplevel1, app.Running); app.End (token1); @@ -228,13 +228,13 @@ public class ApplicationImplBeginEndTests SessionToken token2 = app.Begin (toplevel2); SessionToken token3 = app.Begin (toplevel3); - Assert.Same (toplevel3, app.Current); + Assert.Same (toplevel3, app.Running); app.End (token3); - Assert.Same (toplevel2, app.Current); + Assert.Same (toplevel2, app.Running); app.End (token2); - Assert.Same (toplevel1, app.Current); + Assert.Same (toplevel1, app.Running); app.End (token1); } @@ -265,7 +265,7 @@ public class ApplicationImplBeginEndTests } Assert.Equal (5, app.SessionStack.Count); - Assert.Same (toplevels [4], app.Current); + Assert.Same (toplevels [4], app.Running); // End them in reverse order (LIFO) for (var i = 4; i >= 0; i--) @@ -275,7 +275,7 @@ public class ApplicationImplBeginEndTests if (i > 0) { Assert.Equal (i, app.SessionStack.Count); - Assert.Same (toplevels [i - 1], app.Current); + Assert.Same (toplevels [i - 1], app.Running); } else { @@ -358,7 +358,7 @@ public class ApplicationImplBeginEndTests app.Begin (toplevel2); Assert.Equal (2, app.SessionStack.Count); - Assert.NotNull (app.Current); + Assert.NotNull (app.Running); } finally { @@ -371,7 +371,7 @@ public class ApplicationImplBeginEndTests // Verify cleanup happened Assert.Empty (app.SessionStack); - Assert.Null (app.Current); + Assert.Null (app.Running); Assert.Null (app.CachedSessionTokenToplevel); } } @@ -432,7 +432,7 @@ public class ApplicationImplBeginEndTests Assert.True (toplevel1Deactivated); Assert.True (toplevel2Activated); - Assert.Same (toplevel2, app.Current); + Assert.Same (toplevel2, app.Running); } finally { diff --git a/Tests/UnitTests/Application/ApplicationImplTests.cs b/Tests/UnitTests/Application/ApplicationImplTests.cs index e9ac29e76..f6d35be6a 100644 --- a/Tests/UnitTests/Application/ApplicationImplTests.cs +++ b/Tests/UnitTests/Application/ApplicationImplTests.cs @@ -81,7 +81,7 @@ public class ApplicationImplTests TimeSpan.FromMilliseconds (150), () => { - if (app.Current is { }) + if (app.Running is { }) { app.RequestStop (); @@ -91,7 +91,7 @@ public class ApplicationImplTests return false; } ); - Assert.Null (app?.Current); + Assert.Null (app?.Running); // Blocks until the timeout call is hit @@ -100,10 +100,10 @@ public class ApplicationImplTests // We returned false above, so we should not have to remove the timeout Assert.False (app?.RemoveTimeout (timeoutToken!)); - Assert.NotNull (app?.Current); - app.Current?.Dispose (); + Assert.NotNull (app?.Running); + app.Running?.Dispose (); app.Shutdown (); - Assert.Null (app.Current); + Assert.Null (app.Running); } [Fact] @@ -124,7 +124,7 @@ public class ApplicationImplTests { Assert.True (top!.IsRunning); - if (app.Current != null) + if (app.Running != null) { app.RequestStop (); @@ -146,8 +146,8 @@ public class ApplicationImplTests Assert.False (top!.IsRunning); // BUGBUG: Shutdown sets Top to null, not End. - //Assert.Null (Application.Current); - app.Current?.Dispose (); + //Assert.Null (Application.Running); + app.Running?.Dispose (); app.Shutdown (); } @@ -156,13 +156,13 @@ public class ApplicationImplTests { IApplication app = NewMockedApplicationImpl ()!; - Assert.Null (app.Current); + Assert.Null (app.Running); Assert.Null (app.Driver); app.Init ("fake"); Toplevel top = new Window (); - app.Current = top; + app.Running = top; var closedCount = 0; @@ -193,7 +193,7 @@ public class ApplicationImplTests Assert.Equal (1, closedCount); Assert.Equal (1, unloadedCount); - app.Current?.Dispose (); + app.Running?.Dispose (); app.Shutdown (); Assert.Equal (1, closedCount); Assert.Equal (1, unloadedCount); @@ -204,7 +204,7 @@ public class ApplicationImplTests { IApplication app = NewMockedApplicationImpl ()!; - Assert.Null (app.Current); + Assert.Null (app.Running); Assert.Null (app.Driver); app.Init ("fake"); @@ -228,7 +228,7 @@ public class ApplicationImplTests { Assert.True (top!.IsRunning); - if (app.Current != null) + if (app.Running != null) { app.RequestStop (); @@ -251,7 +251,7 @@ public class ApplicationImplTests // We returned false above, so we should not have to remove the timeout Assert.False (app.RemoveTimeout (timeoutToken)); - app.Current?.Dispose (); + app.Running?.Dispose (); app.Shutdown (); Assert.Equal (1, closedCount); Assert.Equal (1, unloadedCount); @@ -275,7 +275,7 @@ public class ApplicationImplTests { Assert.True (top!.IsRunning); - if (app.Current != null) + if (app.Running != null) { app.Keyboard.RaiseKeyDownEvent (app.Keyboard.QuitKey); } @@ -294,10 +294,10 @@ public class ApplicationImplTests Assert.False (top!.IsRunning); - Assert.NotNull (app.Current); + Assert.NotNull (app.Running); top.Dispose (); app.Shutdown (); - Assert.Null (app.Current); + Assert.Null (app.Running); } [Fact] @@ -308,16 +308,16 @@ public class ApplicationImplTests app.Init ("fake"); app.AddTimeout (TimeSpan.Zero, () => IdleExit (app)); - Assert.Null (app.Current); + Assert.Null (app.Running); // Blocks until the timeout call is hit app.Run (); - Assert.NotNull (app.Current); - app.Current?.Dispose (); + Assert.NotNull (app.Running); + app.Running?.Dispose (); app.Shutdown (); - Assert.Null (app.Current); + Assert.Null (app.Running); } [Fact] @@ -357,7 +357,7 @@ public class ApplicationImplTests app.Run (t); - app.Current?.Dispose (); + app.Running?.Dispose (); app.Shutdown (); Assert.Equal (2, closing); @@ -366,7 +366,7 @@ public class ApplicationImplTests private bool IdleExit (IApplication app) { - if (app.Current != null) + if (app.Running != null) { app.RequestStop (); @@ -408,7 +408,7 @@ public class ApplicationImplTests () => { // Run asynchronous logic inside Task.Run - if (app.Current != null) + if (app.Running != null) { b.NewKeyDownEvent (Key.Enter); b.NewKeyUpEvent (Key.Enter); @@ -417,7 +417,7 @@ public class ApplicationImplTests return false; }); - Assert.Null (app.Current); + Assert.Null (app.Running); var w = new Window { @@ -428,10 +428,10 @@ public class ApplicationImplTests // Blocks until the timeout call is hit app.Run (w); - Assert.NotNull (app.Current); - app.Current?.Dispose (); + Assert.NotNull (app.Running); + app.Running?.Dispose (); app.Shutdown (); - Assert.Null (app.Current); + Assert.Null (app.Running); Assert.True (result); } @@ -448,7 +448,7 @@ public class ApplicationImplTests //Assert.Null (v2.Popover); //Assert.Null (v2.Navigation); - Assert.Null (v2.Current); + Assert.Null (v2.Running); Assert.Empty (v2.SessionStack); // Init should populate instance fields @@ -459,7 +459,7 @@ public class ApplicationImplTests Assert.True (v2.Initialized); Assert.NotNull (v2.Popover); Assert.NotNull (v2.Navigation); - Assert.Null (v2.Current); // Top is still null until Run + Assert.Null (v2.Running); // Top is still null until Run // Shutdown should clean up instance fields v2.Shutdown (); @@ -469,7 +469,7 @@ public class ApplicationImplTests //Assert.Null (v2.Popover); //Assert.Null (v2.Navigation); - Assert.Null (v2.Current); + Assert.Null (v2.Running); Assert.Empty (v2.SessionStack); } } diff --git a/Tests/UnitTests/Application/ApplicationPopoverTests.cs b/Tests/UnitTests/Application/ApplicationPopoverTests.cs index 1ca1944d0..b59bcdabc 100644 --- a/Tests/UnitTests/Application/ApplicationPopoverTests.cs +++ b/Tests/UnitTests/Application/ApplicationPopoverTests.cs @@ -197,14 +197,14 @@ public class ApplicationPopoverTests // Arrange Application.Init ("fake"); - Application.Current = new (); + Application.Running = new (); PopoverTestClass? popover = new (); // Act Application.Popover?.Register (popover); // Assert - Assert.Equal (Application.Current, popover.Current); + Assert.Equal (Application.Running, popover.Toplevel); } finally { @@ -219,7 +219,7 @@ public class ApplicationPopoverTests { // Arrange Application.Init ("fake"); - Application.Current = new() { Id = "initialTop" }; + Application.Running = new() { Id = "initialTop" }; PopoverTestClass? popover = new () { }; var keyDownEvents = 0; @@ -234,7 +234,7 @@ public class ApplicationPopoverTests // Act Application.RaiseKeyDownEvent (Key.A); // Goes to initialTop - Application.Current = new() { Id = "secondaryTop" }; + Application.Running = new() { Id = "secondaryTop" }; Application.RaiseKeyDownEvent (Key.A); // Goes to secondaryTop // Test @@ -267,7 +267,7 @@ public class ApplicationPopoverTests // Arrange Application.Init ("fake"); - Application.Current = new () + Application.Running = new () { Frame = new (0, 0, 10, 10), Id = "top" @@ -282,7 +282,7 @@ public class ApplicationPopoverTests Height = 2 }; - Application.Current.Add (view); + Application.Running.Add (view); popover = new () { @@ -316,7 +316,7 @@ public class ApplicationPopoverTests finally { popover?.Dispose (); - Application.Current?.Dispose (); + Application.Running?.Dispose (); Application.ResetState (true); } } diff --git a/Tests/UnitTests/Application/ApplicationScreenTests.cs b/Tests/UnitTests/Application/ApplicationScreenTests.cs index 9d4185adf..195adef29 100644 --- a/Tests/UnitTests/Application/ApplicationScreenTests.cs +++ b/Tests/UnitTests/Application/ApplicationScreenTests.cs @@ -46,35 +46,35 @@ public class ApplicationScreenTests Assert.Equal (0, clearedContentsRaised); // Act - Application.Current!.SetNeedsLayout (); + Application.Running!.SetNeedsLayout (); Application.LayoutAndDraw (); // Assert Assert.Equal (0, clearedContentsRaised); // Act - Application.Current.X = 1; + Application.Running.X = 1; Application.LayoutAndDraw (); // Assert Assert.Equal (1, clearedContentsRaised); // Act - Application.Current.Width = 10; + Application.Running.Width = 10; Application.LayoutAndDraw (); // Assert Assert.Equal (2, clearedContentsRaised); // Act - Application.Current.Y = 1; + Application.Running.Y = 1; Application.LayoutAndDraw (); // Assert Assert.Equal (3, clearedContentsRaised); // Act - Application.Current.Height = 10; + Application.Running.Height = 10; Application.LayoutAndDraw (); // Assert diff --git a/Tests/UnitTests/Application/ApplicationTests.cs b/Tests/UnitTests/Application/ApplicationTests.cs index 549d3c233..9b9d48421 100644 --- a/Tests/UnitTests/Application/ApplicationTests.cs +++ b/Tests/UnitTests/Application/ApplicationTests.cs @@ -70,13 +70,13 @@ public class ApplicationTests [SetupFakeApplication] public void Begin_Sets_Application_Top_To_Console_Size () { - Assert.Null (Application.Current); + Assert.Null (Application.Running); Application.Driver!.SetScreenSize (80, 25); Toplevel top = new (); Application.Begin (top); - Assert.Equal (new (0, 0, 80, 25), Application.Current!.Frame); + Assert.Equal (new (0, 0, 80, 25), Application.Running!.Frame); Application.Driver!.SetScreenSize (5, 5); - Assert.Equal (new (0, 0, 5, 5), Application.Current!.Frame); + Assert.Equal (new (0, 0, 5, 5), Application.Running!.Frame); top.Dispose (); } @@ -84,21 +84,21 @@ public class ApplicationTests [SetupFakeApplication] public void End_And_Shutdown_Should_Not_Dispose_ApplicationTop () { - Assert.Null (Application.Current); + Assert.Null (Application.Running); SessionToken rs = Application.Begin (new ()); - Application.Current!.Title = "End_And_Shutdown_Should_Not_Dispose_ApplicationTop"; - Assert.Equal (rs.Toplevel, Application.Current); + Application.Running!.Title = "End_And_Shutdown_Should_Not_Dispose_ApplicationTop"; + Assert.Equal (rs.Toplevel, Application.Running); Application.End (rs); #if DEBUG_IDISPOSABLE Assert.True (rs.WasDisposed); - Assert.False (Application.Current!.WasDisposed); // Is true because the rs.Toplevel is the same as Application.Current + Assert.False (Application.Running!.WasDisposed); // Is true because the rs.Toplevel is the same as Application.Running #endif Assert.Null (rs.Toplevel); - Toplevel top = Application.Current; + Toplevel top = Application.Running; #if DEBUG_IDISPOSABLE Exception exception = Record.Exception (Application.Shutdown); @@ -132,12 +132,12 @@ public class ApplicationTests Assert.NotNull (sessionToken); Assert.Equal (rs, sessionToken); - Assert.Equal (topLevel, Application.Current); + Assert.Equal (topLevel, Application.Running); Application.SessionBegun -= newSessionTokenFn; Application.End (sessionToken); - Assert.NotNull (Application.Current); + Assert.NotNull (Application.Running); Assert.NotNull (Application.Driver); topLevel.Dispose (); @@ -246,7 +246,7 @@ public class ApplicationTests // Check that all fields and properties are set to their default values // Public Properties - Assert.Null (Application.Current); + Assert.Null (Application.Running); Assert.Null (Application.Mouse.MouseGrabView); // Don't check Application.ForceDriver @@ -391,18 +391,18 @@ public class ApplicationTests Assert.NotNull (sessionToken); Assert.Equal (rs, sessionToken); - Assert.Equal (topLevel, Application.Current); + Assert.Equal (topLevel, Application.Running); Application.SessionBegun -= newSessionTokenFn; Application.End (sessionToken); - Assert.NotNull (Application.Current); + Assert.NotNull (Application.Running); Assert.NotNull (Application.Driver); topLevel.Dispose (); Application.Shutdown (); - Assert.Null (Application.Current); + Assert.Null (Application.Running); Assert.Null (Application.Driver); } @@ -411,11 +411,11 @@ public class ApplicationTests public void Internal_Properties_Correct () { Assert.True (Application.Initialized); - Assert.Null (Application.Current); + Assert.Null (Application.Running); SessionToken rs = Application.Begin (new ()); - Assert.Equal (Application.Current, rs.Toplevel); + Assert.Equal (Application.Running, rs.Toplevel); Assert.Null (Application.Mouse.MouseGrabView); // public - Application.Current!.Dispose (); + Application.Running!.Dispose (); } // Invoke Tests @@ -511,9 +511,9 @@ public class ApplicationTests // Run when already initialized or not with a Driver will not throw (because Window is derived from Toplevel) // Using another type not derived from Toplevel will throws at compile time Application.Run (); - Assert.True (Application.Current is Window); + Assert.True (Application.Running is Window); - Application.Current!.Dispose (); + Application.Running!.Dispose (); } [Fact] @@ -524,15 +524,15 @@ public class ApplicationTests // Run when already initialized or not with a Driver will not throw (because Window is derived from Toplevel) // Using another type not derived from Toplevel will throws at compile time Application.Run (null, "fake"); - Assert.True (Application.Current is Window); + Assert.True (Application.Running is Window); - Application.Current!.Dispose (); + Application.Running!.Dispose (); // Run when already initialized or not with a Driver will not throw (because Dialog is derived from Toplevel) Application.Run (null, "fake"); - Assert.True (Application.Current is Dialog); + Assert.True (Application.Running is Dialog); - Application.Current!.Dispose (); + Application.Running!.Dispose (); Application.Shutdown (); } @@ -540,7 +540,7 @@ public class ApplicationTests [SetupFakeApplication] public void Run_T_After_Init_Does_Not_Disposes_Application_Top () { - // Init doesn't create a Toplevel and assigned it to Application.Current + // Init doesn't create a Toplevel and assigned it to Application.Running // but Begin does var initTop = new Toplevel (); @@ -554,13 +554,13 @@ public class ApplicationTests initTop.Dispose (); Assert.True (initTop.WasDisposed); #endif - Application.Current!.Dispose (); + Application.Running!.Dispose (); return; void OnApplicationOnIteration (object s, IterationEventArgs a) { - Assert.NotEqual (initTop, Application.Current); + Assert.NotEqual (initTop, Application.Running); #if DEBUG_IDISPOSABLE Assert.False (initTop.WasDisposed); #endif @@ -577,7 +577,7 @@ public class ApplicationTests // Init has been called and we're passing no driver to Run. This is ok. Application.Run (); - Application.Current!.Dispose (); + Application.Running!.Dispose (); } [Fact] @@ -589,7 +589,7 @@ public class ApplicationTests // Init has been called, selecting FakeDriver; we're passing no driver to Run. Should be fine. Application.Run (); - Application.Current!.Dispose (); + Application.Running!.Dispose (); } [Fact] @@ -620,7 +620,7 @@ public class ApplicationTests // Init has NOT been called and we're passing a valid driver to Run. This is ok. Application.Run (null, "fake"); - Application.Current!.Dispose (); + Application.Running!.Dispose (); } [Fact] @@ -744,9 +744,9 @@ public class ApplicationTests Assert.NotNull (w); Assert.Equal (string.Empty, w.Title); // Valid - w has not been disposed. The user may want to run it again - Assert.NotNull (Application.Current); - Assert.Equal (w, Application.Current); - Assert.NotEqual (top, Application.Current); + Assert.NotNull (Application.Running); + Assert.Equal (w, Application.Running); + Assert.NotEqual (top, Application.Running); Application.Run (w); // Valid - w has not been disposed. @@ -774,14 +774,14 @@ public class ApplicationTests [Fact] public void Run_Creates_Top_Without_Init () { - Assert.Null (Application.Current); + Assert.Null (Application.Running); Application.StopAfterFirstIteration = true; Application.Iteration += OnApplicationOnIteration; Toplevel top = Application.Run (null, "fake"); Application.Iteration -= OnApplicationOnIteration; #if DEBUG_IDISPOSABLE - Assert.Equal (top, Application.Current); + Assert.Equal (top, Application.Running); Assert.False (top.WasDisposed); Exception exception = Record.Exception (Application.Shutdown); Assert.NotNull (exception); @@ -794,38 +794,38 @@ public class ApplicationTests #if DEBUG_IDISPOSABLE Assert.True (top.WasDisposed); #endif - Assert.NotNull (Application.Current); + Assert.NotNull (Application.Running); Application.Shutdown (); - Assert.Null (Application.Current); + Assert.Null (Application.Running); return; - void OnApplicationOnIteration (object s, IterationEventArgs e) { Assert.NotNull (Application.Current); } + void OnApplicationOnIteration (object s, IterationEventArgs e) { Assert.NotNull (Application.Running); } } [Fact] public void Run_T_Creates_Top_Without_Init () { - Assert.Null (Application.Current); + Assert.Null (Application.Running); Application.StopAfterFirstIteration = true; Application.Run (null, "fake"); #if DEBUG_IDISPOSABLE - Assert.False (Application.Current!.WasDisposed); + Assert.False (Application.Running!.WasDisposed); Exception exception = Record.Exception (Application.Shutdown); Assert.NotNull (exception); - Assert.False (Application.Current!.WasDisposed); + Assert.False (Application.Running!.WasDisposed); // It's up to caller to dispose it - Application.Current!.Dispose (); - Assert.True (Application.Current!.WasDisposed); + Application.Running!.Dispose (); + Assert.True (Application.Running!.WasDisposed); #endif - Assert.NotNull (Application.Current); + Assert.NotNull (Application.Running); Application.Shutdown (); - Assert.Null (Application.Current); + Assert.Null (Application.Running); } [Fact] @@ -839,7 +839,7 @@ public class ApplicationTests // the new(Toplevel) may be a derived class that is possible using Application static // properties that is only available after the Application.Init was called - Assert.Null (Application.Current); + Assert.Null (Application.Running); Assert.Throws (() => Application.Run (new Toplevel ())); @@ -849,25 +849,25 @@ public class ApplicationTests Application.Run (new Toplevel ()); Application.Iteration -= OnApplication_OnIteration; #if DEBUG_IDISPOSABLE - Assert.False (Application.Current!.WasDisposed); + Assert.False (Application.Running!.WasDisposed); Exception exception = Record.Exception (Application.Shutdown); Assert.NotNull (exception); - Assert.False (Application.Current!.WasDisposed); + Assert.False (Application.Running!.WasDisposed); // It's up to caller to dispose it - Application.Current!.Dispose (); - Assert.True (Application.Current!.WasDisposed); + Application.Running!.Dispose (); + Assert.True (Application.Running!.WasDisposed); #endif - Assert.NotNull (Application.Current); + Assert.NotNull (Application.Running); Application.Shutdown (); - Assert.Null (Application.Current); + Assert.Null (Application.Running); return; void OnApplication_OnIteration (object s, IterationEventArgs e) { - Assert.NotNull (Application.Current); + Assert.NotNull (Application.Running); Application.RequestStop (); } } @@ -892,9 +892,9 @@ public class ApplicationTests TaskScheduler.FromCurrentSynchronizationContext ()); Application.Run (); Assert.NotNull (Application.Driver); - Assert.NotNull (Application.Current); - Assert.False (Application.Current!.IsRunning); - Application.Current!.Dispose (); + Assert.NotNull (Application.Running); + Assert.False (Application.Running!.IsRunning); + Application.Running!.Dispose (); Application.Shutdown (); } diff --git a/Tests/UnitTests/Application/Mouse/ApplicationMouseEnterLeaveTests.cs b/Tests/UnitTests/Application/Mouse/ApplicationMouseEnterLeaveTests.cs index 06c3cc4d1..2191be72e 100644 --- a/Tests/UnitTests/Application/Mouse/ApplicationMouseEnterLeaveTests.cs +++ b/Tests/UnitTests/Application/Mouse/ApplicationMouseEnterLeaveTests.cs @@ -41,9 +41,9 @@ public class ApplicationMouseEnterLeaveTests public void RaiseMouseEnterLeaveEvents_MouseEntersView_CallsOnMouseEnter () { // Arrange - Application.Current = new () { Frame = new (0, 0, 10, 10) }; + Application.Running = new () { Frame = new (0, 0, 10, 10) }; var view = new TestView (); - Application.Current.Add (view); + Application.Running.Add (view); var mousePosition = new Point (1, 1); List currentViewsUnderMouse = new () { view }; @@ -66,7 +66,7 @@ public class ApplicationMouseEnterLeaveTests finally { // Cleanup - Application.Current?.Dispose (); + Application.Running?.Dispose (); Application.ResetState (); } } @@ -75,9 +75,9 @@ public class ApplicationMouseEnterLeaveTests public void RaiseMouseEnterLeaveEvents_MouseLeavesView_CallsOnMouseLeave () { // Arrange - Application.Current = new () { Frame = new (0, 0, 10, 10) }; + Application.Running = new () { Frame = new (0, 0, 10, 10) }; var view = new TestView (); - Application.Current.Add (view); + Application.Running.Add (view); var mousePosition = new Point (0, 0); List currentViewsUnderMouse = new (); var mouseEvent = new MouseEventArgs (); @@ -97,7 +97,7 @@ public class ApplicationMouseEnterLeaveTests finally { // Cleanup - Application.Current?.Dispose (); + Application.Running?.Dispose (); Application.ResetState (); } } @@ -106,7 +106,7 @@ public class ApplicationMouseEnterLeaveTests public void RaiseMouseEnterLeaveEvents_MouseMovesBetweenAdjacentViews_CallsOnMouseEnterAndLeave () { // Arrange - Application.Current = new () { Frame = new (0, 0, 10, 10) }; + Application.Running = new () { Frame = new (0, 0, 10, 10) }; var view1 = new TestView (); // at 1,1 to 2,2 var view2 = new TestView () // at 2,2 to 3,3 @@ -114,8 +114,8 @@ public class ApplicationMouseEnterLeaveTests X = 2, Y = 2 }; - Application.Current.Add (view1); - Application.Current.Add (view2); + Application.Running.Add (view1); + Application.Running.Add (view2); Application.CachedViewsUnderMouse.Clear (); @@ -126,7 +126,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (0, view1.OnMouseEnterCalled); @@ -139,7 +139,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (1, view1.OnMouseEnterCalled); @@ -152,7 +152,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (1, view1.OnMouseEnterCalled); @@ -165,7 +165,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (1, view1.OnMouseEnterCalled); @@ -178,7 +178,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (1, view1.OnMouseEnterCalled); @@ -189,7 +189,7 @@ public class ApplicationMouseEnterLeaveTests finally { // Cleanup - Application.Current?.Dispose (); + Application.Running?.Dispose (); Application.ResetState (); } } @@ -198,9 +198,9 @@ public class ApplicationMouseEnterLeaveTests public void RaiseMouseEnterLeaveEvents_NoViewsUnderMouse_DoesNotCallOnMouseEnterOrLeave () { // Arrange - Application.Current = new () { Frame = new (0, 0, 10, 10) }; + Application.Running = new () { Frame = new (0, 0, 10, 10) }; var view = new TestView (); - Application.Current.Add (view); + Application.Running.Add (view); var mousePosition = new Point (0, 0); List currentViewsUnderMouse = new (); var mouseEvent = new MouseEventArgs (); @@ -219,7 +219,7 @@ public class ApplicationMouseEnterLeaveTests finally { // Cleanup - Application.Current?.Dispose (); + Application.Running?.Dispose (); Application.ResetState (); } } @@ -228,7 +228,7 @@ public class ApplicationMouseEnterLeaveTests public void RaiseMouseEnterLeaveEvents_MouseMovesBetweenOverlappingPeerViews_CallsOnMouseEnterAndLeave () { // Arrange - Application.Current = new () { Frame = new (0, 0, 10, 10) }; + Application.Running = new () { Frame = new (0, 0, 10, 10) }; var view1 = new TestView { @@ -241,8 +241,8 @@ public class ApplicationMouseEnterLeaveTests X = 2, Y = 2 }; - Application.Current.Add (view1); - Application.Current.Add (view2); + Application.Running.Add (view1); + Application.Running.Add (view2); Application.CachedViewsUnderMouse.Clear (); @@ -253,7 +253,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (0, view1.OnMouseEnterCalled); @@ -266,7 +266,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (1, view1.OnMouseEnterCalled); @@ -279,7 +279,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (1, view1.OnMouseEnterCalled); @@ -292,7 +292,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (1, view1.OnMouseEnterCalled); @@ -305,7 +305,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (1, view1.OnMouseEnterCalled); @@ -318,7 +318,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (1, view1.OnMouseEnterCalled); @@ -329,7 +329,7 @@ public class ApplicationMouseEnterLeaveTests finally { // Cleanup - Application.Current?.Dispose (); + Application.Running?.Dispose (); Application.ResetState (); } } @@ -338,7 +338,7 @@ public class ApplicationMouseEnterLeaveTests public void RaiseMouseEnterLeaveEvents_MouseMovesBetweenOverlappingSubViews_CallsOnMouseEnterAndLeave () { // Arrange - Application.Current = new () { Frame = new (0, 0, 10, 10) }; + Application.Running = new () { Frame = new (0, 0, 10, 10) }; var view1 = new TestView { @@ -358,7 +358,7 @@ public class ApplicationMouseEnterLeaveTests Arrangement = ViewArrangement.Overlapped }; // at 2,2 to 4,4 (screen) view1.Add (subView); - Application.Current.Add (view1); + Application.Running.Add (view1); Application.CachedViewsUnderMouse.Clear (); @@ -372,7 +372,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (0, view1.OnMouseEnterCalled); @@ -385,7 +385,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (1, view1.OnMouseEnterCalled); @@ -398,7 +398,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (1, view1.OnMouseEnterCalled); @@ -411,7 +411,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (1, view1.OnMouseEnterCalled); @@ -424,7 +424,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (2, view1.OnMouseEnterCalled); @@ -437,7 +437,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (2, view1.OnMouseEnterCalled); @@ -450,7 +450,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (2, view1.OnMouseEnterCalled); @@ -463,7 +463,7 @@ public class ApplicationMouseEnterLeaveTests Application.RaiseMouseEnterLeaveEvents ( mousePosition, - Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); + Application.Running.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse)); // Assert Assert.Equal (3, view1.OnMouseEnterCalled); @@ -474,7 +474,7 @@ public class ApplicationMouseEnterLeaveTests finally { // Cleanup - Application.Current?.Dispose (); + Application.Running?.Dispose (); Application.ResetState (); } } diff --git a/Tests/UnitTests/Application/Mouse/ApplicationMouseTests.cs b/Tests/UnitTests/Application/Mouse/ApplicationMouseTests.cs index 6116bcf63..d6a8a6235 100644 --- a/Tests/UnitTests/Application/Mouse/ApplicationMouseTests.cs +++ b/Tests/UnitTests/Application/Mouse/ApplicationMouseTests.cs @@ -202,15 +202,15 @@ public class ApplicationMouseTests var clicked = false; - Application.Current = new Toplevel () + Application.Running = new Toplevel () { Id = "top", }; - Application.Current.X = 0; - Application.Current.Y = 0; - Application.Current.Width = size.Width * 2; - Application.Current.Height = size.Height * 2; - Application.Current.BorderStyle = LineStyle.None; + Application.Running.X = 0; + Application.Running.Y = 0; + Application.Running.Width = size.Width * 2; + Application.Running.Height = size.Height * 2; + Application.Running.BorderStyle = LineStyle.None; var view = new View { Id = "view", X = pos.X, Y = pos.Y, Width = size.Width, Height = size.Height }; @@ -218,7 +218,7 @@ public class ApplicationMouseTests view.BorderStyle = LineStyle.Single; view.CanFocus = true; - Application.Current.Add (view); + Application.Running.Add (view); var mouseEvent = new MouseEventArgs { Position = new (clickX, clickY), ScreenPosition = new (clickX, clickY), Flags = MouseFlags.Button1Clicked }; @@ -231,7 +231,7 @@ public class ApplicationMouseTests Application.RaiseMouseEvent (mouseEvent); Assert.Equal (expectedClicked, clicked); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (ignoreDisposed: true); } diff --git a/Tests/UnitTests/Application/SessionTokenTests.cs b/Tests/UnitTests/Application/SessionTokenTests.cs index 1e642d04d..05609c6df 100644 --- a/Tests/UnitTests/Application/SessionTokenTests.cs +++ b/Tests/UnitTests/Application/SessionTokenTests.cs @@ -29,7 +29,7 @@ public class SessionTokenTests Assert.NotNull (rs); Application.End (rs); - Assert.NotNull (Application.Current); + Assert.NotNull (Application.Running); // v2 does not use main loop, it uses MainLoop and its internal //Assert.NotNull (Application.MainLoop); diff --git a/Tests/UnitTests/Application/SynchronizatonContextTests.cs b/Tests/UnitTests/Application/SynchronizatonContextTests.cs index 119cd3147..06a8db3d2 100644 --- a/Tests/UnitTests/Application/SynchronizatonContextTests.cs +++ b/Tests/UnitTests/Application/SynchronizatonContextTests.cs @@ -39,7 +39,7 @@ public class SyncrhonizationContextTests Task.Run (() => { - while (Application.Current is null || Application.Current is { IsRunning: false }) + while (Application.Running is null || Application.Running is { IsRunning: false }) { Thread.Sleep (500); } @@ -56,7 +56,7 @@ public class SyncrhonizationContextTests null ); - if (Application.Current is { IsRunning: true }) + if (Application.Running is { IsRunning: true }) { Assert.False (success); } diff --git a/Tests/UnitTests/Dialogs/DialogTests.cs b/Tests/UnitTests/Dialogs/DialogTests.cs index a4ba9591a..ddd524fbe 100644 --- a/Tests/UnitTests/Dialogs/DialogTests.cs +++ b/Tests/UnitTests/Dialogs/DialogTests.cs @@ -902,8 +902,8 @@ public class DialogTests (ITestOutputHelper output) #if DEBUG_IDISPOSABLE Assert.False (dlg.WasDisposed); - Assert.False (Application.Current!.WasDisposed); - Assert.Equal (dlg, Application.Current); + Assert.False (Application.Running!.WasDisposed); + Assert.Equal (dlg, Application.Running); #endif Assert.True (dlg.Canceled); @@ -925,8 +925,8 @@ public class DialogTests (ITestOutputHelper output) Application.Run (dlg2); Assert.True (dlg.WasDisposed); - Assert.False (Application.Current.WasDisposed); - Assert.Equal (dlg2, Application.Current); + Assert.False (Application.Running.WasDisposed); + Assert.Equal (dlg2, Application.Running); Assert.False (dlg2.WasDisposed); dlg2.Dispose (); @@ -937,10 +937,10 @@ public class DialogTests (ITestOutputHelper output) //Assert.NotNull (exception); //Assert.StartsWith ("Cannot access a disposed object.", exception.Message); - Assert.True (Application.Current.WasDisposed); + Assert.True (Application.Running.WasDisposed); Application.Shutdown (); Assert.True (dlg2.WasDisposed); - Assert.Null (Application.Current); + Assert.Null (Application.Running); #endif return; @@ -1174,8 +1174,8 @@ public class DialogTests (ITestOutputHelper output) switch (iterations) { case 0: - Application.Current!.SetNeedsLayout (); - Application.Current.SetNeedsDraw (); + Application.Running!.SetNeedsLayout (); + Application.Running.SetNeedsDraw (); break; @@ -1216,7 +1216,7 @@ public class DialogTests (ITestOutputHelper output) └───────────────────────┘", output); - Assert.False (Application.Current!.NewKeyDownEvent (Key.Enter)); + Assert.False (Application.Running!.NewKeyDownEvent (Key.Enter)); break; case 7: @@ -1410,9 +1410,9 @@ public class DialogTests (ITestOutputHelper output) #if DEBUG_IDISPOSABLE Assert.False (dlg.WasDisposed); - Assert.False (Application.Current!.WasDisposed); - Assert.NotEqual (top, Application.Current); - Assert.Equal (dlg, Application.Current); + Assert.False (Application.Running!.WasDisposed); + Assert.NotEqual (top, Application.Running); + Assert.Equal (dlg, Application.Running); #endif // dlg wasn't disposed yet and it's possible to access to his properties @@ -1426,11 +1426,11 @@ public class DialogTests (ITestOutputHelper output) top.Dispose (); #if DEBUG_IDISPOSABLE Assert.True (dlg.WasDisposed); - Assert.True (Application.Current.WasDisposed); - Assert.NotNull (Application.Current); + Assert.True (Application.Running.WasDisposed); + Assert.NotNull (Application.Running); #endif Application.Shutdown (); - Assert.Null (Application.Current); + Assert.Null (Application.Running); return; diff --git a/Tests/UnitTests/Dialogs/MessageBoxTests.cs b/Tests/UnitTests/Dialogs/MessageBoxTests.cs index 0699309b7..6ede6c95e 100644 --- a/Tests/UnitTests/Dialogs/MessageBoxTests.cs +++ b/Tests/UnitTests/Dialogs/MessageBoxTests.cs @@ -193,7 +193,7 @@ public class MessageBoxTests (ITestOutputHelper output) } else if (iterations == 1) { - mbFrame = Application.Current!.Frame; + mbFrame = Application.Running!.Frame; Application.RequestStop (); } } @@ -378,8 +378,8 @@ public class MessageBoxTests (ITestOutputHelper output) { AutoInitShutdownAttribute.RunIteration (); - Assert.IsType (Application.Current); - Assert.Equal (new (height, width), Application.Current.Frame.Size); + Assert.IsType (Application.Running); + Assert.Equal (new (height, width), Application.Running.Frame.Size); Application.RequestStop (); } @@ -415,8 +415,8 @@ public class MessageBoxTests (ITestOutputHelper output) { AutoInitShutdownAttribute.RunIteration (); - Assert.IsType (Application.Current); - Assert.Equal (new (height, width), Application.Current.Frame.Size); + Assert.IsType (Application.Running); + Assert.Equal (new (height, width), Application.Running.Frame.Size); Application.RequestStop (); } @@ -448,8 +448,8 @@ public class MessageBoxTests (ITestOutputHelper output) { AutoInitShutdownAttribute.RunIteration (); - Assert.IsType (Application.Current); - Assert.Equal (new (height, width), Application.Current.Frame.Size); + Assert.IsType (Application.Running); + Assert.Equal (new (height, width), Application.Running.Frame.Size); Application.RequestStop (); } diff --git a/Tests/UnitTests/View/Adornment/AdornmentSubViewTests.cs b/Tests/UnitTests/View/Adornment/AdornmentSubViewTests.cs index 7bfa4747a..a5566f6f6 100644 --- a/Tests/UnitTests/View/Adornment/AdornmentSubViewTests.cs +++ b/Tests/UnitTests/View/Adornment/AdornmentSubViewTests.cs @@ -14,14 +14,14 @@ public class AdornmentSubViewTests (ITestOutputHelper output) [InlineData (2, 1, true)] public void Adornment_WithSubView_Finds (int viewMargin, int subViewMargin, bool expectedFound) { - Application.Current = new Toplevel() + Application.Running = new Toplevel() { Width = 10, Height = 10 }; - Application.Current.Margin!.Thickness = new Thickness (viewMargin); + Application.Running.Margin!.Thickness = new Thickness (viewMargin); // Turn of TransparentMouse for the test - Application.Current.Margin!.ViewportSettings = ViewportSettingsFlags.None; + Application.Running.Margin!.ViewportSettings = ViewportSettingsFlags.None; var subView = new View () { @@ -34,26 +34,26 @@ public class AdornmentSubViewTests (ITestOutputHelper output) // Turn of TransparentMouse for the test subView.Margin!.ViewportSettings = ViewportSettingsFlags.None; - Application.Current.Margin!.Add (subView); - Application.Current.Layout (); + Application.Running.Margin!.Add (subView); + Application.Running.Layout (); - var foundView = Application.Current.GetViewsUnderLocation (new Point(0, 0), ViewportSettingsFlags.None).LastOrDefault (); + var foundView = Application.Running.GetViewsUnderLocation (new Point(0, 0), ViewportSettingsFlags.None).LastOrDefault (); bool found = foundView == subView || foundView == subView.Margin; Assert.Equal (expectedFound, found); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (ignoreDisposed: true); } [Fact] public void Adornment_WithNonVisibleSubView_Finds_Adornment () { - Application.Current = new Toplevel () + Application.Running = new Toplevel () { Width = 10, Height = 10 }; - Application.Current.Padding.Thickness = new Thickness (1); + Application.Running.Padding.Thickness = new Thickness (1); var subView = new View () { @@ -63,11 +63,11 @@ public class AdornmentSubViewTests (ITestOutputHelper output) Height = 1, Visible = false }; - Application.Current.Padding.Add (subView); - Application.Current.Layout (); + Application.Running.Padding.Add (subView); + Application.Running.Layout (); - Assert.Equal (Application.Current.Padding, Application.Current.GetViewsUnderLocation (new Point(0, 0), ViewportSettingsFlags.None).LastOrDefault ()); - Application.Current?.Dispose (); + Assert.Equal (Application.Running.Padding, Application.Running.GetViewsUnderLocation (new Point(0, 0), ViewportSettingsFlags.None).LastOrDefault ()); + Application.Running?.Dispose (); Application.ResetState (ignoreDisposed: true); } } diff --git a/Tests/UnitTests/View/Adornment/MarginTests.cs b/Tests/UnitTests/View/Adornment/MarginTests.cs index 3a4bc20ba..95905a8b5 100644 --- a/Tests/UnitTests/View/Adornment/MarginTests.cs +++ b/Tests/UnitTests/View/Adornment/MarginTests.cs @@ -15,27 +15,27 @@ public class MarginTests (ITestOutputHelper output) view.Margin!.Diagnostics = ViewDiagnosticFlags.Thickness; view.Margin.Thickness = new (1); - Application.Current = new Toplevel (); - Application.SessionStack.Push (Application.Current); + Application.Running = new Toplevel (); + Application.SessionStack.Push (Application.Running); - Application.Current.SetScheme (new() + Application.Running.SetScheme (new() { Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red) }); - Application.Current.Add (view); + Application.Running.Add (view); Assert.Equal (ColorName16.Red, view.Margin.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ()); - Assert.Equal (ColorName16.Red, Application.Current.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ()); + Assert.Equal (ColorName16.Red, Application.Running.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ()); - Application.Current.BeginInit (); - Application.Current.EndInit (); + Application.Running.BeginInit (); + Application.Running.EndInit (); Application.LayoutAndDraw(); DriverAssert.AssertDriverContentsAre ( @"", output ); - DriverAssert.AssertDriverAttributesAre ("0", output, null, Application.Current.GetAttributeForRole (VisualRole.Normal)); + DriverAssert.AssertDriverAttributesAre ("0", output, null, Application.Running.GetAttributeForRole (VisualRole.Normal)); Application.ResetState (true); } @@ -51,20 +51,20 @@ public class MarginTests (ITestOutputHelper output) view.Margin.Thickness = new (1); view.Margin.ViewportSettings = ViewportSettingsFlags.None; - Application.Current = new Toplevel (); - Application.SessionStack.Push (Application.Current); + Application.Running = new Toplevel (); + Application.SessionStack.Push (Application.Running); - Application.Current.SetScheme (new () + Application.Running.SetScheme (new () { Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red) }); - Application.Current.Add (view); + Application.Running.Add (view); Assert.Equal (ColorName16.Red, view.Margin.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ()); - Assert.Equal (ColorName16.Red, Application.Current.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ()); + Assert.Equal (ColorName16.Red, Application.Running.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ()); - Application.Current.BeginInit (); - Application.Current.EndInit (); + Application.Running.BeginInit (); + Application.Running.EndInit (); Application.LayoutAndDraw (); DriverAssert.AssertDriverContentsAre ( @@ -74,7 +74,7 @@ M M MMM", output ); - DriverAssert.AssertDriverAttributesAre ("0", output, null, Application.Current.GetAttributeForRole (VisualRole.Normal)); + DriverAssert.AssertDriverAttributesAre ("0", output, null, Application.Running.GetAttributeForRole (VisualRole.Normal)); Application.ResetState (true); } diff --git a/Tests/UnitTests/View/Keyboard/KeyBindingsTests.cs b/Tests/UnitTests/View/Keyboard/KeyBindingsTests.cs index 236ba0600..69b99f28b 100644 --- a/Tests/UnitTests/View/Keyboard/KeyBindingsTests.cs +++ b/Tests/UnitTests/View/Keyboard/KeyBindingsTests.cs @@ -160,14 +160,14 @@ public class KeyBindingsTests () var hotKeyRaised = false; var acceptRaised = false; var selectRaised = false; - Application.Current = new Toplevel (); + Application.Running = new Toplevel (); var view = new View { CanFocus = true, HotKeySpecifier = new Rune ('_'), Title = "_Test" }; - Application.Current.Add (view); + Application.Running.Add (view); view.HandlingHotKey += (s, e) => hotKeyRaised = true; view.Accepting += (s, e) => acceptRaised = true; view.Selecting += (s, e) => selectRaised = true; @@ -191,7 +191,7 @@ public class KeyBindingsTests () Assert.False (acceptRaised); Assert.False (selectRaised); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } // tests that test KeyBindingScope.Focus and KeyBindingScope.HotKey (tests for KeyBindingScope.Application are in Application/KeyboardTests.cs) diff --git a/Tests/UnitTests/View/Layout/GetViewsUnderLocationTests.cs b/Tests/UnitTests/View/Layout/GetViewsUnderLocationTests.cs index 97a4fc19d..c0dbb6ebd 100644 --- a/Tests/UnitTests/View/Layout/GetViewsUnderLocationTests.cs +++ b/Tests/UnitTests/View/Layout/GetViewsUnderLocationTests.cs @@ -70,22 +70,22 @@ public class GetViewsUnderLocationTests ) { // Arrange - Application.Current = new () + Application.Running = new () { Id = "Top", Frame = new (frameX, frameY, 10, 10) }; - Application.Current.Margin!.Thickness = new (marginThickness); - Application.Current.Margin!.Id = "Margin"; - Application.Current.Border!.Thickness = new (borderThickness); - Application.Current.Border!.Id = "Border"; - Application.Current.Padding!.Thickness = new (paddingThickness); - Application.Current.Padding.Id = "Padding"; + Application.Running.Margin!.Thickness = new (marginThickness); + Application.Running.Margin!.Id = "Margin"; + Application.Running.Border!.Thickness = new (borderThickness); + Application.Running.Border!.Id = "Border"; + Application.Running.Padding!.Thickness = new (paddingThickness); + Application.Running.Padding.Id = "Padding"; var location = new Point (testX, testY); // Act - List viewsUnderMouse = Application.Current.GetViewsUnderLocation (location, ViewportSettingsFlags.TransparentMouse); + List viewsUnderMouse = Application.Running.GetViewsUnderLocation (location, ViewportSettingsFlags.TransparentMouse); // Assert if (expectedViewsFound.Length == 0) @@ -98,7 +98,7 @@ public class GetViewsUnderLocationTests Assert.Equal (expectedViewsFound, foundIds); } - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -109,7 +109,7 @@ public class GetViewsUnderLocationTests public void Returns_Top_If_No_SubViews (int testX, int testY) { // Arrange - Application.Current = new () + Application.Running = new () { Frame = new (0, 0, 10, 10) }; @@ -117,11 +117,11 @@ public class GetViewsUnderLocationTests var location = new Point (testX, testY); // Act - List viewsUnderMouse = Application.Current.GetViewsUnderLocation (location, ViewportSettingsFlags.TransparentMouse); + List viewsUnderMouse = Application.Running.GetViewsUnderLocation (location, ViewportSettingsFlags.TransparentMouse); // Assert - Assert.Contains (viewsUnderMouse, v => v == Application.Current); - Application.Current.Dispose (); + Assert.Contains (viewsUnderMouse, v => v == Application.Running); + Application.Running.Dispose (); Application.ResetState (true); } @@ -134,13 +134,13 @@ public class GetViewsUnderLocationTests { Application.ResetState (true); - Application.Current = new () + Application.Running = new () { Width = 10, Height = 10 }; - Assert.Same (Application.Current, Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ()); - Application.Current.Dispose (); + Assert.Same (Application.Running, Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ()); + Application.Running.Dispose (); Application.ResetState (true); } @@ -155,7 +155,7 @@ public class GetViewsUnderLocationTests [InlineData (5, 6, true)] public void Returns_Correct_If_SubViews (int testX, int testY, bool expectedSubViewFound) { - Application.Current = new () + Application.Running = new () { Width = 10, Height = 10 }; @@ -165,12 +165,12 @@ public class GetViewsUnderLocationTests X = 1, Y = 2, Width = 5, Height = 5 }; - Application.Current.Add (subview); + Application.Running.Add (subview); - View? found = Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); + View? found = Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); Assert.Equal (expectedSubViewFound, found == subview); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -184,7 +184,7 @@ public class GetViewsUnderLocationTests [InlineData (5, 6, false)] public void Returns_Null_If_SubView_NotVisible (int testX, int testY, bool expectedSubViewFound) { - Application.Current = new () + Application.Running = new () { Width = 10, Height = 10 }; @@ -195,12 +195,12 @@ public class GetViewsUnderLocationTests Width = 5, Height = 5, Visible = false }; - Application.Current.Add (subview); + Application.Running.Add (subview); - View? found = Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); + View? found = Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); Assert.Equal (expectedSubViewFound, found == subview); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -214,7 +214,7 @@ public class GetViewsUnderLocationTests [InlineData (5, 6, false)] public void Returns_Null_If_Not_Visible_And_SubView_Visible (int testX, int testY, bool expectedSubViewFound) { - Application.Current = new () + Application.Running = new () { Width = 10, Height = 10, Visible = false @@ -225,14 +225,14 @@ public class GetViewsUnderLocationTests X = 1, Y = 2, Width = 5, Height = 5 }; - Application.Current.Add (subview); + Application.Running.Add (subview); subview.Visible = true; Assert.True (subview.Visible); - Assert.False (Application.Current.Visible); - View? found = Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); + Assert.False (Application.Running.Visible); + View? found = Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); Assert.Equal (expectedSubViewFound, found == subview); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -249,23 +249,23 @@ public class GetViewsUnderLocationTests [InlineData (6, 7, true)] public void Returns_Correct_If_Start_Has_Adornments (int testX, int testY, bool expectedSubViewFound) { - Application.Current = new () + Application.Running = new () { Width = 10, Height = 10 }; - Application.Current.Margin!.Thickness = new (1); + Application.Running.Margin!.Thickness = new (1); var subview = new View { X = 1, Y = 2, Width = 5, Height = 5 }; - Application.Current.Add (subview); + Application.Running.Add (subview); - View? found = Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); + View? found = Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); Assert.Equal (expectedSubViewFound, found == subview); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -280,24 +280,24 @@ public class GetViewsUnderLocationTests [InlineData (-1, 0, 0, false)] public void Returns_Correct_If_Start_Has_Offset_Viewport (int offset, int testX, int testY, bool expectedSubViewFound) { - Application.Current = new () + Application.Running = new () { Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.AllowNegativeLocation }; - Application.Current.Viewport = new (offset, offset, 10, 10); + Application.Running.Viewport = new (offset, offset, 10, 10); var subview = new View { X = 1, Y = 1, Width = 2, Height = 2 }; - Application.Current.Add (subview); + Application.Running.Add (subview); - View? found = Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); + View? found = Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); Assert.Equal (expectedSubViewFound, found == subview); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -313,25 +313,25 @@ public class GetViewsUnderLocationTests [InlineData (6, 7, false)] public void Returns_Correct_If_Start_Has_Adornment_WithSubView (int testX, int testY, bool expectedSubViewFound) { - Application.Current = new () + Application.Running = new () { Width = 10, Height = 10 }; - Application.Current.Padding!.Thickness = new (1); + Application.Running.Padding!.Thickness = new (1); var subview = new View { X = Pos.AnchorEnd (1), Y = Pos.AnchorEnd (1), Width = 1, Height = 1 }; - Application.Current.Padding.Add (subview); - Application.Current.BeginInit (); - Application.Current.EndInit (); + Application.Running.Padding.Add (subview); + Application.Running.BeginInit (); + Application.Running.EndInit (); - View? found = Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); + View? found = Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); Assert.Equal (expectedSubViewFound, found == subview); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -347,17 +347,17 @@ public class GetViewsUnderLocationTests { Application.ResetState (true); - Application.Current = new () + Application.Running = new () { Id = "Top", Width = 10, Height = 10 }; - Application.Current.Margin!.Thickness = new (1); - Application.Current.Margin!.Id = "Margin"; - Application.Current.Border!.Thickness = new (1); - Application.Current.Border!.Id = "Border"; - Application.Current.Padding!.Thickness = new (1); - Application.Current.Padding.Id = "Padding"; + Application.Running.Margin!.Thickness = new (1); + Application.Running.Margin!.Id = "Margin"; + Application.Running.Border!.Thickness = new (1); + Application.Running.Border!.Id = "Border"; + Application.Running.Padding!.Thickness = new (1); + Application.Running.Padding.Id = "Padding"; var subview = new View { @@ -365,13 +365,13 @@ public class GetViewsUnderLocationTests X = 1, Y = 1, Width = 1, Height = 1 }; - Application.Current.Add (subview); + Application.Running.Add (subview); - List viewsUnderMouse = Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse); + List viewsUnderMouse = Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse); string [] foundIds = viewsUnderMouse.Select (v => v!.Id).ToArray (); Assert.Equal (expectedViewsFound, foundIds); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -388,7 +388,7 @@ public class GetViewsUnderLocationTests [InlineData (2, 3, new [] { "Top", "subview" })] public void Returns_Correct_If_SubView_Has_Adornments (int testX, int testY, string [] expectedViewsFound) { - Application.Current = new () + Application.Running = new () { Id = "Top", Width = 10, Height = 10 @@ -402,13 +402,13 @@ public class GetViewsUnderLocationTests }; subview.Border!.Thickness = new (1); subview.Border!.Id = "border"; - Application.Current.Add (subview); + Application.Running.Add (subview); - List viewsUnderMouse = Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse); + List viewsUnderMouse = Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse); string [] foundIds = viewsUnderMouse.Select (v => v!.Id).ToArray (); Assert.Equal (expectedViewsFound, foundIds); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -425,7 +425,7 @@ public class GetViewsUnderLocationTests [InlineData (2, 3, new [] { "Top", "subview" })] public void Returns_Correct_If_SubView_Has_Adornments_With_TransparentMouse (int testX, int testY, string [] expectedViewsFound) { - Application.Current = new () + Application.Running = new () { Id = "Top", Width = 10, Height = 10 @@ -440,13 +440,13 @@ public class GetViewsUnderLocationTests subview.Border!.Thickness = new (1); subview.Border!.ViewportSettings = ViewportSettingsFlags.TransparentMouse; subview.Border!.Id = "border"; - Application.Current.Add (subview); + Application.Running.Add (subview); - List viewsUnderMouse = Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse); + List viewsUnderMouse = Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse); string [] foundIds = viewsUnderMouse.Select (v => v!.Id).ToArray (); Assert.Equal (expectedViewsFound, foundIds); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -463,7 +463,7 @@ public class GetViewsUnderLocationTests [InlineData (5, 5, true)] public void Returns_Correct_If_SubView_Has_Adornment_WithSubView (int testX, int testY, bool expectedSubViewFound) { - Application.Current = new () + Application.Running = new () { Width = 10, Height = 10 }; @@ -486,14 +486,14 @@ public class GetViewsUnderLocationTests Height = 1 }; subview.Padding.Add (paddingSubView); - Application.Current.Add (subview); - Application.Current.BeginInit (); - Application.Current.EndInit (); + Application.Running.Add (subview); + Application.Running.BeginInit (); + Application.Running.EndInit (); - View? found = Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); + View? found = Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); Assert.Equal (expectedSubViewFound, found == paddingSubView); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -510,7 +510,7 @@ public class GetViewsUnderLocationTests [InlineData (5, 5, true)] public void Returns_Correct_If_SubView_Is_Scrolled_And_Has_Adornment_WithSubView (int testX, int testY, bool expectedSubViewFound) { - Application.Current = new () + Application.Running = new () { Width = 10, Height = 10 }; @@ -537,14 +537,14 @@ public class GetViewsUnderLocationTests Height = 1 }; subview.Padding.Add (paddingSubView); - Application.Current.Add (subview); - Application.Current.BeginInit (); - Application.Current.EndInit (); + Application.Running.Add (subview); + Application.Running.BeginInit (); + Application.Running.EndInit (); - View? found = Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); + View? found = Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); Assert.Equal (expectedSubViewFound, found == paddingSubView); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -560,7 +560,7 @@ public class GetViewsUnderLocationTests [InlineData (5, 5, 2)] public void Returns_Correct_With_NestedSubViews (int testX, int testY, int expectedSubViewFound) { - Application.Current = new () + Application.Running = new () { Width = 10, Height = 10 }; @@ -583,11 +583,11 @@ public class GetViewsUnderLocationTests } } - Application.Current.Add (subviews [0]); + Application.Running.Add (subviews [0]); - View? found = Application.Current.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); + View? found = Application.Running.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); Assert.Equal (expectedSubViewFound, subviews.IndexOf (found!)); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -604,7 +604,7 @@ public class GetViewsUnderLocationTests public void Tiled_SubViews (int mouseX, int mouseY, string [] viewIdStrings) { // Arrange - Application.Current = new () + Application.Running = new () { Frame = new (0, 0, 10, 10), Id = "top" @@ -630,15 +630,15 @@ public class GetViewsUnderLocationTests Arrangement = ViewArrangement.Overlapped }; // at 2,2 to 4,3 (screen) view.Add (subView); - Application.Current.Add (view); + Application.Running.Add (view); - List found = Application.Current.GetViewsUnderLocation (new (mouseX, mouseY), ViewportSettingsFlags.TransparentMouse); + List found = Application.Running.GetViewsUnderLocation (new (mouseX, mouseY), ViewportSettingsFlags.TransparentMouse); string [] foundIds = found.Select (v => v!.Id).ToArray (); Assert.Equal (viewIdStrings, foundIds); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -656,7 +656,7 @@ public class GetViewsUnderLocationTests public void Popover (int mouseX, int mouseY, string [] viewIdStrings) { // Arrange - Application.Current = new () + Application.Running = new () { Frame = new (0, 0, 10, 10), Id = "top" @@ -683,15 +683,15 @@ public class GetViewsUnderLocationTests }; // at 2,2 to 4,3 (screen) view.Add (popOver); - Application.Current.Add (view); + Application.Running.Add (view); - List found = Application.Current.GetViewsUnderLocation (new (mouseX, mouseY), ViewportSettingsFlags.TransparentMouse); + List found = Application.Running.GetViewsUnderLocation (new (mouseX, mouseY), ViewportSettingsFlags.TransparentMouse); string [] foundIds = found.Select (v => v!.Id).ToArray (); Assert.Equal (viewIdStrings, foundIds); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -717,9 +717,9 @@ public class GetViewsUnderLocationTests Application.SessionStack.Clear (); Application.SessionStack.Push (topToplevel); Application.SessionStack.Push (secondaryToplevel); - Application.Current = secondaryToplevel; + Application.Running = secondaryToplevel; - List found = Application.Current.GetViewsUnderLocation (new (2, 2), ViewportSettingsFlags.TransparentMouse); + List found = Application.Running.GetViewsUnderLocation (new (2, 2), ViewportSettingsFlags.TransparentMouse); Assert.Contains (found, v => v?.Id == topToplevel.Id); Assert.Contains (found, v => v == topToplevel); @@ -751,9 +751,9 @@ public class GetViewsUnderLocationTests Application.SessionStack.Clear (); Application.SessionStack.Push (topToplevel); Application.SessionStack.Push (secondaryToplevel); - Application.Current = secondaryToplevel; + Application.Running = secondaryToplevel; - List found = Application.Current.GetViewsUnderLocation (new (7, 7), ViewportSettingsFlags.TransparentMouse); + List found = Application.Running.GetViewsUnderLocation (new (7, 7), ViewportSettingsFlags.TransparentMouse); Assert.Contains (found, v => v?.Id == secondaryToplevel.Id); Assert.DoesNotContain (found, v => v?.Id == topToplevel.Id); @@ -784,17 +784,17 @@ public class GetViewsUnderLocationTests Application.SessionStack.Clear (); Application.SessionStack.Push (topToplevel); Application.SessionStack.Push (secondaryToplevel); - Application.Current = secondaryToplevel; + Application.Running = secondaryToplevel; secondaryToplevel.Margin!.ViewportSettings = ViewportSettingsFlags.None; - List found = Application.Current.GetViewsUnderLocation (new (5, 5), ViewportSettingsFlags.TransparentMouse); + List found = Application.Running.GetViewsUnderLocation (new (5, 5), ViewportSettingsFlags.TransparentMouse); Assert.Contains (found, v => v == secondaryToplevel); Assert.Contains (found, v => v == secondaryToplevel.Margin); Assert.DoesNotContain (found, v => v?.Id == topToplevel.Id); secondaryToplevel.Margin!.ViewportSettings = ViewportSettingsFlags.TransparentMouse; - found = Application.Current.GetViewsUnderLocation (new (5, 5), ViewportSettingsFlags.TransparentMouse); + found = Application.Running.GetViewsUnderLocation (new (5, 5), ViewportSettingsFlags.TransparentMouse); Assert.DoesNotContain (found, v => v == secondaryToplevel); Assert.DoesNotContain (found, v => v == secondaryToplevel.Margin); Assert.Contains (found, v => v?.Id == topToplevel.Id); @@ -827,9 +827,9 @@ public class GetViewsUnderLocationTests Application.SessionStack.Clear (); Application.SessionStack.Push (topToplevel); Application.SessionStack.Push (secondaryToplevel); - Application.Current = secondaryToplevel; + Application.Running = secondaryToplevel; - List found = Application.Current.GetViewsUnderLocation (new (20, 20), ViewportSettingsFlags.TransparentMouse); + List found = Application.Running.GetViewsUnderLocation (new (20, 20), ViewportSettingsFlags.TransparentMouse); Assert.Empty (found); topToplevel.Dispose (); diff --git a/Tests/UnitTests/View/Layout/Pos.CombineTests.cs b/Tests/UnitTests/View/Layout/Pos.CombineTests.cs index cbbf50da6..ba228f641 100644 --- a/Tests/UnitTests/View/Layout/Pos.CombineTests.cs +++ b/Tests/UnitTests/View/Layout/Pos.CombineTests.cs @@ -40,7 +40,7 @@ public class PosCombineTests (ITestOutputHelper output) [SetupFakeApplication] public void PosCombine_DimCombine_View_With_SubViews () { - Application.Current = new Toplevel () { Width = 80, Height = 25 }; + Application.Running = new Toplevel () { Width = 80, Height = 25 }; var win1 = new Window { Id = "win1", Width = 20, Height = 10 }; var view1 = new View { @@ -59,18 +59,18 @@ public class PosCombineTests (ITestOutputHelper output) view2.Add (view3); win2.Add (view2); win1.Add (view1, win2); - Application.Current.Add (win1); - Application.Current.Layout (); + Application.Running.Add (win1); + Application.Running.Layout (); - Assert.Equal (new Rectangle (0, 0, 80, 25), Application.Current.Frame); + Assert.Equal (new Rectangle (0, 0, 80, 25), Application.Running.Frame); Assert.Equal (new Rectangle (0, 0, 5, 1), view1.Frame); Assert.Equal (new Rectangle (0, 0, 20, 10), win1.Frame); Assert.Equal (new Rectangle (0, 2, 10, 3), win2.Frame); Assert.Equal (new Rectangle (0, 0, 8, 1), view2.Frame); Assert.Equal (new Rectangle (0, 0, 7, 1), view3.Frame); - var foundView = Application.Current.GetViewsUnderLocation (new Point(9, 4), ViewportSettingsFlags.None).LastOrDefault (); + var foundView = Application.Running.GetViewsUnderLocation (new Point(9, 4), ViewportSettingsFlags.None).LastOrDefault (); Assert.Equal (foundView, view2); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -89,13 +89,13 @@ public class PosCombineTests (ITestOutputHelper output) top.Add (w); Application.Begin (top); - f.X = Pos.X (Application.Current) + Pos.X (v2) - Pos.X (v1); - f.Y = Pos.Y (Application.Current) + Pos.Y (v2) - Pos.Y (v1); + f.X = Pos.X (Application.Running) + Pos.X (v2) - Pos.X (v1); + f.Y = Pos.Y (Application.Running) + Pos.Y (v2) - Pos.Y (v1); - Application.Current.SubViewsLaidOut += (s, e) => + Application.Running.SubViewsLaidOut += (s, e) => { - Assert.Equal (0, Application.Current.Frame.X); - Assert.Equal (0, Application.Current.Frame.Y); + Assert.Equal (0, Application.Running.Frame.X); + Assert.Equal (0, Application.Running.Frame.Y); Assert.Equal (2, w.Frame.X); Assert.Equal (2, w.Frame.Y); Assert.Equal (2, f.Frame.X); @@ -109,7 +109,7 @@ public class PosCombineTests (ITestOutputHelper output) Application.StopAfterFirstIteration = true; Assert.Throws (() => Application.Run ()); - Application.Current.Dispose (); + Application.Running.Dispose (); top.Dispose (); Application.Shutdown (); } diff --git a/Tests/UnitTests/View/Layout/SetLayoutTests.cs b/Tests/UnitTests/View/Layout/SetLayoutTests.cs index 7ccf52dca..b43c15257 100644 --- a/Tests/UnitTests/View/Layout/SetLayoutTests.cs +++ b/Tests/UnitTests/View/Layout/SetLayoutTests.cs @@ -12,7 +12,7 @@ public class SetLayoutTests (ITestOutputHelper output) [AutoInitShutdown] public void Screen_Size_Change_Causes_Layout () { - Application.Current = new (); + Application.Running = new (); var view = new View { @@ -22,21 +22,21 @@ public class SetLayoutTests (ITestOutputHelper output) Height = 1, Text = "0123456789" }; - Application.Current.Add (view); + Application.Running.Add (view); - var rs = Application.Begin (Application.Current); + var rs = Application.Begin (Application.Running); Application.Driver!.SetScreenSize (80, 25); Assert.Equal (new (0, 0, 80, 25), new Rectangle (0, 0, Application.Screen.Width, Application.Screen.Height)); - Assert.Equal (new (0, 0, Application.Screen.Width, Application.Screen.Height), Application.Current.Frame); - Assert.Equal (new (0, 0, 80, 25), Application.Current.Frame); + Assert.Equal (new (0, 0, Application.Screen.Width, Application.Screen.Height), Application.Running.Frame); + Assert.Equal (new (0, 0, 80, 25), Application.Running.Frame); Application.Driver!.SetScreenSize (20, 10); - Assert.Equal (new (0, 0, Application.Screen.Width, Application.Screen.Height), Application.Current.Frame); + Assert.Equal (new (0, 0, Application.Screen.Width, Application.Screen.Height), Application.Running.Frame); - Assert.Equal (new (0, 0, 20, 10), Application.Current.Frame); + Assert.Equal (new (0, 0, 20, 10), Application.Running.Frame); Application.End (rs); - Application.Current.Dispose (); + Application.Running.Dispose (); } } diff --git a/Tests/UnitTests/View/Navigation/CanFocusTests.cs b/Tests/UnitTests/View/Navigation/CanFocusTests.cs index 8a82c605d..6c7a67ddd 100644 --- a/Tests/UnitTests/View/Navigation/CanFocusTests.cs +++ b/Tests/UnitTests/View/Navigation/CanFocusTests.cs @@ -89,13 +89,13 @@ public class CanFocusTests public void CanFocus_Set_True_Get_AdvanceFocus_Works () { IApplication app = Application.Create (); - app.Current = new () { App = app }; + app.Running = new () { App = app }; Label label = new () { Text = "label" }; View view = new () { Text = "view", CanFocus = true }; - app.Current.Add (label, view); + app.Running.Add (label, view); - app.Current.SetFocus (); + app.Running.SetFocus (); Assert.Equal (view, app.Navigation!.GetFocused ()); Assert.False (label.CanFocus); Assert.False (label.HasFocus); @@ -125,7 +125,7 @@ public class CanFocusTests Assert.True (label.HasFocus); Assert.False (view.HasFocus); - app.Current.Dispose (); + app.Running.Dispose (); app.ResetState (); } } diff --git a/Tests/UnitTests/View/Navigation/NavigationTests.cs b/Tests/UnitTests/View/Navigation/NavigationTests.cs index 466d6a1ca..43b135514 100644 --- a/Tests/UnitTests/View/Navigation/NavigationTests.cs +++ b/Tests/UnitTests/View/Navigation/NavigationTests.cs @@ -27,7 +27,7 @@ public class NavigationTests (ITestOutputHelper output) : TestsAllViews } Toplevel top = new (); - Application.Current = top; + Application.Running = top; View otherView = new () { @@ -117,7 +117,7 @@ public class NavigationTests (ITestOutputHelper output) : TestsAllViews } Toplevel top = new (); - Application.Current = top; + Application.Running = top; View otherView = new () { @@ -148,8 +148,8 @@ public class NavigationTests (ITestOutputHelper output) : TestsAllViews // Ensure the view is Visible view.Visible = true; - Application.Current.SetFocus (); - Assert.True (Application.Current!.HasFocus); + Application.Running.SetFocus (); + Assert.True (Application.Running!.HasFocus); Assert.True (top.HasFocus); // Start with the focus on our test view @@ -280,7 +280,7 @@ public class NavigationTests (ITestOutputHelper output) : TestsAllViews Toplevel top = new (); - Application.Current = top; + Application.Running = top; View otherView = new () { diff --git a/Tests/UnitTests/View/TextTests.cs b/Tests/UnitTests/View/TextTests.cs index 625d0ce49..3de40b494 100644 --- a/Tests/UnitTests/View/TextTests.cs +++ b/Tests/UnitTests/View/TextTests.cs @@ -395,7 +395,7 @@ Y Assert.Equal (new (1, 5), view.TextFormatter.ConstrainToSize); Assert.Equal (new () { "Views" }, view.TextFormatter.GetLines ()); Assert.Equal (new (0, 0, 4, 10), win.Frame); - Assert.Equal (new (0, 0, 4, 10), Application.Current.Frame); + Assert.Equal (new (0, 0, 4, 10), Application.Running.Frame); var expected = @" ┌──┐ diff --git a/Tests/UnitTests/View/ViewCommandTests.cs b/Tests/UnitTests/View/ViewCommandTests.cs index cc48653eb..4ffaa31ae 100644 --- a/Tests/UnitTests/View/ViewCommandTests.cs +++ b/Tests/UnitTests/View/ViewCommandTests.cs @@ -46,9 +46,9 @@ public class ViewCommandTests w.LayoutSubViews (); - Application.Current = w; + Application.Running = w; Application.SessionStack.Push (w); - Assert.Same (Application.Current, w); + Assert.Same (Application.Running, w); // Click button 2 Rectangle btn2Frame = btnB.FrameToScreen (); @@ -121,9 +121,9 @@ public class ViewCommandTests w.Add (btn); - Application.Current = w; + Application.Running = w; Application.SessionStack.Push (w); - Assert.Same (Application.Current, w); + Assert.Same (Application.Running, w); w.LayoutSubViews (); diff --git a/Tests/UnitTests/View/Viewport/ViewportSettings.TransparentMouseTests.cs b/Tests/UnitTests/View/Viewport/ViewportSettings.TransparentMouseTests.cs index 2e66c4c9b..472cd1f8d 100644 --- a/Tests/UnitTests/View/Viewport/ViewportSettings.TransparentMouseTests.cs +++ b/Tests/UnitTests/View/Viewport/ViewportSettings.TransparentMouseTests.cs @@ -23,7 +23,7 @@ public class TransparentMouseTests { Id = "top", }; - Application.Current = top; + Application.Running = top; var underlying = new MouseTrackingView { Id = "underlying", X = 0, Y = 0, Width = 10, Height = 10 }; var overlay = new MouseTrackingView { Id = "overlay", X = 0, Y = 0, Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.TransparentMouse }; @@ -56,7 +56,7 @@ public class TransparentMouseTests { // Arrange var top = new Toplevel (); - Application.Current = top; + Application.Running = top; var underlying = new MouseTrackingView { X = 0, Y = 0, Width = 10, Height = 10 }; var overlay = new MouseTrackingView { X = 0, Y = 0, Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.None }; @@ -90,7 +90,7 @@ public class TransparentMouseTests { // Arrange var top = new Toplevel (); - Application.Current = top; + Application.Running = top; var underlying = new MouseTrackingView { X = 0, Y = 0, Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.TransparentMouse }; var overlay = new MouseTrackingView { X = 0, Y = 0, Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.TransparentMouse }; diff --git a/Tests/UnitTests/Views/AppendAutocompleteTests.cs b/Tests/UnitTests/Views/AppendAutocompleteTests.cs index 3fa75b7b8..31a03432d 100644 --- a/Tests/UnitTests/Views/AppendAutocompleteTests.cs +++ b/Tests/UnitTests/Views/AppendAutocompleteTests.cs @@ -30,12 +30,12 @@ public class AppendAutocompleteTests (ITestOutputHelper output) Assert.Equal ("f", tf.Text); // Still has focus though - Assert.Same (tf, Application.Current.Focused); + Assert.Same (tf, Application.Running.Focused); // But can tab away Application.RaiseKeyDownEvent ('\t'); - Assert.NotSame (tf, Application.Current.Focused); - Application.Current.Dispose (); + Assert.NotSame (tf, Application.Running.Focused); + Application.Running.Dispose (); } [Fact] @@ -69,7 +69,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output) tf.PositionCursor (); DriverAssert.AssertDriverContentsAre ("fish", output); Assert.Equal ("fi", tf.Text); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Theory] @@ -107,7 +107,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output) tf.PositionCursor (); DriverAssert.AssertDriverContentsAre ("fish", output); Assert.Equal ("f", tf.Text); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -133,7 +133,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output) tf.Draw (); DriverAssert.AssertDriverContentsAre ("f", output); Assert.Equal ("f ", tf.Text); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -157,7 +157,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output) tf.Draw (); DriverAssert.AssertDriverContentsAre ("fx", output); Assert.Equal ("fx", tf.Text); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -195,7 +195,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output) tf.Draw (); DriverAssert.AssertDriverContentsAre ("my FISH", output); Assert.Equal ("my FISH", tf.Text); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -231,12 +231,12 @@ public class AppendAutocompleteTests (ITestOutputHelper output) Assert.Equal ("fish", tf.Text); // Tab should autcomplete but not move focus - Assert.Same (tf, Application.Current.Focused); + Assert.Same (tf, Application.Running.Focused); // Second tab should move focus (nothing to autocomplete) Application.RaiseKeyDownEvent ('\t'); - Assert.NotSame (tf, Application.Current.Focused); - Application.Current.Dispose (); + Assert.NotSame (tf, Application.Running.Focused); + Application.Running.Dispose (); } [Theory] @@ -256,7 +256,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output) tf.PositionCursor (); DriverAssert.AssertDriverContentsAre (expectRender, output); Assert.Equal ("f", tf.Text); - Application.Current.Dispose (); + Application.Running.Dispose (); } private TextField GetTextFieldsInView () diff --git a/Tests/UnitTests/Views/ButtonTests.cs b/Tests/UnitTests/Views/ButtonTests.cs index 83d8cc032..97b375197 100644 --- a/Tests/UnitTests/Views/ButtonTests.cs +++ b/Tests/UnitTests/Views/ButtonTests.cs @@ -209,7 +209,7 @@ public class ButtonTests (ITestOutputHelper output) clicked = false; // Toplevel does not handle Enter, so it should get passed on to button - Assert.False (Application.Current.NewKeyDownEvent (Key.Enter)); + Assert.False (Application.Running.NewKeyDownEvent (Key.Enter)); Assert.True (clicked); clicked = false; diff --git a/Tests/UnitTests/Views/CheckBoxTests.cs b/Tests/UnitTests/Views/CheckBoxTests.cs index 39fe5db91..c7884bc78 100644 --- a/Tests/UnitTests/Views/CheckBoxTests.cs +++ b/Tests/UnitTests/Views/CheckBoxTests.cs @@ -15,11 +15,11 @@ public class CheckBoxTests (ITestOutputHelper output) [Fact] public void Commands_Select () { - Application.Current = new (); + Application.Running = new (); View otherView = new () { CanFocus = true }; var ckb = new CheckBox (); - Application.Current.Add (ckb, otherView); - Application.Current.SetFocus (); + Application.Running.Add (ckb, otherView); + Application.Running.SetFocus (); Assert.True (ckb.HasFocus); var checkedStateChangingCount = 0; @@ -63,7 +63,7 @@ public class CheckBoxTests (ITestOutputHelper output) Assert.Equal (3, selectCount); Assert.Equal (1, acceptCount); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (); } diff --git a/Tests/UnitTests/Views/ColorPickerTests.cs b/Tests/UnitTests/Views/ColorPickerTests.cs index 8e454a289..c90bcb92f 100644 --- a/Tests/UnitTests/Views/ColorPickerTests.cs +++ b/Tests/UnitTests/Views/ColorPickerTests.cs @@ -12,7 +12,7 @@ public class ColorPickerTests var otherView = new View { CanFocus = true }; - Application.Current?.Add (otherView); // thi sets focus to otherView + Application.Running?.Add (otherView); // thi sets focus to otherView Assert.True (otherView.HasFocus); cp.SetFocus (); @@ -772,11 +772,11 @@ public class ColorPickerTests cp.Style.ShowColorName = showName; cp.ApplyStyleChanges (); - Application.Current = new () { Width = 20, Height = 5 }; - Application.Current.Add (cp); + Application.Running = new () { Width = 20, Height = 5 }; + Application.Running.Add (cp); - Application.Current.LayoutSubViews (); - Application.Current.SetFocus (); + Application.Running.LayoutSubViews (); + Application.Running.SetFocus (); return cp; } diff --git a/Tests/UnitTests/Views/ComboBoxTests.cs b/Tests/UnitTests/Views/ComboBoxTests.cs index 260251659..c6b81881d 100644 --- a/Tests/UnitTests/Views/ComboBoxTests.cs +++ b/Tests/UnitTests/Views/ComboBoxTests.cs @@ -1015,7 +1015,7 @@ Three { var cb = new ComboBox (); var top = new Toplevel (); - Application.Current = top; + Application.Running = top; top.Add (cb); top.FocusDeepest (NavigationDirection.Forward, null); @@ -1054,7 +1054,7 @@ Three Assert.Equal (-1, cb.SelectedItem); Assert.Equal ("", cb.Text); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } } diff --git a/Tests/UnitTests/Views/HexViewTests.cs b/Tests/UnitTests/Views/HexViewTests.cs index 63ea65cea..cf10d4b03 100644 --- a/Tests/UnitTests/Views/HexViewTests.cs +++ b/Tests/UnitTests/Views/HexViewTests.cs @@ -32,9 +32,9 @@ public class HexViewTests { var hv = new HexView (LoadStream (null, out _, true)) { Width = 20, Height = 20 }; - Application.Current = new (); - Application.Current.Add (hv); - Application.Current.SetFocus (); + Application.Running = new (); + Application.Running.Add (hv); + Application.Running.SetFocus (); // Needed because HexView relies on LayoutComplete to calc sizes hv.LayoutSubViews (); @@ -69,14 +69,14 @@ public class HexViewTests Assert.Empty (hv.Edits); Assert.Equal (127, hv.Source.Length); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } [Fact] public void ApplyEdits_With_Argument () { - Application.Current = new (); + Application.Running = new (); byte [] buffer = Encoding.Default.GetBytes ("Fest"); var original = new MemoryStream (); @@ -87,8 +87,8 @@ public class HexViewTests original.CopyTo (copy); copy.Flush (); var hv = new HexView (copy) { Width = Dim.Fill (), Height = Dim.Fill () }; - Application.Current.Add (hv); - Application.Current.SetFocus (); + Application.Running.Add (hv); + Application.Running.SetFocus (); // Needed because HexView relies on LayoutComplete to calc sizes hv.LayoutSubViews (); @@ -119,7 +119,7 @@ public class HexViewTests Assert.Equal ("Zest", Encoding.Default.GetString (readBuffer)); Assert.Equal (Encoding.Default.GetString (buffer), Encoding.Default.GetString (readBuffer)); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -143,10 +143,10 @@ public class HexViewTests public void Position_Encoding_Default () { var hv = new HexView (LoadStream (null, out _)) { Width = 100, Height = 100 }; - Application.Current = new (); - Application.Current.Add (hv); + Application.Running = new (); + Application.Running.Add (hv); - Application.Current.LayoutSubViews (); + Application.Running.LayoutSubViews (); Assert.Equal (63, hv.Source!.Length); Assert.Equal (20, hv.BytesPerLine); @@ -171,7 +171,7 @@ public class HexViewTests Assert.Equal (new (3, 3), hv.GetPosition (hv.Address)); Assert.Equal (hv.Source!.Length, hv.Address); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -179,8 +179,8 @@ public class HexViewTests public void Position_Encoding_Unicode () { var hv = new HexView (LoadStream (null, out _, true)) { Width = 100, Height = 100 }; - Application.Current = new (); - Application.Current.Add (hv); + Application.Running = new (); + Application.Running.Add (hv); hv.LayoutSubViews (); @@ -206,7 +206,7 @@ public class HexViewTests Assert.Equal (new (6, 6), hv.GetPosition (hv.Address)); Assert.Equal (hv.Source!.Length, hv.Address); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -258,9 +258,9 @@ public class HexViewTests [Fact] public void KeyBindings_Test_Movement_LeftSide () { - Application.Current = new (); + Application.Running = new (); var hv = new HexView (LoadStream (null, out _)) { Width = 20, Height = 10 }; - Application.Current.Add (hv); + Application.Running.Add (hv); hv.LayoutSubViews (); @@ -306,7 +306,7 @@ public class HexViewTests Assert.True (Application.RaiseKeyDownEvent (Key.CursorUp.WithCtrl)); Assert.Equal (0, hv.Address); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -314,10 +314,10 @@ public class HexViewTests public void PositionChanged_Event () { var hv = new HexView (LoadStream (null, out _)) { Width = 20, Height = 10 }; - Application.Current = new (); - Application.Current.Add (hv); + Application.Running = new (); + Application.Running.Add (hv); - Application.Current.LayoutSubViews (); + Application.Running.LayoutSubViews (); HexViewEventArgs hexViewEventArgs = null!; hv.PositionChanged += (s, e) => hexViewEventArgs = e; @@ -331,7 +331,7 @@ public class HexViewTests Assert.Equal (4, hexViewEventArgs.BytesPerLine); Assert.Equal (new (1, 1), hexViewEventArgs.Position); Assert.Equal (5, hexViewEventArgs.Address); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -339,32 +339,32 @@ public class HexViewTests public void Source_Sets_Address_To_Zero_If_Greater_Than_Source_Length () { var hv = new HexView (LoadStream (null, out _)) { Width = 10, Height = 5 }; - Application.Current = new (); - Application.Current.Add (hv); + Application.Running = new (); + Application.Running.Add (hv); - Application.Current.Layout (); + Application.Running.Layout (); Assert.True (hv.NewKeyDownEvent (Key.End)); Assert.Equal (MEM_STRING_LENGTH, hv.Address); hv.Source = new MemoryStream (); - Application.Current.Layout (); + Application.Running.Layout (); Assert.Equal (0, hv.Address); hv.Source = LoadStream (null, out _); hv.Width = Dim.Fill (); hv.Height = Dim.Fill (); - Application.Current.Layout (); + Application.Running.Layout (); Assert.Equal (0, hv.Address); Assert.True (hv.NewKeyDownEvent (Key.End)); Assert.Equal (MEM_STRING_LENGTH, hv.Address); hv.Source = new MemoryStream (); - Application.Current.Layout (); + Application.Running.Layout (); Assert.Equal (0, hv.Address); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } diff --git a/Tests/UnitTests/Views/LabelTests.cs b/Tests/UnitTests/Views/LabelTests.cs index 7b949c459..8fb0433c3 100644 --- a/Tests/UnitTests/Views/LabelTests.cs +++ b/Tests/UnitTests/Views/LabelTests.cs @@ -1098,7 +1098,7 @@ e Assert.Equal (new (5, 1), label.TextFormatter.ConstrainToSize); Assert.Equal (["Label"], label.TextFormatter.GetLines ()); Assert.Equal (new (0, 0, 10, 4), win.Frame); - Assert.Equal (new (0, 0, 10, 4), Application.Current.Frame); + Assert.Equal (new (0, 0, 10, 4), Application.Running.Frame); var expected = @" ┌────────┐ @@ -1157,7 +1157,7 @@ e Assert.Equal (new (5, 1), label.TextFormatter.ConstrainToSize); Assert.Equal (["Label"], label.TextFormatter.GetLines ()); Assert.Equal (new (0, 0, 10, 4), win.Frame); - Assert.Equal (new (0, 0, 10, 4), Application.Current.Frame); + Assert.Equal (new (0, 0, 10, 4), Application.Running.Frame); var expected = @" ┌────────┐ @@ -1230,10 +1230,10 @@ e CanFocus = true }; - Application.Current = new (); - Application.Current.Add (otherView, label, nextView); + Application.Running = new (); + Application.Running.Add (otherView, label, nextView); - Application.Current.SetFocus (); + Application.Running.SetFocus (); Assert.True (otherView.HasFocus); Assert.True (Application.RaiseKeyDownEvent (label.HotKey)); @@ -1241,7 +1241,7 @@ e Assert.False (label.HasFocus); Assert.True (nextView.HasFocus); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (); } @@ -1251,18 +1251,18 @@ e View otherView = new () { X = 0, Y = 0, Width = 1, Height = 1, Id = "otherView", CanFocus = true }; Label label = new () { X = 0, Y = 1, Text = "_label" }; View nextView = new () { X = Pos.Right (label), Y = Pos.Top (label), Width = 1, Height = 1, Id = "nextView", CanFocus = true }; - Application.Current = new (); - Application.Current.Add (otherView, label, nextView); - Application.Current.Layout (); + Application.Running = new (); + Application.Running.Add (otherView, label, nextView); + Application.Running.Layout (); - Application.Current.SetFocus (); + Application.Running.SetFocus (); // click on label Application.RaiseMouseEvent (new () { ScreenPosition = label.Frame.Location, Flags = MouseFlags.Button1Clicked }); Assert.False (label.HasFocus); Assert.True (nextView.HasFocus); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (); } @@ -1281,8 +1281,8 @@ e CanFocus = true }; - Application.Current = new (); - Application.Current.Add (label, view); + Application.Running = new (); + Application.Running.Add (label, view); view.SetFocus (); Assert.True (label.CanFocus); @@ -1295,7 +1295,7 @@ e Assert.True (label.HasFocus); Assert.False (view.HasFocus); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (); } @@ -1320,14 +1320,14 @@ e CanFocus = true }; - Application.Current = new () + Application.Running = new () { Width = 10, Height = 10 }; - Application.Current.Add (label, otherView); - Application.Current.SetFocus (); - Application.Current.Layout (); + Application.Running.Add (label, otherView); + Application.Running.SetFocus (); + Application.Running.Layout (); Assert.True (label.CanFocus); Assert.True (label.HasFocus); @@ -1347,7 +1347,7 @@ e Assert.False (label.HasFocus); Assert.True (otherView.HasFocus); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (); } diff --git a/Tests/UnitTests/Views/Menuv1/MenuBarv1Tests.cs b/Tests/UnitTests/Views/Menuv1/MenuBarv1Tests.cs index 1241716ca..9a5708076 100644 --- a/Tests/UnitTests/Views/Menuv1/MenuBarv1Tests.cs +++ b/Tests/UnitTests/Views/Menuv1/MenuBarv1Tests.cs @@ -698,7 +698,7 @@ public class MenuBarv1Tests (ITestOutputHelper output) Dialog.DefaultShadow = ShadowStyle.None; Button.DefaultShadow = ShadowStyle.None; - Assert.Equal (new (0, 0, 40, 15), Application.Current!.GetClip ()!.GetBounds ()); + Assert.Equal (new (0, 0, 40, 15), Application.Running!.GetClip ()!.GetBounds ()); DriverAssert.AssertDriverContentsWithFrameAre (@"", output); List items = new () @@ -1100,11 +1100,11 @@ wo Assert.False (copyAction); #if SUPPORT_ALT_TO_ACTIVATE_MENU - Assert.False (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.AltMask))); - Assert.False (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.AltMask))); - Assert.True (Application.Current.ProcessKeyUp (new KeyEventArgs (Key.AltMask))); + Assert.False (Application.Running.ProcessKeyDown (new KeyEventArgs (Key.AltMask))); + Assert.False (Application.Running.ProcessKeyDown (new KeyEventArgs (Key.AltMask))); + Assert.True (Application.Running.ProcessKeyUp (new KeyEventArgs (Key.AltMask))); Assert.True (menu.IsMenuOpen); - Application.Current.Draw (); + Application.Running.Draw (); string expected = @" File Edit @@ -1113,26 +1113,26 @@ wo var pos = DriverAsserts.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new (1, 0, 11, 1), pos); - Assert.True (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.N))); + Assert.True (Application.Running.ProcessKeyDown (new KeyEventArgs (Key.N))); AutoInitShutdownAttribute.RunIteration (); Assert.False (newAction); // not yet, hot keys don't work if the item is not visible - Assert.True (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.F))); + Assert.True (Application.Running.ProcessKeyDown (new KeyEventArgs (Key.F))); AutoInitShutdownAttribute.RunIteration (); - Assert.True (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.N))); + Assert.True (Application.Running.ProcessKeyDown (new KeyEventArgs (Key.N))); AutoInitShutdownAttribute.RunIteration (); Assert.True (newAction); - Application.Current.Draw (); + Application.Running.Draw (); expected = @" File Edit "; - Assert.False (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.AltMask))); - Assert.True (Application.Current.ProcessKeyUp (new KeyEventArgs (Key.AltMask))); - Assert.True (Application.Current.ProcessKeyUp (new KeyEventArgs (Key.AltMask))); + Assert.False (Application.Running.ProcessKeyDown (new KeyEventArgs (Key.AltMask))); + Assert.True (Application.Running.ProcessKeyUp (new KeyEventArgs (Key.AltMask))); + Assert.True (Application.Running.ProcessKeyUp (new KeyEventArgs (Key.AltMask))); Assert.True (menu.IsMenuOpen); - Application.Current.Draw (); + Application.Running.Draw (); expected = @" File Edit @@ -1141,8 +1141,8 @@ wo pos = DriverAsserts.AssertDriverContentsWithFrameAre (expected, output); Assert.Equal (new (1, 0, 11, 1), pos); - Assert.True (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.CursorRight))); - Assert.True (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.C))); + Assert.True (Application.Running.ProcessKeyDown (new KeyEventArgs (Key.CursorRight))); + Assert.True (Application.Running.ProcessKeyDown (new KeyEventArgs (Key.C))); AutoInitShutdownAttribute.RunIteration (); Assert.True (copyAction); #endif @@ -1211,19 +1211,19 @@ wo Assert.True (menu.NewKeyDownEvent (Key.F.WithAlt)); Assert.True (menu.IsMenuOpen); - Application.Current.Draw (); + Application.Running.Draw (); DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output); - Assert.True (Application.Current.SubViews.ElementAt (1).NewKeyDownEvent (Key.N)); + Assert.True (Application.Running.SubViews.ElementAt (1).NewKeyDownEvent (Key.N)); AutoInitShutdownAttribute.RunIteration (); Assert.True (newAction); Assert.True (menu.NewKeyDownEvent (Key.E.WithAlt)); Assert.True (menu.IsMenuOpen); - Application.Current.Draw (); + Application.Running.Draw (); DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output); - Assert.True (Application.Current.SubViews.ElementAt (1).NewKeyDownEvent (Key.C)); + Assert.True (Application.Running.SubViews.ElementAt (1).NewKeyDownEvent (Key.C)); AutoInitShutdownAttribute.RunIteration (); Assert.True (copyAction); top.Dispose (); @@ -1945,7 +1945,7 @@ wo Application.AddTimeout (TimeSpan.Zero, () => { - Toplevel top = Application.Current; + Toplevel top = Application.Running; AutoInitShutdownAttribute.RunIteration (); @@ -2090,7 +2090,7 @@ wo DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output); // Open second - Assert.True (Application.Current.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorRight)); + Assert.True (Application.Running.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorRight)); Assert.True (menu.IsMenuOpen); top.SetClipToScreen (); top.Draw (); @@ -2141,7 +2141,7 @@ wo Assert.True (top.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorRight)); Assert.True (menu.IsMenuOpen); top.SetClipToScreen (); - Application.Current.Draw (); + Application.Running.Draw (); DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output); // Close menu @@ -3075,7 +3075,7 @@ Edit pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output); - Assert.True (Application.Current.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorDown)); + Assert.True (Application.Running.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorDown)); top.Draw (); expected = @" @@ -3090,7 +3090,7 @@ Edit pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output); - Assert.True (Application.Current.SubViews.ElementAt (2).NewKeyDownEvent (Key.CursorLeft)); + Assert.True (Application.Running.SubViews.ElementAt (2).NewKeyDownEvent (Key.CursorLeft)); top.Draw (); expected = @" @@ -3104,7 +3104,7 @@ Edit pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output); - Assert.True (Application.Current.SubViews.ElementAt (1).NewKeyDownEvent (Key.Esc)); + Assert.True (Application.Running.SubViews.ElementAt (1).NewKeyDownEvent (Key.Esc)); top.Draw (); expected = @" @@ -3186,7 +3186,7 @@ Edit menu.NewMouseEvent ( new () { - Position = new (1, 2), Flags = MouseFlags.ReportMousePosition, View = Application.Current.SubViews.ElementAt (1) + Position = new (1, 2), Flags = MouseFlags.ReportMousePosition, View = Application.Running.SubViews.ElementAt (1) } ); top.Draw (); @@ -3208,7 +3208,7 @@ Edit menu.NewMouseEvent ( new () { - Position = new (1, 1), Flags = MouseFlags.ReportMousePosition, View = Application.Current.SubViews.ElementAt (1) + Position = new (1, 1), Flags = MouseFlags.ReportMousePosition, View = Application.Running.SubViews.ElementAt (1) } ) ); @@ -3227,7 +3227,7 @@ Edit Assert.Equal (new (1, 0, 10, 6), pos); menu.NewMouseEvent ( - new () { Position = new (70, 2), Flags = MouseFlags.Button1Clicked, View = Application.Current } + new () { Position = new (70, 2), Flags = MouseFlags.Button1Clicked, View = Application.Running } ); top.Draw (); diff --git a/Tests/UnitTests/Views/ShortcutTests.cs b/Tests/UnitTests/Views/ShortcutTests.cs index 79da2dbc6..fdfbae54e 100644 --- a/Tests/UnitTests/Views/ShortcutTests.cs +++ b/Tests/UnitTests/Views/ShortcutTests.cs @@ -23,7 +23,7 @@ public class ShortcutTests [InlineData (9, 0)] public void MouseClick_Raises_Accepted (int x, int expectedAccepted) { - Application.Current = new (); + Application.Running = new (); var shortcut = new Shortcut { @@ -31,8 +31,8 @@ public class ShortcutTests Text = "0", Title = "C" }; - Application.Current.Add (shortcut); - Application.Current.Layout (); + Application.Running.Add (shortcut); + Application.Running.Layout (); var accepted = 0; shortcut.Accepting += (s, e) => accepted++; @@ -46,7 +46,7 @@ public class ShortcutTests Assert.Equal (expectedAccepted, accepted); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -74,7 +74,7 @@ public class ShortcutTests int expectedShortcutSelected ) { - Application.Current = new (); + Application.Running = new (); var shortcut = new Shortcut { @@ -93,9 +93,9 @@ public class ShortcutTests var shortcutSelectCount = 0; shortcut.Selecting += (s, e) => { shortcutSelectCount++; }; - Application.Current.Add (shortcut); - Application.Current.SetRelativeLayout (new (100, 100)); - Application.Current.LayoutSubViews (); + Application.Running.Add (shortcut); + Application.Running.SetRelativeLayout (new (100, 100)); + Application.Running.LayoutSubViews (); Application.RaiseMouseEvent ( new () @@ -109,7 +109,7 @@ public class ShortcutTests Assert.Equal (expectedCommandViewAccepted, commandViewAcceptCount); Assert.Equal (expectedCommandViewSelected, commandViewSelectCount); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -130,7 +130,7 @@ public class ShortcutTests [InlineData (9, 0, 0)] public void MouseClick_Button_CommandView_Raises_Shortcut_Accepted (int mouseX, int expectedAccept, int expectedButtonAccept) { - Application.Current = new (); + Application.Running = new (); var shortcut = new Shortcut { @@ -147,9 +147,9 @@ public class ShortcutTests }; var buttonAccepted = 0; shortcut.CommandView.Accepting += (s, e) => { buttonAccepted++; }; - Application.Current.Add (shortcut); - Application.Current.SetRelativeLayout (new (100, 100)); - Application.Current.LayoutSubViews (); + Application.Running.Add (shortcut); + Application.Running.SetRelativeLayout (new (100, 100)); + Application.Running.LayoutSubViews (); var accepted = 0; shortcut.Accepting += (s, e) => { accepted++; }; @@ -164,7 +164,7 @@ public class ShortcutTests Assert.Equal (expectedAccept, accepted); Assert.Equal (expectedButtonAccept, buttonAccepted); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -186,7 +186,7 @@ public class ShortcutTests [InlineData (10, 1, 0)] public void MouseClick_CheckBox_CommandView_Raises_Shortcut_Accepted_Selected_Correctly (int mouseX, int expectedAccepted, int expectedCheckboxAccepted) { - Application.Current = new (); + Application.Running = new (); var shortcut = new Shortcut { @@ -212,9 +212,9 @@ public class ShortcutTests checkboxSelected++; }; - Application.Current.Add (shortcut); - Application.Current.SetRelativeLayout (new (100, 100)); - Application.Current.LayoutSubViews (); + Application.Running.Add (shortcut); + Application.Running.SetRelativeLayout (new (100, 100)); + Application.Running.LayoutSubViews (); var selected = 0; shortcut.Selecting += (s, e) => @@ -241,7 +241,7 @@ public class ShortcutTests Assert.Equal (expectedCheckboxAccepted, checkboxAccepted); Assert.Equal (expectedCheckboxAccepted, checkboxSelected); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -260,7 +260,7 @@ public class ShortcutTests [InlineData (false, KeyCode.F1, 0, 0)] public void KeyDown_Raises_Accepted_Selected (bool canFocus, KeyCode key, int expectedAccept, int expectedSelect) { - Application.Current = new (); + Application.Running = new (); var shortcut = new Shortcut { @@ -269,7 +269,7 @@ public class ShortcutTests Title = "_C", CanFocus = canFocus }; - Application.Current.Add (shortcut); + Application.Running.Add (shortcut); shortcut.SetFocus (); Assert.Equal (canFocus, shortcut.HasFocus); @@ -285,7 +285,7 @@ public class ShortcutTests Assert.Equal (expectedAccept, accepted); Assert.Equal (expectedSelect, selected); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -305,7 +305,7 @@ public class ShortcutTests [InlineData (false, KeyCode.F1, 0, 0)] public void KeyDown_CheckBox_Raises_Accepted_Selected (bool canFocus, KeyCode key, int expectedAccept, int expectedSelect) { - Application.Current = new (); + Application.Running = new (); var shortcut = new Shortcut { @@ -317,7 +317,7 @@ public class ShortcutTests }, CanFocus = canFocus }; - Application.Current.Add (shortcut); + Application.Running.Add (shortcut); shortcut.SetFocus (); Assert.Equal (canFocus, shortcut.HasFocus); @@ -337,7 +337,7 @@ public class ShortcutTests Assert.Equal (expectedAccept, accepted); Assert.Equal (expectedSelect, selected); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } [Theory] @@ -349,7 +349,7 @@ public class ShortcutTests [InlineData (KeyCode.F1, 0)] public void KeyDown_App_Scope_Invokes_Accept (KeyCode key, int expectedAccept) { - Application.Current = new () { App = Application.Create () }; + Application.Running = new () { App = Application.Create () }; var shortcut = new Shortcut { @@ -357,9 +357,9 @@ public class ShortcutTests Text = "0", Title = "_C" }; - Application.Current.Add (shortcut); + Application.Running.Add (shortcut); shortcut.BindKeyToApplication = true; - Application.Current.SetFocus (); + Application.Running.SetFocus (); var accepted = 0; shortcut.Accepting += (s, e) => accepted++; @@ -368,7 +368,7 @@ public class ShortcutTests Assert.Equal (expectedAccept, accepted); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -427,7 +427,7 @@ public class ShortcutTests [InlineData (false, KeyCode.F1, 0)] public void KeyDown_App_Scope_Invokes_Action (bool canFocus, KeyCode key, int expectedAction) { - Application.Current = new (); + Application.Running = new (); var shortcut = new Shortcut { @@ -438,13 +438,13 @@ public class ShortcutTests CanFocus = canFocus }; - Application.Current.Add (shortcut); + Application.Running.Add (shortcut); // Shortcut requires Init for App scoped hotkeys to work - Application.Current.BeginInit (); - Application.Current.EndInit (); + Application.Running.BeginInit (); + Application.Running.EndInit (); - Application.Current.SetFocus (); + Application.Running.SetFocus (); var action = 0; shortcut.Action += () => action++; @@ -453,7 +453,7 @@ public class ShortcutTests Assert.Equal (expectedAction, action); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (true); } @@ -461,11 +461,11 @@ public class ShortcutTests [Fact] public void Scheme_SetScheme_Does_Not_Fault_3664 () { - Application.Current = new (); + Application.Running = new (); var shortcut = new Shortcut (); - Application.Current.SetScheme (null); + Application.Running.SetScheme (null); Assert.False (shortcut.HasScheme); Assert.NotNull (shortcut.GetScheme ()); @@ -475,7 +475,7 @@ public class ShortcutTests Assert.False (shortcut.HasScheme); Assert.NotNull (shortcut.GetScheme ()); - Application.Current.Dispose (); + Application.Running.Dispose (); Application.ResetState (); } } diff --git a/Tests/UnitTests/Views/SpinnerViewTests.cs b/Tests/UnitTests/Views/SpinnerViewTests.cs index 35b25e039..c0c9983ac 100644 --- a/Tests/UnitTests/Views/SpinnerViewTests.cs +++ b/Tests/UnitTests/Views/SpinnerViewTests.cs @@ -40,7 +40,7 @@ public class SpinnerViewTests (ITestOutputHelper output) // Dispose clears timeout view.Dispose (); Assert.Empty (Application.TimedEvents.Timeouts); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -62,7 +62,7 @@ public class SpinnerViewTests (ITestOutputHelper output) expected = "/"; DriverAssert.AssertDriverContentsWithFrameAre (expected, output); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -95,7 +95,7 @@ public class SpinnerViewTests (ITestOutputHelper output) //expected = "|"; //DriverAsserts.AssertDriverContentsWithFrameAre (expected, output); - Application.Current.Dispose (); + Application.Running.Dispose (); } private SpinnerView GetSpinnerView () diff --git a/Tests/UnitTests/Views/TableViewTests.cs b/Tests/UnitTests/Views/TableViewTests.cs index 4c162a037..0abccf595 100644 --- a/Tests/UnitTests/Views/TableViewTests.cs +++ b/Tests/UnitTests/Views/TableViewTests.cs @@ -3257,19 +3257,19 @@ A B C // Pressing left should move us to the first column without changing focus Application.RaiseKeyDownEvent (Key.CursorLeft); - Assert.Same (tableView, Application.Current!.MostFocused); + Assert.Same (tableView, Application.Running!.MostFocused); Assert.True (tableView.HasFocus); // Because we are now on the leftmost cell a further left press should move focus Application.RaiseKeyDownEvent (Key.CursorLeft); - Assert.NotSame (tableView, Application.Current.MostFocused); + Assert.NotSame (tableView, Application.Running.MostFocused); Assert.False (tableView.HasFocus); - Assert.Same (tf1, Application.Current.MostFocused); + Assert.Same (tf1, Application.Running.MostFocused); Assert.True (tf1.HasFocus); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -3282,19 +3282,19 @@ A B C // First press should move us up Application.RaiseKeyDownEvent (Key.CursorUp); - Assert.Same (tableView, Application.Current!.MostFocused); + Assert.Same (tableView, Application.Running!.MostFocused); Assert.True (tableView.HasFocus); // Because we are now on the top row a further press should move focus Application.RaiseKeyDownEvent (Key.CursorUp); - Assert.NotSame (tableView, Application.Current.MostFocused); + Assert.NotSame (tableView, Application.Running.MostFocused); Assert.False (tableView.HasFocus); - Assert.Same (tf1, Application.Current.MostFocused); + Assert.Same (tf1, Application.Running.MostFocused); Assert.True (tf1.HasFocus); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -3307,19 +3307,19 @@ A B C // First press should move us to the rightmost column without changing focus Application.RaiseKeyDownEvent (Key.CursorRight); - Assert.Same (tableView, Application.Current!.MostFocused); + Assert.Same (tableView, Application.Running!.MostFocused); Assert.True (tableView.HasFocus); // Because we are now on the rightmost cell, a further right press should move focus Application.RaiseKeyDownEvent (Key.CursorRight); - Assert.NotSame (tableView, Application.Current.MostFocused); + Assert.NotSame (tableView, Application.Running.MostFocused); Assert.False (tableView.HasFocus); - Assert.Same (tf2, Application.Current.MostFocused); + Assert.Same (tf2, Application.Running.MostFocused); Assert.True (tf2.HasFocus); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -3332,19 +3332,19 @@ A B C // First press should move us to the bottommost row without changing focus Application.RaiseKeyDownEvent (Key.CursorDown); - Assert.Same (tableView, Application.Current!.MostFocused); + Assert.Same (tableView, Application.Running!.MostFocused); Assert.True (tableView.HasFocus); // Because we are now on the bottommost cell, a further down press should move focus Application.RaiseKeyDownEvent (Key.CursorDown); - Assert.NotSame (tableView, Application.Current.MostFocused); + Assert.NotSame (tableView, Application.Running.MostFocused); Assert.False (tableView.HasFocus); - Assert.Same (tf2, Application.Current.MostFocused); + Assert.Same (tf2, Application.Running.MostFocused); Assert.True (tf2.HasFocus); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -3357,7 +3357,7 @@ A B C // Pressing shift-left should give us a multi selection Application.RaiseKeyDownEvent (Key.CursorLeft.WithShift); - Assert.Same (tableView, Application.Current!.MostFocused); + Assert.Same (tableView, Application.Running!.MostFocused); Assert.True (tableView.HasFocus); Assert.Equal (2, tableView.GetAllSelectedCells ().Count ()); @@ -3368,19 +3368,19 @@ A B C // Selection 'clears' just to the single cell and we remain focused Assert.Single (tableView.GetAllSelectedCells ()); - Assert.Same (tableView, Application.Current.MostFocused); + Assert.Same (tableView, Application.Running.MostFocused); Assert.True (tableView.HasFocus); // A further left will switch focus Application.RaiseKeyDownEvent (Key.CursorLeft); - Assert.NotSame (tableView, Application.Current.MostFocused); + Assert.NotSame (tableView, Application.Running.MostFocused); Assert.False (tableView.HasFocus); - Assert.Same (tf1, Application.Current.MostFocused); + Assert.Same (tf1, Application.Running.MostFocused); Assert.True (tf1.HasFocus); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Theory] @@ -3407,7 +3407,7 @@ A B C } /// - /// Creates 3 views on with the focus in the + /// Creates 3 views on with the focus in the /// . This is a helper method to setup tests that want to /// explore moving input focus out of a tableview. /// @@ -3421,16 +3421,16 @@ A B C tableView.EndInit (); - Application.Current = new (); + Application.Running = new (); tf1 = new (); tf2 = new (); - Application.Current.Add (tf1); - Application.Current.Add (tableView); - Application.Current.Add (tf2); + Application.Running.Add (tf1); + Application.Running.Add (tableView); + Application.Running.Add (tf2); tableView.SetFocus (); - Assert.Same (tableView, Application.Current.MostFocused); + Assert.Same (tableView, Application.Running.MostFocused); Assert.True (tableView.HasFocus); // Set big table diff --git a/Tests/UnitTests/Views/TextFieldTests.cs b/Tests/UnitTests/Views/TextFieldTests.cs index 922178409..22c8d746e 100644 --- a/Tests/UnitTests/Views/TextFieldTests.cs +++ b/Tests/UnitTests/Views/TextFieldTests.cs @@ -84,7 +84,7 @@ public class TextFieldTests (ITestOutputHelper output) tf.Draw (); DriverAssert.AssertDriverContentsAre (expectedRender, output); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -104,7 +104,7 @@ public class TextFieldTests (ITestOutputHelper output) tf.Draw (); DriverAssert.AssertDriverContentsAre ("Misérables", output); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Theory (Skip = "Broke with ContextMenuv2")] @@ -132,7 +132,7 @@ public class TextFieldTests (ITestOutputHelper output) tf.SetClipToScreen (); tf.Draw (); DriverAssert.AssertDriverContentsAre (content, output); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -157,7 +157,7 @@ public class TextFieldTests (ITestOutputHelper output) tf.SetClipToScreen (); tf.Draw (); DriverAssert.AssertDriverContentsAre ("Enter txt", output); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -187,7 +187,7 @@ public class TextFieldTests (ITestOutputHelper output) // All characters in "Enter text" should have the caption attribute DriverAssert.AssertDriverAttributesAre ("0000000000", output, Application.Driver, captionAttr); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -221,7 +221,7 @@ public class TextFieldTests (ITestOutputHelper output) // F is underlined (index 1), remaining characters use normal caption attribute (index 0) DriverAssert.AssertDriverAttributesAre ("1000", output, Application.Driver, captionAttr, hotkeyAttr); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -255,7 +255,7 @@ public class TextFieldTests (ITestOutputHelper output) // "Enter " (6 chars) + "T" (underlined) + "ext" (3 chars) DriverAssert.AssertDriverAttributesAre ("0000001000", output, Application.Driver, captionAttr, hotkeyAttr); - Application.Current.Dispose (); + Application.Running.Dispose (); } [Fact] @@ -1690,7 +1690,7 @@ Les Miśerables", { base.Before (methodUnderTest); - //Application.Current.Scheme = Colors.Schemes ["Base"]; + //Application.Running.Scheme = Colors.Schemes ["Base"]; _textField = new () { // 1 2 3 diff --git a/Tests/UnitTests/Views/TextViewTests.cs b/Tests/UnitTests/Views/TextViewTests.cs index 5d03983eb..84b5e710a 100644 --- a/Tests/UnitTests/Views/TextViewTests.cs +++ b/Tests/UnitTests/Views/TextViewTests.cs @@ -109,7 +109,7 @@ public class TextViewTests Assert.Equal (leftCol, _textView.LeftColumn); } - Application.Current.Remove (_textView); + Application.Running.Remove (_textView); Application.RequestStop (); } } diff --git a/Tests/UnitTests/Views/ToplevelTests.cs b/Tests/UnitTests/Views/ToplevelTests.cs index 8ac269938..53a853890 100644 --- a/Tests/UnitTests/Views/ToplevelTests.cs +++ b/Tests/UnitTests/Views/ToplevelTests.cs @@ -69,11 +69,11 @@ public class ToplevelTests #endif Application.Begin (top); - Assert.Equal (top, Application.Current); + Assert.Equal (top, Application.Running); - // Application.Current without menu and status bar. + // Application.Running without menu and status bar. View supView = View.GetLocationEnsuringFullVisibility (top, 2, 2, out int nx, out int ny /*, out StatusBar sb*/); - Assert.Equal (Application.Current, supView); + Assert.Equal (Application.Running, supView); Assert.Equal (0, nx); Assert.Equal (0, ny); @@ -82,7 +82,7 @@ public class ToplevelTests top.Add (new MenuBar ()); Assert.NotNull (top.MenuBar); - // Application.Current with a menu and without status bar. + // Application.Running with a menu and without status bar. View.GetLocationEnsuringFullVisibility (top, 2, 2, out nx, out ny /*, out sb*/); Assert.Equal (0, nx); Assert.Equal (1, ny); @@ -92,11 +92,11 @@ public class ToplevelTests //top.Add (new StatusBar ()); //Assert.NotNull (top.StatusBar); - // Application.Current with a menu and status bar. + // Application.Running with a menu and status bar. View.GetLocationEnsuringFullVisibility (top, 2, 2, out nx, out ny /*, out sb*/); Assert.Equal (0, nx); - // The available height is lower than the Application.Current height minus + // The available height is lower than the Application.Running height minus // the menu bar and status bar, then the top can go beyond the bottom // Assert.Equal (2, ny); //Assert.NotNull (sb); @@ -106,11 +106,11 @@ public class ToplevelTests Assert.Null (top.MenuBar); Assert.NotNull (menuBar); - // Application.Current without a menu and with a status bar. + // Application.Running without a menu and with a status bar. View.GetLocationEnsuringFullVisibility (top, 2, 2, out nx, out ny /*, out sb*/); Assert.Equal (0, nx); - // The available height is lower than the Application.Current height minus + // The available height is lower than the Application.Running height minus // the status bar, then the top can go beyond the bottom // Assert.Equal (2, ny); //Assert.NotNull (sb); @@ -127,11 +127,11 @@ public class ToplevelTests // The SuperView is always the same regardless of the caller. supView = View.GetLocationEnsuringFullVisibility (win, 0, 0, out nx, out ny /*, out sb*/); - Assert.Equal (Application.Current, supView); + Assert.Equal (Application.Running, supView); supView = View.GetLocationEnsuringFullVisibility (win, 0, 0, out nx, out ny /*, out sb*/); - Assert.Equal (Application.Current, supView); + Assert.Equal (Application.Running, supView); - // Application.Current without menu and status bar. + // Application.Running without menu and status bar. View.GetLocationEnsuringFullVisibility (win, 0, 0, out nx, out ny /*, out sb*/); Assert.Equal (0, nx); Assert.Equal (0, ny); @@ -141,7 +141,7 @@ public class ToplevelTests top.Add (new MenuBar ()); Assert.NotNull (top.MenuBar); - // Application.Current with a menu and without status bar. + // Application.Running with a menu and without status bar. View.GetLocationEnsuringFullVisibility (win, 2, 2, out nx, out ny /*, out sb*/); Assert.Equal (0, nx); Assert.Equal (1, ny); @@ -152,11 +152,11 @@ public class ToplevelTests //Assert.NotNull (top.StatusBar); - // Application.Current with a menu and status bar. + // Application.Running with a menu and status bar. View.GetLocationEnsuringFullVisibility (win, 30, 20, out nx, out ny /*, out sb*/); Assert.Equal (0, nx); - // The available height is lower than the Application.Current height minus + // The available height is lower than the Application.Running height minus // the menu bar and status bar, then the top can go beyond the bottom //Assert.Equal (20, ny); //Assert.NotNull (sb); @@ -177,7 +177,7 @@ public class ToplevelTests win = new () { Width = 60, Height = 15 }; top.Add (win); - // Application.Current without menu and status bar. + // Application.Running without menu and status bar. View.GetLocationEnsuringFullVisibility (win, 0, 0, out nx, out ny /*, out sb*/); Assert.Equal (0, nx); Assert.Equal (0, ny); @@ -187,7 +187,7 @@ public class ToplevelTests top.Add (new MenuBar ()); Assert.NotNull (top.MenuBar); - // Application.Current with a menu and without status bar. + // Application.Running with a menu and without status bar. View.GetLocationEnsuringFullVisibility (win, 2, 2, out nx, out ny /*, out sb*/); Assert.Equal (2, nx); Assert.Equal (2, ny); @@ -198,7 +198,7 @@ public class ToplevelTests //Assert.NotNull (top.StatusBar); - // Application.Current with a menu and status bar. + // Application.Running with a menu and status bar. View.GetLocationEnsuringFullVisibility (win, 30, 20, out nx, out ny /*, out sb*/); Assert.Equal (20, nx); // 20+60=80 @@ -307,7 +307,7 @@ public class ToplevelTests } else if (iterations == 1) { - Assert.Equal (new (2, 2), Application.Current!.Frame.Location); + Assert.Equal (new (2, 2), Application.Running!.Frame.Location); } else if (iterations == 2) { @@ -316,12 +316,12 @@ public class ToplevelTests // Grab the mouse Application.RaiseMouseEvent (new () { ScreenPosition = new (3, 2), Flags = MouseFlags.Button1Pressed }); - Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView); - Assert.Equal (new (2, 2, 10, 3), Application.Current.Frame); + Assert.Equal (Application.Running!.Border, Application.Mouse.MouseGrabView); + Assert.Equal (new (2, 2, 10, 3), Application.Running.Frame); } else if (iterations == 3) { - Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView); + Assert.Equal (Application.Running!.Border, Application.Mouse.MouseGrabView); // Drag to left Application.RaiseMouseEvent ( @@ -333,38 +333,38 @@ public class ToplevelTests }); AutoInitShutdownAttribute.RunIteration (); - Assert.Equal (Application.Current.Border, Application.Mouse.MouseGrabView); - Assert.Equal (new (1, 2, 10, 3), Application.Current.Frame); + Assert.Equal (Application.Running.Border, Application.Mouse.MouseGrabView); + Assert.Equal (new (1, 2, 10, 3), Application.Running.Frame); } else if (iterations == 4) { - Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView); - Assert.Equal (new (1, 2), Application.Current.Frame.Location); + Assert.Equal (Application.Running!.Border, Application.Mouse.MouseGrabView); + Assert.Equal (new (1, 2), Application.Running.Frame.Location); - Assert.Equal (Application.Current.Border, Application.Mouse.MouseGrabView); + Assert.Equal (Application.Running.Border, Application.Mouse.MouseGrabView); } else if (iterations == 5) { - Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView); + Assert.Equal (Application.Running!.Border, Application.Mouse.MouseGrabView); // Drag up Application.RaiseMouseEvent (new () { ScreenPosition = new (2, 1), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition }); AutoInitShutdownAttribute.RunIteration (); - Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView); - Assert.Equal (new (1, 1, 10, 3), Application.Current.Frame); + Assert.Equal (Application.Running!.Border, Application.Mouse.MouseGrabView); + Assert.Equal (new (1, 1, 10, 3), Application.Running.Frame); } else if (iterations == 6) { - Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView); - Assert.Equal (new (1, 1), Application.Current.Frame.Location); + Assert.Equal (Application.Running!.Border, Application.Mouse.MouseGrabView); + Assert.Equal (new (1, 1), Application.Running.Frame.Location); - Assert.Equal (Application.Current.Border, Application.Mouse.MouseGrabView); - Assert.Equal (new (1, 1, 10, 3), Application.Current.Frame); + Assert.Equal (Application.Running.Border, Application.Mouse.MouseGrabView); + Assert.Equal (new (1, 1, 10, 3), Application.Running.Frame); } else if (iterations == 7) { - Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView); + Assert.Equal (Application.Running!.Border, Application.Mouse.MouseGrabView); // Ungrab the mouse Application.RaiseMouseEvent (new () { ScreenPosition = new (2, 1), Flags = MouseFlags.Button1Released }); diff --git a/Tests/UnitTestsParallelizable/Application/ApplicationPopoverTests.cs b/Tests/UnitTestsParallelizable/Application/ApplicationPopoverTests.cs index 3ea1d796e..02ab72866 100644 --- a/Tests/UnitTestsParallelizable/Application/ApplicationPopoverTests.cs +++ b/Tests/UnitTestsParallelizable/Application/ApplicationPopoverTests.cs @@ -191,6 +191,6 @@ public class ApplicationPopoverTests } /// - public Toplevel? Current { get; set; } + public Toplevel? Toplevel { get; set; } } } diff --git a/Tests/UnitTestsParallelizable/Application/PopoverBaseImplTests.cs b/Tests/UnitTestsParallelizable/Application/PopoverBaseImplTests.cs index 7d2d27d50..a8095d908 100644 --- a/Tests/UnitTestsParallelizable/Application/PopoverBaseImplTests.cs +++ b/Tests/UnitTestsParallelizable/Application/PopoverBaseImplTests.cs @@ -27,8 +27,8 @@ public class PopoverBaseImplTests { var popover = new TestPopover (); var top = new Toplevel (); - popover.Current = top; - Assert.Same (top, popover.Current); + popover.Toplevel = top; + Assert.Same (top, popover.Toplevel); } [Fact] diff --git a/Tests/UnitTestsParallelizable/TestSetup.cs b/Tests/UnitTestsParallelizable/TestSetup.cs index 178a0d4de..43a2646b8 100644 --- a/Tests/UnitTestsParallelizable/TestSetup.cs +++ b/Tests/UnitTestsParallelizable/TestSetup.cs @@ -39,7 +39,7 @@ public class GlobalTestSetup : IDisposable // Check that all Application fields and properties are set to their default values // Public Properties - Assert.Null (Application.Current); + Assert.Null (Application.Running); Assert.Null (Application.Mouse.MouseGrabView); // Don't check Application.ForceDriver