mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 10:17:19 +08:00
Merge pull request #14836 from peppy/fix-dialog-overlay-disposal
Fix `DialogOverlay` potentially not expiring dialogs as soon as it should
This commit is contained in:
commit
af9cc9560f
@ -24,9 +24,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestBasic()
|
public void TestBasic()
|
||||||
{
|
{
|
||||||
TestPopupDialog dialog = null;
|
TestPopupDialog firstDialog = null;
|
||||||
|
TestPopupDialog secondDialog = null;
|
||||||
|
|
||||||
AddStep("dialog #1", () => overlay.Push(dialog = new TestPopupDialog
|
AddStep("dialog #1", () => overlay.Push(firstDialog = new TestPopupDialog
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Regular.TrashAlt,
|
Icon = FontAwesome.Regular.TrashAlt,
|
||||||
HeaderText = @"Confirm deletion of",
|
HeaderText = @"Confirm deletion of",
|
||||||
@ -46,9 +47,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddAssert("first dialog displayed", () => overlay.CurrentDialog == dialog);
|
AddAssert("first dialog displayed", () => overlay.CurrentDialog == firstDialog);
|
||||||
|
|
||||||
AddStep("dialog #2", () => overlay.Push(dialog = new TestPopupDialog
|
AddStep("dialog #2", () => overlay.Push(secondDialog = new TestPopupDialog
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.Cog,
|
Icon = FontAwesome.Solid.Cog,
|
||||||
HeaderText = @"What do you want to do with",
|
HeaderText = @"What do you want to do with",
|
||||||
@ -82,30 +83,33 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddAssert("second dialog displayed", () => overlay.CurrentDialog == dialog);
|
AddAssert("second dialog displayed", () => overlay.CurrentDialog == secondDialog);
|
||||||
|
AddAssert("first dialog is not part of hierarchy", () => firstDialog.Parent == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDismissBeforePush()
|
public void TestDismissBeforePush()
|
||||||
{
|
{
|
||||||
|
TestPopupDialog testDialog = null;
|
||||||
AddStep("dismissed dialog push", () =>
|
AddStep("dismissed dialog push", () =>
|
||||||
{
|
{
|
||||||
overlay.Push(new TestPopupDialog
|
overlay.Push(testDialog = new TestPopupDialog
|
||||||
{
|
{
|
||||||
State = { Value = Visibility.Hidden }
|
State = { Value = Visibility.Hidden }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("no dialog pushed", () => overlay.CurrentDialog == null);
|
AddAssert("no dialog pushed", () => overlay.CurrentDialog == null);
|
||||||
|
AddAssert("dialog is not part of hierarchy", () => testDialog.Parent == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDismissBeforePushViaButtonPress()
|
public void TestDismissBeforePushViaButtonPress()
|
||||||
{
|
{
|
||||||
|
TestPopupDialog testDialog = null;
|
||||||
AddStep("dismissed dialog push", () =>
|
AddStep("dismissed dialog push", () =>
|
||||||
{
|
{
|
||||||
TestPopupDialog dialog;
|
overlay.Push(testDialog = new TestPopupDialog
|
||||||
overlay.Push(dialog = new TestPopupDialog
|
|
||||||
{
|
{
|
||||||
Buttons = new PopupDialogButton[]
|
Buttons = new PopupDialogButton[]
|
||||||
{
|
{
|
||||||
@ -113,10 +117,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.PerformOkAction();
|
testDialog.PerformOkAction();
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("no dialog pushed", () => overlay.CurrentDialog == null);
|
AddAssert("no dialog pushed", () => overlay.CurrentDialog == null);
|
||||||
|
AddAssert("dialog is not part of hierarchy", () => testDialog.Parent == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestPopupDialog : PopupDialog
|
private class TestPopupDialog : PopupDialog
|
||||||
|
@ -49,6 +49,8 @@ namespace osu.Game.Overlays
|
|||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool IsPresent => dialogContainer.Children.Count > 0;
|
||||||
|
|
||||||
protected override bool BlockNonPositionalInput => true;
|
protected override bool BlockNonPositionalInput => true;
|
||||||
|
|
||||||
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
|
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user