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

116 lines
3.9 KiB
C#
Raw Normal View History

// 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.
2018-04-13 09:19:50 +00:00
using System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Game.Online.API;
2018-04-13 09:19:50 +00:00
using osu.Game.Overlays;
using osu.Game.Overlays.Profile;
using osu.Game.Users;
2019-03-24 16:02:36 +00:00
namespace osu.Game.Tests.Visual.Online
2018-04-13 09:19:50 +00:00
{
[TestFixture]
public class TestSceneUserProfileOverlay : OsuTestScene
2018-04-13 09:19:50 +00:00
{
protected override bool UseOnlineAPI => true;
2019-07-31 19:44:44 +00:00
2018-04-13 09:19:50 +00:00
private readonly TestUserProfileOverlay profile;
2019-04-03 22:57:15 +00:00
[Resolved]
private IAPIProvider api { get; set; }
2018-04-13 09:19:50 +00:00
public static readonly User TEST_USER = new User
{
Username = @"Somebody",
Id = 1,
Country = new Country { FullName = @"Alien" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c1.jpg",
JoinDate = DateTimeOffset.Now.AddDays(-1),
LastVisit = DateTimeOffset.Now,
ProfileOrder = new[] { "me" },
Statistics = new UserStatistics
{
Ranks = new UserStatistics.UserRanks { Global = 2148, Country = 1 },
PP = 4567.89m,
Level = new UserStatistics.LevelInfo
{
Current = 727,
Progress = 69,
},
RankHistory = new User.RankHistoryData
{
Mode = @"osu",
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
},
},
Badges = new[]
{
new Badge
{
AwardedAt = DateTimeOffset.FromUnixTimeSeconds(1505741569),
Description = "Outstanding help by being a voluntary test subject.",
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg"
}
},
Title = "osu!volunteer",
Colour = "ff0000",
2019-11-28 13:41:29 +00:00
Achievements = Array.Empty<User.UserAchievement>(),
};
public TestSceneUserProfileOverlay()
2018-04-13 09:19:50 +00:00
{
Add(profile = new TestUserProfileOverlay());
}
protected override void LoadComplete()
{
base.LoadComplete();
AddStep("Show offline dummy", () => profile.ShowUser(TEST_USER, false));
2018-04-13 09:19:50 +00:00
AddStep("Show null dummy", () => profile.ShowUser(new User
{
Username = @"Null",
Id = 1,
}, false));
AddStep("Show ppy", () => profile.ShowUser(new User
{
Username = @"peppy",
Id = 2,
IsSupporter = true,
2018-04-13 09:19:50 +00:00
Country = new Country { FullName = @"Australia", FlagName = @"AU" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
}, api.IsLoggedIn));
2018-04-13 09:19:50 +00:00
AddStep("Show flyte", () => profile.ShowUser(new User
{
Username = @"flyte",
Id = 3103765,
Country = new Country { FullName = @"Japan", FlagName = @"JP" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
}, api.IsLoggedIn));
2019-09-29 11:56:33 +00:00
AddStep("Show bancho", () => profile.ShowUser(new User
{
Username = @"BanchoBot",
Id = 3,
IsBot = true,
Country = new Country { FullName = @"Saint Helena", FlagName = @"SH" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c4.jpg"
}, api.IsLoggedIn));
2018-04-13 09:19:50 +00:00
AddStep("Hide", profile.Hide);
AddStep("Show without reload", profile.Show);
}
private class TestUserProfileOverlay : UserProfileOverlay
{
public new ProfileHeader Header => base.Header;
}
}
}