Merge branch 'master' into playlist-test-coverage

This commit is contained in:
Bartłomiej Dach
2022-01-18 20:17:48 +01:00
committed by GitHub
238 changed files with 3708 additions and 5394 deletions

View File

@ -44,6 +44,10 @@ namespace osu.Game.Tests.Visual.Playlists
requestComplete = false;
totalCount = 0;
bindHandler();
// beatmap is required to be an actual beatmap so the scores can get their scores correctly calculated for standardised scoring.
// else the tests that rely on ordering will fall over.
Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
});
[Test]

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
@ -18,6 +19,7 @@ using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Screens.OnlinePlay.Match.Components;
using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Screens.Play;
using osu.Game.Tests.Beatmaps;
@ -33,13 +35,14 @@ namespace osu.Game.Tests.Visual.Playlists
private TestPlaylistsRoomSubScreen match;
private ILive<BeatmapSetInfo> importedBeatmap;
private BeatmapSetInfo importedBeatmap;
[BackgroundDependencyLoader]
private void load(GameHost host, AudioManager audio)
{
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, API, audio, Resources, host, Beatmap.Default));
Dependencies.Cache(ContextFactory);
}
[SetUpSteps]
@ -64,13 +67,15 @@ namespace osu.Game.Tests.Visual.Playlists
room.EndDate.Value = DateTimeOffset.Now.AddMinutes(5);
room.Playlist.Add(new PlaylistItem
{
Beatmap = { Value = importedBeatmap.Value.Beatmaps.First() },
Beatmap = { Value = importedBeatmap.Beatmaps.First() },
Ruleset = { Value = new OsuRuleset().RulesetInfo }
});
});
AddUntilStep("Progress details are hidden", () => match.ChildrenOfType<RoomLocalUserInfo>().FirstOrDefault()?.Parent.Alpha == 0);
AddUntilStep("Leaderboard shows two aggregate scores", () => match.ChildrenOfType<MatchLeaderboardScore>().Count(s => s.ScoreText.Text != "0") == 2);
AddStep("start match", () => match.ChildrenOfType<PlaylistsReadyButton>().First().TriggerClick());
AddUntilStep("player loader loaded", () => Stack.CurrentScreen is PlayerLoader);
}
@ -87,7 +92,7 @@ namespace osu.Game.Tests.Visual.Playlists
room.EndDate.Value = DateTimeOffset.Now.AddMinutes(5);
room.Playlist.Add(new PlaylistItem
{
Beatmap = { Value = importedBeatmap.Value.Beatmaps.First() },
Beatmap = { Value = importedBeatmap.Beatmaps.First() },
Ruleset = { Value = new OsuRuleset().RulesetInfo }
});
});
@ -104,7 +109,7 @@ namespace osu.Game.Tests.Visual.Playlists
room.Host.Value = API.LocalUser.Value;
room.Playlist.Add(new PlaylistItem
{
Beatmap = { Value = importedBeatmap.Value.Beatmaps.First() },
Beatmap = { Value = importedBeatmap.Beatmaps.First() },
Ruleset = { Value = new OsuRuleset().RulesetInfo }
});
});
@ -121,9 +126,9 @@ namespace osu.Game.Tests.Visual.Playlists
AddStep("store real beatmap values", () =>
{
realHash = importedBeatmap.Value.Beatmaps[0].MD5Hash;
realOnlineId = importedBeatmap.Value.Beatmaps[0].OnlineID ?? -1;
realOnlineSetId = importedBeatmap.Value.OnlineID ?? -1;
realHash = importedBeatmap.Beatmaps[0].MD5Hash;
realOnlineId = importedBeatmap.Beatmaps[0].OnlineID;
realOnlineSetId = importedBeatmap.OnlineID;
});
AddStep("import modified beatmap", () =>
@ -133,6 +138,7 @@ namespace osu.Game.Tests.Visual.Playlists
BeatmapInfo =
{
OnlineID = realOnlineId,
Metadata = new BeatmapMetadata(),
BeatmapSet =
{
OnlineID = realOnlineSetId
@ -143,6 +149,8 @@ namespace osu.Game.Tests.Visual.Playlists
modifiedBeatmap.HitObjects.Clear();
modifiedBeatmap.HitObjects.Add(new HitCircle { StartTime = 5000 });
Debug.Assert(modifiedBeatmap.BeatmapInfo.BeatmapSet != null);
manager.Import(modifiedBeatmap.BeatmapInfo.BeatmapSet).WaitSafely();
});
@ -159,6 +167,7 @@ namespace osu.Game.Tests.Visual.Playlists
{
MD5Hash = realHash,
OnlineID = realOnlineId,
Metadata = new BeatmapMetadata(),
BeatmapSet = new BeatmapSetInfo
{
OnlineID = realOnlineSetId,
@ -185,6 +194,8 @@ namespace osu.Game.Tests.Visual.Playlists
},
};
Debug.Assert(originalBeatmap.BeatmapInfo.BeatmapSet != null);
manager.Import(originalBeatmap.BeatmapInfo.BeatmapSet).WaitSafely();
});
@ -202,7 +213,14 @@ namespace osu.Game.Tests.Visual.Playlists
});
}
private void importBeatmap() => AddStep("import beatmap", () => importedBeatmap = manager.Import(CreateBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).GetResultSafely());
private void importBeatmap() => AddStep("import beatmap", () =>
{
var beatmap = CreateBeatmap(new OsuRuleset().RulesetInfo);
Debug.Assert(beatmap.BeatmapInfo.BeatmapSet != null);
importedBeatmap = manager.Import(beatmap.BeatmapInfo.BeatmapSet).GetResultSafely()?.Value.Detach();
});
private class TestPlaylistsRoomSubScreen : PlaylistsRoomSubScreen
{