1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 05:27:24 +08:00
osu-lazer/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs

75 lines
2.5 KiB
C#
Raw Normal View History

2017-05-01 16:00:41 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Extensions.IEnumerableExtensions;
2017-05-03 11:58:46 +08:00
using osu.Framework.Input;
using osu.Framework.Testing;
using osu.Framework.Graphics;
2017-05-03 11:37:47 +08:00
using osu.Game.Rulesets.Mania.UI;
2017-05-03 11:58:46 +08:00
using System.Linq;
using System;
using System.Collections.Generic;
using osu.Game.Beatmaps.Timing;
using OpenTK;
2017-05-01 16:00:41 +08:00
namespace osu.Desktop.VisualTests.Tests
{
internal class TestCaseManiaPlayfield : TestCase
{
public override string Description => @"Mania playfield";
protected override double TimePerAction => 200;
2017-05-01 16:00:41 +08:00
public override void Reset()
{
base.Reset();
const int max_columns = 10;
Action<int, SpecialColumnPosition> createPlayfield = (cols, pos) =>
{
Clear();
Add(new ManiaPlayfield(cols, new List<ControlPoint>())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
SpecialColumnPosition = pos,
Scale = new Vector2(1, -1)
});
};
for (int i = 1; i <= max_columns; i++)
2017-05-01 16:00:41 +08:00
{
int tempI = i;
AddStep($"{i} column" + (i > 1 ? "s" : ""), () => createPlayfield(tempI, SpecialColumnPosition.Normal));
2017-05-03 11:58:46 +08:00
AddStep("Trigger keys down", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyDown));
AddStep("Trigger keys up", () => ((ManiaPlayfield)Children.First()).Columns.Children.ForEach(triggerKeyUp));
AddStep("Left special style", () => createPlayfield(tempI, SpecialColumnPosition.Left));
AddStep("Right special style", () => createPlayfield(tempI, SpecialColumnPosition.Right));
}
AddStep("Normal special style", () => createPlayfield(max_columns, SpecialColumnPosition.Normal));
}
private void triggerKeyDown(Column column)
{
column.TriggerKeyDown(new InputState(), new KeyDownEventArgs
{
Key = column.Key,
Repeat = false
2017-05-01 16:00:41 +08:00
});
}
private void triggerKeyUp(Column column)
{
column.TriggerKeyUp(new InputState(), new KeyUpEventArgs
{
Key = column.Key
});
}
}
2017-05-01 16:00:41 +08:00
}