1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-20 02:39:53 +08:00

Add long and wide Username Test Steps

Add few teststeps for Long User Name (over the 15 character) and Wide
(Like "W") Username.

Signed-off-by: Seokho Song <0xdevssh@gmail.com>
This commit is contained in:
Seokho Song
2018-02-13 03:22:52 +09:00
Unverified
parent c3b134ffee
commit f88db44450
2 changed files with 57 additions and 47 deletions
+40 -30
View File
@@ -5,11 +5,9 @@ using System.ComponentModel;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Online.API;
using osu.Game.Users;
using osu.Game.Online.Chat;
using osu.Game.Configuration;
using osu.Framework.Graphics.UserInterface;
using System;
@@ -19,22 +17,28 @@ namespace osu.Game.Tests.Visual
public class TestCaseChatDisplay : OsuTestCase
{
DummyChatOverlay chat;
private readonly DummyChatOverlay chat;
public TestCaseChatDisplay()
{
chat = new DummyChatOverlay
{
State = Visibility.Visible
};
chat = new DummyChatOverlay
{
State = Visibility.Visible
};
Add(chat);
AddStep("Set Username DummyUser", () => chat.Username = "DummyUser");
AddStep("Type \"Hello\"", () => chat.PostDummyMessage("Hello"));
AddStep("Set Long Username", () => chat.Username = "Over15LengthUserName");
AddStep("Type \"Over15LengthUserName\"", () => chat.PostDummyMessage("Over15LengthUserName"));
AddStep("Set Wide Username", () => chat.Username = "WWWWWWWWWWWWWWW");
AddStep("Type \"Wide!\"", () => chat.PostDummyMessage("Wide!"));
}
[BackgroundDependencyLoader]
private void load(APIAccess api, OsuConfigManager config, OsuColour colours)
private void load(APIAccess api)
{
var channel = new DummyChannel()
var channel = new DummyChannel
{
Name = "#Dummy",
Topic = "Test Chat",
@@ -42,12 +46,12 @@ namespace osu.Game.Tests.Visual
Id = 0
};
api.Scheduler.Add(delegate {
channel.AddNewMessage("This message for test from offline.");
channel.AddNewMessage("TestMessage");
channel.AddNewMessage("!@#$%^&&*()");
channel.AddNewMessage("testTEST");
chat.OpenChannel(channel);
api.Scheduler.Add(delegate {
channel.AddNewMessage("This message for test from offline.");
channel.AddNewMessage("TestMessage");
channel.AddNewMessage("!@#$%^&&*()");
channel.AddNewMessage("testTEST");
chat.OpenChannel(channel);
});
}
@@ -55,25 +59,23 @@ namespace osu.Game.Tests.Visual
private class DummyChatOverlay : ChatOverlay
{
public string Username = "DummyUser";
[BackgroundDependencyLoader]
private void load(APIAccess api, OsuConfigManager config, OsuColour colours)
private void load(APIAccess api)
{
textbox.OnCommit = postDummyMessage;
base.api = api;
Textbox.OnCommit = postDummyMessage;
Api = api;
api.Register(this);
}
private void postDummyMessage(TextBox textbox, bool newText)
public void PostDummyMessage(string postText)
{
var postText = textbox.Text;
textbox.Text = string.Empty;
if (string.IsNullOrWhiteSpace(postText))
return;
var target = base.CurrentChannel;
var target = CurrentChannel;
if (target == null) return;
@@ -109,8 +111,16 @@ namespace osu.Game.Tests.Visual
}
}
var message = new DummyMessage(postText, "DummyUser", isAction, false, 0);
api.Scheduler.Add(delegate { CurrentChannel.AddNewMessages(message); });
var message = new DummyMessage(postText, Username, isAction);
Api.Scheduler.Add(delegate { CurrentChannel.AddNewMessages(message); });
}
private void postDummyMessage(TextBox textbox, bool newText)
{
var postText = textbox.Text;
textbox.Text = string.Empty;
PostDummyMessage(postText);
}
}
@@ -122,7 +132,7 @@ namespace osu.Game.Tests.Visual
//Should be call "API Thread"
public void AddNewMessage(string message)
{
base.AddNewMessages(new DummyMessage(message, null, false, false, messageCounter++));
AddNewMessages(new DummyMessage(message, null, false, false, messageCounter++));
}
}
@@ -135,9 +145,9 @@ namespace osu.Game.Tests.Visual
Content = text;
IsAction = isAction;
Timestamp = DateTimeOffset.Now;
Sender = new User
Sender = new User
{
Username = (username != null)? username : $"User " + number + "",
Username = username ?? $"User {number}",
Id = number,
Colour = isImportant ? "#250cc9" : null,
};
+17 -17
View File
@@ -39,9 +39,9 @@ namespace osu.Game.Overlays
private readonly LoadingAnimation loading;
protected readonly FocusedTextBox textbox;
protected readonly FocusedTextBox Textbox;
protected APIAccess api;
protected APIAccess Api;
private const int transition_length = 500;
@@ -133,7 +133,7 @@ namespace osu.Game.Overlays
},
Children = new Drawable[]
{
textbox = new FocusedTextBox
Textbox = new FocusedTextBox
{
RelativeSizeAxes = Axes.Both,
Height = 1,
@@ -179,12 +179,12 @@ namespace osu.Game.Overlays
if (state == Visibility.Visible)
{
textbox.HoldFocus = false;
Textbox.HoldFocus = false;
if (1f - ChatHeight.Value < channel_selection_min_height)
transformChatHeightTo(1f - channel_selection_min_height, 800, Easing.OutQuint);
}
else
textbox.HoldFocus = true;
Textbox.HoldFocus = true;
};
}
@@ -246,7 +246,7 @@ namespace osu.Game.Overlays
protected override void OnFocus(InputState state)
{
//this is necessary as textbox is masked away and therefore can't get focus :(
GetContainingInputManager().ChangeFocus(textbox);
GetContainingInputManager().ChangeFocus(Textbox);
base.OnFocus(state);
}
@@ -255,7 +255,7 @@ namespace osu.Game.Overlays
this.MoveToY(0, transition_length, Easing.OutQuint);
this.FadeIn(transition_length, Easing.OutQuint);
textbox.HoldFocus = true;
Textbox.HoldFocus = true;
base.PopIn();
}
@@ -264,14 +264,14 @@ namespace osu.Game.Overlays
this.MoveToY(Height, transition_length, Easing.InSine);
this.FadeOut(transition_length, Easing.InSine);
textbox.HoldFocus = false;
Textbox.HoldFocus = false;
base.PopOut();
}
[BackgroundDependencyLoader]
private void load(APIAccess api, OsuConfigManager config, OsuColour colours)
{
this.api = api;
Api = api;
api.Register(this);
ChatHeight = config.GetBindable<double>(OsuSetting.ChatDisplayHeight);
@@ -324,7 +324,7 @@ namespace osu.Game.Overlays
messageRequest = Scheduler.AddDelayed(fetchNewMessages, 1000, true);
};
api.Queue(req);
Api.Queue(req);
}
private Channel currentChannel;
@@ -343,14 +343,14 @@ namespace osu.Game.Overlays
if (value == null)
{
currentChannel = null;
textbox.Current.Disabled = true;
Textbox.Current.Disabled = true;
currentChannelContainer.Clear(false);
return;
}
currentChannel = value;
textbox.Current.Disabled = currentChannel.ReadOnly;
Textbox.Current.Disabled = currentChannel.ReadOnly;
channelTabs.Current.Value = value;
var loaded = loadedChannels.Find(d => d.Channel == value);
@@ -433,7 +433,7 @@ namespace osu.Game.Overlays
Debug.Write("failure!");
};
api.Queue(req);
Api.Queue(req);
}
private void fetchNewMessages()
@@ -459,7 +459,7 @@ namespace osu.Game.Overlays
fetchReq = null;
};
api.Queue(fetchReq);
Api.Queue(fetchReq);
}
private void postMessage(TextBox textbox, bool newText)
@@ -475,7 +475,7 @@ namespace osu.Game.Overlays
if (target == null) return;
if (!api.IsLoggedIn)
if (!Api.IsLoggedIn)
{
target.AddNewMessages(new ErrorMessage("Please login to participate in chat!"));
return;
@@ -515,7 +515,7 @@ namespace osu.Game.Overlays
var message = new LocalEchoMessage
{
Sender = api.LocalUser.Value,
Sender = Api.LocalUser.Value,
Timestamp = DateTimeOffset.Now,
TargetType = TargetType.Channel, //TODO: read this from channel
TargetId = target.Id,
@@ -529,7 +529,7 @@ namespace osu.Game.Overlays
req.Failure += e => target.ReplaceMessage(message, null);
req.Success += m => target.ReplaceMessage(message, m);
api.Queue(req);
Api.Queue(req);
}
private void transformChatHeightTo(double newChatHeight, double duration = 0, Easing easing = Easing.None)