osu/osu.Game.Tournament.Tests/Components/TestSceneTournamentMatchCha...

132 lines
4.0 KiB
C#
Raw Normal View History

2019-03-04 04:24:19 +00: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 05:22:42 +00:00
using osu.Framework.Allocation;
using osu.Framework.Bindables;
2018-11-16 05:22:42 +00:00
using osu.Framework.Graphics;
using osu.Game.Online.Chat;
using osu.Game.Tests.Visual;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.IPC;
2019-06-18 05:51:48 +00:00
using osu.Game.Tournament.Models;
2018-11-16 05:22:42 +00:00
using osu.Game.Users;
2019-06-18 06:28:36 +00:00
namespace osu.Game.Tournament.Tests.Components
2018-11-16 05:22:42 +00:00
{
2019-06-18 04:44:38 +00:00
public class TestSceneTournamentMatchChatDisplay : OsuTestScene
2018-11-16 05:22:42 +00:00
{
private readonly Channel testChannel = new Channel();
2019-06-18 04:44:38 +00:00
private readonly Channel testChannel2 = new Channel();
2018-11-16 05:22:42 +00:00
private readonly User admin = new User
{
Username = "HappyStick",
Id = 2,
Colour = "f2ca34"
};
private readonly User redUser = new User
{
Username = "BanchoBot",
Id = 3,
};
private readonly User blueUser = new User
{
Username = "Zallius",
Id = 4,
};
[Cached]
private LadderInfo ladderInfo = new LadderInfo();
[Cached]
private MatchIPCInfo matchInfo = new MatchIPCInfo(); // hide parent
2019-06-18 04:44:38 +00:00
private readonly TournamentMatchChatDisplay chatDisplay;
2018-11-16 05:22:42 +00:00
2019-06-18 04:44:38 +00:00
public TestSceneTournamentMatchChatDisplay()
{
Add(chatDisplay = new TournamentMatchChatDisplay
2018-11-16 05:22:42 +00:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
2019-06-18 05:57:05 +00:00
ladderInfo.CurrentMatch.Value = new TournamentMatch
2018-11-16 05:22:42 +00:00
{
Team1 =
{
Value = new TournamentTeam { Players = new BindableList<User> { redUser } }
2018-11-16 05:22:42 +00:00
},
Team2 =
{
Value = new TournamentTeam { Players = new BindableList<User> { blueUser } }
2018-11-16 05:22:42 +00:00
}
};
chatDisplay.Channel.Value = testChannel;
}
protected override void LoadComplete()
{
base.LoadComplete();
2019-06-18 04:44:38 +00:00
AddStep("message from admin", () => testChannel.AddNewMessages(new Message(nextMessageId())
2018-11-16 05:22:42 +00:00
{
Sender = admin,
Content = "I am a wang!"
}));
2019-06-18 04:44:38 +00:00
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
2018-11-16 05:22:42 +00:00
{
Sender = redUser,
Content = "I am team red."
}));
2019-06-18 04:44:38 +00:00
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
2018-11-16 05:22:42 +00:00
{
Sender = redUser,
Content = "I plan to win!"
}));
2019-06-18 04:44:38 +00:00
AddStep("message from team blue", () => testChannel.AddNewMessages(new Message(nextMessageId())
2018-11-16 05:22:42 +00:00
{
Sender = blueUser,
Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand."
}));
2019-06-18 04:44:38 +00:00
AddStep("message from admin", () => testChannel.AddNewMessages(new Message(nextMessageId())
2018-11-16 05:22:42 +00:00
{
Sender = admin,
Content = "Okay okay, calm down guys. Let's do this!"
}));
2019-06-18 04:44:38 +00:00
2019-11-11 12:05:36 +00: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 04:44:38 +00:00
AddStep("change channel to 2", () => chatDisplay.Channel.Value = testChannel2);
AddStep("change channel to 1", () => chatDisplay.Channel.Value = testChannel);
2018-11-16 05:22:42 +00:00
}
2019-06-18 04:44:38 +00:00
private int messageId;
private long? nextMessageId() => messageId++;
2018-11-16 05:22:42 +00:00
}
}