Rename IApplication.Current to TopRunnable

Co-authored-by: tig <585482+tig@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-20 19:34:48 +00:00
parent 16b42e86fd
commit 4b975fd5b7
90 changed files with 916 additions and 820 deletions

View File

@@ -16,9 +16,9 @@ public class GuiTestContextKeyEventTests (ITestOutputHelper outputHelper)
public void QuitKey_ViaApplication_Stops (TestDriver d)
{
using GuiTestContext context = With.A<Window> (40, 10, d);
Assert.True (context.App?.Current!.Running);
Assert.True (context.App?.TopRunnable!.Running);
Toplevel? top = context.App?.Current;
Toplevel? top = context.App?.TopRunnable;
context.Then ((_) => context!.App?.Keyboard.RaiseKeyDownEvent (Application.QuitKey));
Assert.False (top!.Running);
}
@@ -28,9 +28,9 @@ public class GuiTestContextKeyEventTests (ITestOutputHelper outputHelper)
public void QuitKey_ViaEnqueueKey_Stops (TestDriver d)
{
using GuiTestContext context = With.A<Window> (40, 10, d, _out);
Assert.True (context.App?.Current!.Running);
Assert.True (context.App?.TopRunnable!.Running);
Toplevel? top = context.App?.Current;
Toplevel? top = context.App?.TopRunnable;
context.EnqueueKeyEvent (Application.QuitKey);
Assert.False (top!.Running);

View File

@@ -43,7 +43,7 @@ public class GuiTestContextTests (ITestOutputHelper outputHelper)
public void With_New_A_Runs (TestDriver d)
{
using GuiTestContext context = With.A<Window> (40, 10, d, _out);
Assert.True (context.App!.Current!.Running);
Assert.True (context.App!.TopRunnable!.Running);
Assert.NotEqual (Rectangle.Empty, context.App!.Screen);
}
@@ -54,9 +54,9 @@ public class GuiTestContextTests (ITestOutputHelper outputHelper)
using GuiTestContext context = With.A<Window> (10, 3, d, _out)
.Then ((app) =>
{
app.Current!.BorderStyle = LineStyle.None;
app.Current!.Border!.Thickness = Thickness.Empty;
app.Current.Text = "hello";
app.TopRunnable!.BorderStyle = LineStyle.None;
app.TopRunnable!.Border!.Thickness = Thickness.Empty;
app.TopRunnable.Text = "hello";
})
.ScreenShot ("ScreenShot", _out)
.AnsiScreenShot ("AnsiScreenShot", _out)

View File

@@ -143,7 +143,7 @@ public class MenuBarv2Tests
.Then ((app) =>
{
menuBar = new MenuBarv2 ();
top = app.Current!;
top = app.TopRunnable!;
top.Add (
new View ()
@@ -153,7 +153,7 @@ public class MenuBarv2Tests
});
menuBar.EnableForDesign (ref top);
app.Current!.Add (menuBar);
app.TopRunnable!.Add (menuBar);
})
.WaitIteration ()
.AssertIsNotType<MenuItemv2> (top?.App?.Navigation!.GetFocused ())
@@ -178,7 +178,7 @@ public class MenuBarv2Tests
{
app = a;
menuBar = new MenuBarv2 ();
Toplevel top = app.Current!;
Toplevel top = app.TopRunnable!;
top.Add (
new View ()
@@ -188,7 +188,7 @@ public class MenuBarv2Tests
});
menuBar.EnableForDesign (ref top);
app.Current!.Add (menuBar);
app.TopRunnable!.Add (menuBar);
})
.WaitIteration ()
.AssertIsNotType<MenuItemv2> (app?.Navigation!.GetFocused ())
@@ -266,10 +266,10 @@ public class MenuBarv2Tests
.Then ((app) =>
{
var menuBar = new MenuBarv2 ();
app.Current!.Add (menuBar);
app.TopRunnable!.Add (menuBar);
// Call EnableForDesign
Toplevel top = app.Current!;
Toplevel top = app.TopRunnable!;
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.TopRunnable!;
menuBar.EnableForDesign (ref top);
app.Current!.Add (menuBar);
app.TopRunnable!.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.TopRunnable!;
top.Add (
new View ()
@@ -352,7 +352,7 @@ public class MenuBarv2Tests
});
menuBar.EnableForDesign (ref top);
app.Current!.Add (menuBar);
app.TopRunnable!.Add (menuBar);
})
.AssertIsNotType<MenuItemv2> (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.TopRunnable;
menuBar.EnableForDesign (ref toplevel!);
app.Current!.Add (menuBar);
app.TopRunnable!.Add (menuBar);
})
.WaitIteration ()
.AssertIsNotType<MenuItemv2> (app?.Navigation!.GetFocused ())
@@ -417,7 +417,7 @@ public class MenuBarv2Tests
{
app = a;
menuBar = new MenuBarv2 ();
Toplevel top = app.Current!;
Toplevel top = app.TopRunnable!;
top.Add (
new View ()
@@ -427,18 +427,18 @@ public class MenuBarv2Tests
});
menuBar.EnableForDesign (ref top);
app.Current!.Add (menuBar);
app.TopRunnable!.Add (menuBar);
})
.WaitIteration ()
.AssertIsNotType<MenuItemv2> (app!.Navigation!.GetFocused ())
.ScreenShot ("MenuBar initial state", _out)
.EnqueueKeyEvent (MenuBarv2.DefaultKey)
.AssertEqual ("_New file", app.Navigation!.GetFocused ()!.Title)
.AssertTrue (app?.Current!.Running)
.AssertTrue (app?.TopRunnable!.Running)
.ScreenShot ($"After {MenuBarv2.DefaultKey}", _out)
.EnqueueKeyEvent (Application.QuitKey)
.AssertFalse (app?.Popover?.GetActivePopover () is PopoverMenu)
.AssertTrue (app!.Current!.Running);
.AssertTrue (app!.TopRunnable!.Running);
}
[Theory]
@@ -453,7 +453,7 @@ public class MenuBarv2Tests
{
app = a;
menuBar = new MenuBarv2 ();
Toplevel top = app.Current!;
Toplevel top = app.TopRunnable!;
top.Add (
new View ()
@@ -470,7 +470,7 @@ public class MenuBarv2Tests
item.Key = Key.Empty;
}
app.Current!.Add (menuBar);
app.TopRunnable!.Add (menuBar);
})
.WaitIteration ()
.AssertIsNotType<MenuItemv2> (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!.Running);
.AssertTrue (app?.TopRunnable!.Running);
}
[Theory]
@@ -506,9 +506,9 @@ public class MenuBarv2Tests
.Then ((a) =>
{
var menuBar = new MenuBarv2 ();
Toplevel top = a.Current!;
Toplevel top = a.TopRunnable!;
menuBar.EnableForDesign (ref top);
a.Current!.Add (menuBar);
a.TopRunnable!.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.TopRunnable!;
menuBar.EnableForDesign (ref top);
a.Current!.Add (menuBar);
a.TopRunnable!.Add (menuBar);
})
.Add (testView)
.WaitIteration ()

