Skip to content

Commit aa03df9

Browse files
authored
Merge pull request #19441 from peppy/test-working-beatmap-unfuck
Reduce calls to `LoadTrack` by implicitly running on test/dummy classes
2 parents 5003eb5 + a21aee4 commit aa03df9

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

osu.Game.Tests/Gameplay/TestSceneMasterGameplayClockContainer.cs

-6
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ public void TestStartThenElapsedTime()
4141
AddStep("create container", () =>
4242
{
4343
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
44-
working.LoadTrack();
45-
4644
Child = gameplayClockContainer = new MasterGameplayClockContainer(working, 0);
4745
});
4846

@@ -58,8 +56,6 @@ public void TestElapseThenReset()
5856
AddStep("create container", () =>
5957
{
6058
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
61-
working.LoadTrack();
62-
6359
Child = gameplayClockContainer = new MasterGameplayClockContainer(working, 0);
6460
});
6561

@@ -102,8 +98,6 @@ public void TestSeekPerformsInGameplayTime(
10298
AddStep("create container", () =>
10399
{
104100
working = new ClockBackedTestWorkingBeatmap(new OsuRuleset().RulesetInfo, new FramedClock(new ManualClock()), Audio);
105-
working.LoadTrack();
106-
107101
Child = gameplayClockContainer = new MasterGameplayClockContainer(working, 0);
108102

109103
gameplayClockContainer.Reset(startClock: !whileStopped);

osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs

-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public void TestSamplePlaybackAtZero()
6969
AddStep("create container", () =>
7070
{
7171
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
72-
working.LoadTrack();
7372

7473
Add(gameplayContainer = new MasterGameplayClockContainer(working, 0)
7574
{
@@ -96,7 +95,6 @@ public void TestSampleHasLifetimeEndWithInitialClockTime()
9695
AddStep("create container", () =>
9796
{
9897
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
99-
working.LoadTrack();
10098

10199
const double start_time = 1000;
102100

osu.Game.Tests/Skins/TestSceneBeatmapSkinResources.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ private void load()
3232
imported?.PerformRead(s =>
3333
{
3434
beatmap = beatmaps.GetWorkingBeatmap(s.Beatmaps[0]);
35-
beatmap.LoadTrack();
3635
});
3736
}
3837

3938
[Test]
4039
public void TestRetrieveOggSample() => AddAssert("sample is non-null", () => beatmap.Skin.GetSample(new SampleInfo("sample")) != null);
4140

4241
[Test]
43-
public void TestRetrieveOggTrack() => AddAssert("track is non-null", () => !(beatmap.Track is TrackVirtual));
42+
public void TestRetrieveOggTrack() => AddAssert("track is non-null", () =>
43+
{
44+
using (var track = beatmap.LoadTrack())
45+
return track is not TrackVirtual;
46+
});
4447
}
4548
}

osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public void SetUp() => Schedule(() =>
3333
increment = skip_time;
3434

3535
var working = CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo));
36-
working.LoadTrack();
3736

3837
Child = gameplayClockContainer = new MasterGameplayClockContainer(working, 0)
3938
{

osu.Game/Beatmaps/DummyWorkingBeatmap.cs

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public DummyWorkingBeatmap([NotNull] AudioManager audio, TextureStore textures)
4444
}, audio)
4545
{
4646
this.textures = textures;
47+
48+
// We are guaranteed to have a virtual track.
49+
// To ease usability, ensure the track is available from point of construction.
50+
LoadTrack();
4751
}
4852

4953
protected override IBeatmap GetBeatmap() => new Beatmap();

osu.Game/Overlays/FirstRunSetup/ScreenUIScale.cs

-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
161161
private void load(AudioManager audio, TextureStore textures, RulesetStore rulesets)
162162
{
163163
Beatmap.Value = new DummyWorkingBeatmap(audio, textures);
164-
Beatmap.Value.LoadTrack();
165164

166165
Ruleset.Value = rulesets.AvailableRulesets.First();
167166

osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ public TestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null, AudioM
3131
this.storyboard = storyboard;
3232
}
3333

34-
public override bool TrackLoaded => true;
35-
3634
public override bool BeatmapLoaded => true;
3735

3836
protected override IBeatmap GetBeatmap() => beatmap;

osu.Game/Tests/Visual/OsuTestScene.cs

+5
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ public ClockBackedTestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IF
365365
}
366366
else
367367
track = audio?.Tracks.GetVirtual(trackLength);
368+
369+
// We are guaranteed to have a virtual track.
370+
// To ease testability, ensure the track is available from point of construction.
371+
// (Usually this would be done by MusicController for us).
372+
LoadTrack();
368373
}
369374

370375
~ClockBackedTestWorkingBeatmap()

0 commit comments

Comments
 (0)