mirror of
https://github.com/ppy/osu.git
synced 2026-05-17 03:52:35 +08:00
0aff50fbf5
This aims to bring some conformity to naming to make it easier to understand component structure for new components. Renames are pulled out of the song select v2 changes and are more relevant there due to many new classes being added. - `V2` suffix is dropped, with v2 components being moved to a relevant V2 namespace. - Related classes have a prefix of the area they are used. - Experimenting with using partial/nested classes in the song select v2 implementation. Not committing to this yet but want to see how it plays out. - Moved base carousel components to a generic namespace to avoid confusion with actual beatmap carousel implementation.
66 lines
2.4 KiB
C#
66 lines
2.4 KiB
C#
// 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.Linq;
|
|
using NUnit.Framework;
|
|
using osu.Framework.Graphics.Primitives;
|
|
using osu.Framework.Testing;
|
|
using osu.Game.Screens.Select;
|
|
using osu.Game.Screens.SelectV2;
|
|
|
|
namespace osu.Game.Tests.Visual.SongSelectV2
|
|
{
|
|
[TestFixture]
|
|
public partial class TestSceneBeatmapCarouselScrolling : BeatmapCarouselTestScene
|
|
{
|
|
[SetUpSteps]
|
|
public void SetUpSteps()
|
|
{
|
|
RemoveAllBeatmaps();
|
|
CreateCarousel();
|
|
SortBy(new FilterCriteria());
|
|
|
|
AddBeatmaps(10);
|
|
WaitForDrawablePanels();
|
|
}
|
|
|
|
[Test]
|
|
public void TestScrollPositionMaintainedOnAddSecondSelected()
|
|
{
|
|
Quad positionBefore = default;
|
|
|
|
AddStep("select middle beatmap", () => Carousel.CurrentSelection = BeatmapSets.ElementAt(BeatmapSets.Count - 2).Beatmaps.First());
|
|
AddStep("scroll to selected item", () => Scroll.ScrollTo(Scroll.ChildrenOfType<PanelBeatmap>().Single(p => p.Selected.Value)));
|
|
|
|
WaitForScrolling();
|
|
|
|
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<PanelBeatmap>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
|
|
|
|
RemoveFirstBeatmap();
|
|
WaitForSorting();
|
|
|
|
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<PanelBeatmap>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
|
|
() => Is.EqualTo(positionBefore));
|
|
}
|
|
|
|
[Test]
|
|
public void TestScrollPositionMaintainedOnAddLastSelected()
|
|
{
|
|
Quad positionBefore = default;
|
|
|
|
AddStep("scroll to last item", () => Scroll.ScrollToEnd(false));
|
|
|
|
AddStep("select last beatmap", () => Carousel.CurrentSelection = BeatmapSets.Last().Beatmaps.Last());
|
|
|
|
WaitForScrolling();
|
|
|
|
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<PanelBeatmap>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
|
|
|
|
RemoveFirstBeatmap();
|
|
WaitForSorting();
|
|
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<PanelBeatmap>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
|
|
() => Is.EqualTo(positionBefore));
|
|
}
|
|
}
|
|
}
|