mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:23:20 +08:00
Add tests to cover the issue
This commit is contained in:
parent
1587d4b26f
commit
1e025b7c31
@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
private readonly Bindable<UserStatus> status = new Bindable<UserStatus>();
|
||||
|
||||
private UserGridPanel peppy;
|
||||
private UserListPanel evast;
|
||||
private TestUserListPanel evast;
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesetStore { get; set; }
|
||||
@ -38,6 +38,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
UserGridPanel flyte;
|
||||
|
||||
activity.Value = null;
|
||||
status.Value = null;
|
||||
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
@ -63,7 +66,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
IsSupporter = true,
|
||||
SupportLevel = 3,
|
||||
}) { Width = 300 },
|
||||
evast = new UserListPanel(new User
|
||||
evast = new TestUserListPanel(new User
|
||||
{
|
||||
Username = @"Evast",
|
||||
Id = 8195163,
|
||||
@ -96,7 +99,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[Test]
|
||||
public void TestUserActivity()
|
||||
{
|
||||
AddStep("set online status", () => peppy.Status.Value = evast.Status.Value = new UserStatusOnline());
|
||||
AddStep("set online status", () => status.Value = new UserStatusOnline());
|
||||
|
||||
AddStep("idle", () => activity.Value = null);
|
||||
AddStep("spectating", () => activity.Value = new UserActivity.Spectating());
|
||||
@ -109,6 +112,29 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("modding", () => activity.Value = new UserActivity.Modding());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUserActivityChange()
|
||||
{
|
||||
AddAssert("visit message is visible", () => evast.LastVisitMessage.IsPresent);
|
||||
AddStep("set online status", () => status.Value = new UserStatusOnline());
|
||||
AddAssert("visit message is not visible", () => !evast.LastVisitMessage.IsPresent);
|
||||
AddStep("set choosing activity", () => activity.Value = new UserActivity.ChoosingBeatmap());
|
||||
AddStep("set offline status", () => status.Value = new UserStatusOffline());
|
||||
AddAssert("visit message is visible", () => evast.LastVisitMessage.IsPresent);
|
||||
AddStep("set online status", () => status.Value = new UserStatusOnline());
|
||||
AddAssert("visit message is not visible", () => !evast.LastVisitMessage.IsPresent);
|
||||
}
|
||||
|
||||
private UserActivity soloGameStatusForRuleset(int rulesetId) => new UserActivity.SoloGame(null, rulesetStore.GetRuleset(rulesetId));
|
||||
|
||||
private class TestUserListPanel : UserListPanel
|
||||
{
|
||||
public TestUserListPanel(User user)
|
||||
: base(user)
|
||||
{
|
||||
}
|
||||
|
||||
public new TextFlowContainer LastVisitMessage => base.LastVisitMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,9 +36,10 @@ namespace osu.Game.Users
|
||||
|
||||
protected DelayedLoadUnloadWrapper Background { get; private set; }
|
||||
|
||||
protected TextFlowContainer LastVisitMessage { get; private set; }
|
||||
|
||||
private SpriteIcon statusIcon;
|
||||
private OsuSpriteText statusMessage;
|
||||
private TextFlowContainer lastVisitMessage;
|
||||
|
||||
protected UserPanel(User user)
|
||||
{
|
||||
@ -153,7 +154,7 @@ namespace osu.Game.Users
|
||||
|
||||
var alignment = rightAlignedChildren ? Anchor.CentreRight : Anchor.CentreLeft;
|
||||
|
||||
statusContainer.Add(lastVisitMessage = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold)).With(text =>
|
||||
statusContainer.Add(LastVisitMessage = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold)).With(text =>
|
||||
{
|
||||
text.Anchor = alignment;
|
||||
text.Origin = alignment;
|
||||
@ -193,7 +194,7 @@ namespace osu.Game.Users
|
||||
}
|
||||
|
||||
// Otherwise use only status
|
||||
lastVisitMessage.FadeTo(status is UserStatusOffline && User.LastVisit.HasValue ? 1 : 0);
|
||||
LastVisitMessage.FadeTo(status is UserStatusOffline && User.LastVisit.HasValue ? 1 : 0);
|
||||
statusMessage.Text = status.Message;
|
||||
statusIcon.FadeColour(status.GetAppropriateColour(colours), 500, Easing.OutQuint);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user