mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 00:02:56 +08:00
make test go indefinitely
This commit is contained in:
parent
a2b15fcdee
commit
56db29d0f5
@ -1,91 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using NUnit.Framework;
|
|
||||||
using osu.Game.Replays;
|
|
||||||
using osu.Game.Rulesets.Osu.Replays;
|
|
||||||
using osu.Game.Rulesets.Osu.UI;
|
|
||||||
using osu.Game.Rulesets.Replays;
|
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests
|
|
||||||
{
|
|
||||||
public partial class TestSceneHitMarker : OsuTestScene
|
|
||||||
{
|
|
||||||
private TestOsuAnalysisContainer analysisContainer;
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestHitMarkers()
|
|
||||||
{
|
|
||||||
createAnalysisContainer();
|
|
||||||
AddStep("enable hit markers", () => analysisContainer.HitMarkerEnabled.Value = true);
|
|
||||||
AddAssert("hit markers visible", () => analysisContainer.HitMarkersVisible);
|
|
||||||
AddStep("disable hit markers", () => analysisContainer.HitMarkerEnabled.Value = false);
|
|
||||||
AddAssert("hit markers not visible", () => !analysisContainer.HitMarkersVisible);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestAimMarker()
|
|
||||||
{
|
|
||||||
createAnalysisContainer();
|
|
||||||
AddStep("enable aim markers", () => analysisContainer.AimMarkersEnabled.Value = true);
|
|
||||||
AddAssert("aim markers visible", () => analysisContainer.AimMarkersVisible);
|
|
||||||
AddStep("disable aim markers", () => analysisContainer.AimMarkersEnabled.Value = false);
|
|
||||||
AddAssert("aim markers not visible", () => !analysisContainer.AimMarkersVisible);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestAimLines()
|
|
||||||
{
|
|
||||||
createAnalysisContainer();
|
|
||||||
AddStep("enable aim lines", () => analysisContainer.AimLinesEnabled.Value = true);
|
|
||||||
AddAssert("aim lines visible", () => analysisContainer.AimLinesVisible);
|
|
||||||
AddStep("disable aim lines", () => analysisContainer.AimLinesEnabled.Value = false);
|
|
||||||
AddAssert("aim lines not visible", () => !analysisContainer.AimLinesVisible);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createAnalysisContainer()
|
|
||||||
{
|
|
||||||
AddStep("create new analysis container", () => Child = analysisContainer = new TestOsuAnalysisContainer(fabricateReplay()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Replay fabricateReplay()
|
|
||||||
{
|
|
||||||
var frames = new List<ReplayFrame>();
|
|
||||||
|
|
||||||
for (int i = 0; i < 50; i++)
|
|
||||||
{
|
|
||||||
frames.Add(new OsuReplayFrame
|
|
||||||
{
|
|
||||||
Time = Time.Current + i * 15,
|
|
||||||
Position = new Vector2(20 + i * 10, 20),
|
|
||||||
Actions =
|
|
||||||
{
|
|
||||||
i % 2 == 0 ? OsuAction.LeftButton : OsuAction.RightButton
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Replay { Frames = frames };
|
|
||||||
}
|
|
||||||
|
|
||||||
private partial class TestOsuAnalysisContainer : OsuAnalysisContainer
|
|
||||||
{
|
|
||||||
public TestOsuAnalysisContainer(Replay replay)
|
|
||||||
: base(replay)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HitMarkersVisible => HitMarkers.Alpha > 0 && HitMarkers.Entries.Any();
|
|
||||||
|
|
||||||
public bool AimMarkersVisible => AimMarkers.Alpha > 0 && AimMarkers.Entries.Any();
|
|
||||||
|
|
||||||
public bool AimLinesVisible => AimLines.Alpha > 0 && AimLines.Vertices.Count > 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
134
osu.Game.Rulesets.Osu.Tests/TestSceneOsuAnalysisContainer.cs
Normal file
134
osu.Game.Rulesets.Osu.Tests/TestSceneOsuAnalysisContainer.cs
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Threading;
|
||||||
|
using osu.Game.Replays;
|
||||||
|
using osu.Game.Rulesets.Osu.Replays;
|
||||||
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
|
using osu.Game.Rulesets.Replays;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
|
{
|
||||||
|
public partial class TestSceneOsuAnalysisContainer : OsuTestScene
|
||||||
|
{
|
||||||
|
private TestOsuAnalysisContainer analysisContainer;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Child = analysisContainer = createAnalysisContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestHitMarkers()
|
||||||
|
{
|
||||||
|
var loop = createAnalysisContainer();
|
||||||
|
AddStep("enable hit markers", () => analysisContainer.AnalysisSettings.HitMarkersEnabled.Value = true);
|
||||||
|
AddAssert("hit markers visible", () => analysisContainer.HitMarkersVisible);
|
||||||
|
AddStep("disable hit markers", () => analysisContainer.AnalysisSettings.HitMarkersEnabled.Value = false);
|
||||||
|
AddAssert("hit markers not visible", () => !analysisContainer.HitMarkersVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAimMarker()
|
||||||
|
{
|
||||||
|
var loop = createAnalysisContainer();
|
||||||
|
AddStep("enable aim markers", () => analysisContainer.AnalysisSettings.AimMarkersEnabled.Value = true);
|
||||||
|
AddAssert("aim markers visible", () => analysisContainer.AimMarkersVisible);
|
||||||
|
AddStep("disable aim markers", () => analysisContainer.AnalysisSettings.AimMarkersEnabled.Value = false);
|
||||||
|
AddAssert("aim markers not visible", () => !analysisContainer.AimMarkersVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAimLines()
|
||||||
|
{
|
||||||
|
var loop = createAnalysisContainer();
|
||||||
|
AddStep("enable aim lines", () => analysisContainer.AnalysisSettings.AimLinesEnabled.Value = true);
|
||||||
|
AddAssert("aim lines visible", () => analysisContainer.AimLinesVisible);
|
||||||
|
AddStep("disable aim lines", () => analysisContainer.AnalysisSettings.AimLinesEnabled.Value = false);
|
||||||
|
AddAssert("aim lines not visible", () => !analysisContainer.AimLinesVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TestOsuAnalysisContainer createAnalysisContainer() => new TestOsuAnalysisContainer();
|
||||||
|
|
||||||
|
private partial class TestOsuAnalysisContainer : OsuAnalysisContainer
|
||||||
|
{
|
||||||
|
public TestOsuAnalysisContainer()
|
||||||
|
: base(new Replay(), new OsuPlayfield())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Replay = fabricateReplay();
|
||||||
|
LoadReplay();
|
||||||
|
|
||||||
|
makeReplayLoop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeReplayLoop()
|
||||||
|
{
|
||||||
|
Scheduler.AddDelayed(() =>
|
||||||
|
{
|
||||||
|
Replay = fabricateReplay();
|
||||||
|
|
||||||
|
HitMarkers.Clear();
|
||||||
|
AimMarkers.Clear();
|
||||||
|
AimLines.Clear();
|
||||||
|
|
||||||
|
LoadReplay();
|
||||||
|
|
||||||
|
makeReplayLoop();
|
||||||
|
}, 15000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HitMarkersVisible => HitMarkers.Alpha > 0 && HitMarkers.Entries.Any();
|
||||||
|
|
||||||
|
public bool AimMarkersVisible => AimMarkers.Alpha > 0 && AimMarkers.Entries.Any();
|
||||||
|
|
||||||
|
public bool AimLinesVisible => AimLines.Alpha > 0 && AimLines.Vertices.Count > 1;
|
||||||
|
|
||||||
|
private Replay fabricateReplay()
|
||||||
|
{
|
||||||
|
var frames = new List<ReplayFrame>();
|
||||||
|
var random = new Random();
|
||||||
|
int posX = 250;
|
||||||
|
int posY = 250;
|
||||||
|
bool leftOrRight = false;
|
||||||
|
|
||||||
|
for (int i = 0; i < 1000; i++)
|
||||||
|
{
|
||||||
|
posX = Math.Clamp(posX + random.Next(-10, 11), 0, 500);
|
||||||
|
posY = Math.Clamp(posY + random.Next(-10, 11), 0, 500);
|
||||||
|
|
||||||
|
var actions = new List<OsuAction>();
|
||||||
|
|
||||||
|
if (i % 20 == 0)
|
||||||
|
{
|
||||||
|
actions.Add(leftOrRight ? OsuAction.LeftButton : OsuAction.RightButton);
|
||||||
|
leftOrRight = !leftOrRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
frames.Add(new OsuReplayFrame
|
||||||
|
{
|
||||||
|
Time = Time.Current + i * 15,
|
||||||
|
Position = new Vector2(posX, posY),
|
||||||
|
Actions = actions
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Replay { Frames = frames };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -142,6 +142,8 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
public void Add(AimPointEntry entry) => lifetimeManager.AddEntry(entry);
|
public void Add(AimPointEntry entry) => lifetimeManager.AddEntry(entry);
|
||||||
|
|
||||||
|
public void Clear() => lifetimeManager.ClearEntries();
|
||||||
|
|
||||||
private void entryBecameAlive(LifetimeEntry entry)
|
private void entryBecameAlive(LifetimeEntry entry)
|
||||||
{
|
{
|
||||||
aliveEntries.Add((AimPointEntry)entry);
|
aliveEntries.Add((AimPointEntry)entry);
|
||||||
|
Loading…
Reference in New Issue
Block a user