mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Rename IApplication.Current to TopRunnable
Co-authored-by: tig <585482+tig@users.noreply.github.com>
This commit is contained in:
@@ -82,7 +82,7 @@ public class ApplicationNavigationTests (ITestOutputHelper output)
|
||||
{
|
||||
IApplication app = Application.Create ();
|
||||
|
||||
app.Current = new ()
|
||||
app.TopRunnable = 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.TopRunnable?.Add (subView1, subView2);
|
||||
Assert.False (app.TopRunnable?.HasFocus);
|
||||
|
||||
app.Current?.SetFocus ();
|
||||
app.TopRunnable?.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.TopRunnable = 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!.TopRunnable.Add (subView1);
|
||||
Assert.False (app.TopRunnable.HasFocus);
|
||||
|
||||
app.Current.SetFocus ();
|
||||
app.TopRunnable.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.TopRunnable.HasFocus);
|
||||
Assert.Equal (app.TopRunnable, app.Navigation.GetFocused ());
|
||||
|
||||
app.Current.HasFocus = false;
|
||||
Assert.False (app.Current.HasFocus);
|
||||
app.TopRunnable.HasFocus = false;
|
||||
Assert.False (app.TopRunnable.HasFocus);
|
||||
Assert.Null (app.Navigation.GetFocused ());
|
||||
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ public class ApplicationImplBeginEndTests
|
||||
try
|
||||
{
|
||||
toplevel = new ();
|
||||
Assert.Null (app.Current);
|
||||
Assert.Null (app.TopRunnable);
|
||||
|
||||
app.Begin (toplevel);
|
||||
|
||||
Assert.NotNull (app.Current);
|
||||
Assert.Same (toplevel, app.Current);
|
||||
Assert.NotNull (app.TopRunnable);
|
||||
Assert.Same (toplevel, app.TopRunnable);
|
||||
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.TopRunnable);
|
||||
|
||||
app.Begin (toplevel2);
|
||||
Assert.Equal (2, app.SessionStack.Count);
|
||||
Assert.Same (toplevel2, app.Current);
|
||||
Assert.Same (toplevel2, app.TopRunnable);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -163,7 +163,7 @@ public class ApplicationImplBeginEndTests
|
||||
app.End (token2);
|
||||
|
||||
Assert.Single (app.SessionStack);
|
||||
Assert.Same (toplevel1, app.Current);
|
||||
Assert.Same (toplevel1, app.TopRunnable);
|
||||
|
||||
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.TopRunnable);
|
||||
|
||||
app.End (token3);
|
||||
Assert.Same (toplevel2, app.Current);
|
||||
Assert.Same (toplevel2, app.TopRunnable);
|
||||
|
||||
app.End (token2);
|
||||
Assert.Same (toplevel1, app.Current);
|
||||
Assert.Same (toplevel1, app.TopRunnable);
|
||||
|
||||
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.TopRunnable);
|
||||
|
||||
// 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.TopRunnable);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -358,7 +358,7 @@ public class ApplicationImplBeginEndTests
|
||||
app.Begin (toplevel2);
|
||||
|
||||
Assert.Equal (2, app.SessionStack.Count);
|
||||
Assert.NotNull (app.Current);
|
||||
Assert.NotNull (app.TopRunnable);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -371,7 +371,7 @@ public class ApplicationImplBeginEndTests
|
||||
|
||||
// Verify cleanup happened
|
||||
Assert.Empty (app.SessionStack);
|
||||
Assert.Null (app.Current);
|
||||
Assert.Null (app.TopRunnable);
|
||||
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.TopRunnable);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ApplicationImplTests
|
||||
TimeSpan.FromMilliseconds (150),
|
||||
() =>
|
||||
{
|
||||
if (app.Current is { })
|
||||
if (app.TopRunnable is { })
|
||||
{
|
||||
app.RequestStop ();
|
||||
|
||||
@@ -91,7 +91,7 @@ public class ApplicationImplTests
|
||||
return false;
|
||||
}
|
||||
);
|
||||
Assert.Null (app?.Current);
|
||||
Assert.Null (app?.TopRunnable);
|
||||
|
||||
// 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?.TopRunnable);
|
||||
app.TopRunnable?.Dispose ();
|
||||
app.Shutdown ();
|
||||
Assert.Null (app.Current);
|
||||
Assert.Null (app.TopRunnable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -124,7 +124,7 @@ public class ApplicationImplTests
|
||||
{
|
||||
Assert.True (top!.Running);
|
||||
|
||||
if (app.Current != null)
|
||||
if (app.TopRunnable != null)
|
||||
{
|
||||
app.RequestStop ();
|
||||
|
||||
@@ -146,8 +146,8 @@ public class ApplicationImplTests
|
||||
Assert.False (top!.Running);
|
||||
|
||||
// BUGBUG: Shutdown sets Top to null, not End.
|
||||
//Assert.Null (Application.Current);
|
||||
app.Current?.Dispose ();
|
||||
//Assert.Null (Application.TopRunnable);
|
||||
app.TopRunnable?.Dispose ();
|
||||
app.Shutdown ();
|
||||
}
|
||||
|
||||
@@ -156,13 +156,13 @@ public class ApplicationImplTests
|
||||
{
|
||||
IApplication app = NewMockedApplicationImpl ()!;
|
||||
|
||||
Assert.Null (app.Current);
|
||||
Assert.Null (app.TopRunnable);
|
||||
Assert.Null (app.Driver);
|
||||
|
||||
app.Init ("fake");
|
||||
|
||||
Toplevel top = new Window ();
|
||||
app.Current = top;
|
||||
app.TopRunnable = top;
|
||||
|
||||
var closedCount = 0;
|
||||
|
||||
@@ -193,7 +193,7 @@ public class ApplicationImplTests
|
||||
Assert.Equal (1, closedCount);
|
||||
Assert.Equal (1, unloadedCount);
|
||||
|
||||
app.Current?.Dispose ();
|
||||
app.TopRunnable?.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.TopRunnable);
|
||||
Assert.Null (app.Driver);
|
||||
|
||||
app.Init ("fake");
|
||||
@@ -228,7 +228,7 @@ public class ApplicationImplTests
|
||||
{
|
||||
Assert.True (top!.Running);
|
||||
|
||||
if (app.Current != null)
|
||||
if (app.TopRunnable != 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.TopRunnable?.Dispose ();
|
||||
app.Shutdown ();
|
||||
Assert.Equal (1, closedCount);
|
||||
Assert.Equal (1, unloadedCount);
|
||||
@@ -275,7 +275,7 @@ public class ApplicationImplTests
|
||||
{
|
||||
Assert.True (top!.Running);
|
||||
|
||||
if (app.Current != null)
|
||||
if (app.TopRunnable != null)
|
||||
{
|
||||
app.Keyboard.RaiseKeyDownEvent (app.Keyboard.QuitKey);
|
||||
}
|
||||
@@ -294,10 +294,10 @@ public class ApplicationImplTests
|
||||
|
||||
Assert.False (top!.Running);
|
||||
|
||||
Assert.NotNull (app.Current);
|
||||
Assert.NotNull (app.TopRunnable);
|
||||
top.Dispose ();
|
||||
app.Shutdown ();
|
||||
Assert.Null (app.Current);
|
||||
Assert.Null (app.TopRunnable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -308,16 +308,16 @@ public class ApplicationImplTests
|
||||
app.Init ("fake");
|
||||
|
||||
app.AddTimeout (TimeSpan.Zero, () => IdleExit (app));
|
||||
Assert.Null (app.Current);
|
||||
Assert.Null (app.TopRunnable);
|
||||
|
||||
// Blocks until the timeout call is hit
|
||||
|
||||
app.Run<Window> ();
|
||||
|
||||
Assert.NotNull (app.Current);
|
||||
app.Current?.Dispose ();
|
||||
Assert.NotNull (app.TopRunnable);
|
||||
app.TopRunnable?.Dispose ();
|
||||
app.Shutdown ();
|
||||
Assert.Null (app.Current);
|
||||
Assert.Null (app.TopRunnable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -357,7 +357,7 @@ public class ApplicationImplTests
|
||||
|
||||
app.Run (t);
|
||||
|
||||
app.Current?.Dispose ();
|
||||
app.TopRunnable?.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.TopRunnable != null)
|
||||
{
|
||||
app.RequestStop ();
|
||||
|
||||
@@ -408,7 +408,7 @@ public class ApplicationImplTests
|
||||
() =>
|
||||
{
|
||||
// Run asynchronous logic inside Task.Run
|
||||
if (app.Current != null)
|
||||
if (app.TopRunnable != 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.TopRunnable);
|
||||
|
||||
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.TopRunnable);
|
||||
app.TopRunnable?.Dispose ();
|
||||
app.Shutdown ();
|
||||
Assert.Null (app.Current);
|
||||
Assert.Null (app.TopRunnable);
|
||||
|
||||
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.TopRunnable);
|
||||
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.TopRunnable); // 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.TopRunnable);
|
||||
Assert.Empty (v2.SessionStack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,14 +197,14 @@ public class ApplicationPopoverTests
|
||||
// Arrange
|
||||
|
||||
Application.Init ("fake");
|
||||
Application.Current = new ();
|
||||
Application.TopRunnable = new ();
|
||||
PopoverTestClass? popover = new ();
|
||||
|
||||
// Act
|
||||
Application.Popover?.Register (popover);
|
||||
|
||||
// Assert
|
||||
Assert.Equal (Application.Current, popover.Current);
|
||||
Assert.Equal (Application.TopRunnable, popover.Current);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -219,7 +219,7 @@ public class ApplicationPopoverTests
|
||||
{
|
||||
// Arrange
|
||||
Application.Init ("fake");
|
||||
Application.Current = new() { Id = "initialTop" };
|
||||
Application.TopRunnable = 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.TopRunnable = 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.TopRunnable = new ()
|
||||
{
|
||||
Frame = new (0, 0, 10, 10),
|
||||
Id = "top"
|
||||
@@ -282,7 +282,7 @@ public class ApplicationPopoverTests
|
||||
Height = 2
|
||||
};
|
||||
|
||||
Application.Current.Add (view);
|
||||
Application.TopRunnable.Add (view);
|
||||
|
||||
popover = new ()
|
||||
{
|
||||
@@ -316,7 +316,7 @@ public class ApplicationPopoverTests
|
||||
finally
|
||||
{
|
||||
popover?.Dispose ();
|
||||
Application.Current?.Dispose ();
|
||||
Application.TopRunnable?.Dispose ();
|
||||
Application.ResetState (true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,35 +46,35 @@ public class ApplicationScreenTests
|
||||
Assert.Equal (0, clearedContentsRaised);
|
||||
|
||||
// Act
|
||||
Application.Current!.SetNeedsLayout ();
|
||||
Application.TopRunnable!.SetNeedsLayout ();
|
||||
Application.LayoutAndDraw ();
|
||||
|
||||
// Assert
|
||||
Assert.Equal (0, clearedContentsRaised);
|
||||
|
||||
// Act
|
||||
Application.Current.X = 1;
|
||||
Application.TopRunnable.X = 1;
|
||||
Application.LayoutAndDraw ();
|
||||
|
||||
// Assert
|
||||
Assert.Equal (1, clearedContentsRaised);
|
||||
|
||||
// Act
|
||||
Application.Current.Width = 10;
|
||||
Application.TopRunnable.Width = 10;
|
||||
Application.LayoutAndDraw ();
|
||||
|
||||
// Assert
|
||||
Assert.Equal (2, clearedContentsRaised);
|
||||
|
||||
// Act
|
||||
Application.Current.Y = 1;
|
||||
Application.TopRunnable.Y = 1;
|
||||
Application.LayoutAndDraw ();
|
||||
|
||||
// Assert
|
||||
Assert.Equal (3, clearedContentsRaised);
|
||||
|
||||
// Act
|
||||
Application.Current.Height = 10;
|
||||
Application.TopRunnable.Height = 10;
|
||||
Application.LayoutAndDraw ();
|
||||
|
||||
// Assert
|
||||
|
||||
@@ -70,13 +70,13 @@ public class ApplicationTests
|
||||
[SetupFakeApplication]
|
||||
public void Begin_Sets_Application_Top_To_Console_Size ()
|
||||
{
|
||||
Assert.Null (Application.Current);
|
||||
Assert.Null (Application.TopRunnable);
|
||||
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.TopRunnable!.Frame);
|
||||
Application.Driver!.SetScreenSize (5, 5);
|
||||
Assert.Equal (new (0, 0, 5, 5), Application.Current!.Frame);
|
||||
Assert.Equal (new (0, 0, 5, 5), Application.TopRunnable!.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.TopRunnable);
|
||||
|
||||
SessionToken rs = Application.Begin (new ());
|
||||
Application.Current!.Title = "End_And_Shutdown_Should_Not_Dispose_ApplicationTop";
|
||||
Assert.Equal (rs.Toplevel, Application.Current);
|
||||
Application.TopRunnable!.Title = "End_And_Shutdown_Should_Not_Dispose_ApplicationTop";
|
||||
Assert.Equal (rs.Toplevel, Application.TopRunnable);
|
||||
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.TopRunnable!.WasDisposed); // Is true because the rs.Toplevel is the same as Application.TopRunnable
|
||||
#endif
|
||||
|
||||
Assert.Null (rs.Toplevel);
|
||||
|
||||
Toplevel top = Application.Current;
|
||||
Toplevel top = Application.TopRunnable;
|
||||
|
||||
#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.TopRunnable);
|
||||
|
||||
Application.SessionBegun -= newSessionTokenFn;
|
||||
Application.End (sessionToken);
|
||||
|
||||
Assert.NotNull (Application.Current);
|
||||
Assert.NotNull (Application.TopRunnable);
|
||||
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.TopRunnable);
|
||||
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.TopRunnable);
|
||||
|
||||
Application.SessionBegun -= newSessionTokenFn;
|
||||
Application.End (sessionToken);
|
||||
|
||||
Assert.NotNull (Application.Current);
|
||||
Assert.NotNull (Application.TopRunnable);
|
||||
Assert.NotNull (Application.Driver);
|
||||
|
||||
topLevel.Dispose ();
|
||||
Application.Shutdown ();
|
||||
|
||||
Assert.Null (Application.Current);
|
||||
Assert.Null (Application.TopRunnable);
|
||||
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.TopRunnable);
|
||||
SessionToken rs = Application.Begin (new ());
|
||||
Assert.Equal (Application.Current, rs.Toplevel);
|
||||
Assert.Equal (Application.TopRunnable, rs.Toplevel);
|
||||
Assert.Null (Application.Mouse.MouseGrabView); // public
|
||||
Application.Current!.Dispose ();
|
||||
Application.TopRunnable!.Dispose ();
|
||||
}
|
||||
|
||||
// Invoke Tests
|
||||
@@ -511,9 +511,9 @@ public class ApplicationTests
|
||||
// Run<Toplevel> 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<Window> ();
|
||||
Assert.True (Application.Current is Window);
|
||||
Assert.True (Application.TopRunnable is Window);
|
||||
|
||||
Application.Current!.Dispose ();
|
||||
Application.TopRunnable!.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -524,15 +524,15 @@ public class ApplicationTests
|
||||
// Run<Toplevel> 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<Window> (null, "fake");
|
||||
Assert.True (Application.Current is Window);
|
||||
Assert.True (Application.TopRunnable is Window);
|
||||
|
||||
Application.Current!.Dispose ();
|
||||
Application.TopRunnable!.Dispose ();
|
||||
|
||||
// Run<Toplevel> when already initialized or not with a Driver will not throw (because Dialog is derived from Toplevel)
|
||||
Application.Run<Dialog> (null, "fake");
|
||||
Assert.True (Application.Current is Dialog);
|
||||
Assert.True (Application.TopRunnable is Dialog);
|
||||
|
||||
Application.Current!.Dispose ();
|
||||
Application.TopRunnable!.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.TopRunnable
|
||||
// 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.TopRunnable!.Dispose ();
|
||||
|
||||
return;
|
||||
|
||||
void OnApplicationOnIteration (object s, IterationEventArgs a)
|
||||
{
|
||||
Assert.NotEqual (initTop, Application.Current);
|
||||
Assert.NotEqual (initTop, Application.TopRunnable);
|
||||
#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<TestTopLevel>. This is ok.
|
||||
Application.Run<Toplevel> ();
|
||||
|
||||
Application.Current!.Dispose ();
|
||||
Application.TopRunnable!.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -589,7 +589,7 @@ public class ApplicationTests
|
||||
// Init has been called, selecting FakeDriver; we're passing no driver to Run<TestTopLevel>. Should be fine.
|
||||
Application.Run<Toplevel> ();
|
||||
|
||||
Application.Current!.Dispose ();
|
||||
Application.TopRunnable!.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -620,7 +620,7 @@ public class ApplicationTests
|
||||
// Init has NOT been called and we're passing a valid driver to Run<TestTopLevel>. This is ok.
|
||||
Application.Run<Toplevel> (null, "fake");
|
||||
|
||||
Application.Current!.Dispose ();
|
||||
Application.TopRunnable!.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.TopRunnable);
|
||||
Assert.Equal (w, Application.TopRunnable);
|
||||
Assert.NotEqual (top, Application.TopRunnable);
|
||||
|
||||
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.TopRunnable);
|
||||
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.TopRunnable);
|
||||
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.TopRunnable);
|
||||
|
||||
Application.Shutdown ();
|
||||
Assert.Null (Application.Current);
|
||||
Assert.Null (Application.TopRunnable);
|
||||
|
||||
return;
|
||||
|
||||
void OnApplicationOnIteration (object s, IterationEventArgs e) { Assert.NotNull (Application.Current); }
|
||||
void OnApplicationOnIteration (object s, IterationEventArgs e) { Assert.NotNull (Application.TopRunnable); }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Run_T_Creates_Top_Without_Init ()
|
||||
{
|
||||
Assert.Null (Application.Current);
|
||||
Assert.Null (Application.TopRunnable);
|
||||
|
||||
Application.StopAfterFirstIteration = true;
|
||||
|
||||
Application.Run<Toplevel> (null, "fake");
|
||||
#if DEBUG_IDISPOSABLE
|
||||
Assert.False (Application.Current!.WasDisposed);
|
||||
Assert.False (Application.TopRunnable!.WasDisposed);
|
||||
Exception exception = Record.Exception (Application.Shutdown);
|
||||
Assert.NotNull (exception);
|
||||
Assert.False (Application.Current!.WasDisposed);
|
||||
Assert.False (Application.TopRunnable!.WasDisposed);
|
||||
|
||||
// It's up to caller to dispose it
|
||||
Application.Current!.Dispose ();
|
||||
Assert.True (Application.Current!.WasDisposed);
|
||||
Application.TopRunnable!.Dispose ();
|
||||
Assert.True (Application.TopRunnable!.WasDisposed);
|
||||
#endif
|
||||
Assert.NotNull (Application.Current);
|
||||
Assert.NotNull (Application.TopRunnable);
|
||||
|
||||
Application.Shutdown ();
|
||||
Assert.Null (Application.Current);
|
||||
Assert.Null (Application.TopRunnable);
|
||||
}
|
||||
|
||||
[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.TopRunnable);
|
||||
|
||||
Assert.Throws<NotInitializedException> (() => 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.TopRunnable!.WasDisposed);
|
||||
Exception exception = Record.Exception (Application.Shutdown);
|
||||
Assert.NotNull (exception);
|
||||
Assert.False (Application.Current!.WasDisposed);
|
||||
Assert.False (Application.TopRunnable!.WasDisposed);
|
||||
|
||||
// It's up to caller to dispose it
|
||||
Application.Current!.Dispose ();
|
||||
Assert.True (Application.Current!.WasDisposed);
|
||||
Application.TopRunnable!.Dispose ();
|
||||
Assert.True (Application.TopRunnable!.WasDisposed);
|
||||
#endif
|
||||
Assert.NotNull (Application.Current);
|
||||
Assert.NotNull (Application.TopRunnable);
|
||||
|
||||
Application.Shutdown ();
|
||||
Assert.Null (Application.Current);
|
||||
Assert.Null (Application.TopRunnable);
|
||||
|
||||
return;
|
||||
|
||||
void OnApplication_OnIteration (object s, IterationEventArgs e)
|
||||
{
|
||||
Assert.NotNull (Application.Current);
|
||||
Assert.NotNull (Application.TopRunnable);
|
||||
Application.RequestStop ();
|
||||
}
|
||||
}
|
||||
@@ -892,9 +892,9 @@ public class ApplicationTests
|
||||
TaskScheduler.FromCurrentSynchronizationContext ());
|
||||
Application.Run<TestToplevel> ();
|
||||
Assert.NotNull (Application.Driver);
|
||||
Assert.NotNull (Application.Current);
|
||||
Assert.False (Application.Current!.Running);
|
||||
Application.Current!.Dispose ();
|
||||
Assert.NotNull (Application.TopRunnable);
|
||||
Assert.False (Application.TopRunnable!.Running);
|
||||
Application.TopRunnable!.Dispose ();
|
||||
Application.Shutdown ();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ public class ApplicationMouseEnterLeaveTests
|
||||
public void RaiseMouseEnterLeaveEvents_MouseEntersView_CallsOnMouseEnter ()
|
||||
{
|
||||
// Arrange
|
||||
Application.Current = new () { Frame = new (0, 0, 10, 10) };
|
||||
Application.TopRunnable = new () { Frame = new (0, 0, 10, 10) };
|
||||
var view = new TestView ();
|
||||
Application.Current.Add (view);
|
||||
Application.TopRunnable.Add (view);
|
||||
var mousePosition = new Point (1, 1);
|
||||
List<View> currentViewsUnderMouse = new () { view };
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ApplicationMouseEnterLeaveTests
|
||||
finally
|
||||
{
|
||||
// Cleanup
|
||||
Application.Current?.Dispose ();
|
||||
Application.TopRunnable?.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.TopRunnable = new () { Frame = new (0, 0, 10, 10) };
|
||||
var view = new TestView ();
|
||||
Application.Current.Add (view);
|
||||
Application.TopRunnable.Add (view);
|
||||
var mousePosition = new Point (0, 0);
|
||||
List<View> currentViewsUnderMouse = new ();
|
||||
var mouseEvent = new MouseEventArgs ();
|
||||
@@ -97,7 +97,7 @@ public class ApplicationMouseEnterLeaveTests
|
||||
finally
|
||||
{
|
||||
// Cleanup
|
||||
Application.Current?.Dispose ();
|
||||
Application.TopRunnable?.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.TopRunnable = 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.TopRunnable.Add (view1);
|
||||
Application.TopRunnable.Add (view2);
|
||||
|
||||
Application.CachedViewsUnderMouse.Clear ();
|
||||
|
||||
@@ -126,7 +126,7 @@ public class ApplicationMouseEnterLeaveTests
|
||||
|
||||
Application.RaiseMouseEnterLeaveEvents (
|
||||
mousePosition,
|
||||
Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse));
|
||||
Application.TopRunnable.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.TopRunnable.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.TopRunnable.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.TopRunnable.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.TopRunnable.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse));
|
||||
|
||||
// Assert
|
||||
Assert.Equal (1, view1.OnMouseEnterCalled);
|
||||
@@ -189,7 +189,7 @@ public class ApplicationMouseEnterLeaveTests
|
||||
finally
|
||||
{
|
||||
// Cleanup
|
||||
Application.Current?.Dispose ();
|
||||
Application.TopRunnable?.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.TopRunnable = new () { Frame = new (0, 0, 10, 10) };
|
||||
var view = new TestView ();
|
||||
Application.Current.Add (view);
|
||||
Application.TopRunnable.Add (view);
|
||||
var mousePosition = new Point (0, 0);
|
||||
List<View> currentViewsUnderMouse = new ();
|
||||
var mouseEvent = new MouseEventArgs ();
|
||||
@@ -219,7 +219,7 @@ public class ApplicationMouseEnterLeaveTests
|
||||
finally
|
||||
{
|
||||
// Cleanup
|
||||
Application.Current?.Dispose ();
|
||||
Application.TopRunnable?.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.TopRunnable = 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.TopRunnable.Add (view1);
|
||||
Application.TopRunnable.Add (view2);
|
||||
|
||||
Application.CachedViewsUnderMouse.Clear ();
|
||||
|
||||
@@ -253,7 +253,7 @@ public class ApplicationMouseEnterLeaveTests
|
||||
|
||||
Application.RaiseMouseEnterLeaveEvents (
|
||||
mousePosition,
|
||||
Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse));
|
||||
Application.TopRunnable.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.TopRunnable.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.TopRunnable.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.TopRunnable.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.TopRunnable.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.TopRunnable.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse));
|
||||
|
||||
// Assert
|
||||
Assert.Equal (1, view1.OnMouseEnterCalled);
|
||||
@@ -329,7 +329,7 @@ public class ApplicationMouseEnterLeaveTests
|
||||
finally
|
||||
{
|
||||
// Cleanup
|
||||
Application.Current?.Dispose ();
|
||||
Application.TopRunnable?.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.TopRunnable = 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.TopRunnable.Add (view1);
|
||||
|
||||
Application.CachedViewsUnderMouse.Clear ();
|
||||
|
||||
@@ -372,7 +372,7 @@ public class ApplicationMouseEnterLeaveTests
|
||||
|
||||
Application.RaiseMouseEnterLeaveEvents (
|
||||
mousePosition,
|
||||
Application.Current.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse));
|
||||
Application.TopRunnable.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.TopRunnable.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.TopRunnable.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.TopRunnable.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.TopRunnable.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.TopRunnable.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.TopRunnable.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.TopRunnable.GetViewsUnderLocation (mousePosition, ViewportSettingsFlags.TransparentMouse));
|
||||
|
||||
// Assert
|
||||
Assert.Equal (3, view1.OnMouseEnterCalled);
|
||||
@@ -474,7 +474,7 @@ public class ApplicationMouseEnterLeaveTests
|
||||
finally
|
||||
{
|
||||
// Cleanup
|
||||
Application.Current?.Dispose ();
|
||||
Application.TopRunnable?.Dispose ();
|
||||
Application.ResetState ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,15 +202,15 @@ public class ApplicationMouseTests
|
||||
|
||||
var clicked = false;
|
||||
|
||||
Application.Current = new Toplevel ()
|
||||
Application.TopRunnable = 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.TopRunnable.X = 0;
|
||||
Application.TopRunnable.Y = 0;
|
||||
Application.TopRunnable.Width = size.Width * 2;
|
||||
Application.TopRunnable.Height = size.Height * 2;
|
||||
Application.TopRunnable.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.TopRunnable.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.TopRunnable.Dispose ();
|
||||
Application.ResetState (ignoreDisposed: true);
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class SessionTokenTests
|
||||
Assert.NotNull (rs);
|
||||
Application.End (rs);
|
||||
|
||||
Assert.NotNull (Application.Current);
|
||||
Assert.NotNull (Application.TopRunnable);
|
||||
|
||||
// v2 does not use main loop, it uses MainLoop<T> and its internal
|
||||
//Assert.NotNull (Application.MainLoop);
|
||||
|
||||
@@ -39,7 +39,7 @@ public class SyncrhonizationContextTests
|
||||
|
||||
Task.Run (() =>
|
||||
{
|
||||
while (Application.Current is null || Application.Current is { Running: false })
|
||||
while (Application.TopRunnable is null || Application.TopRunnable is { Running: false })
|
||||
{
|
||||
Thread.Sleep (500);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class SyncrhonizationContextTests
|
||||
null
|
||||
);
|
||||
|
||||
if (Application.Current is { Running: true })
|
||||
if (Application.TopRunnable is { Running: true })
|
||||
{
|
||||
Assert.False (success);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user