alpha patterns
This commit is contained in:
@@ -10,8 +10,22 @@ import (
|
||||
"mxl-pattern-generator/internal/audio"
|
||||
"mxl-pattern-generator/internal/flowdef"
|
||||
"mxl-pattern-generator/internal/video"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
func TestAlphaFlag(t *testing.T) {
|
||||
var args appArgs
|
||||
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
||||
addFlags(flags, &args)
|
||||
if err := flags.Parse([]string{"--alpha"}); err != nil {
|
||||
t.Fatalf("Parse: %v", err)
|
||||
}
|
||||
if !args.videoAlpha {
|
||||
t.Fatal("videoAlpha = false, want true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseArgsHelpStopsBeforeValidation(t *testing.T) {
|
||||
var stdout, stderr bytes.Buffer
|
||||
|
||||
@@ -181,6 +195,16 @@ func TestValidateMediaSelection(t *testing.T) {
|
||||
name: "video enabled by default",
|
||||
args: appArgs{},
|
||||
},
|
||||
{
|
||||
name: "alpha without video",
|
||||
args: appArgs{noVideo: true, videoAlpha: true, audioChannels: 2},
|
||||
wantErrSub: "cannot be used with --no-video",
|
||||
},
|
||||
{
|
||||
name: "alpha with custom video definition",
|
||||
args: appArgs{videoAlpha: true, videoFlowDefFile: "video.json"},
|
||||
wantErrSub: "cannot be used with --video",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
@@ -233,6 +257,26 @@ func TestBuildVideoConfigFromArgs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildVideoConfigWithAlpha(t *testing.T) {
|
||||
cfg, err := buildVideoConfig(appArgs{
|
||||
videoUUID: "5fbec3b1-1b0f-417d-9059-8b94a47197ed",
|
||||
videoWidth: 1280,
|
||||
videoHeight: 720,
|
||||
videoFPS: "50",
|
||||
pattern: "gray-ramp",
|
||||
videoAlpha: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("buildVideoConfig: %v", err)
|
||||
}
|
||||
if cfg.Definition.MediaType != flowdef.MediaTypeV210A {
|
||||
t.Fatalf("media type = %q, want %q", cfg.Definition.MediaType, flowdef.MediaTypeV210A)
|
||||
}
|
||||
if !cfg.HasAlpha() {
|
||||
t.Fatal("HasAlpha() = false, want true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildVideoConfigBackends(t *testing.T) {
|
||||
for _, backend := range []video.Backend{video.BackendGPU, video.BackendCPU} {
|
||||
t.Run(string(backend), func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user