2021-12-03 16:18:02 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-12-03 16:18:02 +08:00
|
|
|
using NUnit.Framework;
|
2022-01-03 16:02:15 +08:00
|
|
|
using osu.Framework.Extensions;
|
2021-12-03 16:18:02 +08:00
|
|
|
using osu.Game.Configuration;
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
using osu.Game.Tests.Beatmaps.IO;
|
|
|
|
using osuTK.Input;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Navigation
|
|
|
|
{
|
|
|
|
public class TestSceneMouseWheelVolumeAdjust : OsuGameTestScene
|
|
|
|
{
|
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
base.SetUpSteps();
|
|
|
|
|
|
|
|
// Headless tests are always at minimum volume. This covers interactive tests, matching that initial value.
|
|
|
|
AddStep("Set volume to min", () => Game.Audio.Volume.Value = 0);
|
|
|
|
AddAssert("Volume is min", () => Game.Audio.AggregateVolume.Value == 0);
|
|
|
|
AddStep("Move mouse to centre", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.Centre));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestAdjustVolumeFromMainMenu()
|
|
|
|
{
|
|
|
|
// First scroll makes volume controls appear, second adjusts volume.
|
2021-12-23 12:25:23 +08:00
|
|
|
AddUntilStep("Adjust volume using mouse wheel", () =>
|
|
|
|
{
|
|
|
|
InputManager.ScrollVerticalBy(5);
|
|
|
|
return Game.Audio.AggregateVolume.Value > 0;
|
|
|
|
});
|
2021-12-03 16:18:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestAdjustVolumeFromPlayerWheelEnabled()
|
|
|
|
{
|
|
|
|
loadToPlayerNonBreakTime();
|
|
|
|
|
|
|
|
// First scroll makes volume controls appear, second adjusts volume.
|
2021-12-23 12:25:23 +08:00
|
|
|
AddUntilStep("Adjust volume using mouse wheel", () =>
|
|
|
|
{
|
|
|
|
InputManager.ScrollVerticalBy(5);
|
|
|
|
return Game.Audio.AggregateVolume.Value > 0;
|
|
|
|
});
|
2021-12-03 16:18:02 +08:00
|
|
|
AddAssert("Volume is above zero", () => Game.Audio.Volume.Value > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestAdjustVolumeFromPlayerWheelDisabled()
|
|
|
|
{
|
|
|
|
AddStep("disable wheel volume adjust", () => Game.LocalConfig.SetValue(OsuSetting.MouseDisableWheel, true));
|
|
|
|
|
|
|
|
loadToPlayerNonBreakTime();
|
|
|
|
|
|
|
|
// First scroll makes volume controls appear, second adjusts volume.
|
2021-12-23 12:25:23 +08:00
|
|
|
AddRepeatStep("Adjust volume using mouse wheel", () => InputManager.ScrollVerticalBy(5), 10);
|
2021-12-03 16:18:02 +08:00
|
|
|
AddAssert("Volume is still zero", () => Game.Audio.Volume.Value == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestAdjustVolumeFromPlayerWheelDisabledHoldingAlt()
|
|
|
|
{
|
|
|
|
AddStep("disable wheel volume adjust", () => Game.LocalConfig.SetValue(OsuSetting.MouseDisableWheel, true));
|
|
|
|
|
|
|
|
loadToPlayerNonBreakTime();
|
|
|
|
|
|
|
|
// First scroll makes volume controls appear, second adjusts volume.
|
2021-12-23 12:25:23 +08:00
|
|
|
AddUntilStep("Adjust volume using mouse wheel holding alt", () =>
|
2021-12-03 16:18:02 +08:00
|
|
|
{
|
|
|
|
InputManager.PressKey(Key.AltLeft);
|
|
|
|
InputManager.ScrollVerticalBy(5);
|
|
|
|
InputManager.ReleaseKey(Key.AltLeft);
|
2021-12-23 12:25:23 +08:00
|
|
|
return Game.Audio.AggregateVolume.Value > 0;
|
|
|
|
});
|
2021-12-03 16:18:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void loadToPlayerNonBreakTime()
|
|
|
|
{
|
|
|
|
Player player = null;
|
|
|
|
Screens.Select.SongSelect songSelect = null;
|
|
|
|
PushAndConfirm(() => songSelect = new TestSceneScreenNavigation.TestPlaySongSelect());
|
|
|
|
AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded);
|
|
|
|
|
2021-12-17 17:26:12 +08:00
|
|
|
AddStep("import beatmap", () => BeatmapImportHelper.LoadOszIntoOsu(Game, virtualTrack: true).WaitSafely());
|
2021-12-03 16:18:02 +08:00
|
|
|
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
|
|
|
|
AddStep("press enter", () => InputManager.Key(Key.Enter));
|
|
|
|
|
|
|
|
AddUntilStep("wait for player", () =>
|
|
|
|
{
|
2022-04-24 04:14:14 +08:00
|
|
|
DismissAnyNotifications();
|
2021-12-03 16:18:02 +08:00
|
|
|
return (player = Game.ScreenStack.CurrentScreen as Player) != null;
|
|
|
|
});
|
|
|
|
|
|
|
|
AddUntilStep("wait for play time active", () => !player.IsBreakTime.Value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|