Show download progress on card body rather than in button

This commit is contained in:
Bartłomiej Dach
2021-11-10 16:03:48 +01:00
parent f090e5ca75
commit 91baaa73f3
5 changed files with 148 additions and 47 deletions

View File

@ -27,6 +27,9 @@ namespace osu.Game.Tests.Visual.Beatmaps
private APIBeatmapSet[] testCases;
[Resolved]
private BeatmapManager beatmaps { get; set; }
#region Test case generation
[BackgroundDependencyLoader]
@ -35,6 +38,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
var normal = CreateAPIBeatmapSet(Ruleset.Value);
normal.HasVideo = true;
normal.HasStoryboard = true;
normal.OnlineID = 241526;
var withStatistics = CreateAPIBeatmapSet(Ruleset.Value);
withStatistics.Title = withStatistics.TitleUnicode = "play favourite stats";
@ -180,6 +184,19 @@ namespace osu.Game.Tests.Visual.Beatmaps
request.TriggerSuccess();
return true;
});
ensureSoleilyRemoved();
}
private void ensureSoleilyRemoved()
{
AddUntilStep("ensure manager loaded", () => beatmaps != null);
AddStep("remove soleily", () =>
{
var beatmap = beatmaps.QueryBeatmapSet(b => b.OnlineBeatmapSetID == 241526);
if (beatmap != null) beatmaps.Delete(beatmap);
});
}
private Drawable createContent(OverlayColourScheme colourScheme, Func<APIBeatmapSet, Drawable> creationFunc)

View File

@ -6,7 +6,6 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables.Cards.Buttons;
using osu.Game.Configuration;
@ -15,7 +14,6 @@ using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Ranking.Expanded.Accuracy;
using osu.Game.Tests.Resources;
using osuTK;
@ -42,22 +40,21 @@ namespace osu.Game.Tests.Visual.Beatmaps
assertDownloadVisible(true);
assertDownloadEnabled(true);
assertProgressVisible(false);
assertPlayVisible(false);
AddAssert("tooltip text correct", () => downloadButton.Download.TooltipText == BeatmapsetsStrings.PanelDownloadAll);
AddStep("set downloading state", () => downloadButton.State.Value = DownloadState.Downloading);
assertDownloadVisible(false);
assertProgressVisible(true);
assertDownloadVisible(true);
assertDownloadEnabled(false);
assertPlayVisible(false);
AddStep("set progress to 30%", () => downloadButton.Progress.Value = 0.3f);
AddStep("set progress to 100%", () => downloadButton.Progress.Value = 1f);
AddStep("set importing state", () => downloadButton.State.Value = DownloadState.Importing);
assertDownloadVisible(true);
assertDownloadEnabled(false);
assertPlayVisible(false);
AddStep("set locally available state", () => downloadButton.State.Value = DownloadState.LocallyAvailable);
assertDownloadVisible(false);
assertProgressVisible(false);
assertPlayVisible(true);
}
@ -113,8 +110,6 @@ namespace osu.Game.Tests.Visual.Beatmaps
private void assertDownloadVisible(bool visible) => AddUntilStep($"download {(visible ? "visible" : "not visible")}", () => downloadButton.Download.IsPresent == visible);
private void assertDownloadEnabled(bool enabled) => AddAssert($"download {(enabled ? "enabled" : "disabled")}", () => downloadButton.Download.Enabled.Value == enabled);
private void assertProgressVisible(bool visible) => AddUntilStep($"progress {(visible ? "visible" : "not visible")}", () => downloadButton.ChildrenOfType<SmoothCircularProgress>().Single().IsPresent == visible);
private void assertPlayVisible(bool visible) => AddUntilStep($"play {(visible ? "visible" : "not visible")}", () => downloadButton.Play.IsPresent == visible);
private static APIBeatmapSet createSoleily() => new APIBeatmapSet