2019-01-24 16:43:03 +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.
|
2018-12-27 12:30:36 +08:00
|
|
|
|
2020-12-18 14:18:06 +08:00
|
|
|
using System;
|
2021-07-13 14:10:44 +08:00
|
|
|
using System.Linq;
|
2021-08-03 19:02:31 +08:00
|
|
|
using NUnit.Framework;
|
2021-08-03 19:32:51 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
2018-12-27 12:30:36 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-08-03 19:02:31 +08:00
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Framework.Utils;
|
2021-11-04 17:02:44 +08:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-12-25 12:38:11 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
|
|
|
using osu.Game.Online.Rooms.RoomStatuses;
|
2021-08-12 16:02:55 +08:00
|
|
|
using osu.Game.Overlays;
|
2021-08-05 19:56:14 +08:00
|
|
|
using osu.Game.Rulesets.Osu;
|
2021-08-18 19:53:17 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Lounge;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
2021-08-05 19:56:14 +08:00
|
|
|
using osu.Game.Tests.Beatmaps;
|
2021-07-06 19:04:32 +08:00
|
|
|
using osuTK;
|
2018-12-27 12:30:36 +08:00
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
2018-12-27 12:30:36 +08:00
|
|
|
{
|
2021-07-06 17:10:40 +08:00
|
|
|
public class TestSceneDrawableRoom : OsuTestScene
|
2018-12-27 12:30:36 +08:00
|
|
|
{
|
2021-08-12 16:02:55 +08:00
|
|
|
[Cached]
|
|
|
|
protected readonly OverlayColourProvider ColourProvider = new OverlayColourProvider(OverlayColourScheme.Plum);
|
|
|
|
|
2021-08-19 15:49:08 +08:00
|
|
|
private readonly Bindable<Room> selectedRoom = new Bindable<Room>();
|
|
|
|
|
2021-08-03 19:32:51 +08:00
|
|
|
[Test]
|
|
|
|
public void TestMultipleStatuses()
|
2021-07-06 17:23:37 +08:00
|
|
|
{
|
2021-08-03 19:32:51 +08:00
|
|
|
AddStep("create rooms", () =>
|
2021-07-06 17:23:37 +08:00
|
|
|
{
|
2021-08-03 19:32:51 +08:00
|
|
|
Child = new FillFlowContainer
|
2021-07-13 14:10:44 +08:00
|
|
|
{
|
2021-08-03 19:32:51 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Size = new Vector2(0.9f),
|
|
|
|
Spacing = new Vector2(10),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2021-09-29 19:24:49 +08:00
|
|
|
createLoungeRoom(new Room
|
2021-08-03 19:32:51 +08:00
|
|
|
{
|
2021-09-29 19:24:49 +08:00
|
|
|
Name = { Value = "Multiplayer room" },
|
2021-08-03 19:32:51 +08:00
|
|
|
Status = { Value = new RoomStatusOpen() },
|
|
|
|
EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
|
2021-09-29 19:24:49 +08:00
|
|
|
Type = { Value = MatchType.HeadToHead },
|
2021-08-05 19:56:14 +08:00
|
|
|
Playlist =
|
|
|
|
{
|
|
|
|
new PlaylistItem
|
|
|
|
{
|
|
|
|
Beatmap =
|
|
|
|
{
|
|
|
|
Value = new TestBeatmap(new OsuRuleset().RulesetInfo)
|
|
|
|
{
|
|
|
|
BeatmapInfo =
|
|
|
|
{
|
2021-11-11 16:18:51 +08:00
|
|
|
StarRating = 2.5
|
2021-08-05 19:56:14 +08:00
|
|
|
}
|
|
|
|
}.BeatmapInfo,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-03 19:32:51 +08:00
|
|
|
}),
|
2021-09-29 19:24:49 +08:00
|
|
|
createLoungeRoom(new Room
|
2021-11-04 00:32:18 +08:00
|
|
|
{
|
|
|
|
Name = { Value = "Multiplayer room" },
|
|
|
|
Status = { Value = new RoomStatusOpen() },
|
|
|
|
EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
|
|
|
|
Type = { Value = MatchType.HeadToHead },
|
|
|
|
Playlist =
|
|
|
|
{
|
|
|
|
new PlaylistItem
|
|
|
|
{
|
|
|
|
Beatmap =
|
|
|
|
{
|
|
|
|
Value = new TestBeatmap(new OsuRuleset().RulesetInfo)
|
|
|
|
{
|
|
|
|
BeatmapInfo =
|
|
|
|
{
|
2021-11-11 16:18:51 +08:00
|
|
|
StarRating = 2.5,
|
2021-11-04 00:32:18 +08:00
|
|
|
Metadata =
|
|
|
|
{
|
|
|
|
Artist = "very very very very very very very very very long artist",
|
|
|
|
ArtistUnicode = "very very very very very very very very very long artist",
|
|
|
|
Title = "very very very very very very very very very very very long title",
|
|
|
|
TitleUnicode = "very very very very very very very very very very very long title",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.BeatmapInfo,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
createLoungeRoom(new Room
|
2021-08-03 19:32:51 +08:00
|
|
|
{
|
2021-09-29 19:24:49 +08:00
|
|
|
Name = { Value = "Playlist room with multiple beatmaps" },
|
2021-08-03 19:32:51 +08:00
|
|
|
Status = { Value = new RoomStatusPlaying() },
|
|
|
|
EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
|
2021-08-05 19:56:14 +08:00
|
|
|
Playlist =
|
|
|
|
{
|
|
|
|
new PlaylistItem
|
|
|
|
{
|
|
|
|
Beatmap =
|
|
|
|
{
|
|
|
|
Value = new TestBeatmap(new OsuRuleset().RulesetInfo)
|
|
|
|
{
|
|
|
|
BeatmapInfo =
|
|
|
|
{
|
2021-11-11 16:18:51 +08:00
|
|
|
StarRating = 2.5
|
2021-08-05 19:56:14 +08:00
|
|
|
}
|
|
|
|
}.BeatmapInfo,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new PlaylistItem
|
|
|
|
{
|
|
|
|
Beatmap =
|
|
|
|
{
|
|
|
|
Value = new TestBeatmap(new OsuRuleset().RulesetInfo)
|
|
|
|
{
|
|
|
|
BeatmapInfo =
|
|
|
|
{
|
2021-11-11 16:18:51 +08:00
|
|
|
StarRating = 4.5
|
2021-08-05 19:56:14 +08:00
|
|
|
}
|
|
|
|
}.BeatmapInfo,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-03 19:32:51 +08:00
|
|
|
}),
|
2021-09-29 19:24:49 +08:00
|
|
|
createLoungeRoom(new Room
|
2021-08-03 19:32:51 +08:00
|
|
|
{
|
2021-09-29 19:24:49 +08:00
|
|
|
Name = { Value = "Finished room" },
|
2021-08-03 19:32:51 +08:00
|
|
|
Status = { Value = new RoomStatusEnded() },
|
|
|
|
EndDate = { Value = DateTimeOffset.Now },
|
|
|
|
}),
|
2021-09-29 19:24:49 +08:00
|
|
|
createLoungeRoom(new Room
|
2021-08-03 19:32:51 +08:00
|
|
|
{
|
2021-09-29 19:24:49 +08:00
|
|
|
Name = { Value = "Spotlight room" },
|
2021-08-03 19:32:51 +08:00
|
|
|
Status = { Value = new RoomStatusOpen() },
|
|
|
|
Category = { Value = RoomCategory.Spotlight },
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
2021-07-06 17:23:37 +08:00
|
|
|
}
|
2021-08-03 19:02:31 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestEnableAndDisablePassword()
|
|
|
|
{
|
|
|
|
DrawableRoom drawableRoom = null;
|
|
|
|
Room room = null;
|
|
|
|
|
2021-09-29 19:24:49 +08:00
|
|
|
AddStep("create room", () => Child = drawableRoom = createLoungeRoom(room = new Room
|
2021-08-03 19:02:31 +08:00
|
|
|
{
|
|
|
|
Name = { Value = "Room with password" },
|
|
|
|
Status = { Value = new RoomStatusOpen() },
|
2021-08-19 15:09:17 +08:00
|
|
|
Type = { Value = MatchType.HeadToHead },
|
2021-08-03 19:32:51 +08:00
|
|
|
}));
|
2021-08-03 19:02:31 +08:00
|
|
|
|
2021-09-29 18:15:58 +08:00
|
|
|
AddUntilStep("wait for panel load", () => drawableRoom.ChildrenOfType<DrawableRoomParticipantsList>().Any());
|
2021-09-08 23:39:54 +08:00
|
|
|
|
2021-08-03 19:02:31 +08:00
|
|
|
AddAssert("password icon hidden", () => Precision.AlmostEquals(0, drawableRoom.ChildrenOfType<DrawableRoom.PasswordProtectedIcon>().Single().Alpha));
|
|
|
|
|
|
|
|
AddStep("set password", () => room.Password.Value = "password");
|
|
|
|
AddAssert("password icon visible", () => Precision.AlmostEquals(1, drawableRoom.ChildrenOfType<DrawableRoom.PasswordProtectedIcon>().Single().Alpha));
|
|
|
|
|
|
|
|
AddStep("unset password", () => room.Password.Value = string.Empty);
|
|
|
|
AddAssert("password icon hidden", () => Precision.AlmostEquals(0, drawableRoom.ChildrenOfType<DrawableRoom.PasswordProtectedIcon>().Single().Alpha));
|
|
|
|
}
|
2021-08-03 19:32:51 +08:00
|
|
|
|
2021-09-29 19:24:49 +08:00
|
|
|
private DrawableRoom createLoungeRoom(Room room)
|
2021-08-03 19:32:51 +08:00
|
|
|
{
|
2021-11-04 17:02:44 +08:00
|
|
|
room.Host.Value ??= new APIUser { Username = "peppy", Id = 2 };
|
2021-08-03 19:32:51 +08:00
|
|
|
|
|
|
|
if (room.RecentParticipants.Count == 0)
|
|
|
|
{
|
2021-11-04 17:02:44 +08:00
|
|
|
room.RecentParticipants.AddRange(Enumerable.Range(0, 20).Select(i => new APIUser
|
2021-08-03 19:32:51 +08:00
|
|
|
{
|
|
|
|
Id = i,
|
|
|
|
Username = $"User {i}"
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2021-08-19 15:49:08 +08:00
|
|
|
return new DrawableLoungeRoom(room)
|
|
|
|
{
|
|
|
|
MatchingFilter = true,
|
|
|
|
SelectedRoom = { BindTarget = selectedRoom }
|
|
|
|
};
|
2021-08-03 19:32:51 +08:00
|
|
|
}
|
2018-12-27 12:30:36 +08:00
|
|
|
}
|
|
|
|
}
|