2019-01-27 22:45:00 +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.
|
2019-01-11 00:12:19 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osu.Game.Online.API.Requests;
|
2021-11-04 09:02:44 +00:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2019-05-21 04:36:21 +00:00
|
|
|
|
using osu.Game.Overlays;
|
2019-01-11 00:12:19 +00:00
|
|
|
|
using osu.Game.Overlays.Profile;
|
|
|
|
|
using osu.Game.Users;
|
|
|
|
|
|
2019-04-03 22:24:42 +00:00
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
2019-01-11 00:12:19 +00:00
|
|
|
|
{
|
2019-05-14 19:37:25 +00:00
|
|
|
|
public class TestSceneUserProfileHeader : OsuTestScene
|
2019-01-11 00:12:19 +00:00
|
|
|
|
{
|
2019-09-13 08:15:33 +00:00
|
|
|
|
protected override bool UseOnlineAPI => true;
|
2019-07-31 19:44:44 +00:00
|
|
|
|
|
2020-01-24 09:42:48 +00:00
|
|
|
|
[Cached]
|
|
|
|
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
|
|
|
|
|
2019-01-11 00:12:19 +00:00
|
|
|
|
[Resolved]
|
2019-04-03 22:24:42 +00:00
|
|
|
|
private IAPIProvider api { get; set; }
|
2019-01-11 00:12:19 +00:00
|
|
|
|
|
|
|
|
|
private readonly ProfileHeader header;
|
|
|
|
|
|
2019-05-14 19:37:25 +00:00
|
|
|
|
public TestSceneUserProfileHeader()
|
2019-01-11 00:12:19 +00:00
|
|
|
|
{
|
|
|
|
|
header = new ProfileHeader();
|
|
|
|
|
Add(header);
|
|
|
|
|
|
2019-06-19 09:34:01 +00:00
|
|
|
|
AddStep("Show test dummy", () => header.User.Value = TestSceneUserProfileOverlay.TEST_USER);
|
2019-01-11 00:12:19 +00:00
|
|
|
|
|
2021-11-04 09:02:44 +00:00
|
|
|
|
AddStep("Show null dummy", () => header.User.Value = new APIUser
|
2019-01-11 00:12:19 +00:00
|
|
|
|
{
|
|
|
|
|
Username = "Null"
|
|
|
|
|
});
|
|
|
|
|
|
2021-11-04 09:02:44 +00:00
|
|
|
|
AddStep("Show online dummy", () => header.User.Value = new APIUser
|
2019-06-19 09:34:01 +00:00
|
|
|
|
{
|
|
|
|
|
Username = "IAmOnline",
|
|
|
|
|
LastVisit = DateTimeOffset.Now,
|
|
|
|
|
IsOnline = true,
|
|
|
|
|
});
|
|
|
|
|
|
2021-11-04 09:02:44 +00:00
|
|
|
|
AddStep("Show offline dummy", () => header.User.Value = new APIUser
|
2019-06-19 09:34:01 +00:00
|
|
|
|
{
|
|
|
|
|
Username = "IAmOffline",
|
|
|
|
|
LastVisit = DateTimeOffset.Now,
|
|
|
|
|
IsOnline = false,
|
|
|
|
|
});
|
|
|
|
|
|
2021-11-04 09:02:44 +00:00
|
|
|
|
addOnlineStep("Show ppy", new APIUser
|
2019-01-11 00:12:19 +00:00
|
|
|
|
{
|
|
|
|
|
Username = @"peppy",
|
|
|
|
|
Id = 2,
|
|
|
|
|
IsSupporter = true,
|
|
|
|
|
Country = new Country { FullName = @"Australia", FlagName = @"AU" },
|
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
|
|
|
|
|
});
|
|
|
|
|
|
2021-11-04 09:02:44 +00:00
|
|
|
|
addOnlineStep("Show flyte", new APIUser
|
2019-01-11 00:12:19 +00:00
|
|
|
|
{
|
|
|
|
|
Username = @"flyte",
|
|
|
|
|
Id = 3103765,
|
|
|
|
|
Country = new Country { FullName = @"Japan", FlagName = @"JP" },
|
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-04 09:02:44 +00:00
|
|
|
|
private void addOnlineStep(string name, APIUser fallback)
|
2019-01-11 00:12:19 +00:00
|
|
|
|
{
|
|
|
|
|
AddStep(name, () =>
|
|
|
|
|
{
|
|
|
|
|
if (api.IsLoggedIn)
|
|
|
|
|
{
|
|
|
|
|
var request = new GetUserRequest(fallback.Id);
|
2019-03-09 22:58:14 +00:00
|
|
|
|
request.Success += user => header.User.Value = user;
|
2019-01-11 00:12:19 +00:00
|
|
|
|
api.Queue(request);
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-03-09 22:58:14 +00:00
|
|
|
|
header.User.Value = fallback;
|
2019-01-11 00:12:19 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|