2019-03-04 04:24:19 +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.
|
2018-08-25 16:14:18 +00:00
|
|
|
|
|
2023-07-24 10:49:11 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NUnit.Framework;
|
2018-08-25 16:14:18 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2023-07-24 10:49:11 +00:00
|
|
|
|
using osu.Framework.Testing;
|
2019-06-18 05:51:48 +00:00
|
|
|
|
using osu.Game.Tournament.Models;
|
2018-08-25 16:14:18 +00:00
|
|
|
|
using osu.Game.Tournament.Screens.Ladder.Components;
|
|
|
|
|
|
2019-06-18 06:28:36 +00:00
|
|
|
|
namespace osu.Game.Tournament.Tests.Components
|
2018-08-25 16:14:18 +00:00
|
|
|
|
{
|
2019-07-29 22:23:25 +00:00
|
|
|
|
public partial class TestSceneDrawableTournamentMatch : TournamentTestScene
|
2018-08-25 16:14:18 +00:00
|
|
|
|
{
|
2023-07-24 10:49:11 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestBasic()
|
2018-08-25 16:14:18 +00:00
|
|
|
|
{
|
2023-07-24 10:49:11 +00:00
|
|
|
|
Container<DrawableTournamentMatch> level1 = null!;
|
|
|
|
|
Container<DrawableTournamentMatch> level2 = null!;
|
2018-08-26 09:37:46 +00:00
|
|
|
|
|
2023-07-24 10:49:11 +00:00
|
|
|
|
TournamentMatch match1 = null!;
|
|
|
|
|
TournamentMatch match2 = null!;
|
2018-08-25 16:14:18 +00:00
|
|
|
|
|
2023-07-24 10:49:11 +00:00
|
|
|
|
AddStep("setup test", () =>
|
|
|
|
|
{
|
|
|
|
|
match1 = new TournamentMatch(
|
|
|
|
|
new TournamentTeam { FlagName = { Value = "AU" }, FullName = { Value = "Australia" }, },
|
|
|
|
|
new TournamentTeam { FlagName = { Value = "JP" }, FullName = { Value = "Japan" }, Acronym = { Value = "JPN" } })
|
2018-08-25 16:14:18 +00:00
|
|
|
|
{
|
2023-07-24 10:49:11 +00:00
|
|
|
|
Team1Score = { Value = 4 },
|
|
|
|
|
Team2Score = { Value = 1 },
|
|
|
|
|
};
|
2018-08-25 16:14:18 +00:00
|
|
|
|
|
2023-07-24 10:49:11 +00:00
|
|
|
|
match2 = new TournamentMatch(
|
|
|
|
|
new TournamentTeam
|
|
|
|
|
{
|
|
|
|
|
FlagName = { Value = "RO" },
|
|
|
|
|
FullName = { Value = "Romania" },
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Child = new FillFlowContainer
|
2018-08-25 16:14:18 +00:00
|
|
|
|
{
|
2023-07-24 10:49:11 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Children = new Drawable[]
|
2018-08-26 09:37:46 +00:00
|
|
|
|
{
|
2023-07-24 10:49:11 +00:00
|
|
|
|
level1 = new FillFlowContainer<DrawableTournamentMatch>
|
2018-08-26 09:37:46 +00:00
|
|
|
|
{
|
2023-07-24 10:49:11 +00:00
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new DrawableTournamentMatch(match1),
|
|
|
|
|
new DrawableTournamentMatch(match2),
|
|
|
|
|
new DrawableTournamentMatch(new TournamentMatch()),
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
level2 = new FillFlowContainer<DrawableTournamentMatch>
|
2018-08-26 09:37:46 +00:00
|
|
|
|
{
|
2023-07-24 10:49:11 +00:00
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Margin = new MarginPadding(20),
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new DrawableTournamentMatch(new TournamentMatch()),
|
|
|
|
|
new DrawableTournamentMatch(new TournamentMatch())
|
|
|
|
|
}
|
2018-08-26 09:37:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-24 10:49:11 +00:00
|
|
|
|
};
|
2018-08-25 16:14:18 +00:00
|
|
|
|
|
2023-07-24 10:49:11 +00:00
|
|
|
|
level1.Children[0].Match.Progression.Value = level2.Children[0].Match;
|
|
|
|
|
level1.Children[1].Match.Progression.Value = level2.Children[0].Match;
|
|
|
|
|
});
|
2018-08-26 09:37:46 +00:00
|
|
|
|
|
2019-06-18 05:57:05 +00:00
|
|
|
|
AddRepeatStep("change scores", () => match1.Team2Score.Value++, 4);
|
|
|
|
|
AddStep("add new team", () => match2.Team2.Value = new TournamentTeam { FlagName = { Value = "PT" }, FullName = { Value = "Portugal" } });
|
|
|
|
|
AddStep("Add progression", () => level1.Children[2].Match.Progression.Value = level2.Children[1].Match);
|
2018-08-25 16:14:18 +00:00
|
|
|
|
|
2019-06-18 05:57:05 +00:00
|
|
|
|
AddStep("start match", () => match2.StartMatch());
|
2018-08-26 09:37:46 +00:00
|
|
|
|
|
2019-06-18 05:57:05 +00:00
|
|
|
|
AddRepeatStep("change scores", () => match2.Team1Score.Value++, 10);
|
2018-08-26 09:37:46 +00:00
|
|
|
|
|
2019-06-18 05:57:05 +00:00
|
|
|
|
AddStep("start submatch", () => level2.Children[0].Match.StartMatch());
|
2018-08-26 09:37:46 +00:00
|
|
|
|
|
2019-06-18 05:57:05 +00:00
|
|
|
|
AddRepeatStep("change scores", () => level2.Children[0].Match.Team1Score.Value++, 5);
|
2018-08-26 10:11:46 +00:00
|
|
|
|
|
2019-06-18 05:57:05 +00:00
|
|
|
|
AddRepeatStep("change scores", () => level2.Children[0].Match.Team2Score.Value++, 4);
|
2023-07-24 10:49:11 +00:00
|
|
|
|
|
|
|
|
|
AddStep("select as current", () => match1.Current.Value = true);
|
|
|
|
|
AddStep("select as editing", () => this.ChildrenOfType<DrawableTournamentMatch>().Last().Selected = true);
|
2018-08-25 16:14:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|