2019-03-04 12:24:19 +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.
|
2018-11-11 09:13:17 +08:00
|
|
|
|
2021-01-24 00:01:47 +08:00
|
|
|
using System;
|
|
|
|
using NUnit.Framework;
|
2018-11-11 09:13:17 +08:00
|
|
|
using osu.Framework.Allocation;
|
2020-03-07 12:26:54 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Tournament.Components;
|
2018-11-11 09:13:17 +08:00
|
|
|
using osu.Game.Tournament.Screens.Schedule;
|
|
|
|
|
2019-06-18 14:28:36 +08:00
|
|
|
namespace osu.Game.Tournament.Tests.Screens
|
2018-11-11 09:13:17 +08:00
|
|
|
{
|
2023-07-24 17:22:32 +08:00
|
|
|
public partial class TestSceneScheduleScreen : TournamentScreenTestScene
|
2018-11-11 09:13:17 +08:00
|
|
|
{
|
2023-08-31 17:05:18 +08:00
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
AddStep("clear matches", () => Ladder.Matches.Clear());
|
|
|
|
|
|
|
|
base.SetUpSteps();
|
|
|
|
}
|
|
|
|
|
2018-11-11 09:13:17 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2020-03-07 12:26:54 +08:00
|
|
|
Add(new TourneyVideo("main") { RelativeSizeAxes = Axes.Both });
|
2018-11-11 09:13:17 +08:00
|
|
|
Add(new ScheduleScreen());
|
|
|
|
}
|
2021-01-24 00:01:47 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCurrentMatchTime()
|
|
|
|
{
|
|
|
|
setMatchDate(TimeSpan.FromDays(-1));
|
|
|
|
setMatchDate(TimeSpan.FromSeconds(5));
|
|
|
|
setMatchDate(TimeSpan.FromMinutes(4));
|
|
|
|
setMatchDate(TimeSpan.FromHours(3));
|
|
|
|
}
|
|
|
|
|
2021-07-16 23:21:58 +08:00
|
|
|
[Test]
|
|
|
|
public void TestNoCurrentMatch()
|
|
|
|
{
|
|
|
|
AddStep("Set null current match", () => Ladder.CurrentMatch.Value = null);
|
|
|
|
}
|
|
|
|
|
2023-08-31 17:05:18 +08:00
|
|
|
[Test]
|
|
|
|
public void TestUpcomingMatches()
|
|
|
|
{
|
|
|
|
AddStep("Add upcoming match", () =>
|
|
|
|
{
|
|
|
|
var tournamentMatch = CreateSampleMatch();
|
|
|
|
|
|
|
|
tournamentMatch.Date.Value = DateTimeOffset.UtcNow.AddMinutes(5);
|
|
|
|
tournamentMatch.Completed.Value = false;
|
|
|
|
|
|
|
|
Ladder.Matches.Add(tournamentMatch);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestRecentMatches()
|
|
|
|
{
|
|
|
|
AddStep("Add recent match", () =>
|
|
|
|
{
|
|
|
|
var tournamentMatch = CreateSampleMatch();
|
|
|
|
|
|
|
|
tournamentMatch.Date.Value = DateTimeOffset.UtcNow;
|
|
|
|
tournamentMatch.Completed.Value = true;
|
|
|
|
tournamentMatch.Team1Score.Value = tournamentMatch.PointsToWin;
|
|
|
|
tournamentMatch.Team2Score.Value = tournamentMatch.PointsToWin / 2;
|
|
|
|
|
|
|
|
Ladder.Matches.Add(tournamentMatch);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-01-24 00:01:47 +08:00
|
|
|
private void setMatchDate(TimeSpan relativeTime)
|
|
|
|
// Humanizer cannot handle negative timespans.
|
|
|
|
=> AddStep($"start time is {relativeTime}", () =>
|
|
|
|
{
|
|
|
|
var match = CreateSampleMatch();
|
|
|
|
match.Date.Value = DateTimeOffset.Now + relativeTime;
|
|
|
|
Ladder.CurrentMatch.Value = match;
|
|
|
|
});
|
2018-11-11 09:13:17 +08:00
|
|
|
}
|
|
|
|
}
|