mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 02:43:19 +08:00
Add comprehensive tests of difficulty adjust settings
This commit is contained in:
parent
88b00123f6
commit
533db01cc0
@ -1,6 +1,7 @@
|
||||
// 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.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -8,6 +9,8 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -16,12 +19,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneModDifficultyAdjustSettings : OsuManualInputManagerTestScene
|
||||
{
|
||||
private OsuModDifficultyAdjust modDifficultyAdjust;
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("create difficulty adjust", () =>
|
||||
AddStep("create control", () =>
|
||||
{
|
||||
var modDifficultyAdjust = new OsuModDifficultyAdjust();
|
||||
modDifficultyAdjust = new OsuModDifficultyAdjust();
|
||||
|
||||
Child = new Container
|
||||
{
|
||||
@ -44,14 +49,140 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
setBeatmapWithDifficultyParameters(5);
|
||||
setBeatmapWithDifficultyParameters(8);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBasic()
|
||||
public void TestFollowsBeatmapDefaultsVisually()
|
||||
{
|
||||
setBeatmapWithDifficultyParameters(5);
|
||||
|
||||
checkSliderAtValue("Circle Size", 5);
|
||||
checkBindableAtValue("Circle Size", null);
|
||||
|
||||
setBeatmapWithDifficultyParameters(8);
|
||||
|
||||
checkSliderAtValue("Circle Size", 8);
|
||||
checkBindableAtValue("Circle Size", null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOutOfRangeValueStillApplied()
|
||||
{
|
||||
AddStep("set override cs to 11", () => modDifficultyAdjust.CircleSize.Value = 11);
|
||||
|
||||
checkSliderAtValue("Circle Size", 11);
|
||||
checkBindableAtValue("Circle Size", 11);
|
||||
|
||||
// this is a no-op, just showing that it won't reset the value during deserialisation.
|
||||
setExtendedLimits(false);
|
||||
|
||||
checkSliderAtValue("Circle Size", 11);
|
||||
checkBindableAtValue("Circle Size", 11);
|
||||
|
||||
// setting extended limits will reset the serialisation exception.
|
||||
// this should be fine as the goal is to allow, at most, the value of extended limits.
|
||||
setExtendedLimits(true);
|
||||
|
||||
checkSliderAtValue("Circle Size", 11);
|
||||
checkBindableAtValue("Circle Size", 11);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExtendedLimits()
|
||||
{
|
||||
setSliderValue("Circle Size", 99);
|
||||
|
||||
checkSliderAtValue("Circle Size", 10);
|
||||
checkBindableAtValue("Circle Size", 10);
|
||||
|
||||
setExtendedLimits(true);
|
||||
|
||||
checkSliderAtValue("Circle Size", 10);
|
||||
checkBindableAtValue("Circle Size", 10);
|
||||
|
||||
setSliderValue("Circle Size", 99);
|
||||
|
||||
checkSliderAtValue("Circle Size", 11);
|
||||
checkBindableAtValue("Circle Size", 11);
|
||||
|
||||
setExtendedLimits(false);
|
||||
|
||||
checkSliderAtValue("Circle Size", 10);
|
||||
checkBindableAtValue("Circle Size", 10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUserOverrideMaintainedOnBeatmapChange()
|
||||
{
|
||||
setSliderValue("Circle Size", 9);
|
||||
|
||||
setBeatmapWithDifficultyParameters(2);
|
||||
|
||||
checkSliderAtValue("Circle Size", 9);
|
||||
checkBindableAtValue("Circle Size", 9);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestResetToDefault()
|
||||
{
|
||||
setBeatmapWithDifficultyParameters(2);
|
||||
|
||||
setSliderValue("Circle Size", 9);
|
||||
checkSliderAtValue("Circle Size", 9);
|
||||
checkBindableAtValue("Circle Size", 9);
|
||||
|
||||
resetToDefault("Circle Size");
|
||||
checkSliderAtValue("Circle Size", 2);
|
||||
checkBindableAtValue("Circle Size", null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUserOverrideMaintainedOnMatchingBeatmapValue()
|
||||
{
|
||||
setBeatmapWithDifficultyParameters(2);
|
||||
|
||||
checkSliderAtValue("Circle Size", 2);
|
||||
checkBindableAtValue("Circle Size", null);
|
||||
|
||||
setSliderValue("Circle Size", 9);
|
||||
checkSliderAtValue("Circle Size", 9);
|
||||
checkBindableAtValue("Circle Size", 9);
|
||||
|
||||
setBeatmapWithDifficultyParameters(4);
|
||||
|
||||
checkSliderAtValue("Circle Size", 9);
|
||||
checkBindableAtValue("Circle Size", 9);
|
||||
}
|
||||
|
||||
private void resetToDefault(string name)
|
||||
{
|
||||
AddStep($"Reset {name} to default", () =>
|
||||
this.ChildrenOfType<DifficultyAdjustSettingsControl>().First(c => c.LabelText == name)
|
||||
.Current.SetDefault());
|
||||
}
|
||||
|
||||
private void setExtendedLimits(bool status) =>
|
||||
AddStep($"Set extended limits {status}", () => modDifficultyAdjust.ExtendedLimits.Value = status);
|
||||
|
||||
private void setSliderValue(string name, float value)
|
||||
{
|
||||
AddStep($"Set {name} slider to {value}", () =>
|
||||
this.ChildrenOfType<DifficultyAdjustSettingsControl>().First(c => c.LabelText == name)
|
||||
.ChildrenOfType<SettingsSlider<float>>().First().Current.Value = value);
|
||||
}
|
||||
|
||||
private void checkBindableAtValue(string name, float? expectedValue)
|
||||
{
|
||||
AddAssert($"Bindable {name} is {(expectedValue?.ToString() ?? "null")}", () =>
|
||||
this.ChildrenOfType<DifficultyAdjustSettingsControl>().First(c => c.LabelText == name)
|
||||
.Current.Value == expectedValue);
|
||||
}
|
||||
|
||||
private void checkSliderAtValue(string name, float expectedValue)
|
||||
{
|
||||
AddAssert($"Slider {name} at {expectedValue}", () =>
|
||||
this.ChildrenOfType<DifficultyAdjustSettingsControl>().First(c => c.LabelText == name)
|
||||
.ChildrenOfType<SettingsSlider<float>>().First().Current.Value == expectedValue);
|
||||
}
|
||||
|
||||
private void setBeatmapWithDifficultyParameters(float value)
|
||||
|
Loading…
Reference in New Issue
Block a user