1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 18:07:28 +08:00
osu-lazer/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
3.0 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
2022-06-17 15:37:17 +08:00
#nullable disable
2017-09-18 21:32:49 +08:00
using System.Collections.Generic;
using System.Linq;
2018-03-02 14:34:31 +08:00
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
2017-09-18 21:32:49 +08:00
using osu.Framework.Graphics;
using osu.Framework.Testing;
2017-09-18 21:32:49 +08:00
using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Play;
2022-07-27 15:57:47 +08:00
using osu.Game.Screens.Play.HUD;
using osu.Game.Skinning;
2018-04-13 17:19:50 +08:00
2019-03-25 00:02:36 +08:00
namespace osu.Game.Tests.Visual.Gameplay
2017-09-18 21:32:49 +08:00
{
2018-03-02 14:34:31 +08:00
[TestFixture]
2022-07-27 15:57:47 +08:00
public class TestSceneSongProgress : SkinnableHUDComponentTestScene
2017-09-18 21:32:49 +08:00
{
private DefaultSongProgress progress => this.ChildrenOfType<DefaultSongProgress>().Single();
private GameplayClockContainer gameplayClockContainer;
private const double gameplay_start_time = -2000;
[BackgroundDependencyLoader]
private void load()
2017-09-18 21:32:49 +08:00
{
var working = CreateWorkingBeatmap(Ruleset.Value);
working.LoadTrack();
Add(gameplayClockContainer = new MasterGameplayClockContainer(working, gameplay_start_time));
Dependencies.CacheAs(gameplayClockContainer);
Dependencies.CacheAs(gameplayClockContainer.GameplayClock);
2019-07-05 14:05:23 +08:00
}
2019-07-05 14:05:23 +08:00
[SetUpSteps]
public void SetupSteps()
{
AddStep("reset clock", () => gameplayClockContainer.Reset(false));
2019-07-05 14:05:23 +08:00
}
2019-02-27 18:11:09 +08:00
2019-07-05 14:05:23 +08:00
[Test]
public void TestDisplay()
{
AddStep("display max values", displayMaxValues);
AddStep("seek to intro", () => gameplayClockContainer.Seek(gameplay_start_time));
AddStep("start", gameplayClockContainer.Start);
AddStep("stop", gameplayClockContainer.Stop);
2017-09-18 21:32:49 +08:00
}
2018-04-13 17:19:50 +08:00
[Test]
public void TestToggleSeeking()
{
AddStep("allow seeking", () => progress.AllowSeeking.Value = true);
AddStep("hide graph", () => progress.ShowGraph.Value = false);
AddStep("disallow seeking", () => progress.AllowSeeking.Value = false);
AddStep("allow seeking", () => progress.AllowSeeking.Value = true);
AddStep("show graph", () => progress.ShowGraph.Value = true);
}
2019-07-05 14:05:23 +08:00
private void displayMaxValues()
{
var objects = new List<HitObject>();
for (double i = 0; i < 5000; i++)
objects.Add(new HitObject { StartTime = i });
setObjects(objects);
2019-07-05 14:05:23 +08:00
}
private void setObjects(List<HitObject> objects)
2019-07-05 14:05:23 +08:00
{
this.ChildrenOfType<SongProgress>().ForEach(progress => progress.Objects = objects);
}
protected override Drawable CreateDefaultImplementation() => new DefaultSongProgress
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
};
2019-02-27 18:11:09 +08:00
protected override Drawable CreateLegacyImplementation() => new LegacySongProgress
2019-02-27 18:11:09 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};
2017-09-18 21:32:49 +08:00
}
}