mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 08:22:56 +08:00
Add new test and assertions to existing DialogOverlay
test
This commit is contained in:
parent
fc5987bf69
commit
b33d5e7a7a
@ -2,7 +2,9 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Dialog;
|
using osu.Game.Overlays.Dialog;
|
||||||
|
|
||||||
@ -11,13 +13,20 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneDialogOverlay : OsuTestScene
|
public class TestSceneDialogOverlay : OsuTestScene
|
||||||
{
|
{
|
||||||
public TestSceneDialogOverlay()
|
private DialogOverlay overlay;
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
{
|
{
|
||||||
DialogOverlay overlay;
|
AddStep("create dialog overlay", () => Child = overlay = new DialogOverlay());
|
||||||
|
}
|
||||||
|
|
||||||
Add(overlay = new DialogOverlay());
|
[Test]
|
||||||
|
public void TestBasic()
|
||||||
|
{
|
||||||
|
TestPopupDialog dialog = null;
|
||||||
|
|
||||||
AddStep("dialog #1", () => overlay.Push(new TestPopupDialog
|
AddStep("dialog #1", () => overlay.Push(dialog = new TestPopupDialog
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Regular.TrashAlt,
|
Icon = FontAwesome.Regular.TrashAlt,
|
||||||
HeaderText = @"Confirm deletion of",
|
HeaderText = @"Confirm deletion of",
|
||||||
@ -37,7 +46,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddStep("dialog #2", () => overlay.Push(new TestPopupDialog
|
AddAssert("first dialog displayed", () => overlay.CurrentDialog == dialog);
|
||||||
|
|
||||||
|
AddStep("dialog #2", () => overlay.Push(dialog = 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",
|
||||||
@ -70,6 +81,42 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
AddAssert("second dialog displayed", () => overlay.CurrentDialog == dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDismissBeforePush()
|
||||||
|
{
|
||||||
|
AddStep("dismissed dialog push", () =>
|
||||||
|
{
|
||||||
|
overlay.Push(new TestPopupDialog
|
||||||
|
{
|
||||||
|
State = { Value = Visibility.Hidden }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("no dialog pushed", () => overlay.CurrentDialog == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDismissBeforePushViaButtonPress()
|
||||||
|
{
|
||||||
|
AddStep("dismissed dialog push", () =>
|
||||||
|
{
|
||||||
|
TestPopupDialog dialog;
|
||||||
|
overlay.Push(dialog = new TestPopupDialog
|
||||||
|
{
|
||||||
|
Buttons = new PopupDialogButton[]
|
||||||
|
{
|
||||||
|
new PopupDialogOkButton { Text = @"OK" },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.PerformOkAction();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("no dialog pushed", () => overlay.CurrentDialog == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestPopupDialog : PopupDialog
|
private class TestPopupDialog : PopupDialog
|
||||||
|
Loading…
Reference in New Issue
Block a user