mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 09:02:58 +08:00
Bring profile header test in line with modern conventions
- Removed online code that didn't work anyway after the introduction of the development web instance. - Removed some weird test steps. - Fixed online/offline test steps not working at all due to identical user ID.
This commit is contained in:
parent
a3b81094ca
commit
c112177559
@ -2,85 +2,52 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Profile;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneUserProfileHeader : OsuTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
private ProfileHeader header;
|
||||
|
||||
private readonly ProfileHeader header;
|
||||
|
||||
public TestSceneUserProfileHeader()
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
header = new ProfileHeader();
|
||||
Add(header);
|
||||
AddStep("create header", () => Child = header = new ProfileHeader());
|
||||
}
|
||||
|
||||
AddStep("Show test dummy", () => header.User.Value = TestSceneUserProfileOverlay.TEST_USER);
|
||||
[Test]
|
||||
public void TestBasic()
|
||||
{
|
||||
AddStep("Show example user", () => header.User.Value = TestSceneUserProfileOverlay.TEST_USER);
|
||||
}
|
||||
|
||||
AddStep("Show null dummy", () => header.User.Value = new APIUser
|
||||
{
|
||||
Username = "Null"
|
||||
});
|
||||
|
||||
AddStep("Show online dummy", () => header.User.Value = new APIUser
|
||||
[Test]
|
||||
public void TestOnlineState()
|
||||
{
|
||||
AddStep("Show online user", () => header.User.Value = new APIUser
|
||||
{
|
||||
Id = 1001,
|
||||
Username = "IAmOnline",
|
||||
LastVisit = DateTimeOffset.Now,
|
||||
IsOnline = true,
|
||||
});
|
||||
|
||||
AddStep("Show offline dummy", () => header.User.Value = new APIUser
|
||||
AddStep("Show offline user", () => header.User.Value = new APIUser
|
||||
{
|
||||
Id = 1002,
|
||||
Username = "IAmOffline",
|
||||
LastVisit = DateTimeOffset.Now,
|
||||
LastVisit = DateTimeOffset.Now.AddDays(-10),
|
||||
IsOnline = false,
|
||||
});
|
||||
|
||||
addOnlineStep("Show ppy", new APIUser
|
||||
{
|
||||
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 APIUser
|
||||
{
|
||||
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, APIUser fallback)
|
||||
{
|
||||
AddStep(name, () =>
|
||||
{
|
||||
if (api.IsLoggedIn)
|
||||
{
|
||||
var request = new GetUserRequest(fallback.Id);
|
||||
request.Success += user => header.User.Value = user;
|
||||
api.Queue(request);
|
||||
}
|
||||
else
|
||||
header.User.Value = fallback;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user