mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 23:12:56 +08:00
Add test coverage
This commit is contained in:
parent
8b8eb00bd7
commit
2e0a9f53c1
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
@ -23,32 +24,40 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestGameplayOverlayActivation()
|
public void TestGameplayOverlayActivation()
|
||||||
{
|
{
|
||||||
|
AddAssert("local user playing", () => Player.LocalUserPlaying.Value);
|
||||||
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestGameplayOverlayActivationPaused()
|
public void TestGameplayOverlayActivationPaused()
|
||||||
{
|
{
|
||||||
|
AddAssert("local user playing", () => Player.LocalUserPlaying.Value);
|
||||||
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
||||||
AddStep("pause gameplay", () => Player.Pause());
|
AddStep("pause gameplay", () => Player.Pause());
|
||||||
|
AddAssert("local user not playing", () => !Player.LocalUserPlaying.Value);
|
||||||
AddUntilStep("activation mode is user triggered", () => Player.OverlayActivationMode == OverlayActivation.UserTriggered);
|
AddUntilStep("activation mode is user triggered", () => Player.OverlayActivationMode == OverlayActivation.UserTriggered);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestGameplayOverlayActivationReplayLoaded()
|
public void TestGameplayOverlayActivationReplayLoaded()
|
||||||
{
|
{
|
||||||
|
AddAssert("local user playing", () => Player.LocalUserPlaying.Value);
|
||||||
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
||||||
AddStep("load a replay", () => Player.DrawableRuleset.HasReplayLoaded.Value = true);
|
AddStep("load a replay", () => Player.DrawableRuleset.HasReplayLoaded.Value = true);
|
||||||
|
AddAssert("local user not playing", () => !Player.LocalUserPlaying.Value);
|
||||||
AddAssert("activation mode is user triggered", () => Player.OverlayActivationMode == OverlayActivation.UserTriggered);
|
AddAssert("activation mode is user triggered", () => Player.OverlayActivationMode == OverlayActivation.UserTriggered);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestGameplayOverlayActivationBreaks()
|
public void TestGameplayOverlayActivationBreaks()
|
||||||
{
|
{
|
||||||
|
AddAssert("local user playing", () => Player.LocalUserPlaying.Value);
|
||||||
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
||||||
AddStep("seek to break", () => Player.GameplayClockContainer.Seek(Beatmap.Value.Beatmap.Breaks.First().StartTime));
|
AddStep("seek to break", () => Player.GameplayClockContainer.Seek(Beatmap.Value.Beatmap.Breaks.First().StartTime));
|
||||||
|
AddAssert("local user not playing", () => !Player.LocalUserPlaying.Value);
|
||||||
AddUntilStep("activation mode is user triggered", () => Player.OverlayActivationMode == OverlayActivation.UserTriggered);
|
AddUntilStep("activation mode is user triggered", () => Player.OverlayActivationMode == OverlayActivation.UserTriggered);
|
||||||
AddStep("seek to break end", () => Player.GameplayClockContainer.Seek(Beatmap.Value.Beatmap.Breaks.First().EndTime));
|
AddStep("seek to break end", () => Player.GameplayClockContainer.Seek(Beatmap.Value.Beatmap.Breaks.First().EndTime));
|
||||||
|
AddAssert("local user playing", () => Player.LocalUserPlaying.Value);
|
||||||
AddUntilStep("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
AddUntilStep("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +66,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
protected class OverlayTestPlayer : TestPlayer
|
protected class OverlayTestPlayer : TestPlayer
|
||||||
{
|
{
|
||||||
public new OverlayActivation OverlayActivationMode => base.OverlayActivationMode.Value;
|
public new OverlayActivation OverlayActivationMode => base.OverlayActivationMode.Value;
|
||||||
|
public new Bindable<bool> LocalUserPlaying => base.LocalUserPlaying;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
|
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
|
||||||
|
|
||||||
private readonly Bindable<bool> localUserPlaying = new Bindable<bool>();
|
protected readonly Bindable<bool> LocalUserPlaying = new Bindable<bool>();
|
||||||
|
|
||||||
public int RestartCount;
|
public int RestartCount;
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ namespace osu.Game.Screens.Play
|
|||||||
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
||||||
|
|
||||||
if (game != null)
|
if (game != null)
|
||||||
localUserPlaying.BindTo(game.LocalUserPlaying);
|
LocalUserPlaying.BindTo(game.LocalUserPlaying);
|
||||||
|
|
||||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value);
|
DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value);
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
bool inGameplay = !DrawableRuleset.HasReplayLoaded.Value && !DrawableRuleset.IsPaused.Value && !breakTracker.IsBreakTime.Value;
|
bool inGameplay = !DrawableRuleset.HasReplayLoaded.Value && !DrawableRuleset.IsPaused.Value && !breakTracker.IsBreakTime.Value;
|
||||||
OverlayActivationMode.Value = inGameplay ? OverlayActivation.Disabled : OverlayActivation.UserTriggered;
|
OverlayActivationMode.Value = inGameplay ? OverlayActivation.Disabled : OverlayActivation.UserTriggered;
|
||||||
localUserPlaying.Value = inGameplay;
|
LocalUserPlaying.Value = inGameplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePauseOnFocusLostState() =>
|
private void updatePauseOnFocusLostState() =>
|
||||||
@ -667,7 +667,7 @@ namespace osu.Game.Screens.Play
|
|||||||
screenSuspension?.Expire();
|
screenSuspension?.Expire();
|
||||||
|
|
||||||
// Ensure we reset the LocalUserPlaying state
|
// Ensure we reset the LocalUserPlaying state
|
||||||
localUserPlaying.Value = false;
|
LocalUserPlaying.Value = false;
|
||||||
|
|
||||||
fadeOut();
|
fadeOut();
|
||||||
base.OnSuspending(next);
|
base.OnSuspending(next);
|
||||||
@ -699,7 +699,7 @@ namespace osu.Game.Screens.Play
|
|||||||
musicController.ResetTrackAdjustments();
|
musicController.ResetTrackAdjustments();
|
||||||
|
|
||||||
// Ensure we reset the LocalUserPlaying state
|
// Ensure we reset the LocalUserPlaying state
|
||||||
localUserPlaying.Value = false;
|
LocalUserPlaying.Value = false;
|
||||||
|
|
||||||
fadeOut();
|
fadeOut();
|
||||||
return base.OnExiting(next);
|
return base.OnExiting(next);
|
||||||
|
Loading…
Reference in New Issue
Block a user