2019-01-24 08:43:03 +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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2022-09-21 14:26:25 +00:00
|
|
|
|
using System;
|
2017-09-18 13:32:49 +00:00
|
|
|
|
using System.Collections.Generic;
|
2018-03-02 06:34:31 +00:00
|
|
|
|
using NUnit.Framework;
|
2019-03-05 04:26:54 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2022-07-28 07:12:49 +00:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2017-09-18 13:32:49 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-01-24 05:21:22 +00:00
|
|
|
|
using osu.Framework.Testing;
|
2017-09-18 13:32:49 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2022-07-28 09:20:08 +00:00
|
|
|
|
using osu.Game.Rulesets.Osu;
|
2017-09-18 13:32:49 +00:00
|
|
|
|
using osu.Game.Screens.Play;
|
2022-07-27 07:57:47 +00:00
|
|
|
|
using osu.Game.Screens.Play.HUD;
|
|
|
|
|
using osu.Game.Skinning;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-03-24 16:02:36 +00:00
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
2017-09-18 13:32:49 +00:00
|
|
|
|
{
|
2018-03-02 06:34:31 +00:00
|
|
|
|
[TestFixture]
|
2022-07-27 07:57:47 +00:00
|
|
|
|
public partial class TestSceneSongProgress : SkinnableHUDComponentTestScene
|
2017-09-18 13:32:49 +00:00
|
|
|
|
{
|
2022-07-28 09:20:08 +00:00
|
|
|
|
private GameplayClockContainer gameplayClockContainer = null!;
|
|
|
|
|
|
|
|
|
|
private const double skip_target_time = -2000;
|
2022-07-28 04:24:14 +00:00
|
|
|
|
|
2022-07-28 07:12:49 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2017-09-18 13:32:49 +00:00
|
|
|
|
{
|
2022-07-28 09:20:08 +00:00
|
|
|
|
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
|
|
|
|
|
|
|
|
|
Add(gameplayClockContainer = new MasterGameplayClockContainer(Beatmap.Value, skip_target_time));
|
|
|
|
|
|
2022-08-15 08:36:18 +00:00
|
|
|
|
Dependencies.CacheAs<IGameplayClock>(gameplayClockContainer);
|
2019-07-05 06:05:23 +00:00
|
|
|
|
}
|
2019-03-05 04:26:54 +00:00
|
|
|
|
|
2019-07-05 06:05:23 +00:00
|
|
|
|
[SetUpSteps]
|
|
|
|
|
public void SetupSteps()
|
|
|
|
|
{
|
2022-07-28 07:30:45 +00:00
|
|
|
|
AddStep("reset clock", () => gameplayClockContainer.Reset());
|
2022-07-28 07:19:35 +00:00
|
|
|
|
AddStep("set hit objects", setHitObjects);
|
2019-07-05 06:05:23 +00:00
|
|
|
|
}
|
2019-02-27 10:11:09 +00:00
|
|
|
|
|
2019-07-05 06:05:23 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestDisplay()
|
|
|
|
|
{
|
2022-07-28 09:20:08 +00:00
|
|
|
|
AddStep("seek to intro", () => gameplayClockContainer.Seek(skip_target_time));
|
2022-07-28 07:12:49 +00:00
|
|
|
|
AddStep("start", gameplayClockContainer.Start);
|
|
|
|
|
AddStep("stop", gameplayClockContainer.Stop);
|
2017-09-18 13:32:49 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2022-07-28 04:24:14 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestToggleSeeking()
|
|
|
|
|
{
|
2022-09-21 14:26:25 +00:00
|
|
|
|
void applyToDefaultProgress(Action<DefaultSongProgress> action) =>
|
|
|
|
|
this.ChildrenOfType<DefaultSongProgress>().ForEach(action);
|
2022-07-28 09:20:08 +00:00
|
|
|
|
|
2022-09-21 14:26:25 +00:00
|
|
|
|
AddStep("allow seeking", () => applyToDefaultProgress(s => s.AllowSeeking.Value = true));
|
|
|
|
|
AddStep("hide graph", () => applyToDefaultProgress(s => s.ShowGraph.Value = false));
|
|
|
|
|
AddStep("disallow seeking", () => applyToDefaultProgress(s => s.AllowSeeking.Value = false));
|
|
|
|
|
AddStep("allow seeking", () => applyToDefaultProgress(s => s.AllowSeeking.Value = true));
|
|
|
|
|
AddStep("show graph", () => applyToDefaultProgress(s => s.ShowGraph.Value = true));
|
2022-07-28 04:24:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-28 07:19:35 +00:00
|
|
|
|
private void setHitObjects()
|
2019-07-05 06:05:23 +00:00
|
|
|
|
{
|
|
|
|
|
var objects = new List<HitObject>();
|
|
|
|
|
for (double i = 0; i < 5000; i++)
|
|
|
|
|
objects.Add(new HitObject { StartTime = i });
|
|
|
|
|
|
2022-07-28 07:12:49 +00:00
|
|
|
|
this.ChildrenOfType<SongProgress>().ForEach(progress => progress.Objects = objects);
|
2019-03-05 04:26:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-29 12:40:56 +00:00
|
|
|
|
protected override Drawable CreateDefaultImplementation() => new DefaultSongProgress();
|
2019-02-27 10:11:09 +00:00
|
|
|
|
|
2022-07-29 12:40:56 +00:00
|
|
|
|
protected override Drawable CreateLegacyImplementation() => new LegacySongProgress();
|
2017-09-18 13:32:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|