mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Add full tests
This commit is contained in:
parent
2f9de149dd
commit
d42c45c87e
@ -4,15 +4,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using osu.Game.Online.API;
|
|
||||||
using osu.Game.Online.API.Requests;
|
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Overlays.Chat.Tabs;
|
using osu.Game.Overlays.Chat.Tabs;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -74,50 +71,50 @@ namespace osu.Game.Tests.Visual
|
|||||||
channelTabControl.OnRequestLeave += channel => channelTabControl.RemoveChannel(channel);
|
channelTabControl.OnRequestLeave += channel => channelTabControl.RemoveChannel(channel);
|
||||||
channelTabControl.Current.ValueChanged += channel => currentText.Text = "Currently selected channel: " + channel.ToString();
|
channelTabControl.Current.ValueChanged += channel => currentText.Text = "Currently selected channel: " + channel.ToString();
|
||||||
|
|
||||||
AddStep("Add random private channel", addRandomUser);
|
AddStep("Add random private channel", addRandomPrivateChannel);
|
||||||
AddAssert("There is only one channels", () => channelTabControl.Items.Count() == 2);
|
AddAssert("There is only one channels", () => channelTabControl.Items.Count() == 2);
|
||||||
AddRepeatStep("Add 3 random private channels", addRandomUser, 3);
|
AddRepeatStep("Add 3 random private channels", addRandomPrivateChannel, 3);
|
||||||
AddAssert("There are four channels", () => channelTabControl.Items.Count() == 5);
|
AddAssert("There are four channels", () => channelTabControl.Items.Count() == 5);
|
||||||
AddStep("Add random public channel", () => addChannel(RNG.Next().ToString()));
|
AddStep("Add random public channel", () => addChannel(RNG.Next().ToString()));
|
||||||
|
|
||||||
AddRepeatStep("Select a random channel", () => channelTabControl.Current.Value = channelTabControl.Items.ElementAt(RNG.Next(channelTabControl.Items.Count())), 20);
|
AddRepeatStep("Select a random channel", () => channelTabControl.Current.Value = channelTabControl.Items.ElementAt(RNG.Next(channelTabControl.Items.Count() - 1)), 20);
|
||||||
}
|
|
||||||
|
|
||||||
private List<User> users;
|
Channel channelBefore = channelTabControl.Items.First();
|
||||||
|
AddStep("set first channel", () => channelTabControl.Current.Value = channelBefore);
|
||||||
|
|
||||||
private void addRandomUser()
|
AddStep("select selector tab", () => channelTabControl.Current.Value = channelTabControl.Items.Last());
|
||||||
{
|
AddAssert("selector tab is active", () => channelTabControl.ChannelSelectorActive.Value);
|
||||||
channelTabControl.AddChannel(new Channel
|
|
||||||
|
AddAssert("check channel unchanged", () => channelBefore == channelTabControl.Current.Value);
|
||||||
|
|
||||||
|
AddStep("set second channel", () => channelTabControl.Current.Value = channelTabControl.Items.Skip(1).First());
|
||||||
|
AddAssert("selector tab is inactive", () => !channelTabControl.ChannelSelectorActive.Value);
|
||||||
|
|
||||||
|
AddUntilStep(() =>
|
||||||
{
|
{
|
||||||
Users =
|
var first = channelTabControl.Items.First();
|
||||||
{
|
if (first.Name == "+")
|
||||||
users?.Count > 0
|
return true;
|
||||||
? users[RNG.Next(0, users.Count - 1)]
|
|
||||||
: new User
|
channelTabControl.RemoveChannel(first);
|
||||||
{
|
return false;
|
||||||
Id = RNG.Next(),
|
}, "remove all channels");
|
||||||
Username = "testuser" + RNG.Next(1000)
|
|
||||||
}
|
AddAssert("selector tab is active", () => channelTabControl.ChannelSelectorActive.Value);
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addChannel(string name)
|
private void addRandomPrivateChannel() =>
|
||||||
{
|
channelTabControl.AddChannel(new Channel(new User
|
||||||
|
{
|
||||||
|
Id = RNG.Next(1000, 10000000),
|
||||||
|
Username = "Test User " + RNG.Next(1000)
|
||||||
|
}));
|
||||||
|
|
||||||
|
private void addChannel(string name) =>
|
||||||
channelTabControl.AddChannel(new Channel
|
channelTabControl.AddChannel(new Channel
|
||||||
{
|
{
|
||||||
Type = ChannelType.Public,
|
Type = ChannelType.Public,
|
||||||
Name = name
|
Name = name
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(IAPIProvider api)
|
|
||||||
{
|
|
||||||
GetUsersRequest req = new GetUsersRequest();
|
|
||||||
req.Success += list => users = list.Select(e => e.User).ToList();
|
|
||||||
|
|
||||||
api.Queue(req);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user