TestCasePlayer uses an actual beatmap if available.

This commit is contained in:
Dean Herbert 2016-11-28 11:38:32 +09:00
parent 4ef0b8ca47
commit cfb2285312

View File

@ -2,6 +2,7 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.GameModes.Testing;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
@ -9,6 +10,8 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Formats;
using OpenTK;
using osu.Framework.Graphics.Sprites;
using osu.Game.Database;
using osu.Game.Modes;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Screens.Play;
@ -18,10 +21,17 @@ namespace osu.Desktop.VisualTests.Tests
{
class TestCasePlayer : TestCase
{
private WorkingBeatmap beatmap;
public override string Name => @"Player";
public override string Description => @"Showing everything to play the game.";
[BackgroundDependencyLoader]
private void load(BeatmapDatabase db)
{
beatmap = db?.GetWorkingBeatmap(db.Query<BeatmapInfo>().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault());
}
public override void Reset()
{
base.Reset();
@ -29,31 +39,37 @@ namespace osu.Desktop.VisualTests.Tests
//ensure we are at offset 0
Clock = new FramedClock();
var objects = new List<HitObject>();
int time = 1500;
for (int i = 0; i < 50; i++)
if (beatmap == null)
{
objects.Add(new HitCircle()
var objects = new List<HitObject>();
int time = 1500;
for (int i = 0; i < 50; i++)
{
StartTime = time,
Position = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : 512,
i % 4 < 2 ? 0 : 384),
NewCombo = i % 4 == 0
});
objects.Add(new HitCircle()
{
StartTime = time,
Position = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : 512,
i % 4 < 2 ? 0 : 384),
NewCombo = i % 4 == 0
});
time += 500;
time += 500;
}
var decoder = new ConstructableBeatmapDecoder();
Beatmap b = new Beatmap
{
HitObjects = objects
};
decoder.Process(b);
beatmap = new WorkingBeatmap(b);
}
var decoder = new ConstructableBeatmapDecoder();
Beatmap b = new Beatmap
{
HitObjects = objects
};
decoder.Process(b);
Add(new Box
{
RelativeSizeAxes = Framework.Graphics.Axes.Both,
@ -62,7 +78,8 @@ namespace osu.Desktop.VisualTests.Tests
Add(new Player
{
Beatmap = new WorkingBeatmap(b)
PreferredPlayMode = PlayMode.Osu,
Beatmap = beatmap
});
}