osu/osu.Game.Tests/Visual/Online/TestSceneFriendDisplay.cs

88 lines
2.6 KiB
C#
Raw Normal View History

2020-03-16 06:42:21 +00:00
// 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;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays.Dashboard.Friends;
using osu.Framework.Graphics;
using osu.Game.Users;
using osu.Game.Overlays;
using osu.Framework.Allocation;
using NUnit.Framework;
namespace osu.Game.Tests.Visual.Online
{
2020-03-23 06:37:34 +00:00
public class TestSceneFriendDisplay : OsuTestScene
2020-03-16 06:42:21 +00:00
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
2020-03-23 01:47:27 +00:00
typeof(FriendDisplay),
typeof(FriendOnlineStreamControl),
2020-03-16 06:42:21 +00:00
typeof(UserListToolbar)
};
2020-03-16 22:50:19 +00:00
protected override bool UseOnlineAPI => true;
2020-03-16 06:42:21 +00:00
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
2020-03-23 01:47:27 +00:00
private FriendDisplay display;
2020-03-16 06:42:21 +00:00
[SetUp]
public void Setup() => Schedule(() =>
{
Child = new BasicScrollContainer
{
RelativeSizeAxes = Axes.Both,
2020-03-23 01:47:27 +00:00
Child = display = new FriendDisplay()
2020-03-16 06:42:21 +00:00
};
});
2020-03-16 22:50:19 +00:00
[Test]
2020-03-17 19:34:46 +00:00
public void TestOffline()
2020-03-16 22:50:19 +00:00
{
2020-03-23 01:47:27 +00:00
AddStep("Populate", () => display.Users = getUsers());
2020-03-16 22:50:19 +00:00
}
2020-03-16 06:42:21 +00:00
[Test]
2020-03-17 19:34:46 +00:00
public void TestOnline()
2020-03-16 06:42:21 +00:00
{
2020-03-23 01:47:27 +00:00
AddStep("Fetch online", () => display?.Fetch());
2020-03-16 06:42:21 +00:00
}
2020-03-17 05:51:54 +00:00
private List<User> getUsers() => new List<User>
2020-03-16 06:42:21 +00:00
{
2020-03-17 05:51:54 +00:00
new User
2020-03-16 06:42:21 +00:00
{
Username = "flyte",
2020-03-16 06:42:21 +00:00
Id = 3103765,
IsOnline = true,
CurrentModeRank = 1111,
Country = new Country { FlagName = "JP" },
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
2020-03-16 06:42:21 +00:00
},
2020-03-17 05:51:54 +00:00
new User
2020-03-16 06:42:21 +00:00
{
Username = "peppy",
2020-03-16 06:42:21 +00:00
Id = 2,
IsOnline = false,
CurrentModeRank = 2222,
Country = new Country { FlagName = "AU" },
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
2020-03-16 06:42:21 +00:00
IsSupporter = true,
SupportLevel = 3,
},
2020-03-17 05:51:54 +00:00
new User
2020-03-16 06:42:21 +00:00
{
Username = "Evast",
2020-03-16 06:42:21 +00:00
Id = 8195163,
Country = new Country { FlagName = "BY" },
CoverUrl = "https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg",
2020-03-16 06:42:21 +00:00
IsOnline = false,
LastVisit = DateTimeOffset.Now
}
};
}
}