mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
add tests for /chat command
This commit is contained in:
parent
1b264a2dd0
commit
7924a990a3
@ -1,6 +1,7 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
@ -85,6 +86,21 @@ namespace osu.Game.Tests.Visual.Online
|
||||
case JoinChannelRequest joinChannel:
|
||||
joinChannel.TriggerSuccess();
|
||||
return true;
|
||||
|
||||
case GetUserRequest getUser:
|
||||
if (getUser.Lookup.Equals("some body", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
getUser.TriggerSuccess(new User()
|
||||
{
|
||||
Username = "some body",
|
||||
Id = 1,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
getUser.TriggerFailure(new Exception());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -322,6 +338,27 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddAssert("Current channel is channel 1", () => currentChannel == channel1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChatCommand()
|
||||
{
|
||||
AddStep("Join channel 1", () => channelManager.JoinChannel(channel1));
|
||||
AddStep("Select channel 1", () => clickDrawable(chatOverlay.TabMap[channel1]));
|
||||
|
||||
AddStep("Open chat with user.", () => channelManager.PostCommand("chat some body"));
|
||||
AddAssert("PM channel is selected", () =>
|
||||
channelManager.CurrentChannel.Value.Type == ChannelType.PM && channelManager.CurrentChannel.Value.Users.Single().Username == "some body");
|
||||
|
||||
AddStep("Open chat with non-existant user", () => channelManager.PostCommand("chat nobody"));
|
||||
AddAssert("Last message is error", () => channelManager.CurrentChannel.Value.Messages.Last().GetType() == typeof(ErrorMessage));
|
||||
|
||||
// Make sure no unnecessary requests are made when the PM chanenl is already open.
|
||||
AddStep("Select channel 1", () => clickDrawable(chatOverlay.TabMap[channel1]));
|
||||
AddStep("Unregister request handling", () => ((DummyAPIAccess)API).HandleRequest = null);
|
||||
AddStep("Open chat with user.", () => channelManager.PostCommand("chat some body"));
|
||||
AddAssert("PM channel is selected", () =>
|
||||
channelManager.CurrentChannel.Value.Type == ChannelType.PM && channelManager.CurrentChannel.Value.Users.Single().Username == "some body");
|
||||
}
|
||||
|
||||
private void pressChannelHotkey(int number)
|
||||
{
|
||||
var channelKey = Key.Number0 + number;
|
||||
|
Loading…
Reference in New Issue
Block a user