1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 20:47:25 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs

114 lines
4.5 KiB
C#
Raw Normal View History

// 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 17:19:50 +08:00
2020-03-04 19:58:15 +08:00
using System;
using System.Collections.Generic;
2018-04-13 17:19:50 +08:00
using NUnit.Framework;
2020-03-05 05:13:31 +08:00
using osu.Framework.Allocation;
using osu.Framework.Bindables;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2020-03-05 05:13:31 +08:00
using osu.Game.Rulesets;
2018-04-13 17:19:50 +08:00
using osu.Game.Users;
2018-11-20 15:51:59 +08:00
using osuTK;
2018-04-13 17:19:50 +08:00
2019-03-25 00:02:36 +08:00
namespace osu.Game.Tests.Visual.Online
2018-04-13 17:19:50 +08:00
{
[TestFixture]
public class TestSceneUserPanel : OsuTestScene
2018-04-13 17:19:50 +08:00
{
2020-03-04 19:58:15 +08:00
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(UserPanel),
typeof(UserListPanel),
typeof(UserGridPanel),
};
2020-03-05 05:02:36 +08:00
private readonly Bindable<UserActivity> activity = new Bindable<UserActivity>();
2019-05-06 03:11:52 +08:00
2020-03-05 09:11:12 +08:00
private UserGridPanel peppy;
private UserListPanel evast;
2020-03-05 05:02:36 +08:00
2020-03-05 05:13:31 +08:00
[Resolved]
private RulesetStore rulesetStore { get; set; }
2020-03-05 05:02:36 +08:00
[SetUp]
public void SetUp() => Schedule(() =>
2018-04-13 17:19:50 +08:00
{
2020-03-05 09:11:12 +08:00
UserGridPanel flyte;
2020-03-05 05:02:36 +08:00
Child = new FillFlowContainer
2018-04-13 17:19:50 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2020-03-04 19:58:15 +08:00
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
2018-04-13 17:19:50 +08:00
Spacing = new Vector2(10f),
2020-03-05 09:11:12 +08:00
Children = new Drawable[]
2018-04-13 17:19:50 +08:00
{
2020-03-04 19:58:15 +08:00
flyte = new UserGridPanel(new User
2018-04-13 17:19:50 +08:00
{
Username = @"flyte",
Id = 3103765,
Country = new Country { FlagName = @"JP" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
}) { Width = 300 },
2020-03-04 19:58:15 +08:00
peppy = new UserGridPanel(new User
2018-04-13 17:19:50 +08:00
{
Username = @"peppy",
Id = 2,
Country = new Country { FlagName = @"AU" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
IsSupporter = true,
2018-12-22 23:51:24 +08:00
SupportLevel = 3,
2018-04-13 17:19:50 +08:00
}) { Width = 300 },
2020-03-05 09:11:12 +08:00
evast = new UserListPanel(new User
2020-03-04 19:58:15 +08:00
{
Username = @"Evast",
Id = 8195163,
Country = new Country { FlagName = @"BY" },
CoverUrl = @"https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg",
IsOnline = false,
LastVisit = DateTimeOffset.Now
})
2018-04-13 17:19:50 +08:00
},
2020-03-05 05:02:36 +08:00
};
2018-04-13 17:19:50 +08:00
flyte.Status.Value = new UserStatusOnline();
2020-03-05 09:11:12 +08:00
2019-05-06 03:11:52 +08:00
peppy.Status.Value = null;
2020-03-05 05:02:36 +08:00
peppy.Activity.BindTo(activity);
2020-03-05 09:11:12 +08:00
evast.Status.Value = null;
evast.Activity.BindTo(activity);
2020-03-05 05:02:36 +08:00
});
2019-05-06 03:11:52 +08:00
[Test]
2020-03-05 05:05:48 +08:00
public void TestUserStatus()
2019-05-06 03:11:52 +08:00
{
2020-03-05 09:11:12 +08:00
AddStep("online", () => peppy.Status.Value = evast.Status.Value = new UserStatusOnline());
AddStep("do not disturb", () => peppy.Status.Value = evast.Status.Value = new UserStatusDoNotDisturb());
AddStep("offline", () => peppy.Status.Value = evast.Status.Value = new UserStatusOffline());
AddStep("null status", () => peppy.Status.Value = evast.Status.Value = null);
2019-05-06 03:11:52 +08:00
}
2018-04-13 17:19:50 +08:00
2019-05-06 03:11:52 +08:00
[Test]
2020-03-05 05:05:48 +08:00
public void TestUserActivity()
2019-05-06 03:11:52 +08:00
{
2020-03-05 09:11:12 +08:00
AddStep("set online status", () => peppy.Status.Value = evast.Status.Value = new UserStatusOnline());
2020-03-05 05:04:49 +08:00
AddStep("idle", () => activity.Value = null);
AddStep("spectating", () => activity.Value = new UserActivity.Spectating());
2020-03-05 05:13:31 +08: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-05 05:04:49 +08: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 17:19:50 +08:00
}
2020-03-05 05:13:31 +08:00
private UserActivity soloGameStatusForRuleset(int rulesetId) => new UserActivity.SoloGame(null, rulesetStore.GetRuleset(rulesetId));
2018-04-13 17:19:50 +08:00
}
}