View File

@@ -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?.TopRunnable!;
app?.TopRunnable!.Add (w1, w2, w3);
})
.AssertTrue (v5.HasFocus)
.EnqueueKeyEvent (Key.F6)

View File

@@ -26,10 +26,10 @@ public class PopoverMenuTests
.Then ((app) =>
{
PopoverMenu popoverMenu = new ();
app.Current!.Add (popoverMenu);
app.TopRunnable!.Add (popoverMenu);
// Call EnableForDesign
Toplevel top = app.Current;
Toplevel top = app.TopRunnable;
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.TopRunnable!;
popoverMenu.EnableForDesign (ref top);
var view = new View
@@ -76,7 +76,7 @@ public class PopoverMenuTests
Id = "focusableView",
Text = "View"
};
app.Current!.Add (view);
app.TopRunnable!.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.TopRunnable!;
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.TopRunnable!.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<PopoverMenu> ().FirstOrDefault ()!.Visible)
.AssertNull (app?.Popover!.GetActivePopover ())
.AssertTrue (app?.Current!.Running);
.AssertTrue (app?.TopRunnable!.Running);
}
[Theory]
@@ -157,7 +157,7 @@ public class PopoverMenuTests
};
// Call EnableForDesign
Toplevel top = app.Current!;
Toplevel top = app.TopRunnable!;
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.TopRunnable!.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.TopRunnable!;
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.TopRunnable!.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!.Running)
.AssertTrue (app?.TopRunnable!.Running)
.EnqueueKeyEvent (Application.QuitKey)
.ScreenShot ($"After {Application.QuitKey}", _out)
.AssertFalse (app?.Popover?.GetActivePopover () is PopoverMenu)
.AssertTrue (app?.Current!.Running);
.AssertTrue (app?.TopRunnable!.Running);
}
[Theory]
@@ -267,7 +267,7 @@ public class PopoverMenuTests
{
App = app
};
Toplevel top = app.Current!;
Toplevel top = app.TopRunnable!;
popoverMenu.EnableForDesign (ref top);
app?.Popover!.Register (popoverMenu);
})
@@ -307,7 +307,7 @@ public class PopoverMenuTests
{
App = app
};
Toplevel top = app.Current!;
Toplevel top = app.TopRunnable!;
popoverMenu.EnableForDesign (ref top);
app?.Popover!.Register (popoverMenu);
})
@@ -346,7 +346,7 @@ public class PopoverMenuTests
{
App = app
};
Toplevel top = app.Current!;
Toplevel top = app.TopRunnable!;
popoverMenu.EnableForDesign (ref top);
app?.Popover!.Register (popoverMenu);
})