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-11-11 01:13:17 +00:00
|
|
|
|
2021-01-23 16:01:47 +00:00
|
|
|
using System;
|
|
|
|
using NUnit.Framework;
|
2018-11-11 01:13:17 +00:00
|
|
|
using osu.Framework.Allocation;
|
2020-03-07 04:26:54 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Tournament.Components;
|
2018-11-11 01:13:17 +00:00
|
|
|
using osu.Game.Tournament.Screens.Schedule;
|
|
|
|
|
2019-06-18 06:28:36 +00:00
|
|
|
namespace osu.Game.Tournament.Tests.Screens
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
2023-07-24 09:22:32 +00:00
|
|
|
public partial class TestSceneScheduleScreen : TournamentScreenTestScene
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
2023-08-31 09:05:18 +00:00
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
AddStep("clear matches", () => Ladder.Matches.Clear());
|
|
|
|
|
|
|
|
base.SetUpSteps();
|
|
|
|
}
|
|
|
|
|
2018-11-11 01:13:17 +00:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2020-03-07 04:26:54 +00:00
|
|
|
Add(new TourneyVideo("main") { RelativeSizeAxes = Axes.Both });
|
2018-11-11 01:13:17 +00:00
|
|
|
Add(new ScheduleScreen());
|
|
|
|
}
|
2021-01-23 16:01:47 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCurrentMatchTime()
|
|
|
|
{
|
|
|
|
setMatchDate(TimeSpan.FromDays(-1));
|
|
|
|
setMatchDate(TimeSpan.FromSeconds(5));
|
|
|
|
setMatchDate(TimeSpan.FromMinutes(4));
|
|
|
|
setMatchDate(TimeSpan.FromHours(3));
|
|
|
|
}
|
|
|
|
|
2021-07-16 15:21:58 +00:00
|
|
|
[Test]
|
|
|
|
public void TestNoCurrentMatch()
|
|
|
|
{
|
|
|
|
AddStep("Set null current match", () => Ladder.CurrentMatch.Value = null);
|
|
|
|
}
|
|
|
|
|
2023-08-31 09:05:18 +00: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-23 16:01:47 +00: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 01:13:17 +00:00
|
|
|
}
|
|
|
|
}
|