1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:07:52 +08:00

Add test coverage for failing case

This commit is contained in:
Joseph Madamba 2023-05-17 20:23:37 -07:00
parent d6fa44240d
commit caa79704ac
No known key found for this signature in database
GPG Key ID: 8B746C7BDDF0BD76
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,31 @@
osu file format v14
[Events]
//Background and Video events
0,0,"BG.jpg",0,0
Video,0,"video.avi"
//Break Periods
//Storyboard Layer 0 (Background)
//Storyboard Layer 1 (Fail)
//Storyboard Layer 2 (Pass)
//Storyboard Layer 3 (Foreground)
//Storyboard Layer 4 (Overlay)
//Storyboard Sound Samples
[TimingPoints]
1674,333.333333333333,4,2,1,70,1,0
1674,-100,4,2,1,70,0,0
3340,-100,4,2,1,70,0,0
3507,-100,4,2,1,70,0,0
3673,-100,4,2,1,70,0,0
[Colours]
Combo1 : 240,80,80
Combo2 : 171,252,203
Combo3 : 128,128,255
Combo4 : 249,254,186
[HitObjects]
148,303,1674,5,6,3:2:0:0:
378,252,1840,1,0,0:0:0:0:
389,270,2340,5,2,0:1:0:0:

View File

@ -1,6 +1,7 @@
// 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.
using System;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -8,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Timing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Formats;
using osu.Game.IO;
@ -42,6 +44,18 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("Load storyboard with missing video", () => loadStoryboard("storyboard_no_video.osu"));
}
[Test]
public void TestVideoSize()
{
AddStep("load storyboard with only video", () =>
{
// LegacyStoryboardDecoder doesn't parse WidescreenStoryboard, so it is set manually
loadStoryboard("storyboard_only_video.osu", s => s.BeatmapInfo.WidescreenStoryboard = false);
});
AddAssert("storyboard is correct width", () => Precision.AlmostEquals(storyboard?.Width ?? 0f, 480 * 16 / 9f));
}
[BackgroundDependencyLoader]
private void load()
{
@ -102,7 +116,7 @@ namespace osu.Game.Tests.Visual.Gameplay
decoupledClock.ChangeSource(Beatmap.Value.Track);
}
private void loadStoryboard(string filename)
private void loadStoryboard(string filename, Action<Storyboard>? setUpStoryboard = null)
{
Storyboard loaded;
@ -113,6 +127,8 @@ namespace osu.Game.Tests.Visual.Gameplay
loaded = decoder.Decode(bfr);
}
setUpStoryboard?.Invoke(loaded);
loadStoryboard(loaded);
}
}