mirror of
https://github.com/osukey/osukey.git
synced 2025-06-09 21:37:59 +09:00
test: adapt and create tests to cover new components
This commit is contained in:
parent
91cde5ffbf
commit
48deef4056
BIN
osu.Game.Tests/Resources/Archives/modified-argon-20221024.osk
Normal file
BIN
osu.Game.Tests/Resources/Archives/modified-argon-20221024.osk
Normal file
Binary file not shown.
@ -41,6 +41,8 @@ namespace osu.Game.Tests.Skins
|
|||||||
"Archives/modified-default-20220818.osk",
|
"Archives/modified-default-20220818.osk",
|
||||||
// Covers longest combo counter
|
// Covers longest combo counter
|
||||||
"Archives/modified-default-20221012.osk",
|
"Archives/modified-default-20221012.osk",
|
||||||
|
// Covers Argon variant of song progress bar
|
||||||
|
"Archives/modified-argon-20221024.osk",
|
||||||
// Covers TextElement and BeatmapInfoDrawable
|
// Covers TextElement and BeatmapInfoDrawable
|
||||||
"Archives/modified-default-20221102.osk"
|
"Archives/modified-default-20221102.osk"
|
||||||
};
|
};
|
||||||
|
@ -20,6 +20,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
var implementation = skin is LegacySkin
|
var implementation = skin is LegacySkin
|
||||||
? CreateLegacyImplementation()
|
? CreateLegacyImplementation()
|
||||||
|
: skin is ArgonSkin
|
||||||
|
? CreateArgonImplementation()
|
||||||
: CreateDefaultImplementation();
|
: CreateDefaultImplementation();
|
||||||
|
|
||||||
implementation.Anchor = Anchor.Centre;
|
implementation.Anchor = Anchor.Centre;
|
||||||
@ -29,6 +31,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
});
|
});
|
||||||
|
|
||||||
protected abstract Drawable CreateDefaultImplementation();
|
protected abstract Drawable CreateDefaultImplementation();
|
||||||
|
protected virtual Drawable CreateArgonImplementation() => CreateDefaultImplementation();
|
||||||
protected abstract Drawable CreateLegacyImplementation();
|
protected abstract Drawable CreateLegacyImplementation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
// 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.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public partial class TestSceneArgonSongProgressGraph : OsuTestScene
|
||||||
|
{
|
||||||
|
private TestArgonSongProgressGraph? graph;
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public void SetupSteps()
|
||||||
|
{
|
||||||
|
AddStep("add new big graph", () =>
|
||||||
|
{
|
||||||
|
if (graph != null)
|
||||||
|
{
|
||||||
|
graph.Expire();
|
||||||
|
graph = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Add(graph = new TestArgonSongProgressGraph
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 200,
|
||||||
|
Anchor = Anchor.TopLeft,
|
||||||
|
Origin = Anchor.TopLeft,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGraphRecreation()
|
||||||
|
{
|
||||||
|
AddAssert("ensure not created", () => graph!.CreationCount == 0);
|
||||||
|
AddStep("display values", displayRandomValues);
|
||||||
|
AddUntilStep("wait for creation count", () => graph!.CreationCount == 1);
|
||||||
|
AddRepeatStep("new values", displayRandomValues, 5);
|
||||||
|
AddWaitStep("wait some", 5);
|
||||||
|
AddAssert("ensure recreation debounced", () => graph!.CreationCount == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void displayRandomValues()
|
||||||
|
{
|
||||||
|
Debug.Assert(graph != null);
|
||||||
|
var objects = new List<HitObject>();
|
||||||
|
for (double i = 0; i < 5000; i += RNG.NextDouble() * 10 + i / 1000)
|
||||||
|
objects.Add(new HitObject { StartTime = i });
|
||||||
|
|
||||||
|
graph.Objects = objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
private partial class TestArgonSongProgressGraph : ArgonSongProgressGraph
|
||||||
|
{
|
||||||
|
public int CreationCount { get; private set; }
|
||||||
|
|
||||||
|
protected override void RecreateGraph()
|
||||||
|
{
|
||||||
|
base.RecreateGraph();
|
||||||
|
CreationCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -72,6 +72,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
protected override Drawable CreateDefaultImplementation() => new DefaultSongProgress();
|
protected override Drawable CreateDefaultImplementation() => new DefaultSongProgress();
|
||||||
|
|
||||||
|
protected override Drawable CreateArgonImplementation() => new ArgonSongProgress();
|
||||||
|
|
||||||
protected override Drawable CreateLegacyImplementation() => new LegacySongProgress();
|
protected override Drawable CreateLegacyImplementation() => new LegacySongProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user