1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-23 18:22:56 +08:00
osu-lazer/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsRoomSubScreen.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
2.7 KiB
C#
Raw Normal View History

2024-11-21 17:04:44 +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;
2024-11-22 16:55:28 +08:00
using System.Linq;
2024-11-21 17:04:44 +08:00
using NUnit.Framework;
2024-11-22 16:55:28 +08:00
using osu.Framework.Allocation;
2024-11-21 17:04:44 +08:00
using osu.Framework.Screens;
2024-11-22 16:55:28 +08:00
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
2024-11-21 17:04:44 +08:00
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Rooms;
using osu.Game.Online.Rooms.RoomStatuses;
using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Tests.Visual.OnlinePlay;
namespace osu.Game.Tests.Visual.Playlists
{
2024-11-21 17:38:56 +08:00
public partial class TestScenePlaylistsRoomSubScreen : OnlinePlayTestScene
2024-11-21 17:04:44 +08:00
{
2024-11-22 16:55:28 +08:00
[Resolved]
private IAPIProvider api { get; set; } = null!;
2024-11-21 17:04:44 +08:00
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager;
[Test]
public void TestStatusUpdateOnEnter()
{
Room room = null!;
PlaylistsRoomSubScreen roomScreen = null!;
AddStep("create room", () =>
{
RoomManager.AddRoom(room = new Room
{
Name = @"Test Room",
Host = new APIUser { Username = @"Host" },
Category = RoomCategory.Normal,
EndDate = DateTimeOffset.Now.AddMinutes(-1)
});
});
AddStep("push screen", () => LoadScreen(roomScreen = new PlaylistsRoomSubScreen(room)));
AddUntilStep("wait for screen load", () => roomScreen.IsCurrentScreen());
AddAssert("status is still ended", () => roomScreen.Room.Status, Is.TypeOf<RoomStatusEnded>);
}
2024-11-22 16:55:28 +08:00
[Test]
public void TestCloseButtonGoesAwayAfterGracePeriod()
{
Room room = null!;
PlaylistsRoomSubScreen roomScreen = null!;
AddStep("create room", () =>
{
RoomManager.AddRoom(room = new Room
{
Name = @"Test Room",
Host = api.LocalUser.Value,
Category = RoomCategory.Normal,
StartDate = DateTimeOffset.Now.AddMinutes(-5).AddSeconds(3),
EndDate = DateTimeOffset.Now.AddMinutes(30)
});
});
AddStep("push screen", () => LoadScreen(roomScreen = new PlaylistsRoomSubScreen(room)));
AddUntilStep("wait for screen load", () => roomScreen.IsCurrentScreen());
AddAssert("close button present", () => roomScreen.ChildrenOfType<DangerousRoundedButton>().Any());
AddUntilStep("wait for close button to disappear", () => !roomScreen.ChildrenOfType<DangerousRoundedButton>().Any());
}
2024-11-21 17:04:44 +08:00
}
}