Skip to content

Commit

Permalink
Merge pull request #131 from Altenhh/Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
naoei authored Dec 21, 2020
2 parents daad872 + a4765de commit 09d13cf
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 1 deletion.
88 changes: 88 additions & 0 deletions osu.Game.Rulesets.Tau.Tests/Objects/TestSceneBeat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Tau.Objects;
using osu.Game.Rulesets.Tau.Objects.Drawables;
using osu.Game.Tests.Visual;
using osuTK;

namespace osu.Game.Rulesets.Tau.Tests.Objects
{
[TestFixture]
public class TestSceneBeat : OsuTestScene
{
private readonly Container content;
protected override Container<Drawable> Content => content;

private int depthIndex;

public TestSceneBeat()
{
base.Content.Add(content = new TauInputManager(new RulesetInfo { ID = 0 })
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(768),
RelativeSizeAxes = Axes.None,
Scale = new Vector2(.6f)
});

AddStep("Miss Single", () => testSingle());
AddStep("Hit Single", () => testSingle(true));
AddStep("Miss Stream", () => testStream());
AddStep("Hit Stream", () => testStream(true));
AddUntilStep("Wait for object despawn", () => !Children.Any(h => h is DrawableTauHitObject hitObject && hitObject.AllJudged == false));
}

private void testSingle(bool auto = false, double timeOffset = 0, float angle = 0)
{
var beat = new Beat
{
StartTime = Time.Current + 1000 + timeOffset,
Angle = angle
};

beat.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());

Add(new TestDrawableBeat(beat, auto)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Depth = depthIndex++
});
}

private void testStream(bool auto = false)
{
for (int i = 0; i <= 1000; i += 100)
{
testSingle(auto, i, i / 10f);
}
}

private class TestDrawableBeat : DrawableBeat
{
private readonly bool auto;

public TestDrawableBeat(Beat h, bool auto)
: base(h)
{
this.auto = auto;
}

protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (auto && !userTriggered && timeOffset > 0)
// Force success.
ApplyResult(r => r.Type = HitResult.Great);
else if (timeOffset > 0)
// We'll have to manually apply the result anyways because we have no way of checking if the paddle is in the correct spot.
ApplyResult(r => r.Type = HitResult.Miss);
}
}
}
}
44 changes: 44 additions & 0 deletions osu.Game.Rulesets.Tau.Tests/TestSceneKiai.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Rulesets.Tau.UI;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Tau.Tests
{
public class TestSceneKiai : TestScene
{
public TestSceneKiai()
{
AddStep("Hit Single", () => testSingle());
AddStep("Hit Stream", testMultiple);

AddStep("Hit hard beat", () => Add(new KiaiHitExplosion(Color4.White, true)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(0.5f)
}));
}

private void testSingle(float angle = 0)
{
Add(new KiaiHitExplosion(Color4.White)
{
Position = Extensions.GetCircularPosition(0.15f, angle),
Angle = angle,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
}

private void testMultiple()
{
for (int i = 0; i <= 1000; i += 100)
{
var angle = i / 5f;
Scheduler.AddDelayed(() => testSingle(angle), i);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<StartupObject>osu.Game.Rulesets.Tau.Tests.VisualTestRunner</StartupObject>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup Label="Service">
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
Expand Down

0 comments on commit 09d13cf

Please sign in to comment.