Added tests for video backgrounds

This commit is contained in:
Haspamelodica 2023-04-21 03:24:11 +02:00
parent e90660c1a4
commit e9fb836e9c
4 changed files with 77 additions and 2 deletions

View File

@ -21,6 +21,7 @@
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Beatmaps;
using osu.Game.Skinning;
using osu.Game.Storyboards;
using osu.Game.Tests.Resources;
using osuTK;
using osuTK.Graphics;
@ -160,6 +161,36 @@ public void TestDecodeBeatmapEvents()
}
}
[Test]
public void TestDecodeVideoWithLowercaseExtension()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = TestResources.OpenResource("video-with-lowercase-extension.osb"))
using (var stream = new LineBufferedReader(resStream))
{
var beatmap = decoder.Decode(stream);
var metadata = beatmap.Metadata;
Assert.AreEqual("BG.jpg", metadata.BackgroundFile);
}
}
[Test]
public void TestDecodeVideoWithUppercaseExtension()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = TestResources.OpenResource("video-with-uppercase-extension.osb"))
using (var stream = new LineBufferedReader(resStream))
{
var beatmap = decoder.Decode(stream);
var metadata = beatmap.Metadata;
Assert.AreEqual("BG.jpg", metadata.BackgroundFile);
}
}
[Test]
public void TestDecodeImageSpecifiedAsVideo()
{

View File

@ -169,6 +169,40 @@ public void TestDecodeVariableWithSuffix()
}
}
[Test]
public void TestDecodeVideoWithLowercaseExtension()
{
var decoder = new LegacyStoryboardDecoder();
using (var resStream = TestResources.OpenResource("video-with-lowercase-extension.osb"))
using (var stream = new LineBufferedReader(resStream))
{
var storyboard = decoder.Decode(stream);
StoryboardLayer video = storyboard.Layers.Single(l => l.Name == "Video");
Assert.That(video.Elements.Count, Is.EqualTo(1));
Assert.AreEqual("Video.avi", ((StoryboardVideo)video.Elements[0]).Path);
}
}
[Test]
public void TestDecodeVideoWithUppercaseExtension()
{
var decoder = new LegacyStoryboardDecoder();
using (var resStream = TestResources.OpenResource("video-with-uppercase-extension.osb"))
using (var stream = new LineBufferedReader(resStream))
{
var storyboard = decoder.Decode(stream);
StoryboardLayer video = storyboard.Layers.Single(l => l.Name == "Video");
Assert.That(video.Elements.Count, Is.EqualTo(1));
Assert.AreEqual("Video.AVI", ((StoryboardVideo)video.Elements[0]).Path);
}
}
[Test]
public void TestDecodeImageSpecifiedAsVideo()
{
@ -179,8 +213,8 @@ public void TestDecodeImageSpecifiedAsVideo()
{
var storyboard = decoder.Decode(stream);
StoryboardLayer foreground = storyboard.Layers.Single(l => l.Name == "Video");
Assert.That(foreground.Elements.Count, Is.Zero);
StoryboardLayer video = storyboard.Layers.Single(l => l.Name == "Video");
Assert.That(video.Elements.Count, Is.Zero);
}
}

View File

@ -0,0 +1,5 @@
osu file format v14
[Events]
0,0,"BG.jpg",0,0
Video,0,"Video.avi",0,0

View File

@ -0,0 +1,5 @@
osu file format v14
[Events]
0,0,"BG.jpg",0,0
Video,0,"Video.AVI",0,0