1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-09 05:37:25 +08:00
osu-lazer/osu.Game.Tests/Visual/TestCaseUserProfile.cs

104 lines
3.5 KiB
C#
Raw Normal View History

2018-01-05 19:21:19 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
2017-09-18 21:32:49 +08:00
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
2017-12-22 17:58:35 +08:00
using System.Collections.Generic;
2017-09-18 21:32:49 +08:00
using System.Linq;
2018-03-02 14:34:31 +08:00
using NUnit.Framework;
2017-12-22 17:58:35 +08:00
using osu.Game.Graphics.UserInterface;
2017-09-18 21:32:49 +08:00
using osu.Game.Overlays;
2017-12-22 17:58:35 +08:00
using osu.Game.Overlays.Profile;
2017-09-18 21:32:49 +08:00
using osu.Game.Users;
namespace osu.Game.Tests.Visual
{
2018-03-02 14:34:31 +08:00
[TestFixture]
2017-12-20 20:47:45 +08:00
public class TestCaseUserProfile : OsuTestCase
2017-09-18 21:32:49 +08:00
{
private readonly TestUserProfileOverlay profile;
2017-12-22 17:58:35 +08:00
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ProfileHeader),
typeof(UserProfileOverlay),
typeof(RankGraph),
2017-12-22 17:58:35 +08:00
typeof(LineGraph),
};
2017-09-18 21:32:49 +08:00
public TestCaseUserProfile()
{
Add(profile = new TestUserProfileOverlay());
}
protected override void LoadComplete()
{
base.LoadComplete();
2017-09-18 21:32:49 +08:00
AddStep("Show offline dummy", () => profile.ShowUser(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,
Age = 1,
ProfileOrder = new[] { "me" },
Statistics = new UserStatistics
{
2018-02-07 17:04:32 +08:00
Ranks = new UserStatistics.UserRanks { Global = 2148, Country = 1 },
PP = 4567.89m,
2017-09-18 21:32:49 +08:00
},
RankHistory = new User.RankHistoryData
{
Mode = @"osu",
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
}
}, false));
checkSupporterTag(false);
AddStep("Show null dummy", () => profile.ShowUser(new User
{
Username = @"Null",
Id = 1,
}, false));
2017-09-18 21:32:49 +08:00
AddStep("Show ppy", () => profile.ShowUser(new User
{
Username = @"peppy",
Id = 2,
Country = new Country { FullName = @"Australia", FlagName = @"AU" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
}));
checkSupporterTag(true);
2017-09-18 21:32:49 +08: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"
}));
2017-09-18 21:32:49 +08:00
AddStep("Hide", profile.Hide);
AddStep("Show without reload", profile.Show);
}
private void checkSupporterTag(bool isSupporter)
{
AddUntilStep(() => profile.Header.User != null, "wait for load");
if (isSupporter)
AddAssert("is supporter", () => profile.Header.SupporterTag.Alpha == 1);
else
AddAssert("no supporter", () => profile.Header.SupporterTag.Alpha == 0);
}
private class TestUserProfileOverlay : UserProfileOverlay
{
public new ProfileHeader Header => base.Header;
}
2017-09-18 21:32:49 +08:00
}
}