1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-13 20:33:35 +08:00
Files
osu-lazer/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselScrolling.cs
T
Bartłomiej Dach 090fe44f86 Assorted test deflaking (#37191)
A few quick ones from https://github.com/ppy/osu/issues/37190.

## [Rewrite `TestSceneDeleteLocalScore` to have less context menu
containers (and hopefully no longer
flake)](https://github.com/ppy/osu/commit/ea0bc5b72374056d1749f8058f4874b7ef66a241)

As seen in
https://github.com/ppy/osu/actions/runs/23890777748#user-content-r3s3.

This is a speculative fix but I'm feeling somewhat confident about this
one.

`BeatmapLeaderboardWedge` has TWO separate `ContextMenuContainer`s
itself, and the test mentioned here was bringing a third. I have a
feeling that the test flaking may have something to do with the fact
that the test logic would attempt to click a menu item on specifically
ONE of the three context menus. My bet is that when it fails, it's
because it's trying the wrong one, but I don't have reproduction.

## [Wait for text to appear in flaking
`TestSceneDrawableRoomPlaylist.TestSelectableMouseHandling`
test](https://github.com/ppy/osu/commit/9d62eea8b56a0eb013e8116db0d38424b500876f)

As seen in
https://github.com/ppy/osu/actions/runs/23888446400#user-content-r1s1.

Speculative. Banking on the fact that it takes time to load the sprite
texts.

## [Remove all tests from `TestSceneWikiMarkdownContainer` dependent on
existence of wiki on
dev](https://github.com/ppy/osu/commit/8f319f91c98510b84e915bb61ec147618a584ce1)

Deletes a flaky as seen in
https://github.com/ppy/osu/actions/runs/23878899702#user-content-r2s2.

The year is 2026 and LLM scrapers hammer [the
entire](https://sourcehut.org/blog/2025-04-15-you-cannot-have-our-users-data/)
[internet](https://blog.metabrainz.org/2025/12/11/we-cant-have-nice-things-because-of-ai-scrapers/)
all over to scrape whatever ounce of Human Content there is left to feed
the Moloch so that it can regurgitate it back in the form of The Most
Average Speech You've Ever Read. We are not immune to this, and as such
the LLM homunculi have hit the dev.ppy.sh wiki instance enough times for
it to just completely [be banished to the
blagole](https://www.youtube.com/watch?v=AfA_2Ku1aJY).

Which means I get to freely delete flaky tests that should never have
been running as part of CI because they're completely useless now and
it's not like we're ever turning them back on again.

## [Use equality check in
`TestSceneBeatmapCarouselScrolling.TestScrollPositionMaintainedOnRemove_SecondSelected`
that's less sensitive to floating
point](https://github.com/ppy/osu/commit/6f2a1de58f7e816830c430e89117ee4c594f529d)

As seen in
https://github.com/ppy/osu/actions/runs/23826420794#user-content-r0s1.
2026-04-04 00:17:31 +09:00

135 lines
5.6 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.Framework.Utils;
using osu.Game.Screens.Select;
namespace osu.Game.Tests.Visual.SongSelect
{
[TestFixture]
public partial class TestSceneBeatmapCarouselScrolling : BeatmapCarouselTestScene
{
[SetUpSteps]
public void SetUpSteps()
{
RemoveAllBeatmaps();
CreateCarousel();
AddBeatmaps(10);
WaitForDrawablePanels();
}
[Test]
public void TestScrollPositionMaintainedOnRemove_SecondSelected()
{
Quad positionBefore = default;
AddStep("select middle beatmap", () => Carousel.CurrentGroupedBeatmap = new GroupedBeatmap(null, BeatmapSets.ElementAt(BeatmapSets.Count - 2).Beatmaps.First()));
WaitForScrolling();
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<PanelBeatmap>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
RemoveFirstBeatmap();
WaitForFiltering();
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<PanelBeatmap>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
() => Is.EqualTo(positionBefore).Using<Quad, Quad>((expected, actual)
=> Precision.AlmostEquals(expected.TopLeft, actual.TopLeft)
&& Precision.AlmostEquals(expected.TopRight, actual.TopRight)
&& Precision.AlmostEquals(expected.BottomLeft, actual.BottomLeft)
&& Precision.AlmostEquals(expected.BottomRight, actual.BottomRight)));
}
[Test]
public void TestScrollPositionMaintainedOnRemove_SecondSelected_WithUserScroll()
{
Quad positionBefore = default;
AddStep("select middle beatmap", () => Carousel.CurrentGroupedBeatmap = new GroupedBeatmap(null, BeatmapSets.ElementAt(BeatmapSets.Count - 2).Beatmaps.First()));
WaitForScrolling();
AddStep("override scroll with user scroll", () =>
{
InputManager.MoveMouseTo(Scroll.ScreenSpaceDrawQuad.Centre);
InputManager.ScrollVerticalBy(-1);
});
WaitForScrolling();
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<PanelBeatmap>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
RemoveFirstBeatmap();
WaitForFiltering();
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<PanelBeatmap>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
() => Is.EqualTo(positionBefore));
}
[Test]
public void TestScrollPositionMaintainedOnRemove_LastSelected()
{
Quad positionBefore = default;
AddStep("scroll to end", () => Scroll.ScrollToEnd(false));
AddStep("select last beatmap", () => Carousel.CurrentGroupedBeatmap = new GroupedBeatmap(null, BeatmapSets.Last().Beatmaps.Last()));
WaitForScrolling();
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<PanelBeatmap>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
RemoveFirstBeatmap();
WaitForFiltering();
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<PanelBeatmap>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
() => Is.EqualTo(positionBefore));
}
[Test]
public void TestScrollToSelectionAfterFilter()
{
Quad positionBefore = default;
AddStep("select first beatmap", () => Carousel.CurrentGroupedBeatmap = new GroupedBeatmap(null, BeatmapSets.First().Beatmaps.First()));
WaitForScrolling();
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<PanelBeatmap>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
AddStep("scroll to end", () => Scroll.ScrollToEnd());
WaitForScrolling();
ApplyToFilterAndWaitForFilter("search", f => f.SearchText = "Some");
AddUntilStep("select screen position returned to selection", () => Carousel.ChildrenOfType<PanelBeatmap>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
() => Is.EqualTo(positionBefore));
}
[Test]
public void TestScrollToSelectionAfterFilter_WithUserScroll()
{
Quad positionBefore = default;
AddStep("select first beatmap", () => Carousel.CurrentGroupedBeatmap = new GroupedBeatmap(null, BeatmapSets.First().Beatmaps.First()));
WaitForScrolling();
AddStep("override scroll with user scroll", () =>
{
InputManager.MoveMouseTo(Scroll.ScreenSpaceDrawQuad.Centre);
InputManager.ScrollVerticalBy(-1);
});
WaitForScrolling();
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<PanelBeatmap>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
ApplyToFilterAndWaitForFilter("search", f => f.SearchText = "Some");
AddUntilStep("select screen position returned to selection", () => Carousel.ChildrenOfType<PanelBeatmap>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
() => Is.EqualTo(positionBefore));
}
}
}