Files
video-v1/vav1/Vav1Player.Tests/Integration/VideoPlaybackIntegrationTests.cs
2025-09-17 04:16:34 +09:00

95 lines
3.0 KiB
C#

using FluentAssertions;
using Vav1Player.Video;
using Vav1Player.Decoder;
namespace Vav1Player.Tests.Integration;
public class VideoPlaybackIntegrationTests
{
[Fact]
public void VideoFileReader_WithSampleMp4_ShouldLoadVideoInfo()
{
// Arrange
var sampleFilePath = Path.Combine("..", "..", "..", "..", "sample", "output.mp4");
// Skip test if sample file doesn't exist
if (!File.Exists(sampleFilePath))
{
return; // Skip test
}
// Act & Assert
var action = () =>
{
using var fileReader = new VideoFileReader(sampleFilePath);
// Verify track info is loaded
fileReader.TrackInfo.Should().NotBeNull();
fileReader.TrackInfo!.CodecType.Should().Be("av01");
fileReader.TrackInfo.Width.Should().BeGreaterThan(0);
fileReader.TrackInfo.Height.Should().BeGreaterThan(0);
fileReader.TrackInfo.Duration.Should().BeGreaterThan(0);
fileReader.TrackInfo.EstimatedFrameRate.Should().BeGreaterThan(0);
// Verify samples are available
fileReader.TotalSamples.Should().BeGreaterThan(0);
fileReader.HasMoreData.Should().BeTrue();
System.Diagnostics.Debug.WriteLine($"Video Info: {fileReader.TrackInfo.Width}x{fileReader.TrackInfo.Height}, " +
$"{fileReader.TrackInfo.Duration:F2}s, {fileReader.TrackInfo.EstimatedFrameRate:F2} FPS, " +
$"{fileReader.TotalSamples} samples");
};
action.Should().NotThrow();
}
[Fact]
public async Task VideoFileReader_WithSampleMp4_ShouldReadVideoChunks()
{
// Arrange
var sampleFilePath = Path.Combine("..", "..", "..", "..", "sample", "output.mp4");
// Skip test if sample file doesn't exist
if (!File.Exists(sampleFilePath))
{
return; // Skip test
}
// Act & Assert
using var fileReader = new VideoFileReader(sampleFilePath);
// Try to read first few chunks
var chunks = new List<VideoDataChunk>();
for (int i = 0; i < Math.Min(5, fileReader.TotalSamples); i++)
{
var chunk = await fileReader.ReadNextChunkAsync();
if (chunk != null)
{
chunks.Add(chunk);
System.Diagnostics.Debug.WriteLine($"Read chunk: {chunk}");
}
}
chunks.Should().NotBeEmpty();
chunks.Should().AllSatisfy(chunk =>
{
chunk.Data.Should().NotBeEmpty();
chunk.PresentationTimeMs.Should().BeGreaterOrEqualTo(0);
chunk.SampleIndex.Should().BeGreaterOrEqualTo(0);
});
}
[Fact]
public void Dav1dDecoder_ShouldInitializeCorrectly()
{
// Act & Assert
var action = () =>
{
using var decoder = new Dav1dDecoder();
// Just verify it initializes without throwing
};
action.Should().NotThrow();
}
}