mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 09:23:06 +08:00
Add test coverage
This commit is contained in:
parent
b292bf3832
commit
be1d3c0ea4
@ -111,6 +111,87 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("complete request", () => pendingRequest.TriggerSuccess(TEST_USER));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCustomColourScheme()
|
||||
{
|
||||
int hue = 0;
|
||||
|
||||
AddSliderStep("hue", 0, 360, 222, h => hue = h);
|
||||
|
||||
AddStep("set up request handling", () =>
|
||||
{
|
||||
dummyAPI.HandleRequest = req =>
|
||||
{
|
||||
if (req is GetUserRequest getUserRequest)
|
||||
{
|
||||
getUserRequest.TriggerSuccess(new APIUser
|
||||
{
|
||||
Username = $"Colorful #{hue}",
|
||||
Id = 1,
|
||||
CountryCode = CountryCode.JP,
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c2.jpg",
|
||||
ProfileHue = hue,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("show user", () => profile.ShowUser(new APIUser { Id = 1 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCustomColourSchemeWithReload()
|
||||
{
|
||||
int hue = 0;
|
||||
GetUserRequest pendingRequest = null!;
|
||||
|
||||
AddSliderStep("hue", 0, 360, 222, h => hue = h);
|
||||
|
||||
AddStep("set up request handling", () =>
|
||||
{
|
||||
dummyAPI.HandleRequest = req =>
|
||||
{
|
||||
if (req is GetUserRequest getUserRequest)
|
||||
{
|
||||
pendingRequest = getUserRequest;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("show user", () => profile.ShowUser(new APIUser { Id = 1 }));
|
||||
|
||||
AddWaitStep("wait some", 3);
|
||||
AddStep("complete request", () => pendingRequest.TriggerSuccess(new APIUser
|
||||
{
|
||||
Username = $"Colorful #{hue}",
|
||||
Id = 1,
|
||||
CountryCode = CountryCode.JP,
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c2.jpg",
|
||||
ProfileHue = hue,
|
||||
}));
|
||||
|
||||
int hue2 = 0;
|
||||
|
||||
AddSliderStep("hue 2", 0, 360, 50, h => hue2 = h);
|
||||
AddStep("show user", () => profile.ShowUser(new APIUser { Id = 1 }));
|
||||
AddWaitStep("wait some", 3);
|
||||
|
||||
AddStep("complete request", () => pendingRequest.TriggerSuccess(new APIUser
|
||||
{
|
||||
Username = $"Colorful #{hue2}",
|
||||
Id = 1,
|
||||
CountryCode = CountryCode.JP,
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c2.jpg",
|
||||
ProfileHue = hue2,
|
||||
}));
|
||||
}
|
||||
|
||||
public static readonly APIUser TEST_USER = new APIUser
|
||||
{
|
||||
Username = @"Somebody",
|
||||
|
Loading…
Reference in New Issue
Block a user