1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 11:27:24 +08:00
osu-lazer/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs

64 lines
2.1 KiB
C#
Raw Normal View History

// 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;
using System.Collections.Generic;
2020-03-03 23:08:51 +08:00
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Overlays;
using osu.Game.Overlays.Home.Friends;
2020-03-03 23:08:51 +08:00
using osu.Game.Users;
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneFriendsOnlineStatusControl : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(FriendsOnlineStatusControl),
typeof(FriendsOnlineStatusItem),
typeof(OverlayUpdateStreamControl<>),
typeof(OverlayUpdateStreamItem<>),
typeof(FriendsBundle)
};
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
private FriendsOnlineStatusControl control;
[SetUp]
2020-03-04 05:15:10 +08:00
public void SetUp() => Schedule(() => Child = control = new FriendsOnlineStatusControl
{
2020-03-04 05:15:10 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
[Test]
public void Populate()
{
2020-03-03 23:08:51 +08:00
AddStep("Populate", () => control.Populate(new List<User>
{
2020-03-03 23:08:51 +08:00
new User
{
IsOnline = true
},
new User
{
IsOnline = false
},
new User
{
IsOnline = false
}
}));
2020-03-03 23:08:51 +08:00
2020-03-04 05:31:06 +08:00
AddAssert("3 users", () => control.Items.FirstOrDefault(item => item.Status == FriendsOnlineStatus.All)?.Count == 3);
AddAssert("1 online user", () => control.Items.FirstOrDefault(item => item.Status == FriendsOnlineStatus.Online)?.Count == 1);
AddAssert("2 offline users", () => control.Items.FirstOrDefault(item => item.Status == FriendsOnlineStatus.Offline)?.Count == 2);
}
}
}