2020-08-26 04:43:23 +08: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.
|
|
|
|
|
|
|
|
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-28 02:30:57 +08:00
|
|
|
public class TestSceneSimpleStatisticTable : OsuTestScene
|
2020-08-26 04:43:23 +08: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-28 02:30:57 +08:00
|
|
|
() => container.Add(new SimpleStatisticTable(2, Enumerable.Empty<SimpleStatisticItem>())));
|
2020-08-26 04:43:23 +08: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-28 02:30:57 +08:00
|
|
|
container.Add(new SimpleStatisticTable(columnCount, items));
|
2020-08-26 04:43:23 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|