Skip to content

Commit 6e93790

Browse files
committed
Reorganise tests to make more logical when manually testing
1 parent 342a66b commit 6e93790

5 files changed

+134
-75
lines changed

osu.Game.Tests/Visual/SongSelect/BeatmapCarouselV2TestScene.cs

-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using osu.Game.Graphics;
1818
using osu.Game.Graphics.Containers;
1919
using osu.Game.Screens.Select;
20-
using osu.Game.Screens.Select.Filter;
2120
using osu.Game.Screens.SelectV2;
2221
using osu.Game.Tests.Beatmaps;
2322
using osu.Game.Tests.Resources;
@@ -54,16 +53,6 @@ protected BeatmapCarouselV2TestScene()
5453
Scheduler.AddDelayed(updateStats, 100, true);
5554
}
5655

57-
[SetUpSteps]
58-
public virtual void SetUpSteps()
59-
{
60-
RemoveAllBeatmaps();
61-
62-
CreateCarousel();
63-
64-
SortBy(new FilterCriteria { Sort = SortMode.Title });
65-
}
66-
6756
protected void CreateCarousel()
6857
{
6958
AddStep("create components", () =>

osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselV2Basics.cs

+22-59
Original file line numberDiff line numberDiff line change
@@ -2,102 +2,65 @@
22
// See the LICENCE file in the repository root for full licence text.
33

44
using System.Collections.Generic;
5-
using System.Linq;
65
using System.Threading.Tasks;
76
using NUnit.Framework;
8-
using osu.Framework.Graphics.Primitives;
9-
using osu.Framework.Testing;
107
using osu.Framework.Utils;
118
using osu.Game.Beatmaps;
129
using osu.Game.Screens.Select;
1310
using osu.Game.Screens.Select.Filter;
14-
using osu.Game.Screens.SelectV2;
1511
using osu.Game.Tests.Resources;
1612

1713
namespace osu.Game.Tests.Visual.SongSelect
1814
{
1915
/// <summary>
20-
/// Currently covers adding and removing of items and scrolling.
21-
/// If we add more tests here, these two categories can likely be split out into separate scenes.
16+
/// Covers common steps which can be used for manual testing.
2217
/// </summary>
2318
[TestFixture]
2419
public partial class TestSceneBeatmapCarouselV2Basics : BeatmapCarouselV2TestScene
2520
{
2621
[Test]
22+
[Explicit]
2723
public void TestBasics()
2824
{
29-
AddBeatmaps(10);
30-
AddBeatmaps(10, randomMetadata: true);
31-
AddBeatmaps(1);
32-
RemoveFirstBeatmap();
25+
CreateCarousel();
3326
RemoveAllBeatmaps();
34-
}
35-
36-
[Test]
37-
public void TestOffScreenLoading()
38-
{
39-
AddStep("disable masking", () => Scroll.Masking = false);
40-
AddStep("enable masking", () => Scroll.Masking = true);
41-
}
4227

43-
[Test]
44-
public void TestAddRemoveOneByOne()
45-
{
46-
AddRepeatStep("add beatmaps", () => BeatmapSets.Add(TestResources.CreateTestBeatmapSetInfo(RNG.Next(1, 4))), 20);
47-
AddRepeatStep("remove beatmaps", () => BeatmapSets.RemoveAt(RNG.Next(0, BeatmapSets.Count)), 20);
28+
AddBeatmaps(10, randomMetadata: true);
29+
AddBeatmaps(10);
30+
AddBeatmaps(1);
4831
}
4932

5033
[Test]
34+
[Explicit]
5135
public void TestSorting()
5236
{
53-
AddBeatmaps(10);
37+
SortBy(new FilterCriteria { Sort = SortMode.Artist });
5438
SortBy(new FilterCriteria { Group = GroupMode.Difficulty, Sort = SortMode.Difficulty });
5539
SortBy(new FilterCriteria { Group = GroupMode.Artist, Sort = SortMode.Artist });
56-
SortBy(new FilterCriteria { Sort = SortMode.Artist });
5740
}
5841

5942
[Test]
60-
public void TestScrollPositionMaintainedOnAddSecondSelected()
43+
[Explicit]
44+
public void TestRemovals()
6145
{
62-
Quad positionBefore = default;
63-
64-
AddBeatmaps(10);
65-
WaitForDrawablePanels();
66-
67-
AddStep("select middle beatmap", () => Carousel.CurrentSelection = BeatmapSets.ElementAt(BeatmapSets.Count - 2));
68-
AddStep("scroll to selected item", () => Scroll.ScrollTo(Scroll.ChildrenOfType<BeatmapPanel>().Single(p => p.Selected.Value)));
69-
70-
WaitForScrolling();
71-
72-
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<BeatmapPanel>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
73-
7446
RemoveFirstBeatmap();
75-
WaitForSorting();
76-
77-
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<BeatmapPanel>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
78-
() => Is.EqualTo(positionBefore));
47+
RemoveAllBeatmaps();
7948
}
8049

8150
[Test]
82-
public void TestScrollPositionMaintainedOnAddLastSelected()
51+
[Explicit]
52+
public void TestAddRemoveRepeatedOps()
8353
{
84-
Quad positionBefore = default;
85-
86-
AddBeatmaps(10);
87-
WaitForDrawablePanels();
88-
89-
AddStep("scroll to last item", () => Scroll.ScrollToEnd(false));
90-
91-
AddStep("select last beatmap", () => Carousel.CurrentSelection = BeatmapSets.Last());
92-
93-
WaitForScrolling();
94-
95-
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<BeatmapPanel>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
54+
AddRepeatStep("add beatmaps", () => BeatmapSets.Add(TestResources.CreateTestBeatmapSetInfo(RNG.Next(1, 4))), 20);
55+
AddRepeatStep("remove beatmaps", () => BeatmapSets.RemoveAt(RNG.Next(0, BeatmapSets.Count)), 20);
56+
}
9657

97-
RemoveFirstBeatmap();
98-
WaitForSorting();
99-
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<BeatmapPanel>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
100-
() => Is.EqualTo(positionBefore));
58+
[Test]
59+
[Explicit]
60+
public void TestMasking()
61+
{
62+
AddStep("disable masking", () => Scroll.Masking = false);
63+
AddStep("enable masking", () => Scroll.Masking = true);
10164
}
10265

10366
[Test]

osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselV2GroupSelection.cs osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselV2DifficultyGrouping.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
namespace osu.Game.Tests.Visual.SongSelect
1313
{
1414
[TestFixture]
15-
public partial class TestSceneBeatmapCarouselV2GroupSelection : BeatmapCarouselV2TestScene
15+
public partial class TestSceneBeatmapCarouselV2DifficultyGrouping : BeatmapCarouselV2TestScene
1616
{
17-
public override void SetUpSteps()
17+
[SetUpSteps]
18+
public void SetUpSteps()
1819
{
1920
RemoveAllBeatmaps();
20-
2121
CreateCarousel();
22-
2322
SortBy(new FilterCriteria { Group = GroupMode.Difficulty, Sort = SortMode.Difficulty });
2423
}
2524

osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselV2Selection.cs osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselV2NoGrouping.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,24 @@
55
using NUnit.Framework;
66
using osu.Framework.Testing;
77
using osu.Game.Beatmaps;
8+
using osu.Game.Screens.Select;
9+
using osu.Game.Screens.Select.Filter;
810
using osu.Game.Screens.SelectV2;
911
using osuTK.Input;
1012

1113
namespace osu.Game.Tests.Visual.SongSelect
1214
{
1315
[TestFixture]
14-
public partial class TestSceneBeatmapCarouselV2Selection : BeatmapCarouselV2TestScene
16+
public partial class TestSceneBeatmapCarouselV2NoGrouping : BeatmapCarouselV2TestScene
1517
{
18+
[SetUpSteps]
19+
public void SetUpSteps()
20+
{
21+
RemoveAllBeatmaps();
22+
CreateCarousel();
23+
SortBy(new FilterCriteria { Sort = SortMode.Title });
24+
}
25+
1626
/// <summary>
1727
/// Keyboard selection via up and down arrows doesn't actually change the selection until
1828
/// the select key is pressed.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using NUnit.Framework;
8+
using osu.Framework.Graphics.Primitives;
9+
using osu.Framework.Testing;
10+
using osu.Framework.Utils;
11+
using osu.Game.Beatmaps;
12+
using osu.Game.Screens.Select;
13+
using osu.Game.Screens.SelectV2;
14+
using osu.Game.Tests.Resources;
15+
16+
namespace osu.Game.Tests.Visual.SongSelect
17+
{
18+
[TestFixture]
19+
public partial class TestSceneBeatmapCarouselV2Scrolling : BeatmapCarouselV2TestScene
20+
{
21+
[SetUpSteps]
22+
public void SetUpSteps()
23+
{
24+
RemoveAllBeatmaps();
25+
CreateCarousel();
26+
SortBy(new FilterCriteria());
27+
}
28+
29+
[Test]
30+
public void TestScrollPositionMaintainedOnAddSecondSelected()
31+
{
32+
Quad positionBefore = default;
33+
34+
AddBeatmaps(10);
35+
WaitForDrawablePanels();
36+
37+
AddStep("select middle beatmap", () => Carousel.CurrentSelection = BeatmapSets.ElementAt(BeatmapSets.Count - 2));
38+
AddStep("scroll to selected item", () => Scroll.ScrollTo(Scroll.ChildrenOfType<BeatmapPanel>().Single(p => p.Selected.Value)));
39+
40+
WaitForScrolling();
41+
42+
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<BeatmapPanel>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
43+
44+
RemoveFirstBeatmap();
45+
WaitForSorting();
46+
47+
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<BeatmapPanel>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
48+
() => Is.EqualTo(positionBefore));
49+
}
50+
51+
[Test]
52+
public void TestScrollPositionMaintainedOnAddLastSelected()
53+
{
54+
Quad positionBefore = default;
55+
56+
AddBeatmaps(10);
57+
WaitForDrawablePanels();
58+
59+
AddStep("scroll to last item", () => Scroll.ScrollToEnd(false));
60+
61+
AddStep("select last beatmap", () => Carousel.CurrentSelection = BeatmapSets.Last());
62+
63+
WaitForScrolling();
64+
65+
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<BeatmapPanel>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
66+
67+
RemoveFirstBeatmap();
68+
WaitForSorting();
69+
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<BeatmapPanel>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
70+
() => Is.EqualTo(positionBefore));
71+
}
72+
73+
[Test]
74+
[Explicit]
75+
public void TestPerformanceWithManyBeatmaps()
76+
{
77+
const int count = 200000;
78+
79+
List<BeatmapSetInfo> generated = new List<BeatmapSetInfo>();
80+
81+
AddStep($"populate {count} test beatmaps", () =>
82+
{
83+
generated.Clear();
84+
Task.Run(() =>
85+
{
86+
for (int j = 0; j < count; j++)
87+
generated.Add(TestResources.CreateTestBeatmapSetInfo(RNG.Next(1, 4)));
88+
}).ConfigureAwait(true);
89+
});
90+
91+
AddUntilStep("wait for beatmaps populated", () => generated.Count, () => Is.GreaterThan(count / 3));
92+
AddUntilStep("this takes a while", () => generated.Count, () => Is.GreaterThan(count / 3 * 2));
93+
AddUntilStep("maybe they are done now", () => generated.Count, () => Is.EqualTo(count));
94+
95+
AddStep("add all beatmaps", () => BeatmapSets.AddRange(generated));
96+
}
97+
}
98+
}

0 commit comments

Comments
 (0)