1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 17:02:55 +08:00

Update test scene to be non-skinnable (and add test covering momentary display)

This commit is contained in:
Dean Herbert 2020-10-30 14:20:00 +09:00
parent 8928aa6d92
commit bd7871d9f5

View File

@ -2,29 +2,23 @@
// 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 System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osuTK.Input; using osuTK.Input;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
{ {
public class TestSceneHUDOverlay : SkinnableTestScene public class TestSceneHUDOverlay : OsuManualInputManagerTestScene
{ {
private HUDOverlay hudOverlay; private HUDOverlay hudOverlay;
private IEnumerable<HUDOverlay> hudOverlays => CreatedDrawables.OfType<HUDOverlay>();
// best way to check without exposing. // best way to check without exposing.
private Drawable hideTarget => hudOverlay.KeyCounter; private Drawable hideTarget => hudOverlay.KeyCounter;
private FillFlowContainer<KeyCounter> keyCounterFlow => hudOverlay.KeyCounter.ChildrenOfType<FillFlowContainer<KeyCounter>>().First(); private FillFlowContainer<KeyCounter> keyCounterFlow => hudOverlay.KeyCounter.ChildrenOfType<FillFlowContainer<KeyCounter>>().First();
@ -37,17 +31,9 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
createNew(); createNew();
AddRepeatStep("increase combo", () => AddRepeatStep("increase combo", () => { hudOverlay.ComboCounter.Current.Value++; }, 10);
{
foreach (var hud in hudOverlays)
hud.ComboCounter.Current.Value++;
}, 10);
AddStep("reset combo", () => AddStep("reset combo", () => { hudOverlay.ComboCounter.Current.Value = 0; });
{
foreach (var hud in hudOverlays)
hud.ComboCounter.Current.Value = 0;
});
} }
[Test] [Test]
@ -77,7 +63,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
createNew(); createNew();
AddStep("set showhud false", () => hudOverlays.ForEach(h => h.ShowHud.Value = false)); AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent); AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent); AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent);
@ -86,6 +72,27 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("key counter flow not affected", () => keyCounterFlow.IsPresent); AddAssert("key counter flow not affected", () => keyCounterFlow.IsPresent);
} }
[Test]
public void TestMomentaryShowHUD()
{
createNew();
HUDVisibilityMode originalConfigValue = HUDVisibilityMode.HideDuringBreaks;
AddStep("get original config value", () => originalConfigValue = config.Get<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode));
AddStep("set hud to never show", () => config.Set(OsuSetting.HUDVisibilityMode, HUDVisibilityMode.Never));
AddUntilStep("wait for fade", () => !hideTarget.IsPresent);
AddStep("trigger momentary show", () => InputManager.PressKey(Key.ControlLeft));
AddUntilStep("wait for visible", () => hideTarget.IsPresent);
AddStep("stop trigering", () => InputManager.ReleaseKey(Key.ControlLeft));
AddUntilStep("wait for fade", () => !hideTarget.IsPresent);
AddStep("set original config value", () => config.Set(OsuSetting.HUDVisibilityMode, originalConfigValue));
}
[Test] [Test]
public void TestExternalHideDoesntAffectConfig() public void TestExternalHideDoesntAffectConfig()
{ {
@ -113,14 +120,14 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("set keycounter visible false", () => AddStep("set keycounter visible false", () =>
{ {
config.Set<bool>(OsuSetting.KeyOverlay, false); config.Set<bool>(OsuSetting.KeyOverlay, false);
hudOverlays.ForEach(h => h.KeyCounter.AlwaysVisible.Value = false); hudOverlay.KeyCounter.AlwaysVisible.Value = false;
}); });
AddStep("set showhud false", () => hudOverlays.ForEach(h => h.ShowHud.Value = false)); AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent); AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
AddAssert("key counters hidden", () => !keyCounterFlow.IsPresent); AddAssert("key counters hidden", () => !keyCounterFlow.IsPresent);
AddStep("set showhud true", () => hudOverlays.ForEach(h => h.ShowHud.Value = true)); AddStep("set showhud true", () => hudOverlay.ShowHud.Value = true);
AddUntilStep("hidetarget is visible", () => hideTarget.IsPresent); AddUntilStep("hidetarget is visible", () => hideTarget.IsPresent);
AddAssert("key counters still hidden", () => !keyCounterFlow.IsPresent); AddAssert("key counters still hidden", () => !keyCounterFlow.IsPresent);
@ -130,8 +137,6 @@ namespace osu.Game.Tests.Visual.Gameplay
private void createNew(Action<HUDOverlay> action = null) private void createNew(Action<HUDOverlay> action = null)
{ {
AddStep("create overlay", () => AddStep("create overlay", () =>
{
SetContents(() =>
{ {
hudOverlay = new HUDOverlay(null, null, null, Array.Empty<Mod>()); hudOverlay = new HUDOverlay(null, null, null, Array.Empty<Mod>());
@ -142,11 +147,8 @@ namespace osu.Game.Tests.Visual.Gameplay
action?.Invoke(hudOverlay); action?.Invoke(hudOverlay);
return hudOverlay; Child = hudOverlay;
});
}); });
} }
protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
} }
} }