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

99 lines
3.1 KiB
C#
Raw Normal View History

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.
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;
using osu.Game.Overlays;
using osu.Game.Overlays.Profile;
using osu.Game.Overlays.Profile.Header;
2019-04-26 04:49:44 +00:00
using osu.Game.Overlays.Profile.Header.Components;
using osu.Game.Users;
2019-04-03 22:24:42 +00:00
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneUserProfileHeader : OsuTestScene
{
protected override bool UseOnlineAPI => true;
2019-07-31 19:44:44 +00:00
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ProfileHeader),
typeof(RankGraph),
typeof(LineGraph),
typeof(OverlayHeaderTabControl),
2019-04-25 09:43:29 +00:00
typeof(CentreHeaderContainer),
2019-04-25 10:51:05 +00:00
typeof(BottomHeaderContainer),
typeof(DetailHeaderContainer),
2019-04-25 10:51:05 +00:00
typeof(ProfileHeaderButton)
};
[Resolved]
2019-04-03 22:24:42 +00:00
private IAPIProvider api { get; set; }
private readonly ProfileHeader header;
public TestSceneUserProfileHeader()
{
header = new ProfileHeader();
Add(header);
2019-06-19 09:34:01 +00:00
AddStep("Show test dummy", () => header.User.Value = TestSceneUserProfileOverlay.TEST_USER);
2019-03-09 22:58:14 +00:00
AddStep("Show null dummy", () => header.User.Value = new User
{
Username = "Null"
});
2019-06-19 09:34:01 +00: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,
});
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-09 22:58:14 +00:00
request.Success += user => header.User.Value = user;
api.Queue(request);
}
else
2019-03-09 22:58:14 +00:00
header.User.Value = fallback;
});
}
}
}