mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Add basic handling of download failures
This commit is contained in:
@ -24,6 +24,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
private TestSceneOnlinePlayBeatmapAvailabilityTracker.TestBeatmapModelDownloader beatmapDownloader = null!;
|
private TestSceneOnlinePlayBeatmapAvailabilityTracker.TestBeatmapModelDownloader beatmapDownloader = null!;
|
||||||
|
|
||||||
|
private BeatmapSetInfo testBeatmapSetInfo = null!;
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
@ -34,15 +36,11 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
private UpdateBeatmapSetButton? getUpdateButton() => carousel.ChildrenOfType<UpdateBeatmapSetButton>().SingleOrDefault();
|
||||||
public void TestBeatmapWithOnlineUpdates()
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
{
|
{
|
||||||
ArchiveDownloadRequest<IBeatmapSetInfo>? downloadRequest = null;
|
|
||||||
|
|
||||||
UpdateBeatmapSetButton? getUpdateButton() => carousel.ChildrenOfType<UpdateBeatmapSetButton>().SingleOrDefault();
|
|
||||||
|
|
||||||
var testBeatmapSetInfo = TestResources.CreateTestBeatmapSetInfo();
|
|
||||||
|
|
||||||
AddStep("create carousel", () =>
|
AddStep("create carousel", () =>
|
||||||
{
|
{
|
||||||
Child = carousel = new BeatmapCarousel
|
Child = carousel = new BeatmapCarousel
|
||||||
@ -50,7 +48,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
BeatmapSets = new List<BeatmapSetInfo>
|
BeatmapSets = new List<BeatmapSetInfo>
|
||||||
{
|
{
|
||||||
testBeatmapSetInfo,
|
(testBeatmapSetInfo = TestResources.CreateTestBeatmapSetInfo()),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -58,6 +56,12 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddUntilStep("wait for load", () => carousel.BeatmapSetsLoaded);
|
AddUntilStep("wait for load", () => carousel.BeatmapSetsLoaded);
|
||||||
|
|
||||||
AddAssert("update button not visible", () => getUpdateButton() == null);
|
AddAssert("update button not visible", () => getUpdateButton() == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDownloadToCompletion()
|
||||||
|
{
|
||||||
|
ArchiveDownloadRequest<IBeatmapSetInfo>? downloadRequest = null;
|
||||||
|
|
||||||
AddStep("update online hash", () =>
|
AddStep("update online hash", () =>
|
||||||
{
|
{
|
||||||
@ -77,6 +81,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
return downloadRequest != null;
|
return downloadRequest != null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for button disabled", () => getUpdateButton()?.Enabled.Value == false);
|
||||||
|
|
||||||
AddUntilStep("progress download to completion", () =>
|
AddUntilStep("progress download to completion", () =>
|
||||||
{
|
{
|
||||||
if (downloadRequest is TestSceneOnlinePlayBeatmapAvailabilityTracker.TestDownloadRequest testRequest)
|
if (downloadRequest is TestSceneOnlinePlayBeatmapAvailabilityTracker.TestDownloadRequest testRequest)
|
||||||
@ -100,5 +106,49 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDownloadFailed()
|
||||||
|
{
|
||||||
|
ArchiveDownloadRequest<IBeatmapSetInfo>? downloadRequest = null;
|
||||||
|
|
||||||
|
AddStep("update online hash", () =>
|
||||||
|
{
|
||||||
|
testBeatmapSetInfo.Beatmaps.First().OnlineMD5Hash = "different hash";
|
||||||
|
testBeatmapSetInfo.Beatmaps.First().LastOnlineUpdate = DateTimeOffset.Now;
|
||||||
|
|
||||||
|
carousel.UpdateBeatmapSet(testBeatmapSetInfo);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("update button visible", () => getUpdateButton() != null);
|
||||||
|
|
||||||
|
AddStep("click button", () => getUpdateButton()?.TriggerClick());
|
||||||
|
|
||||||
|
AddUntilStep("wait for download started", () =>
|
||||||
|
{
|
||||||
|
downloadRequest = beatmapDownloader.GetExistingDownload(testBeatmapSetInfo);
|
||||||
|
return downloadRequest != null;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for button disabled", () => getUpdateButton()?.Enabled.Value == false);
|
||||||
|
|
||||||
|
AddUntilStep("progress download to failure", () =>
|
||||||
|
{
|
||||||
|
if (downloadRequest is TestSceneOnlinePlayBeatmapAvailabilityTracker.TestDownloadRequest testRequest)
|
||||||
|
{
|
||||||
|
testRequest.SetProgress(testRequest.Progress + 0.1f);
|
||||||
|
|
||||||
|
if (testRequest.Progress >= 0.5f)
|
||||||
|
{
|
||||||
|
testRequest.TriggerFailure(new Exception());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for button enabled", () => getUpdateButton()?.Enabled.Value == true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ namespace osu.Game.Database
|
|||||||
notification.State = ProgressNotificationState.Cancelled;
|
notification.State = ProgressNotificationState.Cancelled;
|
||||||
|
|
||||||
if (!(error is OperationCanceledException))
|
if (!(error is OperationCanceledException))
|
||||||
Logger.Error(error, $"{importer.HumanisedModelName.Titleize()} download failed!");
|
Logger.Error(error, $"{importer?.HumanisedModelName.Titleize()} download failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,12 +90,9 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
TooltipText = "Update beatmap with online changes";
|
|
||||||
|
|
||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
beatmapDownloader.Download(beatmapSetInfo);
|
beatmapDownloader.Download(beatmapSetInfo);
|
||||||
|
|
||||||
attachExistingDownload();
|
attachExistingDownload();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -116,7 +113,15 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
Enabled.Value = false;
|
Enabled.Value = false;
|
||||||
TooltipText = string.Empty;
|
TooltipText = string.Empty;
|
||||||
|
|
||||||
download.DownloadProgressed += progress => progressFill.ResizeWidthTo(progress, 100);
|
download.DownloadProgressed += progress => progressFill.ResizeWidthTo(progress, 100, Easing.OutQuint);
|
||||||
|
download.Failure += _ => attachExistingDownload();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Enabled.Value = true;
|
||||||
|
TooltipText = "Update beatmap with online changes";
|
||||||
|
|
||||||
|
progressFill.ResizeWidthTo(0, 100, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user