mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Added IsLoaded property to allow control if a change was done before or after the toplevel was loaded.
This commit is contained in:
@@ -1031,5 +1031,53 @@ namespace Terminal.Gui.TopLevelTests {
|
||||
Application.Driver.GetCursorVisibility (out cursor);
|
||||
Assert.Equal (CursorVisibility.Invisible, cursor);
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void IsLoaded_Application_Begin ()
|
||||
{
|
||||
var top = Application.Top;
|
||||
Assert.False (top.IsLoaded);
|
||||
|
||||
Application.Begin (top);
|
||||
Assert.True (top.IsLoaded);
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void IsLoaded_With_Sub_Toplevel_Application_Begin_NeedDisplay ()
|
||||
{
|
||||
var top = Application.Top;
|
||||
var subTop = new Toplevel ();
|
||||
var view = new View (new Rect (0, 0, 20, 10));
|
||||
subTop.Add (view);
|
||||
top.Add (subTop);
|
||||
|
||||
Assert.False (top.IsLoaded);
|
||||
Assert.False (subTop.IsLoaded);
|
||||
Assert.Equal (new Rect (0, 0, 20, 10), view.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 20, 10), view.NeedDisplay);
|
||||
|
||||
view.LayoutStarted += view_LayoutStarted;
|
||||
|
||||
void view_LayoutStarted (View.LayoutEventArgs e)
|
||||
{
|
||||
Assert.Equal (new Rect (0, 0, 20, 10), view.NeedDisplay);
|
||||
view.LayoutStarted -= view_LayoutStarted;
|
||||
}
|
||||
|
||||
Application.Begin (top);
|
||||
|
||||
Assert.True (top.IsLoaded);
|
||||
Assert.True (subTop.IsLoaded);
|
||||
Assert.Equal (new Rect (0, 0, 20, 10), view.Frame);
|
||||
|
||||
view.Frame = new Rect (1, 3, 10, 5);
|
||||
Assert.Equal (new Rect (1, 3, 10, 5), view.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 20, 10), view.NeedDisplay);
|
||||
|
||||
view.Redraw (view.Bounds);
|
||||
view.Frame = new Rect (1, 3, 10, 5);
|
||||
Assert.Equal (new Rect (1, 3, 10, 5), view.Frame);
|
||||
Assert.Equal (new Rect (1, 3, 10, 5), view.NeedDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user