mirror of
https://github.com/ppy/osu.git
synced 2025-03-06 04:33:21 +08:00
Add test coverage for news sidebar showing wrong headers
This commit is contained in:
parent
4b127d5029
commit
4cad5890c6
@ -38,6 +38,14 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
AddUntilStep("No month sections were created", () => !sidebar.ChildrenOfType<MonthSection>().Any());
|
AddUntilStep("No month sections were created", () => !sidebar.ChildrenOfType<MonthSection>().Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMetadataWithMultipleYears()
|
||||||
|
{
|
||||||
|
AddStep("Add data spanning multiple years", () => sidebar.Metadata.Value = metadata_with_multiple_years);
|
||||||
|
AddUntilStep("2022 month sections exist", () => sidebar.ChildrenOfType<MonthSection>().Any(s => s.Year == 2022));
|
||||||
|
AddUntilStep("2021 month sections exist", () => sidebar.ChildrenOfType<MonthSection>().Any(s => s.Year == 2021));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestYearsPanelVisibility()
|
public void TestYearsPanelVisibility()
|
||||||
{
|
{
|
||||||
@ -133,6 +141,74 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
NewsPosts = Array.Empty<APINewsPost>()
|
NewsPosts = Array.Empty<APINewsPost>()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// see https://osu.ppy.sh/docs/index.html#get-news-listing:
|
||||||
|
// "NewsPost collections queried by year will also include posts published in November and December of the previous year if the current date is the same year and before April."
|
||||||
|
private static readonly APINewsSidebar metadata_with_multiple_years = new APINewsSidebar
|
||||||
|
{
|
||||||
|
CurrentYear = 2022,
|
||||||
|
Years = new[]
|
||||||
|
{
|
||||||
|
2022,
|
||||||
|
2021,
|
||||||
|
2020,
|
||||||
|
2019,
|
||||||
|
2018,
|
||||||
|
2017,
|
||||||
|
2016,
|
||||||
|
2015,
|
||||||
|
2014,
|
||||||
|
2013
|
||||||
|
},
|
||||||
|
NewsPosts = new List<APINewsPost>
|
||||||
|
{
|
||||||
|
new APINewsPost
|
||||||
|
{
|
||||||
|
Title = "(Mar 2022) Short title",
|
||||||
|
PublishedAt = new DateTime(2022, 3, 1)
|
||||||
|
},
|
||||||
|
new APINewsPost
|
||||||
|
{
|
||||||
|
Title = "(Mar 2022) Oh boy that's a long post title I wonder if it will break anything",
|
||||||
|
PublishedAt = new DateTime(2022, 3, 1)
|
||||||
|
},
|
||||||
|
new APINewsPost
|
||||||
|
{
|
||||||
|
Title = "(Feb 2022) Medium title, nothing to see here",
|
||||||
|
PublishedAt = new DateTime(2022, 2, 1)
|
||||||
|
},
|
||||||
|
new APINewsPost
|
||||||
|
{
|
||||||
|
Title = "(Feb 2022) Short title",
|
||||||
|
PublishedAt = new DateTime(2022, 2, 1)
|
||||||
|
},
|
||||||
|
new APINewsPost
|
||||||
|
{
|
||||||
|
Title = "(Jan 2022) Oh boy that's a long post title I wonder if it will break anything",
|
||||||
|
PublishedAt = new DateTime(2022, 1, 1)
|
||||||
|
},
|
||||||
|
new APINewsPost
|
||||||
|
{
|
||||||
|
Title = "(Jan 2022) Medium title, nothing to see here",
|
||||||
|
PublishedAt = new DateTime(2022, 1, 1)
|
||||||
|
},
|
||||||
|
new APINewsPost
|
||||||
|
{
|
||||||
|
Title = "(Jan 2022) Short title",
|
||||||
|
PublishedAt = new DateTime(2022, 1, 1)
|
||||||
|
},
|
||||||
|
new APINewsPost
|
||||||
|
{
|
||||||
|
Title = "(Dec 2021) Surprise, the last year's not gone yet",
|
||||||
|
PublishedAt = new DateTime(2021, 12, 1)
|
||||||
|
},
|
||||||
|
new APINewsPost
|
||||||
|
{
|
||||||
|
Title = "(Nov 2021) Same goes for November",
|
||||||
|
PublishedAt = new DateTime(2021, 11, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private class TestNewsSidebar : NewsSidebar
|
private class TestNewsSidebar : NewsSidebar
|
||||||
{
|
{
|
||||||
public Action<int> YearChanged;
|
public Action<int> YearChanged;
|
||||||
|
@ -24,16 +24,21 @@ namespace osu.Game.Overlays.News.Sidebar
|
|||||||
{
|
{
|
||||||
public class MonthSection : CompositeDrawable
|
public class MonthSection : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
public int Year { get; private set; }
|
||||||
|
public int Month { get; private set; }
|
||||||
|
public readonly BindableBool Expanded = new BindableBool();
|
||||||
|
|
||||||
private const int animation_duration = 250;
|
private const int animation_duration = 250;
|
||||||
private Sample sampleOpen;
|
private Sample sampleOpen;
|
||||||
private Sample sampleClose;
|
private Sample sampleClose;
|
||||||
|
|
||||||
public readonly BindableBool Expanded = new BindableBool();
|
|
||||||
|
|
||||||
public MonthSection(int month, int year, IEnumerable<APINewsPost> posts)
|
public MonthSection(int month, int year, IEnumerable<APINewsPost> posts)
|
||||||
{
|
{
|
||||||
Debug.Assert(posts.All(p => p.PublishedAt.Month == month && p.PublishedAt.Year == year));
|
Debug.Assert(posts.All(p => p.PublishedAt.Month == month && p.PublishedAt.Year == year));
|
||||||
|
|
||||||
|
Year = year;
|
||||||
|
Month = month;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user