// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Testing; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; using osu.Game.Overlays.News.Sidebar; namespace osu.Game.Tests.Visual.Online { public class TestSceneNewsSideBar : OsuTestScene { [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); private NewsSideBar sidebar; [SetUp] public void SetUp() => Schedule(() => Child = sidebar = new NewsSideBar()); [Test] public void TestMetadataChange() { AddUntilStep("Years panel is hidden", () => yearsPanel?.Alpha == 0); AddStep("Add data", () => sidebar.Metadata.Value = metadata); AddUntilStep("Years panel is visible", () => yearsPanel?.Alpha == 1); } private YearsPanel yearsPanel => sidebar.ChildrenOfType().FirstOrDefault(); private static readonly APINewsSidebar metadata = new APINewsSidebar { CurrentYear = 2021, Years = new[] { 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013 }, NewsPosts = new List { new APINewsPost { Title = "(Mar) Short title", PublishedAt = new DateTime(2021, 3, 1) }, new APINewsPost { Title = "(Mar) Oh boy that's a long post title I wonder if it will break anything", PublishedAt = new DateTime(2021, 3, 1) }, new APINewsPost { Title = "(Mar) Medium title, nothing to see here", PublishedAt = new DateTime(2021, 3, 1) }, new APINewsPost { Title = "(Feb) Short title", PublishedAt = new DateTime(2021, 2, 1) }, new APINewsPost { Title = "(Feb) Oh boy that's a long post title I wonder if it will break anything", PublishedAt = new DateTime(2021, 2, 1) }, new APINewsPost { Title = "(Feb) Medium title, nothing to see here", PublishedAt = new DateTime(2021, 2, 1) }, new APINewsPost { Title = "Short title", PublishedAt = new DateTime(2021, 1, 1) }, new APINewsPost { Title = "Oh boy that's a long post title I wonder if it will break anything", PublishedAt = new DateTime(2021, 1, 1) }, new APINewsPost { Title = "Medium title, nothing to see here", PublishedAt = new DateTime(2021, 1, 1) } } }; } }