mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:52:53 +08:00
Add unit test for handling login state in UserProfileOverlay
This commit is contained in:
parent
ec7b82f5e8
commit
826c82de47
@ -78,6 +78,31 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("complete request", () => pendingRequest.TriggerSuccess(TEST_USER));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLogin()
|
||||
{
|
||||
GetUserRequest pendingRequest = null!;
|
||||
|
||||
AddStep("set up request handling", () =>
|
||||
{
|
||||
dummyAPI.HandleRequest = req =>
|
||||
{
|
||||
if (dummyAPI.State.Value == APIState.Online && req is GetUserRequest getUserRequest)
|
||||
{
|
||||
pendingRequest = getUserRequest;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
});
|
||||
AddStep("logout", () => dummyAPI.Logout());
|
||||
AddStep("show user", () => profile.ShowUser(new APIUser { Id = 1 }));
|
||||
AddStep("login", () => dummyAPI.Login("username", "password"));
|
||||
AddWaitStep("wait some", 3);
|
||||
AddStep("complete request", () => pendingRequest.TriggerSuccess(TEST_USER));
|
||||
}
|
||||
|
||||
public static readonly APIUser TEST_USER = new APIUser
|
||||
{
|
||||
Username = @"Somebody",
|
||||
|
Loading…
Reference in New Issue
Block a user