mirror of
https://github.com/ppy/osu
synced 2024-12-12 01:48:49 +00:00
Merge branch 'chat-mention' of https://github.com/Craftplacer/osu into chat-mention
This commit is contained in:
commit
61cf88be82
@ -46,36 +46,100 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[Test]
|
||||
public void TestPublicChannelMention()
|
||||
{
|
||||
AddStep("Switch to PMs", () => testContainer.ChannelManager.CurrentChannel.Value = privateMessageChannel);
|
||||
AddStep("switch to PMs", () => testContainer.ChannelManager.CurrentChannel.Value = privateMessageChannel);
|
||||
|
||||
AddStep("Send regular message", () => publicChannel.AddNewMessages(new Message(messageIdCounter++) { Content = "Hello everyone!", Sender = friend, ChannelId = publicChannel.Id }));
|
||||
AddAssert("Expect no notifications", () => testContainer.NotificationOverlay.UnreadCount.Value == 0);
|
||||
AddStep("receive public message", () => receiveMessage(friend, publicChannel, "Hello everyone"));
|
||||
AddAssert("no notifications fired", () => testContainer.NotificationOverlay.UnreadCount.Value == 0);
|
||||
|
||||
AddStep("Send message containing mention", () => publicChannel.AddNewMessages(new Message(messageIdCounter++) { Content = $"Hello {API.LocalUser.Value.Username.ToLowerInvariant()}!", Sender = friend, ChannelId = publicChannel.Id }));
|
||||
AddAssert("Expect 1 notification", () => testContainer.NotificationOverlay.UnreadCount.Value == 1);
|
||||
AddStep("receive message containing mention", () => receiveMessage(friend, publicChannel, $"Hello {API.LocalUser.Value.Username.ToLowerInvariant()}!"));
|
||||
AddAssert("1 notification fired", () => testContainer.NotificationOverlay.UnreadCount.Value == 1);
|
||||
|
||||
AddStep("Open notification overlay", () => testContainer.NotificationOverlay.Show());
|
||||
AddStep("Click notification", clickNotification<MessageNotifier.MentionNotification>);
|
||||
AddStep("open notification overlay", () => testContainer.NotificationOverlay.Show());
|
||||
AddStep("click notification", clickNotification<MessageNotifier.MentionNotification>);
|
||||
|
||||
AddAssert("Expect ChatOverlay is open", () => testContainer.ChatOverlay.State.Value == Visibility.Visible);
|
||||
AddAssert("Expect the public channel to be selected", () => testContainer.ChannelManager.CurrentChannel.Value == publicChannel);
|
||||
AddAssert("chat overlay is open", () => testContainer.ChatOverlay.State.Value == Visibility.Visible);
|
||||
AddAssert("public channel is selected", () => testContainer.ChannelManager.CurrentChannel.Value == publicChannel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPrivateMessageNotification()
|
||||
{
|
||||
AddStep("Switch to public channel", () => testContainer.ChannelManager.CurrentChannel.Value = publicChannel);
|
||||
AddStep("switch to public channel", () => testContainer.ChannelManager.CurrentChannel.Value = publicChannel);
|
||||
|
||||
AddStep("Send PM", () => privateMessageChannel.AddNewMessages(new Message(messageIdCounter++) { Content = $"Hello {API.LocalUser.Value.Username}!", Sender = friend, ChannelId = privateMessageChannel.Id }));
|
||||
AddAssert("Expect 1 notification", () => testContainer.NotificationOverlay.UnreadCount.Value == 1);
|
||||
AddStep("receive PM", () => receiveMessage(friend, privateMessageChannel, $"Hello {API.LocalUser.Value.Username}"));
|
||||
AddAssert("1 notification fired", () => testContainer.NotificationOverlay.UnreadCount.Value == 1);
|
||||
|
||||
AddStep("Open notification overlay", () => testContainer.NotificationOverlay.Show());
|
||||
AddStep("Click notification", clickNotification<MessageNotifier.PrivateMessageNotification>);
|
||||
AddStep("open notification overlay", () => testContainer.NotificationOverlay.Show());
|
||||
AddStep("click notification", clickNotification<MessageNotifier.PrivateMessageNotification>);
|
||||
|
||||
AddAssert("Expect ChatOverlay is open", () => testContainer.ChatOverlay.State.Value == Visibility.Visible);
|
||||
AddAssert("Expect the PM channel to be selected", () => testContainer.ChannelManager.CurrentChannel.Value == privateMessageChannel);
|
||||
AddAssert("chat overlay is open", () => testContainer.ChatOverlay.State.Value == Visibility.Visible);
|
||||
AddAssert("PM channel is selected", () => testContainer.ChannelManager.CurrentChannel.Value == privateMessageChannel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoNotificationWhenPMChannelOpen()
|
||||
{
|
||||
AddStep("switch to PMs", () => testContainer.ChannelManager.CurrentChannel.Value = privateMessageChannel);
|
||||
|
||||
AddStep("receive PM", () => receiveMessage(friend, privateMessageChannel, "you're reading this, right?"));
|
||||
|
||||
AddAssert("no notifications fired", () => testContainer.NotificationOverlay.UnreadCount.Value == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoNotificationWhenMentionedInOpenPublicChannel()
|
||||
{
|
||||
AddStep("switch to public channel", () => testContainer.ChannelManager.CurrentChannel.Value = publicChannel);
|
||||
|
||||
AddStep("receive mention", () => receiveMessage(friend, publicChannel, $"{API.LocalUser.Value.Username.ToUpperInvariant()} has been reading this"));
|
||||
|
||||
AddAssert("no notifications fired", () => testContainer.NotificationOverlay.UnreadCount.Value == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoNotificationOnSelfMention()
|
||||
{
|
||||
AddStep("switch to PM channel", () => testContainer.ChannelManager.CurrentChannel.Value = privateMessageChannel);
|
||||
|
||||
AddStep("receive self-mention", () => receiveMessage(API.LocalUser.Value, publicChannel, $"my name is {API.LocalUser.Value.Username}"));
|
||||
|
||||
AddAssert("no notifications fired", () => testContainer.NotificationOverlay.UnreadCount.Value == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoNotificationOnPMFromSelf()
|
||||
{
|
||||
AddStep("switch to public channel", () => testContainer.ChannelManager.CurrentChannel.Value = publicChannel);
|
||||
|
||||
AddStep("receive PM from self", () => receiveMessage(API.LocalUser.Value, privateMessageChannel, "hey hey"));
|
||||
|
||||
AddAssert("no notifications fired", () => testContainer.NotificationOverlay.UnreadCount.Value == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNotificationsNotFiredTwice()
|
||||
{
|
||||
AddStep("switch to public channel", () => testContainer.ChannelManager.CurrentChannel.Value = publicChannel);
|
||||
|
||||
AddStep("receive same PM twice", () =>
|
||||
{
|
||||
var message = createMessage(friend, privateMessageChannel, "hey hey");
|
||||
privateMessageChannel.AddNewMessages(message, message);
|
||||
});
|
||||
|
||||
AddStep("open notification overlay", () => testContainer.NotificationOverlay.Show());
|
||||
AddAssert("1 notification fired", () => testContainer.NotificationOverlay.UnreadCount.Value == 1);
|
||||
}
|
||||
|
||||
private void receiveMessage(User sender, Channel channel, string content) => channel.AddNewMessages(createMessage(sender, channel, content));
|
||||
|
||||
private Message createMessage(User sender, Channel channel, string content) => new Message(messageIdCounter++)
|
||||
{
|
||||
Content = content,
|
||||
Sender = sender,
|
||||
ChannelId = channel.Id
|
||||
};
|
||||
|
||||
private void clickNotification<T>() where T : Notification
|
||||
{
|
||||
var notification = testContainer.NotificationOverlay.ChildrenOfType<T>().Single();
|
||||
|
Loading…
Reference in New Issue
Block a user