mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 08:22:56 +08:00
Add failing test
This commit is contained in:
parent
2c0140f865
commit
fe8e9d455a
@ -0,0 +1,41 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Screens;
|
||||
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
|
||||
{
|
||||
public class TestScenePlaylistsRoomSubScreen : OnlinePlayTestScene
|
||||
{
|
||||
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>);
|
||||
}
|
||||
}
|
||||
}
|
@ -29,38 +29,28 @@ namespace osu.Game.Tests.Visual.OnlinePlay
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var room = new Room
|
||||
AddRoom(new Room
|
||||
{
|
||||
RoomID = -currentRoomId,
|
||||
Name = $@"Room {currentRoomId}",
|
||||
Host = new APIUser { Username = @"Host" },
|
||||
Duration = TimeSpan.FromSeconds(10),
|
||||
Category = withSpotlightRooms && i % 2 == 0 ? RoomCategory.Spotlight : RoomCategory.Normal,
|
||||
};
|
||||
|
||||
if (withPassword)
|
||||
room.Password = @"password";
|
||||
|
||||
if (ruleset != null)
|
||||
{
|
||||
room.PlaylistItemStats = new Room.RoomPlaylistItemStats
|
||||
{
|
||||
RulesetIDs = new[] { ruleset.OnlineID },
|
||||
};
|
||||
|
||||
room.Playlist =
|
||||
[
|
||||
new PlaylistItem(new BeatmapInfo { Metadata = new BeatmapMetadata() })
|
||||
{
|
||||
RulesetID = ruleset.OnlineID,
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
CreateRoom(room);
|
||||
|
||||
currentRoomId++;
|
||||
Password = withPassword ? @"password" : null,
|
||||
PlaylistItemStats = ruleset == null
|
||||
? null
|
||||
: new Room.RoomPlaylistItemStats { RulesetIDs = [ruleset.OnlineID] },
|
||||
Playlist = ruleset == null
|
||||
? Array.Empty<PlaylistItem>()
|
||||
: [new PlaylistItem(new BeatmapInfo { Metadata = new BeatmapMetadata() }) { RulesetID = ruleset.OnlineID }]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRoom(Room room)
|
||||
{
|
||||
room.RoomID = -currentRoomId;
|
||||
CreateRoom(room);
|
||||
currentRoomId++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user