2024-06-04 21:36:22 +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 System;
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
2024-07-29 20:20:47 +08:00
|
|
|
using osu.Framework.Allocation;
|
2024-07-30 16:07:38 +08:00
|
|
|
using osu.Framework.Screens;
|
2024-06-04 21:36:22 +08:00
|
|
|
using osu.Game.Online.API;
|
2024-07-29 20:20:47 +08:00
|
|
|
using osu.Game.Online.Metadata;
|
2024-06-04 21:36:22 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
2024-07-29 20:20:47 +08:00
|
|
|
using osu.Game.Overlays;
|
2024-06-04 21:36:22 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
using osu.Game.Tests.Resources;
|
2024-07-29 20:20:47 +08:00
|
|
|
using osu.Game.Tests.Visual.Metadata;
|
2024-06-04 21:36:22 +08:00
|
|
|
using osu.Game.Tests.Visual.OnlinePlay;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.DailyChallenge
|
|
|
|
{
|
|
|
|
public partial class TestSceneDailyChallenge : OnlinePlayTestScene
|
|
|
|
{
|
2024-07-29 20:20:47 +08:00
|
|
|
[Cached(typeof(MetadataClient))]
|
|
|
|
private TestMetadataClient metadataClient = new TestMetadataClient();
|
|
|
|
|
|
|
|
[Cached(typeof(INotificationOverlay))]
|
|
|
|
private NotificationOverlay notificationOverlay = new NotificationOverlay();
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
base.Content.Add(notificationOverlay);
|
2024-07-31 01:53:10 +08:00
|
|
|
base.Content.Add(metadataClient);
|
2024-07-29 20:20:47 +08:00
|
|
|
}
|
|
|
|
|
2024-06-04 21:36:22 +08:00
|
|
|
[Test]
|
|
|
|
public void TestDailyChallenge()
|
|
|
|
{
|
|
|
|
var room = new Room
|
|
|
|
{
|
|
|
|
RoomID = { Value = 1234 },
|
|
|
|
Name = { Value = "Daily Challenge: June 4, 2024" },
|
|
|
|
Playlist =
|
|
|
|
{
|
|
|
|
new PlaylistItem(TestResources.CreateTestBeatmapSetInfo().Beatmaps.First())
|
|
|
|
{
|
|
|
|
RequiredMods = [new APIMod(new OsuModTraceable())],
|
|
|
|
AllowedMods = [new APIMod(new OsuModDoubleTime())]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
EndDate = { Value = DateTimeOffset.Now.AddHours(12) },
|
|
|
|
Category = { Value = RoomCategory.DailyChallenge }
|
|
|
|
};
|
|
|
|
|
|
|
|
AddStep("add room", () => API.Perform(new CreateRoomRequest(room)));
|
|
|
|
AddStep("push screen", () => LoadScreen(new Screens.OnlinePlay.DailyChallenge.DailyChallenge(room)));
|
|
|
|
}
|
2024-07-29 20:20:47 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestNotifications()
|
|
|
|
{
|
|
|
|
var room = new Room
|
|
|
|
{
|
|
|
|
RoomID = { Value = 1234 },
|
|
|
|
Name = { Value = "Daily Challenge: June 4, 2024" },
|
|
|
|
Playlist =
|
|
|
|
{
|
2024-07-31 01:53:10 +08:00
|
|
|
new PlaylistItem(TestResources.CreateTestBeatmapSetInfo().Beatmaps.First())
|
2024-07-29 20:20:47 +08:00
|
|
|
{
|
|
|
|
RequiredMods = [new APIMod(new OsuModTraceable())],
|
|
|
|
AllowedMods = [new APIMod(new OsuModDoubleTime())]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
EndDate = { Value = DateTimeOffset.Now.AddHours(12) },
|
|
|
|
Category = { Value = RoomCategory.DailyChallenge }
|
|
|
|
};
|
|
|
|
|
|
|
|
AddStep("add room", () => API.Perform(new CreateRoomRequest(room)));
|
|
|
|
AddStep("set daily challenge info", () => metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = 1234 });
|
2024-07-30 16:07:38 +08:00
|
|
|
|
|
|
|
Screens.OnlinePlay.DailyChallenge.DailyChallenge screen = null!;
|
|
|
|
AddStep("push screen", () => LoadScreen(screen = new Screens.OnlinePlay.DailyChallenge.DailyChallenge(room)));
|
|
|
|
AddUntilStep("wait for screen", () => screen.IsCurrentScreen());
|
2024-07-29 20:20:47 +08:00
|
|
|
AddStep("daily challenge ended", () => metadataClient.DailyChallengeInfo.Value = null);
|
|
|
|
}
|
2024-06-04 21:36:22 +08:00
|
|
|
}
|
|
|
|
}
|