2020-03-16 14:42:21 +08: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.
|
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-03-16 14:42:21 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2020-10-22 13:43:47 +08:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
2020-03-16 14:42:21 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-11-04 17:02:44 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-10-22 13:43:47 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2020-03-16 14:42:21 +08:00
|
|
|
|
using osu.Game.Overlays.Dashboard.Friends;
|
|
|
|
|
using osu.Game.Users;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
|
|
|
|
{
|
2020-03-23 14:37:34 +08:00
|
|
|
|
public partial class TestSceneFriendDisplay : OsuTestScene
|
2020-03-16 14:42:21 +08:00
|
|
|
|
{
|
2020-03-17 06:50:19 +08:00
|
|
|
|
protected override bool UseOnlineAPI => true;
|
|
|
|
|
|
2020-03-16 14:42:21 +08:00
|
|
|
|
[Cached]
|
|
|
|
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
|
|
|
|
|
2020-12-18 07:51:19 +08:00
|
|
|
|
private FriendDisplay display;
|
2020-03-16 14:42:21 +08:00
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup() => Schedule(() =>
|
|
|
|
|
{
|
|
|
|
|
Child = new BasicScrollContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-12-18 07:51:19 +08:00
|
|
|
|
Child = display = new FriendDisplay()
|
2020-03-16 14:42:21 +08:00
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
2020-03-17 06:50:19 +08:00
|
|
|
|
[Test]
|
2020-03-18 03:34:46 +08:00
|
|
|
|
public void TestOffline()
|
2020-03-17 06:50:19 +08:00
|
|
|
|
{
|
2020-10-22 13:19:12 +08:00
|
|
|
|
AddStep("Populate with offline test users", () => display.Users = getUsers());
|
2020-03-17 06:50:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-16 14:42:21 +08:00
|
|
|
|
[Test]
|
2020-03-18 03:34:46 +08:00
|
|
|
|
public void TestOnline()
|
2020-03-16 14:42:21 +08:00
|
|
|
|
{
|
2020-12-18 07:51:19 +08:00
|
|
|
|
// No need to do anything, fetch is performed automatically.
|
2020-03-16 14:42:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-04 17:02:44 +08:00
|
|
|
|
private List<APIUser> getUsers() => new List<APIUser>
|
2020-03-16 14:42:21 +08:00
|
|
|
|
{
|
2021-11-04 17:02:44 +08:00
|
|
|
|
new APIUser
|
2020-03-16 14:42:21 +08:00
|
|
|
|
{
|
2020-03-17 06:36:48 +08:00
|
|
|
|
Username = "flyte",
|
2020-03-16 14:42:21 +08:00
|
|
|
|
Id = 3103765,
|
|
|
|
|
IsOnline = true,
|
2021-03-02 04:07:25 +08:00
|
|
|
|
Statistics = new UserStatistics { GlobalRank = 1111 },
|
2022-07-18 13:40:34 +08:00
|
|
|
|
CountryCode = CountryCode.JP,
|
2020-03-17 06:36:48 +08:00
|
|
|
|
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
|
2020-03-16 14:42:21 +08:00
|
|
|
|
},
|
2021-11-04 17:02:44 +08:00
|
|
|
|
new APIUser
|
2020-03-16 14:42:21 +08:00
|
|
|
|
{
|
2020-03-17 06:36:48 +08:00
|
|
|
|
Username = "peppy",
|
2020-03-16 14:42:21 +08:00
|
|
|
|
Id = 2,
|
|
|
|
|
IsOnline = false,
|
2021-03-02 04:07:25 +08:00
|
|
|
|
Statistics = new UserStatistics { GlobalRank = 2222 },
|
2022-07-18 13:40:34 +08:00
|
|
|
|
CountryCode = CountryCode.AU,
|
2020-03-17 06:36:48 +08:00
|
|
|
|
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
2020-03-16 14:42:21 +08:00
|
|
|
|
IsSupporter = true,
|
|
|
|
|
SupportLevel = 3,
|
|
|
|
|
},
|
2021-11-04 17:02:44 +08:00
|
|
|
|
new APIUser
|
2020-03-16 14:42:21 +08:00
|
|
|
|
{
|
2020-03-17 06:36:48 +08:00
|
|
|
|
Username = "Evast",
|
2020-03-16 14:42:21 +08:00
|
|
|
|
Id = 8195163,
|
2022-07-18 13:40:34 +08:00
|
|
|
|
CountryCode = CountryCode.BY,
|
2020-03-17 06:36:48 +08:00
|
|
|
|
CoverUrl = "https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg",
|
2020-03-16 14:42:21 +08:00
|
|
|
|
IsOnline = false,
|
|
|
|
|
LastVisit = DateTimeOffset.Now
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|