-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathTestSceneSliderHardBeat.cs
118 lines (101 loc) · 4.21 KB
/
TestSceneSliderHardBeat.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Tau.Configuration;
using osu.Game.Rulesets.Tau.Objects;
using osu.Game.Rulesets.Tau.Objects.Drawables;
using osu.Game.Rulesets.Tau.UI;
namespace osu.Game.Rulesets.Tau.Tests.Objects
{
[TestFixture]
public partial class TestSceneSliderHardBeat : TauTestScene
{
private int depthIndex;
private TauPlayfieldAdjustmentContainer container;
private BindableBool highlightHardNotes = new BindableBool();
[BackgroundDependencyLoader]
private void load() {
var config = (TauRulesetConfigManager)RulesetConfigs.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
config.BindWith(TauRulesetSettings.HighlightHardBeats, highlightHardNotes);
}
[Test]
public void TestSingleSlider()
{
AddStep("clear screen", Clear);
AddStep("add container", () => Add(container = new TauPlayfieldAdjustmentContainer()));
AddStep("highlighting disabled", () => highlightHardNotes.Value = false);
AddStep("Miss Single", () => container.Add(testSingle()));
AddStep("Hit Single", () => container.Add(testSingle(true)));
AddUntilStep("Wait for object despawn", () => !container.Any(h => h is DrawableSlider { AllJudged: false }));
}
[Test]
public void TestHighlightedSingleSlider()
{
AddStep("clear screen", Clear);
AddStep("add container", () => Add(container = new TauPlayfieldAdjustmentContainer()));
AddStep("highlighting enabled", () => highlightHardNotes.Value = true);
AddStep("Miss single highlighted", () => container.Add(testSingle()));
AddStep("Hit single highlighted", () => container.Add(testSingle(true)));
AddUntilStep("Wait for object despawn", () => !container.Any(h => h is DrawableSlider { AllJudged: false }));
}
[Test]
public void TestSliderPerformance()
{
AddStep("clear screen", Clear);
AddStep("add container", () => Add(container = new TauPlayfieldAdjustmentContainer()));
AddStep("Miss many", () => container.AddRange(testMultiple(100)));
AddStep("Hit many", () => container.AddRange(testMultiple(100, true)));
}
private IEnumerable<Drawable> testMultiple(int count, bool auto = false)
=> Enumerable.Range(0, count).Select(x => testSingle(auto, 1000 + x * 100));
private Drawable testSingle(bool auto = false, double timeOffset = 1000)
{
var slider = createSlider(timeOffset);
slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
return new TestDrawableSlider(slider, auto)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Depth = depthIndex++
};
}
private Slider createSlider(double timeOffset)
=> new()
{
StartTime = Time.Current + timeOffset,
IsHard = true,
Path = new PolarSliderPath(new SliderNode[]
{
new(0, 0),
new(500, 90),
new(1000, 180),
})
};
private partial class TestDrawableSlider : DrawableSlider
{
private readonly bool auto;
public TestDrawableSlider(Slider h, bool auto)
: base(h)
{
this.auto = auto;
}
protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (auto && !userTriggered && timeOffset > 0)
{
// force success
ApplyResult(HitResult.Great);
}
else
base.CheckForResult(userTriggered, timeOffset);
}
}
}
}