mirror of
https://github.com/ppy/osu
synced 2025-01-28 00:32:59 +00:00
Merge pull request #17788 from peppy/fix-replay-download-button-tests
Fix multiple issues in `ReplayDownloadButton` test scene
This commit is contained in:
commit
59ff9be316
@ -26,6 +26,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[TestFixture]
|
||||
public class TestSceneReplayDownloadButton : OsuManualInputManagerTestScene
|
||||
{
|
||||
private const long online_score_id = 2553163309;
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
|
||||
@ -43,6 +45,15 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("delete previous imports", () =>
|
||||
{
|
||||
scoreManager.Delete(s => s.OnlineID == online_score_id);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDisplayStates()
|
||||
{
|
||||
@ -180,7 +191,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
return new APIScore
|
||||
{
|
||||
OnlineID = 2553163309,
|
||||
OnlineID = online_score_id,
|
||||
RulesetID = 0,
|
||||
Beatmap = CreateAPIBeatmapSet(new OsuRuleset().RulesetInfo).Beatmaps.First(),
|
||||
HasReplay = replayAvailable,
|
||||
|
@ -47,7 +47,10 @@ namespace osu.Game.Online
|
||||
Downloader.DownloadBegan += downloadBegan;
|
||||
Downloader.DownloadFailed += downloadFailed;
|
||||
|
||||
realmSubscription = realm.RegisterForNotifications(r => r.All<ScoreInfo>().Where(s => ((s.OnlineID > 0 && s.OnlineID == TrackedItem.OnlineID) || s.Hash == TrackedItem.Hash) && !s.DeletePending), (items, changes, ___) =>
|
||||
realmSubscription = realm.RegisterForNotifications(r => r.All<ScoreInfo>().Where(s =>
|
||||
((s.OnlineID > 0 && s.OnlineID == TrackedItem.OnlineID)
|
||||
|| (!string.IsNullOrEmpty(s.Hash) && s.Hash == TrackedItem.Hash))
|
||||
&& !s.DeletePending), (items, changes, ___) =>
|
||||
{
|
||||
if (items.Any())
|
||||
Schedule(() => UpdateState(DownloadState.LocallyAvailable));
|
||||
|
@ -351,8 +351,7 @@ namespace osu.Game.Stores
|
||||
|
||||
using (var transaction = realm.BeginWrite())
|
||||
{
|
||||
if (existing.DeletePending)
|
||||
UndeleteForReuse(existing);
|
||||
UndeleteForReuse(existing);
|
||||
transaction.Commit();
|
||||
}
|
||||
|
||||
@ -388,9 +387,7 @@ namespace osu.Game.Stores
|
||||
{
|
||||
LogForModel(item, @$"Found existing {HumanisedModelName} for {item} (ID {existing.ID}) – skipping import.");
|
||||
|
||||
if (existing.DeletePending)
|
||||
UndeleteForReuse(existing);
|
||||
|
||||
UndeleteForReuse(existing);
|
||||
transaction.Commit();
|
||||
|
||||
return existing.ToLive(Realm);
|
||||
@ -536,6 +533,10 @@ namespace osu.Game.Stores
|
||||
/// <param name="existing">The existing model.</param>
|
||||
protected virtual void UndeleteForReuse(TModel existing)
|
||||
{
|
||||
if (!existing.DeletePending)
|
||||
return;
|
||||
|
||||
LogForModel(existing, $@"Existing {HumanisedModelName}'s deletion flag has been removed to allow for reuse.");
|
||||
existing.DeletePending = false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user