1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 00:42:55 +08:00

Use api.IsLoggedIn

This commit is contained in:
Andrei Zavatski 2019-11-06 12:46:25 +03:00
parent 1f3b209a6c
commit 4330507da8
2 changed files with 10 additions and 4 deletions

View File

@ -10,6 +10,7 @@ using osu.Framework.Allocation;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Users; using osu.Game.Users;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Online.API;
namespace osu.Game.Tests.Visual.Online namespace osu.Game.Tests.Visual.Online
{ {
@ -21,6 +22,11 @@ namespace osu.Game.Tests.Visual.Online
typeof(VotePill) typeof(VotePill)
}; };
protected override bool UseOnlineAPI => true;
[Resolved]
private IAPIProvider api { get; set; }
private VotePill votePill; private VotePill votePill;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -33,7 +39,7 @@ namespace osu.Game.Tests.Visual.Online
VotesCount = 2, VotesCount = 2,
}; };
AddStep("Log in", () => API.LocalUser.Value = new User AddStep("Log in", () => api.LocalUser.Value = new User
{ {
Id = RNG.Next(2, 100000) Id = RNG.Next(2, 100000)
}); });
@ -45,7 +51,7 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Click", () => votePill.Click()); AddStep("Click", () => votePill.Click());
AddAssert("Loading", () => votePill.IsLoading); AddAssert("Loading", () => votePill.IsLoading);
AddStep("Log out", API.Logout); AddStep("Log out", api.Logout);
AddStep("Random comment", () => addVotePill(randomComment)); AddStep("Random comment", () => addVotePill(randomComment));
AddStep("Click", () => votePill.Click()); AddStep("Click", () => votePill.Click());
AddAssert("Not loading", () => !votePill.IsLoading); AddAssert("Not loading", () => !votePill.IsLoading);
@ -54,7 +60,7 @@ namespace osu.Game.Tests.Visual.Online
private Comment getUserComment() => new Comment private Comment getUserComment() => new Comment
{ {
IsVoted = false, IsVoted = false,
UserId = API.LocalUser.Value.Id, UserId = api.LocalUser.Value.Id,
VotesCount = 10, VotesCount = 10,
}; };

View File

@ -59,7 +59,7 @@ namespace osu.Game.Overlays.Comments
AccentColour = borderContainer.BorderColour = sideNumber.Colour = colours.GreenLight; AccentColour = borderContainer.BorderColour = sideNumber.Colour = colours.GreenLight;
hoverLayer.Colour = Color4.Black.Opacity(0.5f); hoverLayer.Colour = Color4.Black.Opacity(0.5f);
if (api.LocalUser.Value.Id != comment.UserId && api.LocalUser.Value.Id != 1) if (api.LocalUser.Value.Id != comment.UserId && api.IsLoggedIn)
Action = onAction; Action = onAction;
} }