mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 09:03:50 +09:00
Merge pull request #15341 from peppy/always-unique-test-online-ids
Ensure all test beatmaps have unique OnlineIDs to avoid import conflicts
This commit is contained in:
@ -38,8 +38,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
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, null, audio, Resources, host, Beatmap.Default));
|
||||||
|
|
||||||
manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -204,7 +202,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestDownloadButtonHiddenWhenBeatmapExists()
|
public void TestDownloadButtonHiddenWhenBeatmapExists()
|
||||||
{
|
{
|
||||||
createPlaylist(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo);
|
var beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo;
|
||||||
|
|
||||||
|
AddStep("import beatmap", () => manager.Import(beatmap.BeatmapSet).Wait());
|
||||||
|
|
||||||
|
createPlaylist(beatmap);
|
||||||
|
|
||||||
assertDownloadButtonVisible(false);
|
assertDownloadButtonVisible(false);
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ using osu.Game.Database;
|
|||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Screens.OnlinePlay.Components;
|
||||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
@ -65,10 +66,32 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddUntilStep("Progress details are hidden", () => match.ChildrenOfType<RoomLocalUserInfo>().FirstOrDefault()?.Parent.Alpha == 0);
|
||||||
|
|
||||||
AddStep("start match", () => match.ChildrenOfType<PlaylistsReadyButton>().First().TriggerClick());
|
AddStep("start match", () => match.ChildrenOfType<PlaylistsReadyButton>().First().TriggerClick());
|
||||||
AddUntilStep("player loader loaded", () => Stack.CurrentScreen is PlayerLoader);
|
AddUntilStep("player loader loaded", () => Stack.CurrentScreen is PlayerLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAttemptLimitedMatch()
|
||||||
|
{
|
||||||
|
setupAndCreateRoom(room =>
|
||||||
|
{
|
||||||
|
room.Name.Value = "my awesome room";
|
||||||
|
room.MaxAttempts.Value = 5;
|
||||||
|
room.Host.Value = API.LocalUser.Value;
|
||||||
|
room.RecentParticipants.Add(room.Host.Value);
|
||||||
|
room.EndDate.Value = DateTimeOffset.Now.AddMinutes(5);
|
||||||
|
room.Playlist.Add(new PlaylistItem
|
||||||
|
{
|
||||||
|
Beatmap = { Value = importedBeatmap.Value.Beatmaps.First() },
|
||||||
|
Ruleset = { Value = new OsuRuleset().RulesetInfo }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("Progress details are visible", () => match.ChildrenOfType<RoomLocalUserInfo>().FirstOrDefault()?.Parent.Alpha == 1);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestPlaylistItemSelectedOnCreate()
|
public void TestPlaylistItemSelectedOnCreate()
|
||||||
{
|
{
|
||||||
@ -91,27 +114,16 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
{
|
{
|
||||||
BeatmapSetInfo importedSet = null;
|
BeatmapSetInfo importedSet = null;
|
||||||
|
|
||||||
// this step is required to make sure the further imports actually get online IDs.
|
|
||||||
// all the playlist logic relies on online ID matching.
|
|
||||||
AddStep("remove all matching online IDs", () =>
|
|
||||||
{
|
|
||||||
var existing = manager.QueryBeatmapSets(s => s.OnlineBeatmapSetID == importedBeatmap.Value.OnlineBeatmapSetID).ToList();
|
|
||||||
|
|
||||||
foreach (var s in existing)
|
|
||||||
{
|
|
||||||
s.OnlineBeatmapSetID = null;
|
|
||||||
foreach (var b in s.Beatmaps)
|
|
||||||
b.OnlineBeatmapID = null;
|
|
||||||
manager.Update(s);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep("import altered beatmap", () =>
|
AddStep("import altered beatmap", () =>
|
||||||
{
|
{
|
||||||
IBeatmap beatmap = CreateBeatmap(new OsuRuleset().RulesetInfo);
|
IBeatmap beatmap = CreateBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
|
|
||||||
beatmap.BeatmapInfo.BaseDifficulty.CircleSize = 1;
|
beatmap.BeatmapInfo.BaseDifficulty.CircleSize = 1;
|
||||||
|
|
||||||
|
// intentionally increment online IDs to clash with import below.
|
||||||
|
beatmap.BeatmapInfo.OnlineBeatmapID++;
|
||||||
|
beatmap.BeatmapInfo.BeatmapSet.OnlineBeatmapSetID++;
|
||||||
|
|
||||||
importedSet = manager.Import(beatmap.BeatmapInfo.BeatmapSet).Result.Value;
|
importedSet = manager.Import(beatmap.BeatmapInfo.BeatmapSet).Result.Value;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -144,10 +156,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void importBeatmap()
|
private void importBeatmap() => AddStep("import beatmap", () => importedBeatmap = manager.Import(CreateBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Result);
|
||||||
{
|
|
||||||
AddStep("import beatmap", () => importedBeatmap = manager.Import(CreateBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestPlaylistsRoomSubScreen : PlaylistsRoomSubScreen
|
private class TestPlaylistsRoomSubScreen : PlaylistsRoomSubScreen
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
@ -16,6 +17,9 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
{
|
{
|
||||||
public class TestBeatmap : Beatmap
|
public class TestBeatmap : Beatmap
|
||||||
{
|
{
|
||||||
|
private static int onlineSetID;
|
||||||
|
private static int onlineBeatmapID;
|
||||||
|
|
||||||
public TestBeatmap(RulesetInfo ruleset, bool withHitObjects = true)
|
public TestBeatmap(RulesetInfo ruleset, bool withHitObjects = true)
|
||||||
{
|
{
|
||||||
var baseBeatmap = CreateBeatmap();
|
var baseBeatmap = CreateBeatmap();
|
||||||
@ -31,8 +35,10 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
BeatmapInfo.RulesetID = ruleset.ID ?? 0;
|
BeatmapInfo.RulesetID = ruleset.ID ?? 0;
|
||||||
BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata;
|
BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata;
|
||||||
BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo };
|
BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo };
|
||||||
|
BeatmapInfo.BeatmapSet.OnlineBeatmapSetID = Interlocked.Increment(ref onlineSetID);
|
||||||
BeatmapInfo.Length = 75000;
|
BeatmapInfo.Length = 75000;
|
||||||
BeatmapInfo.OnlineInfo = new APIBeatmap();
|
BeatmapInfo.OnlineInfo = new APIBeatmap();
|
||||||
|
BeatmapInfo.OnlineBeatmapID = Interlocked.Increment(ref onlineBeatmapID);
|
||||||
BeatmapInfo.BeatmapSet.OnlineInfo = new APIBeatmapSet
|
BeatmapInfo.BeatmapSet.OnlineInfo = new APIBeatmapSet
|
||||||
{
|
{
|
||||||
Status = BeatmapSetOnlineStatus.Ranked,
|
Status = BeatmapSetOnlineStatus.Ranked,
|
||||||
|
Reference in New Issue
Block a user