2025-01-23 15:24:04 +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.
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Utils;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Screens.Select;
|
|
|
|
using osu.Game.Screens.Select.Filter;
|
|
|
|
using osu.Game.Tests.Resources;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.SongSelect
|
|
|
|
{
|
|
|
|
/// <summary>
|
2025-02-06 13:38:51 +08:00
|
|
|
/// Covers common steps which can be used for manual testing.
|
2025-01-23 15:24:04 +08:00
|
|
|
/// </summary>
|
|
|
|
[TestFixture]
|
2025-02-06 13:38:51 +08:00
|
|
|
public partial class TestSceneBeatmapCarouselV2 : BeatmapCarouselV2TestScene
|
2025-01-23 15:24:04 +08:00
|
|
|
{
|
|
|
|
[Test]
|
2025-02-06 13:38:51 +08:00
|
|
|
[Explicit]
|
2025-01-23 15:24:04 +08:00
|
|
|
public void TestBasics()
|
|
|
|
{
|
2025-02-06 13:38:51 +08:00
|
|
|
CreateCarousel();
|
2025-01-23 15:48:03 +08:00
|
|
|
RemoveAllBeatmaps();
|
2025-01-24 18:28:39 +08:00
|
|
|
|
2025-02-06 13:38:51 +08:00
|
|
|
AddBeatmaps(10, randomMetadata: true);
|
|
|
|
AddBeatmaps(10);
|
|
|
|
AddBeatmaps(1);
|
2025-01-23 15:24:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2025-02-06 13:38:51 +08:00
|
|
|
[Explicit]
|
2025-01-23 15:24:04 +08:00
|
|
|
public void TestSorting()
|
|
|
|
{
|
2025-02-06 13:38:51 +08:00
|
|
|
SortBy(new FilterCriteria { Sort = SortMode.Artist });
|
2025-02-03 18:53:46 +08:00
|
|
|
SortBy(new FilterCriteria { Group = GroupMode.Difficulty, Sort = SortMode.Difficulty });
|
2025-02-05 17:59:29 +08:00
|
|
|
SortBy(new FilterCriteria { Group = GroupMode.Artist, Sort = SortMode.Artist });
|
2025-01-23 15:24:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2025-02-06 13:38:51 +08:00
|
|
|
[Explicit]
|
|
|
|
public void TestRemovals()
|
2025-01-23 15:24:04 +08:00
|
|
|
{
|
2025-01-23 15:48:03 +08:00
|
|
|
RemoveFirstBeatmap();
|
2025-02-06 13:38:51 +08:00
|
|
|
RemoveAllBeatmaps();
|
2025-01-23 15:24:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2025-02-06 13:38:51 +08:00
|
|
|
[Explicit]
|
|
|
|
public void TestAddRemoveRepeatedOps()
|
2025-01-23 15:24:04 +08:00
|
|
|
{
|
2025-02-06 13:38:51 +08:00
|
|
|
AddRepeatStep("add beatmaps", () => BeatmapSets.Add(TestResources.CreateTestBeatmapSetInfo(RNG.Next(1, 4))), 20);
|
|
|
|
AddRepeatStep("remove beatmaps", () => BeatmapSets.RemoveAt(RNG.Next(0, BeatmapSets.Count)), 20);
|
|
|
|
}
|
2025-01-23 15:24:04 +08:00
|
|
|
|
2025-02-06 13:38:51 +08:00
|
|
|
[Test]
|
|
|
|
[Explicit]
|
|
|
|
public void TestMasking()
|
|
|
|
{
|
|
|
|
AddStep("disable masking", () => Scroll.Masking = false);
|
|
|
|
AddStep("enable masking", () => Scroll.Masking = true);
|
2025-01-23 15:24:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Explicit]
|
|
|
|
public void TestPerformanceWithManyBeatmaps()
|
|
|
|
{
|
|
|
|
const int count = 200000;
|
|
|
|
|
|
|
|
List<BeatmapSetInfo> generated = new List<BeatmapSetInfo>();
|
|
|
|
|
|
|
|
AddStep($"populate {count} test beatmaps", () =>
|
|
|
|
{
|
|
|
|
generated.Clear();
|
|
|
|
Task.Run(() =>
|
|
|
|
{
|
|
|
|
for (int j = 0; j < count; j++)
|
|
|
|
generated.Add(TestResources.CreateTestBeatmapSetInfo(RNG.Next(1, 4)));
|
|
|
|
}).ConfigureAwait(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddUntilStep("wait for beatmaps populated", () => generated.Count, () => Is.GreaterThan(count / 3));
|
|
|
|
AddUntilStep("this takes a while", () => generated.Count, () => Is.GreaterThan(count / 3 * 2));
|
|
|
|
AddUntilStep("maybe they are done now", () => generated.Count, () => Is.EqualTo(count));
|
|
|
|
|
|
|
|
AddStep("add all beatmaps", () => BeatmapSets.AddRange(generated));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|