diff --git a/osu.Game.Tests/Online/TestSceneBeatmapManager.cs b/osu.Game.Tests/Online/TestSceneBeatmapManager.cs index 0ae0186770..4d5bee13f2 100644 --- a/osu.Game.Tests/Online/TestSceneBeatmapManager.cs +++ b/osu.Game.Tests/Online/TestSceneBeatmapManager.cs @@ -5,6 +5,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Testing; using osu.Game.Beatmaps; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Notifications; using osu.Game.Tests.Visual; @@ -16,7 +17,30 @@ namespace osu.Game.Tests.Online private BeatmapManager beatmaps; private ProgressNotification recentNotification; - private static readonly BeatmapSetInfo test_model = new BeatmapSetInfo { OnlineBeatmapSetID = 1 }; + private static readonly BeatmapSetInfo test_db_model = new BeatmapSetInfo + { + OnlineBeatmapSetID = 1, + Metadata = new BeatmapMetadata + { + Artist = "test author", + Title = "test title", + Author = new APIUser + { + Username = "mapper" + } + } + }; + + private static readonly APIBeatmapSet test_online_model = new APIBeatmapSet + { + OnlineID = 2, + Artist = "test author", + Title = "test title", + Author = new APIUser + { + Username = "mapper" + } + }; [BackgroundDependencyLoader] private void load(BeatmapManager beatmaps) @@ -26,25 +50,41 @@ namespace osu.Game.Tests.Online beatmaps.PostNotification = n => recentNotification = n as ProgressNotification; } + private static readonly object[][] notification_test_cases = + { + new object[] { test_db_model }, + new object[] { test_online_model } + }; + + [TestCaseSource(nameof(notification_test_cases))] + public void TestNotificationMessage(IBeatmapSetInfo model) + { + AddStep("clear recent notification", () => recentNotification = null); + AddStep("download beatmap", () => beatmaps.Download(model)); + + AddUntilStep("wait for notification", () => recentNotification != null); + AddUntilStep("notification text correct", () => recentNotification.Text.ToString() == "Downloading test author - test title (mapper)"); + } + [Test] public void TestCancelDownloadFromRequest() { - AddStep("download beatmap", () => beatmaps.Download(test_model)); + AddStep("download beatmap", () => beatmaps.Download(test_db_model)); - AddStep("cancel download from request", () => beatmaps.GetExistingDownload(test_model).Cancel()); + AddStep("cancel download from request", () => beatmaps.GetExistingDownload(test_db_model).Cancel()); - AddUntilStep("is removed from download list", () => beatmaps.GetExistingDownload(test_model) == null); + AddUntilStep("is removed from download list", () => beatmaps.GetExistingDownload(test_db_model) == null); AddAssert("is notification cancelled", () => recentNotification.State == ProgressNotificationState.Cancelled); } [Test] public void TestCancelDownloadFromNotification() { - AddStep("download beatmap", () => beatmaps.Download(test_model)); + AddStep("download beatmap", () => beatmaps.Download(test_db_model)); AddStep("cancel download from notification", () => recentNotification.Close()); - AddUntilStep("is removed from download list", () => beatmaps.GetExistingDownload(test_model) == null); + AddUntilStep("is removed from download list", () => beatmaps.GetExistingDownload(test_db_model) == null); AddAssert("is notification cancelled", () => recentNotification.State == ProgressNotificationState.Cancelled); } } diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index c44b88ad29..5b74bff817 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -23,9 +23,16 @@ namespace osu.Game.Overlays.Notifications { private const float loading_spinner_size = 22; + private LocalisableString text; + public LocalisableString Text { - set => Schedule(() => textDrawable.Text = value); + get => text; + set + { + text = value; + Schedule(() => textDrawable.Text = text); + } } public string CompletionText { get; set; } = "Task has completed!";