Add test coverage for download button

This commit is contained in:
Bartłomiej Dach
2021-10-23 15:01:53 +02:00
parent 423b1397fc
commit c65e7a4436
3 changed files with 225 additions and 4 deletions

View File

@ -1,16 +1,71 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Online;
using osu.Game.Overlays;
using osuTK;
namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
{
public class DownloadButton : BeatmapCardIconButton
public class DownloadButton : CompositeDrawable
{
protected readonly DownloadIcon Download;
protected readonly PlayIcon Play;
protected readonly BeatmapDownloadTracker Tracker;
private readonly CircularProgress downloadProgress;
public DownloadButton(APIBeatmapSet beatmapSet)
{
Icon.Icon = FontAwesome.Solid.FileDownload;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
InternalChildren = new Drawable[]
{
Tracker = new BeatmapDownloadTracker(beatmapSet),
Download = new DownloadIcon(),
downloadProgress = new CircularProgress
{
Size = new Vector2(16),
InnerRadius = 0.1f,
},
Play = new PlayIcon()
};
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
downloadProgress.Colour = colourProvider.Highlight1;
}
protected override void LoadComplete()
{
base.LoadComplete();
((IBindable<double>)downloadProgress.Current).BindTo(Tracker.Progress);
}
protected class DownloadIcon : BeatmapCardIconButton
{
public DownloadIcon()
{
Icon.Icon = FontAwesome.Solid.Download;
}
}
protected class PlayIcon : BeatmapCardIconButton
{
public PlayIcon()
{
Icon.Icon = FontAwesome.Regular.PlayCircle;
}
}
// TODO: implement behaviour