mirror of
https://github.com/ppy/osu.git
synced 2025-02-06 02:57:49 +08:00
Add online test
This commit is contained in:
parent
6ec01a67af
commit
6a151b8e75
@ -11,6 +11,7 @@ using osu.Game.Overlays;
|
||||
using osu.Framework.Allocation;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
@ -23,10 +24,12 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(UserListToolbar)
|
||||
};
|
||||
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
private FriendsLayout layout;
|
||||
private TestFriendsLayout layout;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
@ -34,10 +37,16 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Child = new BasicScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = layout = new FriendsLayout()
|
||||
Child = layout = new TestFriendsLayout()
|
||||
};
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestOnline()
|
||||
{
|
||||
AddUntilStep("Users loaded", () => layout?.StatusControl.Items.Any() ?? false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPopulate()
|
||||
{
|
||||
@ -76,5 +85,10 @@ namespace osu.Game.Tests.Visual.Online
|
||||
LastVisit = DateTimeOffset.Now
|
||||
}
|
||||
};
|
||||
|
||||
private class TestFriendsLayout : FriendsLayout
|
||||
{
|
||||
public FriendsOnlineStatusControl StatusControl => OnlineStatusControl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,11 +26,13 @@ namespace osu.Game.Overlays.Dashboard.Friends
|
||||
get => users;
|
||||
set
|
||||
{
|
||||
request?.Cancel();
|
||||
|
||||
users = value;
|
||||
|
||||
usersLoaded = true;
|
||||
|
||||
onlineStatusControl.Populate(value);
|
||||
OnlineStatusControl.Populate(value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,9 +44,9 @@ namespace osu.Game.Overlays.Dashboard.Friends
|
||||
|
||||
private Drawable currentContent;
|
||||
|
||||
protected readonly FriendsOnlineStatusControl OnlineStatusControl;
|
||||
private readonly Box background;
|
||||
private readonly Box controlBackground;
|
||||
private readonly FriendsOnlineStatusControl onlineStatusControl;
|
||||
private readonly UserListToolbar userListToolbar;
|
||||
private readonly Container itemsPlaceholder;
|
||||
private readonly LoadingLayer loading;
|
||||
@ -78,7 +80,7 @@ namespace osu.Game.Overlays.Dashboard.Friends
|
||||
Top = 20,
|
||||
Horizontal = 45
|
||||
},
|
||||
Child = onlineStatusControl = new FriendsOnlineStatusControl(),
|
||||
Child = OnlineStatusControl = new FriendsOnlineStatusControl(),
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -152,7 +154,7 @@ namespace osu.Game.Overlays.Dashboard.Friends
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
onlineStatusControl.Current.BindValueChanged(_ => recreatePanels());
|
||||
OnlineStatusControl.Current.BindValueChanged(_ => recreatePanels());
|
||||
userListToolbar.DisplayStyle.BindValueChanged(_ => recreatePanels());
|
||||
userListToolbar.SortCriteria.BindValueChanged(_ => recreatePanels());
|
||||
|
||||
@ -175,7 +177,7 @@ namespace osu.Game.Overlays.Dashboard.Friends
|
||||
if (itemsPlaceholder.Any())
|
||||
loading.Show();
|
||||
|
||||
var groupedUsers = onlineStatusControl.Current.Value?.Users ?? new List<APIFriend>();
|
||||
var groupedUsers = OnlineStatusControl.Current.Value?.Users ?? new List<APIFriend>();
|
||||
|
||||
var sortedUsers = sortUsers(groupedUsers);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user