2019-01-24 16:43:03 +08: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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-09-21 22:26:25 +08:00
|
|
|
|
using System;
|
2023-01-18 14:44:19 +08:00
|
|
|
|
using System.Linq;
|
2018-03-02 14:34:31 +08:00
|
|
|
|
using NUnit.Framework;
|
2019-03-05 12:26:54 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2022-07-28 15:12:49 +08:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2017-09-18 21:32:49 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-01-24 13:21:22 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2022-07-28 17:20:08 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu;
|
2023-01-18 15:13:43 +08:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
2017-09-18 21:32:49 +08:00
|
|
|
|
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 partial class TestSceneSongProgress : SkinnableHUDComponentTestScene
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
2022-07-28 17:20:08 +08:00
|
|
|
|
private GameplayClockContainer gameplayClockContainer = null!;
|
|
|
|
|
|
|
|
|
|
private const double skip_target_time = -2000;
|
2022-07-28 12:24:14 +08:00
|
|
|
|
|
2022-07-28 15:12:49 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
2022-07-28 17:20:08 +08:00
|
|
|
|
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
|
|
|
|
|
2023-01-18 15:13:43 +08:00
|
|
|
|
FrameStabilityContainer frameStabilityContainer;
|
2022-07-28 17:20:08 +08:00
|
|
|
|
|
2023-01-18 15:13:43 +08:00
|
|
|
|
Add(gameplayClockContainer = new MasterGameplayClockContainer(Beatmap.Value, skip_target_time)
|
|
|
|
|
{
|
|
|
|
|
Child = frameStabilityContainer = new FrameStabilityContainer
|
|
|
|
|
{
|
|
|
|
|
MaxCatchUpFrames = 1
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2023-01-18 15:29:42 +08:00
|
|
|
|
Dependencies.CacheAs<IGameplayClock>(gameplayClockContainer);
|
|
|
|
|
Dependencies.CacheAs<IFrameStableClock>(frameStabilityContainer);
|
2019-07-05 14:05:23 +08:00
|
|
|
|
}
|
2019-03-05 12:26:54 +08:00
|
|
|
|
|
2019-07-05 14:05:23 +08:00
|
|
|
|
[SetUpSteps]
|
|
|
|
|
public void SetupSteps()
|
|
|
|
|
{
|
2022-07-28 15:30:45 +08:00
|
|
|
|
AddStep("reset clock", () => gameplayClockContainer.Reset());
|
2023-01-18 15:04:07 +08:00
|
|
|
|
AddStep("set hit objects", () => this.ChildrenOfType<SongProgress>().ForEach(progress => progress.Objects = Beatmap.Value.Beatmap.HitObjects));
|
2023-01-18 14:44:19 +08:00
|
|
|
|
AddStep("hook seeking", () =>
|
|
|
|
|
{
|
2023-01-18 14:45:16 +08:00
|
|
|
|
applyToDefaultProgress(d => d.ChildrenOfType<DefaultSongProgressBar>().Single().OnSeek += t => gameplayClockContainer.Seek(t));
|
2023-01-18 14:44:19 +08:00
|
|
|
|
applyToArgonProgress(d => d.ChildrenOfType<ArgonSongProgressBar>().Single().OnSeek += t => gameplayClockContainer.Seek(t));
|
|
|
|
|
});
|
2022-07-28 17:20:08 +08:00
|
|
|
|
AddStep("seek to intro", () => gameplayClockContainer.Seek(skip_target_time));
|
2023-01-18 17:12:40 +08:00
|
|
|
|
AddStep("start", () => gameplayClockContainer.Start());
|
2017-09-18 21:32:49 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-07-28 12:24:14 +08:00
|
|
|
|
[Test]
|
2023-01-18 14:44:19 +08:00
|
|
|
|
public void TestBasic()
|
2022-07-28 12:24:14 +08:00
|
|
|
|
{
|
2023-01-18 14:44:19 +08:00
|
|
|
|
AddToggleStep("toggle seeking", b =>
|
|
|
|
|
{
|
|
|
|
|
applyToDefaultProgress(s => s.Interactive.Value = b);
|
|
|
|
|
applyToArgonProgress(s => s.Interactive.Value = b);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddToggleStep("toggle graph", b =>
|
|
|
|
|
{
|
|
|
|
|
applyToDefaultProgress(s => s.ShowGraph.Value = b);
|
|
|
|
|
applyToArgonProgress(s => s.ShowGraph.Value = b);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddStep("stop", gameplayClockContainer.Stop);
|
2022-07-28 12:24:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-18 14:44:19 +08:00
|
|
|
|
private void applyToArgonProgress(Action<ArgonSongProgress> action) =>
|
|
|
|
|
this.ChildrenOfType<ArgonSongProgress>().ForEach(action);
|
|
|
|
|
|
|
|
|
|
private void applyToDefaultProgress(Action<DefaultSongProgress> action) =>
|
|
|
|
|
this.ChildrenOfType<DefaultSongProgress>().ForEach(action);
|
|
|
|
|
|
2022-07-29 20:40:56 +08:00
|
|
|
|
protected override Drawable CreateDefaultImplementation() => new DefaultSongProgress();
|
2019-02-27 18:11:09 +08:00
|
|
|
|
|
2023-01-10 05:07:18 +08:00
|
|
|
|
protected override Drawable CreateArgonImplementation() => new ArgonSongProgress();
|
|
|
|
|
|
2022-07-29 20:40:56 +08:00
|
|
|
|
protected override Drawable CreateLegacyImplementation() => new LegacySongProgress();
|
2017-09-18 21:32:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|