Merge branch 'master' into global-bindable-thread-safety

This commit is contained in:
Dean Herbert
2022-01-18 18:12:00 +09:00
248 changed files with 3685 additions and 5403 deletions

View File

@ -126,14 +126,14 @@ namespace osu.Game.Tests.Visual
{
public WorkingBeatmap TestBeatmap;
public TestBeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host, WorkingBeatmap defaultBeatmap)
public TestBeatmapManager(Storage storage, RealmContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host, WorkingBeatmap defaultBeatmap)
: base(storage, contextFactory, rulesets, api, audioManager, resources, host, defaultBeatmap)
{
}
protected override BeatmapModelManager CreateBeatmapModelManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, GameHost host)
protected override BeatmapModelManager CreateBeatmapModelManager(Storage storage, RealmContextFactory contextFactory, RulesetStore rulesets, BeatmapOnlineLookupQueue onlineLookupQueue)
{
return new TestBeatmapModelManager(storage, contextFactory, rulesets, api, host);
return new TestBeatmapModelManager(storage, contextFactory, rulesets, onlineLookupQueue);
}
protected override WorkingBeatmapCache CreateWorkingBeatmapCache(AudioManager audioManager, IResourceStore<byte[]> resources, IResourceStore<byte[]> storage, WorkingBeatmap defaultBeatmap, GameHost host)
@ -157,8 +157,8 @@ namespace osu.Game.Tests.Visual
internal class TestBeatmapModelManager : BeatmapModelManager
{
public TestBeatmapModelManager(Storage storage, IDatabaseContextFactory databaseContextFactory, RulesetStore rulesetStore, IAPIProvider apiProvider, GameHost gameHost)
: base(storage, databaseContextFactory, rulesetStore, gameHost)
public TestBeatmapModelManager(Storage storage, RealmContextFactory databaseContextFactory, RulesetStore rulesetStore, BeatmapOnlineLookupQueue beatmapOnlineLookupQueue)
: base(databaseContextFactory, storage, beatmapOnlineLookupQueue)
{
}

View File

@ -409,18 +409,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
public override Task<APIBeatmap> GetAPIBeatmap(int beatmapId, CancellationToken cancellationToken = default)
{
IBeatmapSetInfo? set = roomManager.ServerSideRooms.SelectMany(r => r.Playlist)
.FirstOrDefault(p => p.BeatmapID == beatmapId)?.Beatmap.Value.BeatmapSet
?? beatmaps.QueryBeatmap(b => b.OnlineID == beatmapId)?.BeatmapSet;
IBeatmapInfo? beatmap = roomManager.ServerSideRooms.SelectMany(r => r.Playlist)
.FirstOrDefault(p => p.BeatmapID == beatmapId)?.Beatmap.Value
?? beatmaps.QueryBeatmap(b => b.OnlineID == beatmapId);
if (set == null)
if (beatmap == null)
throw new InvalidOperationException("Beatmap not found.");
return Task.FromResult(new APIBeatmap
{
BeatmapSet = new APIBeatmapSet { OnlineID = set.OnlineID },
BeatmapSet = new APIBeatmapSet { OnlineID = beatmap.BeatmapSet?.OnlineID ?? -1 },
OnlineID = beatmapId,
Checksum = set.Beatmaps.First(b => b.OnlineID == beatmapId).MD5Hash
Checksum = beatmap.MD5Hash
});
}

View File

@ -70,6 +70,29 @@ namespace osu.Game.Tests.Visual.OnlinePlay
return true;
}
case GetRoomLeaderboardRequest roomLeaderboardRequest:
roomLeaderboardRequest.TriggerSuccess(new APILeaderboard
{
Leaderboard = new List<APIUserScoreAggregate>
{
new APIUserScoreAggregate
{
TotalScore = 1000000,
TotalAttempts = 5,
CompletedBeatmaps = 2,
User = new APIUser { Username = "best user" }
},
new APIUserScoreAggregate
{
TotalScore = 50,
TotalAttempts = 1,
CompletedBeatmaps = 1,
User = new APIUser { Username = "worst user" }
}
}
});
return true;
case PartRoomRequest partRoomRequest:
partRoomRequest.TriggerSuccess();
return true;

View File

@ -75,9 +75,9 @@ namespace osu.Game.Tests.Visual
/// <remarks>
/// In interactive runs (ie. VisualTests) this will use the user's database if <see cref="UseFreshStoragePerRun"/> is not set to <c>true</c>.
/// </remarks>
protected DatabaseContextFactory ContextFactory => contextFactory.Value;
protected RealmContextFactory ContextFactory => contextFactory.Value;
private Lazy<DatabaseContextFactory> contextFactory;
private Lazy<RealmContextFactory> contextFactory;
/// <summary>
/// Whether a fresh storage should be initialised per test (method) run.
@ -119,14 +119,7 @@ namespace osu.Game.Tests.Visual
Resources = parent.Get<OsuGameBase>().Resources;
contextFactory = new Lazy<DatabaseContextFactory>(() =>
{
var factory = new DatabaseContextFactory(LocalStorage);
using (var usage = factory.Get())
usage.Migrate();
return factory;
});
contextFactory = new Lazy<RealmContextFactory>(() => new RealmContextFactory(LocalStorage, "client"));
RecycleLocalStorage(false);
@ -312,9 +305,6 @@ namespace osu.Game.Tests.Visual
if (MusicController?.TrackLoaded == true)
MusicController.Stop();
if (contextFactory?.IsValueCreated == true)
contextFactory.Value.ResetDatabase();
RecycleLocalStorage(true);
}

View File

@ -12,8 +12,11 @@ namespace osu.Game.Tests.Visual
{
base.Update();
// note that this will override any mod rate application
Beatmap.Value.Track.Tempo.Value = Clock.Rate;
if (Beatmap.Value.TrackLoaded)
{
// note that this will override any mod rate application
Beatmap.Value.Track.Tempo.Value = Clock.Rate;
}
}
}
}

View File

@ -94,6 +94,9 @@ namespace osu.Game.Tests.Visual
[BackgroundDependencyLoader]
private void load()
{
if (!LoadedBeatmapSuccessfully)
return;
ScoreProcessor.NewJudgement += r => Results.Add(r);
}
}