2019-03-04 12:24:19 +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-11-16 13:22:42 +08:00
|
|
|
|
|
2023-06-12 20:56:37 +08:00
|
|
|
|
using System.Linq;
|
2023-06-19 00:48:54 +08:00
|
|
|
|
using NUnit.Framework;
|
2018-11-16 13:22:42 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-06-17 15:28:58 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-11-16 13:22:42 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2023-06-12 20:56:37 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2021-11-04 17:02:44 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2018-11-16 13:22:42 +08:00
|
|
|
|
using osu.Game.Online.Chat;
|
2023-06-12 20:56:37 +08:00
|
|
|
|
using osu.Game.Overlays.Chat;
|
2018-11-16 13:22:42 +08:00
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
|
using osu.Game.Tournament.Components;
|
2018-11-17 09:40:44 +08:00
|
|
|
|
using osu.Game.Tournament.IPC;
|
2019-06-18 13:51:48 +08:00
|
|
|
|
using osu.Game.Tournament.Models;
|
2018-11-16 13:22:42 +08:00
|
|
|
|
|
2019-06-18 14:28:36 +08:00
|
|
|
|
namespace osu.Game.Tournament.Tests.Components
|
2018-11-16 13:22:42 +08:00
|
|
|
|
{
|
2019-06-18 12:44:38 +08:00
|
|
|
|
public partial class TestSceneTournamentMatchChatDisplay : OsuTestScene
|
2018-11-16 13:22:42 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly Channel testChannel = new Channel();
|
2019-06-18 12:44:38 +08:00
|
|
|
|
private readonly Channel testChannel2 = new Channel();
|
2018-11-16 13:22:42 +08:00
|
|
|
|
|
2021-11-04 17:02:44 +08:00
|
|
|
|
private readonly APIUser admin = new APIUser
|
2018-11-16 13:22:42 +08:00
|
|
|
|
{
|
|
|
|
|
Username = "HappyStick",
|
|
|
|
|
Id = 2,
|
|
|
|
|
Colour = "f2ca34"
|
|
|
|
|
};
|
|
|
|
|
|
2022-06-18 07:33:26 +08:00
|
|
|
|
private readonly TournamentUser redUser = new TournamentUser
|
2018-11-16 13:22:42 +08:00
|
|
|
|
{
|
|
|
|
|
Username = "BanchoBot",
|
2022-06-18 06:46:37 +08:00
|
|
|
|
OnlineID = 3,
|
2018-11-16 13:22:42 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-06-18 07:33:26 +08:00
|
|
|
|
private readonly TournamentUser blueUser = new TournamentUser
|
2018-11-16 13:22:42 +08:00
|
|
|
|
{
|
|
|
|
|
Username = "Zallius",
|
2022-06-18 06:46:37 +08:00
|
|
|
|
OnlineID = 4,
|
2018-11-16 13:22:42 +08:00
|
|
|
|
};
|
|
|
|
|
|
2023-06-24 03:04:29 +08:00
|
|
|
|
private readonly TournamentUser blueUserWithCustomColour = new TournamentUser
|
|
|
|
|
{
|
|
|
|
|
Username = "nekodex",
|
|
|
|
|
OnlineID = 5,
|
|
|
|
|
};
|
|
|
|
|
|
2018-11-16 13:22:42 +08:00
|
|
|
|
[Cached]
|
|
|
|
|
private LadderInfo ladderInfo = new LadderInfo();
|
|
|
|
|
|
2018-11-17 09:40:44 +08:00
|
|
|
|
[Cached]
|
|
|
|
|
private MatchIPCInfo matchInfo = new MatchIPCInfo(); // hide parent
|
|
|
|
|
|
2019-06-18 12:44:38 +08:00
|
|
|
|
private readonly TournamentMatchChatDisplay chatDisplay;
|
2018-11-16 13:22:42 +08:00
|
|
|
|
|
2019-06-18 12:44:38 +08:00
|
|
|
|
public TestSceneTournamentMatchChatDisplay()
|
|
|
|
|
{
|
|
|
|
|
Add(chatDisplay = new TournamentMatchChatDisplay
|
2018-11-16 13:22:42 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
chatDisplay.Channel.Value = testChannel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2019-06-18 12:44:38 +08:00
|
|
|
|
AddStep("message from admin", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
2018-11-16 13:22:42 +08:00
|
|
|
|
{
|
|
|
|
|
Sender = admin,
|
|
|
|
|
Content = "I am a wang!"
|
|
|
|
|
}));
|
2023-06-25 19:46:58 +08:00
|
|
|
|
|
2023-06-25 23:39:36 +08:00
|
|
|
|
AddStep("set current match", () => ladderInfo.CurrentMatch.Value = new TournamentMatch
|
2023-06-25 19:46:58 +08:00
|
|
|
|
{
|
|
|
|
|
Team1 =
|
|
|
|
|
{
|
|
|
|
|
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { redUser } }
|
|
|
|
|
},
|
|
|
|
|
Team2 =
|
|
|
|
|
{
|
|
|
|
|
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { blueUser, blueUserWithCustomColour } }
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-11-16 13:22:42 +08:00
|
|
|
|
|
2019-06-18 12:44:38 +08:00
|
|
|
|
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
2018-11-16 13:22:42 +08:00
|
|
|
|
{
|
2022-06-18 07:33:26 +08:00
|
|
|
|
Sender = redUser.ToAPIUser(),
|
2018-11-16 13:22:42 +08:00
|
|
|
|
Content = "I am team red."
|
|
|
|
|
}));
|
|
|
|
|
|
2023-06-12 20:56:37 +08:00
|
|
|
|
AddUntilStep("message from team red is red color", () =>
|
2023-06-19 00:48:54 +08:00
|
|
|
|
this.ChildrenOfType<DrawableChatUsername>().Last().AccentColour, () => Is.EqualTo(TournamentGame.COLOUR_RED));
|
2023-06-12 20:56:37 +08:00
|
|
|
|
|
2019-06-18 12:44:38 +08:00
|
|
|
|
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
2018-11-16 13:22:42 +08:00
|
|
|
|
{
|
2022-06-18 07:33:26 +08:00
|
|
|
|
Sender = redUser.ToAPIUser(),
|
2018-11-16 13:22:42 +08:00
|
|
|
|
Content = "I plan to win!"
|
|
|
|
|
}));
|
|
|
|
|
|
2019-06-18 12:44:38 +08:00
|
|
|
|
AddStep("message from team blue", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
2018-11-16 13:22:42 +08:00
|
|
|
|
{
|
2022-06-18 07:33:26 +08:00
|
|
|
|
Sender = blueUser.ToAPIUser(),
|
2018-11-16 13:22:42 +08:00
|
|
|
|
Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand."
|
|
|
|
|
}));
|
|
|
|
|
|
2023-06-12 20:56:37 +08:00
|
|
|
|
AddUntilStep("message from team blue is blue color", () =>
|
2023-06-19 00:48:54 +08:00
|
|
|
|
this.ChildrenOfType<DrawableChatUsername>().Last().AccentColour, () => Is.EqualTo(TournamentGame.COLOUR_BLUE));
|
2023-06-12 20:56:37 +08:00
|
|
|
|
|
2023-06-24 03:04:29 +08:00
|
|
|
|
var userWithCustomColour = blueUserWithCustomColour.ToAPIUser();
|
|
|
|
|
userWithCustomColour.Colour = "#e45678";
|
|
|
|
|
|
|
|
|
|
AddStep("message from team blue with custom colour", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
|
|
|
|
{
|
|
|
|
|
Sender = userWithCustomColour,
|
|
|
|
|
Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand."
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
AddUntilStep("message from team blue is blue color", () =>
|
|
|
|
|
this.ChildrenOfType<DrawableChatUsername>().Last().AccentColour, () => Is.EqualTo(TournamentGame.COLOUR_BLUE));
|
|
|
|
|
|
|
|
|
|
AddUntilStep("message from user with custom colour is inverted", () =>
|
|
|
|
|
this.ChildrenOfType<DrawableChatUsername>().Last().Inverted, () => Is.EqualTo(true));
|
|
|
|
|
|
2019-06-18 12:44:38 +08:00
|
|
|
|
AddStep("message from admin", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
2018-11-16 13:22:42 +08:00
|
|
|
|
{
|
|
|
|
|
Sender = admin,
|
|
|
|
|
Content = "Okay okay, calm down guys. Let's do this!"
|
|
|
|
|
}));
|
2019-06-18 12:44:38 +08:00
|
|
|
|
|
2019-11-11 20:05:36 +08:00
|
|
|
|
AddStep("multiple messages", () => testChannel.AddNewMessages(
|
|
|
|
|
new Message(nextMessageId())
|
|
|
|
|
{
|
|
|
|
|
Sender = admin,
|
|
|
|
|
Content = "I spam you!"
|
|
|
|
|
},
|
|
|
|
|
new Message(nextMessageId())
|
|
|
|
|
{
|
|
|
|
|
Sender = admin,
|
|
|
|
|
Content = "I spam you!!!1"
|
|
|
|
|
},
|
|
|
|
|
new Message(nextMessageId())
|
|
|
|
|
{
|
|
|
|
|
Sender = admin,
|
|
|
|
|
Content = "I spam you!1!1"
|
|
|
|
|
}));
|
2019-06-18 12:44:38 +08:00
|
|
|
|
|
|
|
|
|
AddStep("change channel to 2", () => chatDisplay.Channel.Value = testChannel2);
|
|
|
|
|
|
|
|
|
|
AddStep("change channel to 1", () => chatDisplay.Channel.Value = testChannel);
|
2018-11-16 13:22:42 +08:00
|
|
|
|
}
|
2019-06-18 12:44:38 +08:00
|
|
|
|
|
|
|
|
|
private int messageId;
|
|
|
|
|
|
|
|
|
|
private long? nextMessageId() => messageId++;
|
2018-11-16 13:22:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|