mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 18:53:23 +08:00
Make Populate() accept list of users
This commit is contained in:
parent
160d64eecf
commit
83dad93b6d
@ -3,11 +3,13 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Home.Friends;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
@ -41,12 +43,25 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Test]
|
||||
public void Populate()
|
||||
{
|
||||
AddStep(@"Populate", () => control.Populate(new List<FriendsBundle>
|
||||
AddStep("Populate", () => control.Populate(new List<User>
|
||||
{
|
||||
new FriendsBundle(FriendsOnlineStatus.All, 100),
|
||||
new FriendsBundle(FriendsOnlineStatus.Online, 50),
|
||||
new FriendsBundle(FriendsOnlineStatus.Offline, 50),
|
||||
new User
|
||||
{
|
||||
IsOnline = true
|
||||
},
|
||||
new User
|
||||
{
|
||||
IsOnline = false
|
||||
},
|
||||
new User
|
||||
{
|
||||
IsOnline = false
|
||||
}
|
||||
}));
|
||||
|
||||
AddAssert("3 users", () => control.Items.FirstOrDefault(item => item.Status == FriendsOnlineStatus.All)?.Amount == 3);
|
||||
AddAssert("1 online user", () => control.Items.FirstOrDefault(item => item.Status == FriendsOnlineStatus.Online)?.Amount == 1);
|
||||
AddAssert("2 offline users", () => control.Items.FirstOrDefault(item => item.Status == FriendsOnlineStatus.Offline)?.Amount == 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,26 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.Home.Friends
|
||||
{
|
||||
public class FriendsOnlineStatusControl : OverlayUpdateStreamControl<FriendsBundle>
|
||||
{
|
||||
protected override OverlayUpdateStreamItem<FriendsBundle> CreateStreamItem(FriendsBundle value) => new FriendsOnlineStatusItem(value);
|
||||
|
||||
public void Populate(List<User> users)
|
||||
{
|
||||
var userCount = users.Count;
|
||||
var onlineUsersCount = users.Count(user => user.IsOnline);
|
||||
|
||||
AddItem(new FriendsBundle(FriendsOnlineStatus.All, userCount));
|
||||
AddItem(new FriendsBundle(FriendsOnlineStatus.Online, onlineUsersCount));
|
||||
AddItem(new FriendsBundle(FriendsOnlineStatus.Offline, userCount - onlineUsersCount));
|
||||
|
||||
Current.Value = Items.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Overlays
|
||||
private FillFlowContainer<SpriteText> text;
|
||||
private ExpandingBar expandingBar;
|
||||
|
||||
public OverlayUpdateStreamItem(T value)
|
||||
protected OverlayUpdateStreamItem(T value)
|
||||
: base(value)
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user