From c11217755987abbe9ca0c63ad832f6839463647e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 19 Dec 2021 12:48:09 +0100 Subject: [PATCH] Bring profile header test in line with modern conventions - Removed online code that didn't work anyway after the introduction of the development web instance. - Removed some weird test steps. - Fixed online/offline test steps not working at all due to identical user ID. --- .../Online/TestSceneUserProfileHeader.cs | 73 +++++-------------- 1 file changed, 20 insertions(+), 53 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs index 76997bded7..c319d2f7de 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs @@ -2,85 +2,52 @@ // See the LICENCE file in the repository root for full licence text. using System; +using NUnit.Framework; using osu.Framework.Allocation; -using osu.Game.Online.API; -using osu.Game.Online.API.Requests; +using osu.Framework.Testing; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; using osu.Game.Overlays.Profile; -using osu.Game.Users; namespace osu.Game.Tests.Visual.Online { public class TestSceneUserProfileHeader : OsuTestScene { - protected override bool UseOnlineAPI => true; - [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green); - [Resolved] - private IAPIProvider api { get; set; } + private ProfileHeader header; - private readonly ProfileHeader header; - - public TestSceneUserProfileHeader() + [SetUpSteps] + public void SetUpSteps() { - header = new ProfileHeader(); - Add(header); + AddStep("create header", () => Child = header = new ProfileHeader()); + } - AddStep("Show test dummy", () => header.User.Value = TestSceneUserProfileOverlay.TEST_USER); + [Test] + public void TestBasic() + { + AddStep("Show example user", () => header.User.Value = TestSceneUserProfileOverlay.TEST_USER); + } - AddStep("Show null dummy", () => header.User.Value = new APIUser - { - Username = "Null" - }); - - AddStep("Show online dummy", () => header.User.Value = new APIUser + [Test] + public void TestOnlineState() + { + AddStep("Show online user", () => header.User.Value = new APIUser { + Id = 1001, Username = "IAmOnline", LastVisit = DateTimeOffset.Now, IsOnline = true, }); - AddStep("Show offline dummy", () => header.User.Value = new APIUser + AddStep("Show offline user", () => header.User.Value = new APIUser { + Id = 1002, Username = "IAmOffline", - LastVisit = DateTimeOffset.Now, + LastVisit = DateTimeOffset.Now.AddDays(-10), IsOnline = false, }); - - addOnlineStep("Show ppy", new APIUser - { - Username = @"peppy", - Id = 2, - IsSupporter = true, - Country = new Country { FullName = @"Australia", FlagName = @"AU" }, - CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" - }); - - addOnlineStep("Show flyte", new APIUser - { - Username = @"flyte", - Id = 3103765, - Country = new Country { FullName = @"Japan", FlagName = @"JP" }, - CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" - }); - } - - private void addOnlineStep(string name, APIUser fallback) - { - AddStep(name, () => - { - if (api.IsLoggedIn) - { - var request = new GetUserRequest(fallback.Id); - request.Success += user => header.User.Value = user; - api.Queue(request); - } - else - header.User.Value = fallback; - }); } } }