Add online test

This commit is contained in:
Andrei Zavatski 2020-03-17 01:50:19 +03:00
parent 6ec01a67af
commit 6a151b8e75
2 changed files with 23 additions and 7 deletions

View File

@ -11,6 +11,7 @@ using osu.Game.Overlays;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using System.Linq;
namespace osu.Game.Tests.Visual.Online namespace osu.Game.Tests.Visual.Online
{ {
@ -23,10 +24,12 @@ namespace osu.Game.Tests.Visual.Online
typeof(UserListToolbar) typeof(UserListToolbar)
}; };
protected override bool UseOnlineAPI => true;
[Cached] [Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
private FriendsLayout layout; private TestFriendsLayout layout;
[SetUp] [SetUp]
public void Setup() => Schedule(() => public void Setup() => Schedule(() =>
@ -34,10 +37,16 @@ namespace osu.Game.Tests.Visual.Online
Child = new BasicScrollContainer Child = new BasicScrollContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = layout = new FriendsLayout() Child = layout = new TestFriendsLayout()
}; };
}); });
[Test]
public void TestOnline()
{
AddUntilStep("Users loaded", () => layout?.StatusControl.Items.Any() ?? false);
}
[Test] [Test]
public void TestPopulate() public void TestPopulate()
{ {
@ -76,5 +85,10 @@ namespace osu.Game.Tests.Visual.Online
LastVisit = DateTimeOffset.Now LastVisit = DateTimeOffset.Now
} }
}; };
private class TestFriendsLayout : FriendsLayout
{
public FriendsOnlineStatusControl StatusControl => OnlineStatusControl;
}
} }
} }

View File

@ -26,11 +26,13 @@ namespace osu.Game.Overlays.Dashboard.Friends
get => users; get => users;
set set
{ {
request?.Cancel();
users = value; users = value;
usersLoaded = true; usersLoaded = true;
onlineStatusControl.Populate(value); OnlineStatusControl.Populate(value);
} }
} }
@ -42,9 +44,9 @@ namespace osu.Game.Overlays.Dashboard.Friends
private Drawable currentContent; private Drawable currentContent;
protected readonly FriendsOnlineStatusControl OnlineStatusControl;
private readonly Box background; private readonly Box background;
private readonly Box controlBackground; private readonly Box controlBackground;
private readonly FriendsOnlineStatusControl onlineStatusControl;
private readonly UserListToolbar userListToolbar; private readonly UserListToolbar userListToolbar;
private readonly Container itemsPlaceholder; private readonly Container itemsPlaceholder;
private readonly LoadingLayer loading; private readonly LoadingLayer loading;
@ -78,7 +80,7 @@ namespace osu.Game.Overlays.Dashboard.Friends
Top = 20, Top = 20,
Horizontal = 45 Horizontal = 45
}, },
Child = onlineStatusControl = new FriendsOnlineStatusControl(), Child = OnlineStatusControl = new FriendsOnlineStatusControl(),
} }
} }
}, },
@ -152,7 +154,7 @@ namespace osu.Game.Overlays.Dashboard.Friends
{ {
base.LoadComplete(); base.LoadComplete();
onlineStatusControl.Current.BindValueChanged(_ => recreatePanels()); OnlineStatusControl.Current.BindValueChanged(_ => recreatePanels());
userListToolbar.DisplayStyle.BindValueChanged(_ => recreatePanels()); userListToolbar.DisplayStyle.BindValueChanged(_ => recreatePanels());
userListToolbar.SortCriteria.BindValueChanged(_ => recreatePanels()); userListToolbar.SortCriteria.BindValueChanged(_ => recreatePanels());
@ -175,7 +177,7 @@ namespace osu.Game.Overlays.Dashboard.Friends
if (itemsPlaceholder.Any()) if (itemsPlaceholder.Any())
loading.Show(); loading.Show();
var groupedUsers = onlineStatusControl.Current.Value?.Users ?? new List<APIFriend>(); var groupedUsers = OnlineStatusControl.Current.Value?.Users ?? new List<APIFriend>();
var sortedUsers = sortUsers(groupedUsers); var sortedUsers = sortUsers(groupedUsers);