2020-08-25 20:43:23 +00: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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-08-25 20:43:23 +00:00
|
|
|
using System.Linq;
|
|
|
|
using Humanizer;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Utils;
|
|
|
|
using osu.Game.Screens.Ranking.Statistics;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Ranking
|
|
|
|
{
|
2020-08-27 18:30:57 +00:00
|
|
|
public partial class TestSceneSimpleStatisticTable : OsuTestScene
|
2020-08-25 20:43:23 +00:00
|
|
|
{
|
|
|
|
private Container container;
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void SetUp() => Schedule(() =>
|
|
|
|
{
|
|
|
|
Child = new Container
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Width = 700,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4Extensions.FromHex("#333"),
|
|
|
|
},
|
|
|
|
container = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Padding = new MarginPadding(20)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestEmpty()
|
|
|
|
{
|
|
|
|
AddStep("create with no items",
|
2020-08-27 18:30:57 +00:00
|
|
|
() => container.Add(new SimpleStatisticTable(2, Enumerable.Empty<SimpleStatisticItem>())));
|
2020-08-25 20:43:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestManyItems(
|
|
|
|
[Values(1, 2, 3, 4, 12)] int itemCount,
|
|
|
|
[Values(1, 3, 5)] int columnCount)
|
|
|
|
{
|
|
|
|
AddStep($"create with {"item".ToQuantity(itemCount)}", () =>
|
|
|
|
{
|
|
|
|
var items = Enumerable.Range(1, itemCount)
|
|
|
|
.Select(i => new SimpleStatisticItem<int>($"Statistic #{i}")
|
|
|
|
{
|
|
|
|
Value = RNG.Next(100)
|
|
|
|
});
|
|
|
|
|
2020-08-27 18:30:57 +00:00
|
|
|
container.Add(new SimpleStatisticTable(columnCount, items));
|
2020-08-25 20:43:23 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|