2018-03-02 00:51:04 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
2018-03-02 01:02:09 +08:00
|
|
|
|
using System.Collections.Generic;
|
2018-03-02 00:51:04 +08:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.MathUtils;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Tests
|
|
|
|
|
{
|
|
|
|
|
public class ManiaBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
|
|
|
|
{
|
|
|
|
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Mania";
|
|
|
|
|
|
|
|
|
|
private bool isForCurrentRuleset;
|
|
|
|
|
|
2018-03-02 13:01:34 +08:00
|
|
|
|
[NonParallelizable]
|
2018-03-02 17:20:33 +08:00
|
|
|
|
[TestCase("basic", false), Ignore("See: https://github.com/ppy/osu/issues/2150")]
|
|
|
|
|
public void Test(string name, bool isForCurrentRuleset)
|
2018-03-02 00:51:04 +08:00
|
|
|
|
{
|
|
|
|
|
this.isForCurrentRuleset = isForCurrentRuleset;
|
2018-03-02 17:20:33 +08:00
|
|
|
|
base.Test(name);
|
2018-03-02 00:51:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-02 01:02:09 +08:00
|
|
|
|
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
|
2018-03-02 00:51:04 +08:00
|
|
|
|
{
|
2018-03-02 01:02:09 +08:00
|
|
|
|
yield return new ConvertValue
|
|
|
|
|
{
|
|
|
|
|
StartTime = hitObject.StartTime,
|
|
|
|
|
EndTime = (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime,
|
|
|
|
|
Column = ((ManiaHitObject)hitObject).Column
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-03-02 00:51:04 +08:00
|
|
|
|
|
2018-03-02 19:19:47 +08:00
|
|
|
|
protected override IBeatmapConverter CreateConverter(Beatmap beatmap) => new ManiaBeatmapConverter(isForCurrentRuleset, beatmap);
|
2018-03-02 00:51:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct ConvertValue : IEquatable<ConvertValue>
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A sane value to account for osu!stable using ints everwhere.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float conversion_lenience = 2;
|
|
|
|
|
|
|
|
|
|
public double StartTime;
|
|
|
|
|
public double EndTime;
|
|
|
|
|
public int Column;
|
|
|
|
|
|
|
|
|
|
public bool Equals(ConvertValue other)
|
2018-03-02 17:20:12 +08:00
|
|
|
|
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
|
2018-03-02 00:51:04 +08:00
|
|
|
|
&& Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience)
|
|
|
|
|
&& Column == other.Column;
|
|
|
|
|
}
|
|
|
|
|
}
|