mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-14 01:55:45 +00:00
Refine unit tests for cancellation
This commit is contained in:
parent
3c6cb1fb43
commit
cdf2dd5b65
1 changed files with 24 additions and 4 deletions
|
|
@ -1122,13 +1122,12 @@ public class VideoTest
|
|||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Cancel_CancellationToken_Before_Throws()
|
||||
public void Video_Cancel_CancellationToken_BeforeProcessing_Throws()
|
||||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
||||
|
||||
cts.Cancel();
|
||||
var task = FFMpegArguments
|
||||
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
||||
.WithCustomArgument("-re")
|
||||
|
|
@ -1139,8 +1138,29 @@ public class VideoTest
|
|||
.WithSpeedPreset(Speed.VeryFast))
|
||||
.CancellableThrough(cts.Token);
|
||||
|
||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously());
|
||||
cts.Cancel();
|
||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Cancel_CancellationToken_BeforePassing_Throws()
|
||||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
||||
cts.Cancel();
|
||||
|
||||
var task = FFMpegArguments
|
||||
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
||||
.WithCustomArgument("-re")
|
||||
.ForceFormat("lavfi"))
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithAudioCodec(AudioCodec.Aac)
|
||||
.WithVideoCodec(VideoCodec.LibX264)
|
||||
.WithSpeedPreset(Speed.VeryFast));
|
||||
|
||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.CancellableThrough(cts.Token));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue