2020-06-02 14:38:50 +00: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.
|
|
|
|
|
2020-06-18 13:11:03 +00:00
|
|
|
using System;
|
2020-06-02 14:38:50 +00:00
|
|
|
using System.Collections.Generic;
|
2020-06-22 11:32:04 +00:00
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
2020-06-02 14:38:50 +00:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2020-06-18 13:11:03 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-06-19 11:03:18 +00:00
|
|
|
using osu.Game.Screens.Ranking.Statistics;
|
2020-06-02 14:38:50 +00:00
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Ranking
|
|
|
|
{
|
2020-06-19 11:03:18 +00:00
|
|
|
public class TestSceneHitEventTimingDistributionGraph : OsuTestScene
|
2020-06-02 14:38:50 +00:00
|
|
|
{
|
2020-06-22 11:32:04 +00:00
|
|
|
[Test]
|
|
|
|
public void TestManyDistributedEvents()
|
|
|
|
{
|
|
|
|
createTest(CreateDistributedHitEvents());
|
|
|
|
}
|
|
|
|
|
2020-10-08 19:41:45 +00:00
|
|
|
[Test]
|
|
|
|
public void TestAroundCentre()
|
|
|
|
{
|
2020-10-08 20:04:03 +00:00
|
|
|
createTest(Enumerable.Range(-150, 300).Select(i => new HitEvent(i / 50f, HitResult.Perfect, new HitCircle(), new HitCircle(), null)).ToList());
|
2020-10-08 19:41:45 +00:00
|
|
|
}
|
|
|
|
|
2020-06-22 11:32:04 +00:00
|
|
|
[Test]
|
|
|
|
public void TestZeroTimeOffset()
|
|
|
|
{
|
|
|
|
createTest(Enumerable.Range(0, 100).Select(_ => new HitEvent(0, HitResult.Perfect, new HitCircle(), new HitCircle(), null)).ToList());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestNoEvents()
|
|
|
|
{
|
|
|
|
createTest(new List<HitEvent>());
|
|
|
|
}
|
|
|
|
|
2020-08-31 05:15:47 +00:00
|
|
|
[Test]
|
|
|
|
public void TestMissesDontShow()
|
|
|
|
{
|
|
|
|
createTest(Enumerable.Range(0, 100).Select(i =>
|
|
|
|
{
|
|
|
|
if (i % 2 == 0)
|
|
|
|
return new HitEvent(0, HitResult.Perfect, new HitCircle(), new HitCircle(), null);
|
|
|
|
|
|
|
|
return new HitEvent(30, HitResult.Miss, new HitCircle(), new HitCircle(), null);
|
|
|
|
}).ToList());
|
|
|
|
}
|
|
|
|
|
2020-06-22 11:32:04 +00:00
|
|
|
private void createTest(List<HitEvent> events) => AddStep("create test", () =>
|
2020-06-02 14:38:50 +00:00
|
|
|
{
|
2020-06-12 13:48:43 +00:00
|
|
|
Children = new Drawable[]
|
2020-06-02 14:38:50 +00:00
|
|
|
{
|
2020-06-12 13:48:43 +00:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4Extensions.FromHex("#333")
|
|
|
|
},
|
2020-06-22 11:32:04 +00:00
|
|
|
new HitEventTimingDistributionGraph(events)
|
2020-06-12 13:48:43 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2020-06-22 11:32:04 +00:00
|
|
|
Size = new Vector2(600, 130)
|
2020-06-12 13:48:43 +00:00
|
|
|
}
|
|
|
|
};
|
2020-06-22 11:32:04 +00:00
|
|
|
});
|
2020-06-02 14:38:50 +00:00
|
|
|
|
2020-06-18 13:11:03 +00:00
|
|
|
public static List<HitEvent> CreateDistributedHitEvents()
|
2020-06-02 14:38:50 +00:00
|
|
|
{
|
2020-06-18 13:11:03 +00:00
|
|
|
var hitEvents = new List<HitEvent>();
|
2020-06-02 14:38:50 +00:00
|
|
|
|
2020-06-18 13:11:03 +00:00
|
|
|
for (int i = 0; i < 50; i++)
|
2020-06-02 14:38:50 +00:00
|
|
|
{
|
2020-06-18 13:11:03 +00:00
|
|
|
int count = (int)(Math.Pow(25 - Math.Abs(i - 25), 2));
|
2020-06-02 14:38:50 +00:00
|
|
|
|
2020-06-18 13:11:03 +00:00
|
|
|
for (int j = 0; j < count; j++)
|
|
|
|
hitEvents.Add(new HitEvent(i - 25, HitResult.Perfect, new HitCircle(), new HitCircle(), null));
|
2020-06-02 14:38:50 +00:00
|
|
|
}
|
|
|
|
|
2020-06-18 13:11:03 +00:00
|
|
|
return hitEvents;
|
2020-06-02 14:38:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|