2019-01-24 17:43:03 +09:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2022-06-17 16:37:17 +09:00
|
|
|
#nullable disable
|
|
|
|
|
2020-03-04 14:58:15 +03:00
|
|
|
using System;
|
2018-04-13 18:19:50 +09:00
|
|
|
using NUnit.Framework;
|
2020-03-04 22:13:31 +01:00
|
|
|
using osu.Framework.Allocation;
|
2019-06-12 18:04:57 +09:00
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 18:19:50 +09:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-11-04 18:02:44 +09:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-03-04 22:13:31 +01:00
|
|
|
using osu.Game.Rulesets;
|
2018-04-13 18:19:50 +09:00
|
|
|
using osu.Game.Users;
|
2018-11-20 16:51:59 +09:00
|
|
|
using osuTK;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2019-03-25 01:02:36 +09:00
|
|
|
namespace osu.Game.Tests.Visual.Online
|
2018-04-13 18:19:50 +09:00
|
|
|
{
|
|
|
|
[TestFixture]
|
2022-11-24 14:32:20 +09:00
|
|
|
public partial class TestSceneUserPanel : OsuTestScene
|
2018-04-13 18:19:50 +09:00
|
|
|
{
|
2020-03-04 22:02:36 +01:00
|
|
|
private readonly Bindable<UserActivity> activity = new Bindable<UserActivity>();
|
2020-03-08 03:07:14 +03:00
|
|
|
private readonly Bindable<UserStatus> status = new Bindable<UserStatus>();
|
2019-05-05 21:11:52 +02:00
|
|
|
|
2022-01-13 12:37:57 +09:00
|
|
|
private UserGridPanel boundPanel1;
|
|
|
|
private TestUserListPanel boundPanel2;
|
2020-03-04 22:02:36 +01:00
|
|
|
|
2020-03-04 22:13:31 +01:00
|
|
|
[Resolved]
|
2021-12-03 18:14:44 +09:00
|
|
|
private IRulesetStore rulesetStore { get; set; }
|
2020-03-04 22:13:31 +01:00
|
|
|
|
2020-03-04 22:02:36 +01:00
|
|
|
[SetUp]
|
|
|
|
public void SetUp() => Schedule(() =>
|
2018-04-13 18:19:50 +09:00
|
|
|
{
|
2020-03-25 20:58:51 +03:00
|
|
|
activity.Value = null;
|
|
|
|
status.Value = null;
|
|
|
|
|
2020-03-04 22:02:36 +01:00
|
|
|
Child = new FillFlowContainer
|
2018-04-13 18:19:50 +09:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2020-03-04 14:58:15 +03:00
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2018-04-13 18:19:50 +09:00
|
|
|
Spacing = new Vector2(10f),
|
2020-03-05 04:11:12 +03:00
|
|
|
Children = new Drawable[]
|
2018-04-13 18:19:50 +09:00
|
|
|
{
|
2021-11-04 18:02:44 +09:00
|
|
|
new UserBrickPanel(new APIUser
|
2020-07-18 20:24:38 +03:00
|
|
|
{
|
|
|
|
Username = @"flyte",
|
|
|
|
Id = 3103765,
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
|
|
|
|
}),
|
2021-11-04 18:02:44 +09:00
|
|
|
new UserBrickPanel(new APIUser
|
2020-07-18 20:24:38 +03:00
|
|
|
{
|
|
|
|
Username = @"peppy",
|
|
|
|
Id = 2,
|
|
|
|
Colour = "99EB47",
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
|
|
|
}),
|
2022-01-13 12:37:57 +09:00
|
|
|
new UserGridPanel(new APIUser
|
2018-04-13 18:19:50 +09:00
|
|
|
{
|
|
|
|
Username = @"flyte",
|
|
|
|
Id = 3103765,
|
2022-07-18 08:40:34 +03:00
|
|
|
CountryCode = CountryCode.JP,
|
2022-01-13 12:37:57 +09:00
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg",
|
|
|
|
Status = { Value = new UserStatusOnline() }
|
2018-04-13 18:19:50 +09:00
|
|
|
}) { Width = 300 },
|
2022-01-13 12:37:57 +09:00
|
|
|
boundPanel1 = new UserGridPanel(new APIUser
|
2018-04-13 18:19:50 +09:00
|
|
|
{
|
|
|
|
Username = @"peppy",
|
|
|
|
Id = 2,
|
2022-07-18 08:40:34 +03:00
|
|
|
CountryCode = CountryCode.AU,
|
2018-04-13 18:19:50 +09:00
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
|
|
|
IsSupporter = true,
|
2018-12-22 16:51:24 +01:00
|
|
|
SupportLevel = 3,
|
2018-04-13 18:19:50 +09:00
|
|
|
}) { Width = 300 },
|
2022-01-13 12:37:57 +09:00
|
|
|
boundPanel2 = new TestUserListPanel(new APIUser
|
2020-03-04 14:58:15 +03:00
|
|
|
{
|
|
|
|
Username = @"Evast",
|
|
|
|
Id = 8195163,
|
2022-07-18 08:40:34 +03:00
|
|
|
CountryCode = CountryCode.BY,
|
2020-03-04 14:58:15 +03:00
|
|
|
CoverUrl = @"https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg",
|
|
|
|
IsOnline = false,
|
|
|
|
LastVisit = DateTimeOffset.Now
|
|
|
|
})
|
2018-04-13 18:19:50 +09:00
|
|
|
},
|
2020-03-04 22:02:36 +01:00
|
|
|
};
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2022-01-13 12:37:57 +09:00
|
|
|
boundPanel1.Status.BindTo(status);
|
|
|
|
boundPanel1.Activity.BindTo(activity);
|
2020-03-05 04:11:12 +03:00
|
|
|
|
2022-01-13 12:37:57 +09:00
|
|
|
boundPanel2.Status.BindTo(status);
|
|
|
|
boundPanel2.Activity.BindTo(activity);
|
2020-03-04 22:02:36 +01:00
|
|
|
});
|
2019-05-05 21:11:52 +02:00
|
|
|
|
|
|
|
[Test]
|
2020-03-04 22:05:48 +01:00
|
|
|
public void TestUserStatus()
|
2019-05-05 21:11:52 +02:00
|
|
|
{
|
2020-03-08 03:07:14 +03:00
|
|
|
AddStep("online", () => status.Value = new UserStatusOnline());
|
|
|
|
AddStep("do not disturb", () => status.Value = new UserStatusDoNotDisturb());
|
|
|
|
AddStep("offline", () => status.Value = new UserStatusOffline());
|
|
|
|
AddStep("null status", () => status.Value = null);
|
2019-05-05 21:11:52 +02:00
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
2019-05-05 21:11:52 +02:00
|
|
|
[Test]
|
2020-03-04 22:05:48 +01:00
|
|
|
public void TestUserActivity()
|
2019-05-05 21:11:52 +02:00
|
|
|
{
|
2020-03-25 20:58:51 +03:00
|
|
|
AddStep("set online status", () => status.Value = new UserStatusOnline());
|
2019-06-12 18:04:57 +09:00
|
|
|
|
2020-03-04 22:04:49 +01:00
|
|
|
AddStep("idle", () => activity.Value = null);
|
|
|
|
AddStep("spectating", () => activity.Value = new UserActivity.Spectating());
|
2020-03-04 22:13:31 +01:00
|
|
|
AddStep("solo (osu!)", () => activity.Value = soloGameStatusForRuleset(0));
|
|
|
|
AddStep("solo (osu!taiko)", () => activity.Value = soloGameStatusForRuleset(1));
|
|
|
|
AddStep("solo (osu!catch)", () => activity.Value = soloGameStatusForRuleset(2));
|
|
|
|
AddStep("solo (osu!mania)", () => activity.Value = soloGameStatusForRuleset(3));
|
2020-03-04 22:04:49 +01:00
|
|
|
AddStep("choosing", () => activity.Value = new UserActivity.ChoosingBeatmap());
|
|
|
|
AddStep("editing", () => activity.Value = new UserActivity.Editing(null));
|
|
|
|
AddStep("modding", () => activity.Value = new UserActivity.Modding());
|
2018-04-13 18:19:50 +09:00
|
|
|
}
|
2020-03-04 22:13:31 +01:00
|
|
|
|
2020-03-25 20:58:51 +03:00
|
|
|
[Test]
|
|
|
|
public void TestUserActivityChange()
|
|
|
|
{
|
2022-01-13 12:37:57 +09:00
|
|
|
AddAssert("visit message is visible", () => boundPanel2.LastVisitMessage.IsPresent);
|
2020-03-25 20:58:51 +03:00
|
|
|
AddStep("set online status", () => status.Value = new UserStatusOnline());
|
2022-01-13 12:37:57 +09:00
|
|
|
AddAssert("visit message is not visible", () => !boundPanel2.LastVisitMessage.IsPresent);
|
2020-03-25 20:58:51 +03:00
|
|
|
AddStep("set choosing activity", () => activity.Value = new UserActivity.ChoosingBeatmap());
|
|
|
|
AddStep("set offline status", () => status.Value = new UserStatusOffline());
|
2022-01-13 12:37:57 +09:00
|
|
|
AddAssert("visit message is visible", () => boundPanel2.LastVisitMessage.IsPresent);
|
2020-03-25 20:58:51 +03:00
|
|
|
AddStep("set online status", () => status.Value = new UserStatusOnline());
|
2022-01-13 12:37:57 +09:00
|
|
|
AddAssert("visit message is not visible", () => !boundPanel2.LastVisitMessage.IsPresent);
|
2020-03-25 20:58:51 +03:00
|
|
|
}
|
|
|
|
|
2021-08-16 06:32:33 +08:00
|
|
|
private UserActivity soloGameStatusForRuleset(int rulesetId) => new UserActivity.InSoloGame(null, rulesetStore.GetRuleset(rulesetId));
|
2020-03-25 20:58:51 +03:00
|
|
|
|
2022-11-24 14:32:20 +09:00
|
|
|
private partial class TestUserListPanel : UserListPanel
|
2020-03-25 20:58:51 +03:00
|
|
|
{
|
2021-11-04 18:02:44 +09:00
|
|
|
public TestUserListPanel(APIUser user)
|
2020-03-25 20:58:51 +03:00
|
|
|
: base(user)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public new TextFlowContainer LastVisitMessage => base.LastVisitMessage;
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
}
|
|
|
|
}
|