-
Notifications
You must be signed in to change notification settings - Fork 11
/
still_test.go
116 lines (90 loc) · 2.85 KB
/
still_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright 2013, David Howden
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package raspicam
import (
"strings"
"testing"
"time"
)
func TestDefaultParams(t *testing.T) {
const paramsOut = "--output -"
testNames := [...]string{"Still", "StillYUV", "Vid"}
testCases := [...]CaptureCommand{NewStill(), NewStillYUV(), NewVid()}
for i, test := range testNames {
paramString := strings.Join(testCases[i].Params(), " ")
if paramString != paramsOut {
t.Errorf("%v: Param() returned %v, expected %v", test, paramString, paramsOut)
}
}
}
func TestDefaultParamsOptionalArgs(t *testing.T) {
const paramsOut = "--output - arg1 arg2"
args := strings.Fields("arg1 arg2")
still := NewStill()
still.Command = "test"
still.Args = args
stillYUV := NewStillYUV()
stillYUV.BaseStill.Command = "test"
stillYUV.BaseStill.Args = args
vid := NewVid()
vid.Command = "test"
vid.Args = args
testNames := [...]string{"Still", "StillYUV", "Vid"}
testCases := [...]CaptureCommand{still, stillYUV, vid}
for i, test := range testNames {
paramString := strings.Join(testCases[i].Params(), " ")
if paramString != paramsOut {
t.Errorf("%v: Param() returned %v, expected %v", test, paramString, paramsOut)
}
}
}
func TestBasicParams(t *testing.T) {
const paramsOut = "--output - --timeout 10000 --width 100 --height 1000"
testNames := [...]string{"Still", "StillYUV", "Vid"}
still := NewStill()
still.Timeout = 10 * time.Second
still.Width = 100
still.Height = 1000
stillYUV := NewStillYUV()
stillYUV.Timeout = 10 * time.Second
stillYUV.Width = 100
stillYUV.Height = 1000
vid := NewVid()
vid.Timeout = 10 * time.Second
vid.Width = 100
vid.Height = 1000
testCases := [...]CaptureCommand{still, stillYUV, vid}
for i, test := range testNames {
paramString := strings.Join(testCases[i].Params(), " ")
if paramString != paramsOut {
t.Errorf("%v: Param() returned %v, expected %v", test, paramString, paramsOut)
}
}
}
func TestCameraParams(t *testing.T) {
const paramsOut = "--output - --timeout 10000 --sharpness 11 --contrast 13 --brightness 12"
testNames := [...]string{"Still", "StillYUV", "Vid"}
still := NewStill()
still.Timeout = 10 * time.Second
still.Camera.Sharpness = 11
still.Camera.Brightness = 12
still.Camera.Contrast = 13
stillYUV := NewStillYUV()
stillYUV.Timeout = 10 * time.Second
stillYUV.Camera.Sharpness = 11
stillYUV.Camera.Brightness = 12
stillYUV.Camera.Contrast = 13
vid := NewVid()
vid.Timeout = 10 * time.Second
vid.Camera.Sharpness = 11
vid.Camera.Brightness = 12
vid.Camera.Contrast = 13
testCases := [...]CaptureCommand{still, stillYUV, vid}
for i, test := range testNames {
paramString := strings.Join(testCases[i].Params(), " ")
if paramString != paramsOut {
t.Errorf("%v: Param() returned %v, expected %v", test, paramString, paramsOut)
}
}
}