Add better test coverage of `SettingsPanel`

This commit is contained in:
Dean Herbert 2021-08-16 18:43:02 +09:00
parent c191b38125
commit 4b975ca10d
1 changed files with 24 additions and 11 deletions

View File

@ -4,6 +4,7 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual.Settings
@ -11,27 +12,39 @@ namespace osu.Game.Tests.Visual.Settings
[TestFixture]
public class TestSceneSettingsPanel : OsuTestScene
{
private readonly SettingsPanel settings;
private readonly DialogOverlay dialogOverlay;
private SettingsPanel settings;
private DialogOverlay dialogOverlay;
public TestSceneSettingsPanel()
[SetUpSteps]
public void SetUpSteps()
{
settings = new SettingsOverlay
AddStep("create settings", () =>
{
State = { Value = Visibility.Visible }
};
Add(dialogOverlay = new DialogOverlay
{
Depth = -1
settings?.Expire();
Add(settings = new SettingsOverlay
{
State = { Value = Visibility.Visible }
});
});
}
[Test]
public void ToggleVisibility()
{
AddWaitStep("wait some", 5);
AddToggleStep("toggle editor visibility", visible => settings.ToggleVisibility());
}
[BackgroundDependencyLoader]
private void load()
{
Dependencies.Cache(dialogOverlay);
Add(dialogOverlay = new DialogOverlay
{
Depth = -1
});
Add(settings);
Dependencies.Cache(dialogOverlay);
}
}
}