2019-12-27 11:37:36 +08:00
|
|
|
// 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 NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Overlays.Notifications;
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Online
|
|
|
|
{
|
|
|
|
[HeadlessTest]
|
|
|
|
public class TestSceneBeatmapManager : OsuTestScene
|
|
|
|
{
|
|
|
|
private BeatmapManager beatmaps;
|
|
|
|
private ProgressNotification recentNotification;
|
|
|
|
|
|
|
|
private static readonly BeatmapSetInfo test_model = new BeatmapSetInfo { OnlineBeatmapSetID = 1 };
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(BeatmapManager beatmaps)
|
|
|
|
{
|
|
|
|
this.beatmaps = beatmaps;
|
|
|
|
|
|
|
|
beatmaps.PostNotification = n => recentNotification = n as ProgressNotification;
|
|
|
|
}
|
|
|
|
|
2020-01-07 10:47:00 +08:00
|
|
|
[Test]
|
|
|
|
public void TestCancelDownloadFromRequest()
|
2019-12-27 11:37:36 +08:00
|
|
|
{
|
|
|
|
AddStep("download beatmap", () => beatmaps.Download(test_model));
|
|
|
|
|
2020-01-07 10:47:00 +08:00
|
|
|
AddStep("cancel download from request", () => beatmaps.GetExistingDownload(test_model).Cancel());
|
|
|
|
|
|
|
|
AddUntilStep("is removed from download list", () => beatmaps.GetExistingDownload(test_model) == null);
|
|
|
|
AddAssert("is notification cancelled", () => recentNotification.State == ProgressNotificationState.Cancelled);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCancelDownloadFromNotification()
|
|
|
|
{
|
|
|
|
AddStep("download beatmap", () => beatmaps.Download(test_model));
|
|
|
|
|
|
|
|
AddStep("cancel download from notification", () => recentNotification.Close());
|
2019-12-27 11:37:36 +08:00
|
|
|
|
|
|
|
AddUntilStep("is removed from download list", () => beatmaps.GetExistingDownload(test_model) == null);
|
|
|
|
AddAssert("is notification cancelled", () => recentNotification.State == ProgressNotificationState.Cancelled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|