2019-01-28 06:45:00 +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.
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osu.Game.Online.API.Requests;
|
2019-05-21 12:36:21 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osu.Game.Overlays.Profile;
|
|
|
|
|
using osu.Game.Overlays.Profile.Header;
|
2019-04-26 12:49:44 +08:00
|
|
|
|
using osu.Game.Overlays.Profile.Header.Components;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osu.Game.Users;
|
|
|
|
|
|
2019-04-04 06:24:42 +08:00
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public class TestSceneUserProfileHeader : OsuTestScene
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2019-09-13 16:15:33 +08:00
|
|
|
|
protected override bool UseOnlineAPI => true;
|
2019-08-01 03:44:44 +08:00
|
|
|
|
|
2019-01-11 08:12:19 +08:00
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
|
{
|
|
|
|
|
typeof(ProfileHeader),
|
|
|
|
|
typeof(RankGraph),
|
|
|
|
|
typeof(LineGraph),
|
2019-05-21 12:36:21 +08:00
|
|
|
|
typeof(OverlayHeaderTabControl),
|
2019-04-25 17:43:29 +08:00
|
|
|
|
typeof(CentreHeaderContainer),
|
2019-04-25 18:51:05 +08:00
|
|
|
|
typeof(BottomHeaderContainer),
|
2019-04-25 19:30:16 +08:00
|
|
|
|
typeof(DetailHeaderContainer),
|
2019-04-25 18:51:05 +08:00
|
|
|
|
typeof(ProfileHeaderButton)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[Resolved]
|
2019-04-04 06:24:42 +08:00
|
|
|
|
private IAPIProvider api { get; set; }
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
|
|
|
|
private readonly ProfileHeader header;
|
|
|
|
|
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public TestSceneUserProfileHeader()
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
header = new ProfileHeader();
|
|
|
|
|
Add(header);
|
|
|
|
|
|
2019-06-19 17:34:01 +08:00
|
|
|
|
AddStep("Show test dummy", () => header.User.Value = TestSceneUserProfileOverlay.TEST_USER);
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
2019-03-10 06:58:14 +08:00
|
|
|
|
AddStep("Show null dummy", () => header.User.Value = new User
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
Username = "Null"
|
|
|
|
|
});
|
|
|
|
|
|
2019-06-19 17:34:01 +08:00
|
|
|
|
AddStep("Show online dummy", () => header.User.Value = new User
|
|
|
|
|
{
|
|
|
|
|
Username = "IAmOnline",
|
|
|
|
|
LastVisit = DateTimeOffset.Now,
|
|
|
|
|
IsOnline = true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddStep("Show offline dummy", () => header.User.Value = new User
|
|
|
|
|
{
|
|
|
|
|
Username = "IAmOffline",
|
|
|
|
|
LastVisit = DateTimeOffset.Now,
|
|
|
|
|
IsOnline = false,
|
|
|
|
|
});
|
|
|
|
|
|
2019-01-11 08:12:19 +08:00
|
|
|
|
addOnlineStep("Show ppy", new User
|
|
|
|
|
{
|
|
|
|
|
Username = @"peppy",
|
|
|
|
|
Id = 2,
|
|
|
|
|
IsSupporter = true,
|
|
|
|
|
Country = new Country { FullName = @"Australia", FlagName = @"AU" },
|
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
addOnlineStep("Show flyte", new User
|
|
|
|
|
{
|
|
|
|
|
Username = @"flyte",
|
|
|
|
|
Id = 3103765,
|
|
|
|
|
Country = new Country { FullName = @"Japan", FlagName = @"JP" },
|
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addOnlineStep(string name, User fallback)
|
|
|
|
|
{
|
|
|
|
|
AddStep(name, () =>
|
|
|
|
|
{
|
|
|
|
|
if (api.IsLoggedIn)
|
|
|
|
|
{
|
|
|
|
|
var request = new GetUserRequest(fallback.Id);
|
2019-03-10 06:58:14 +08:00
|
|
|
|
request.Success += user => header.User.Value = user;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
api.Queue(request);
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-03-10 06:58:14 +08:00
|
|
|
|
header.User.Value = fallback;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|