2019-10-12 09:28:15 +03:00
|
|
|
/*
|
|
|
|
DESCRIPTION
|
2019-11-08 09:59:01 +03:00
|
|
|
config_test.go provides tests of functionality in the config package.
|
2019-10-12 09:28:15 +03:00
|
|
|
|
|
|
|
AUTHORS
|
|
|
|
Saxon A. Nelson-Milton <saxon@ausocean.org>
|
|
|
|
|
|
|
|
LICENSE
|
|
|
|
Copyright (C) 2019 the Australian Ocean Lab (AusOcean)
|
|
|
|
|
|
|
|
It is free software: you can redistribute it and/or modify them
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
|
|
|
*/
|
|
|
|
|
2019-11-08 09:59:01 +03:00
|
|
|
package config
|
2019-10-12 09:28:15 +03:00
|
|
|
|
2019-10-12 09:57:09 +03:00
|
|
|
import (
|
|
|
|
"errors"
|
2019-10-13 05:12:31 +03:00
|
|
|
"net/url"
|
|
|
|
"reflect"
|
2019-10-12 09:57:09 +03:00
|
|
|
"testing"
|
|
|
|
)
|
2019-10-12 09:28:15 +03:00
|
|
|
|
|
|
|
func TestClosestValIdx(t *testing.T) {
|
|
|
|
tests := []struct {
|
2020-05-02 06:55:13 +03:00
|
|
|
l []uint
|
|
|
|
v uint
|
|
|
|
want uint
|
2019-10-12 09:28:15 +03:00
|
|
|
}{
|
|
|
|
{
|
2020-05-02 06:55:13 +03:00
|
|
|
l: []uint{2, 5, 8, 11, 14},
|
2019-10-12 09:28:15 +03:00
|
|
|
v: 6,
|
|
|
|
want: 1,
|
|
|
|
},
|
|
|
|
{
|
2020-05-02 06:55:13 +03:00
|
|
|
l: []uint{2, 5, 8, 11, 14},
|
2019-10-12 09:28:15 +03:00
|
|
|
v: 12,
|
|
|
|
want: 3,
|
|
|
|
},
|
|
|
|
{
|
2020-05-02 06:55:13 +03:00
|
|
|
l: []uint{2, 5, 8, 11, 14},
|
2019-10-12 09:28:15 +03:00
|
|
|
v: 13,
|
|
|
|
want: 4,
|
|
|
|
},
|
|
|
|
{
|
2020-05-02 06:55:13 +03:00
|
|
|
l: []uint{2, 5, 8, 11, 14},
|
2019-10-12 09:28:15 +03:00
|
|
|
v: 0,
|
|
|
|
want: 0,
|
|
|
|
},
|
|
|
|
{
|
2020-05-02 06:55:13 +03:00
|
|
|
l: []uint{2, 5, 8, 11, 14},
|
2019-10-12 09:28:15 +03:00
|
|
|
v: 17,
|
|
|
|
want: 4,
|
|
|
|
},
|
|
|
|
{
|
2020-05-02 06:55:13 +03:00
|
|
|
l: []uint{2, 5, 8, 11, 15},
|
2019-10-12 09:28:15 +03:00
|
|
|
v: 13,
|
|
|
|
want: 3,
|
|
|
|
},
|
|
|
|
{
|
2020-05-02 06:55:13 +03:00
|
|
|
l: []uint{},
|
2019-10-12 09:28:15 +03:00
|
|
|
v: 17,
|
|
|
|
want: 0,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, test := range tests {
|
|
|
|
got := closestValIdx(test.v, test.l)
|
|
|
|
if got != test.want {
|
|
|
|
t.Errorf("did not get expected result for test: %d\nGot: %v\nWant: %v", i, got, test.want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-12 09:35:44 +03:00
|
|
|
|
|
|
|
func TestConvRate(t *testing.T) {
|
|
|
|
tests := []struct {
|
2020-05-02 06:55:13 +03:00
|
|
|
l []uint
|
|
|
|
v uint
|
2019-10-12 09:35:44 +03:00
|
|
|
want string
|
|
|
|
}{
|
|
|
|
{
|
2020-05-02 06:55:13 +03:00
|
|
|
l: []uint{512, 1024, 2048, 3072},
|
2019-10-12 09:35:44 +03:00
|
|
|
v: 1400,
|
|
|
|
want: "1024000",
|
|
|
|
},
|
|
|
|
{
|
2020-05-02 06:55:13 +03:00
|
|
|
l: []uint{512, 1024, 2048, 3072},
|
2019-10-12 09:35:44 +03:00
|
|
|
v: 1900,
|
|
|
|
want: "2048000",
|
|
|
|
},
|
|
|
|
{
|
2020-05-02 06:55:13 +03:00
|
|
|
l: []uint{512, 1024, 2048, 3072},
|
2019-10-12 09:35:44 +03:00
|
|
|
v: 4000,
|
|
|
|
want: "3072000",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, test := range tests {
|
|
|
|
got := convRate(test.v, test.l)
|
|
|
|
if got != test.want {
|
|
|
|
t.Errorf("did not get expected result for test: %d\nGot: %v\nWant: %v", i, got, test.want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-12 09:57:09 +03:00
|
|
|
|
2019-10-23 14:17:15 +03:00
|
|
|
func TestCodecOut(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
s settings
|
|
|
|
c Codec
|
|
|
|
want settings
|
|
|
|
err bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
s: settings{ch: 1},
|
|
|
|
c: CodecH264,
|
|
|
|
want: settings{ch: 1, codec: CodecH264},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
s: settings{ch: 1},
|
|
|
|
c: CodecH265,
|
|
|
|
want: settings{ch: 1, codec: CodecH265},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
s: settings{ch: 1},
|
|
|
|
c: CodecMJPEG,
|
|
|
|
want: settings{ch: 1},
|
|
|
|
err: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
s: settings{ch: 2},
|
|
|
|
c: CodecH264,
|
|
|
|
want: settings{ch: 2, codec: CodecH264},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
s: settings{ch: 2},
|
|
|
|
c: CodecH265,
|
|
|
|
want: settings{ch: 2, codec: CodecH265},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
s: settings{ch: 2},
|
|
|
|
c: CodecMJPEG,
|
|
|
|
want: settings{ch: 2, codec: CodecMJPEG},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
s: settings{ch: 1},
|
|
|
|
c: Codec(500),
|
|
|
|
want: settings{ch: 1},
|
|
|
|
err: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
s: settings{ch: 2},
|
|
|
|
c: Codec(500),
|
|
|
|
want: settings{ch: 2},
|
|
|
|
err: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, test := range tests {
|
|
|
|
got, err := CodecOut(test.c)(test.s)
|
|
|
|
if err != nil && test.err != true {
|
|
|
|
t.Errorf("did not expect error: %v for test: %d", err, i)
|
|
|
|
}
|
|
|
|
|
|
|
|
if got != test.want {
|
|
|
|
t.Errorf("did not get expected result for test: %d\nGot: %v\nWant: %v\n", i, got, test.want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-12 09:57:09 +03:00
|
|
|
func TestHeight(t *testing.T) {
|
|
|
|
tests := []struct {
|
2019-10-24 17:36:10 +03:00
|
|
|
s settings
|
2020-05-02 06:55:13 +03:00
|
|
|
h uint
|
2019-10-12 09:57:09 +03:00
|
|
|
want settings
|
|
|
|
err error
|
|
|
|
}{
|
|
|
|
{
|
2019-10-24 17:36:10 +03:00
|
|
|
s: settings{ch: 2},
|
2019-10-12 09:57:09 +03:00
|
|
|
h: 256,
|
2019-10-24 17:36:10 +03:00
|
|
|
want: settings{ch: 2, res: "4480256"},
|
2019-10-12 09:57:09 +03:00
|
|
|
},
|
|
|
|
{
|
2019-10-24 17:36:10 +03:00
|
|
|
s: settings{ch: 2},
|
2019-10-12 09:57:09 +03:00
|
|
|
h: 360,
|
2019-10-24 17:36:10 +03:00
|
|
|
want: settings{ch: 2, res: "6400360"},
|
2019-10-12 09:57:09 +03:00
|
|
|
},
|
|
|
|
{
|
2019-10-24 17:36:10 +03:00
|
|
|
s: settings{ch: 2},
|
2019-10-12 09:57:09 +03:00
|
|
|
h: 720,
|
2019-10-24 17:36:10 +03:00
|
|
|
want: settings{ch: 2, res: "12800720"},
|
2019-10-12 09:57:09 +03:00
|
|
|
},
|
|
|
|
{
|
2019-10-24 17:36:10 +03:00
|
|
|
s: settings{ch: 2},
|
2019-10-12 09:57:09 +03:00
|
|
|
h: 500,
|
2019-10-24 17:36:10 +03:00
|
|
|
want: settings{ch: 2},
|
|
|
|
err: errors.New(""),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
s: settings{ch: 1},
|
|
|
|
h: 1080,
|
2019-10-25 04:33:13 +03:00
|
|
|
want: settings{ch: 1, res: "19201080"},
|
2019-10-24 17:36:10 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
s: settings{ch: 1},
|
|
|
|
h: 1000,
|
|
|
|
want: settings{ch: 1},
|
2019-10-12 09:57:09 +03:00
|
|
|
err: errors.New(""),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, test := range tests {
|
2019-10-24 17:36:10 +03:00
|
|
|
got, err := Height(test.h)(test.s)
|
2019-10-12 09:57:09 +03:00
|
|
|
if test.err == nil && err != nil || test.err != nil && err == nil {
|
2019-10-24 17:36:10 +03:00
|
|
|
t.Errorf("did not get expected error: %v for test: %d", err, i)
|
2019-10-12 09:57:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if got != test.want {
|
|
|
|
t.Errorf("did not get expected result for test: %d\nGot: %v\nWant: %v", i, got, test.want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-12 10:24:21 +03:00
|
|
|
|
2019-10-13 10:41:49 +03:00
|
|
|
func TestVBRBitrate(t *testing.T) {
|
2019-10-12 10:24:21 +03:00
|
|
|
tests := []struct {
|
2020-05-02 06:55:13 +03:00
|
|
|
r uint
|
2019-10-12 10:24:21 +03:00
|
|
|
in settings
|
|
|
|
want settings
|
|
|
|
}{
|
|
|
|
{
|
2019-10-13 10:41:49 +03:00
|
|
|
r: 300,
|
2019-10-12 10:24:21 +03:00
|
|
|
in: settings{vbr: "1"},
|
|
|
|
want: settings{
|
2019-10-13 10:41:49 +03:00
|
|
|
vbr: "1",
|
2019-10-14 02:26:43 +03:00
|
|
|
vbrBitrate: "250000",
|
2019-10-12 10:24:21 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-10-13 10:41:49 +03:00
|
|
|
r: 400,
|
2019-10-12 10:24:21 +03:00
|
|
|
in: settings{vbr: "1"},
|
|
|
|
want: settings{
|
2019-10-13 10:41:49 +03:00
|
|
|
vbr: "1",
|
2019-10-14 02:26:43 +03:00
|
|
|
vbrBitrate: "500000",
|
2019-10-12 10:24:21 +03:00
|
|
|
},
|
|
|
|
},
|
2019-10-13 10:41:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for i, test := range tests {
|
2019-10-14 02:26:43 +03:00
|
|
|
got, _ := VBRBitrate(test.r)(test.in)
|
2019-10-13 10:41:49 +03:00
|
|
|
if got != test.want {
|
|
|
|
t.Errorf("did not get expected result for test: %d\nGot: %v\nWant: %v", i, got, test.want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCBRBitrate(t *testing.T) {
|
|
|
|
tests := []struct {
|
2020-05-02 06:55:13 +03:00
|
|
|
r uint
|
2019-10-13 10:41:49 +03:00
|
|
|
in settings
|
|
|
|
want settings
|
|
|
|
}{
|
2019-10-12 10:24:21 +03:00
|
|
|
{
|
|
|
|
r: 600,
|
|
|
|
in: settings{
|
|
|
|
vbr: "0",
|
|
|
|
res: res256,
|
|
|
|
},
|
|
|
|
want: settings{
|
2019-10-13 10:41:49 +03:00
|
|
|
vbr: "0",
|
|
|
|
res: res256,
|
2019-10-14 02:26:43 +03:00
|
|
|
cbrBitrate: "512000",
|
2019-10-12 10:24:21 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
r: 100,
|
|
|
|
in: settings{
|
|
|
|
vbr: "0",
|
|
|
|
res: res256,
|
|
|
|
},
|
|
|
|
want: settings{
|
2019-10-13 10:41:49 +03:00
|
|
|
vbr: "0",
|
|
|
|
res: res256,
|
2019-10-14 02:26:43 +03:00
|
|
|
cbrBitrate: "128000",
|
2019-10-12 10:24:21 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
r: 2048,
|
|
|
|
in: settings{
|
|
|
|
vbr: "0",
|
|
|
|
res: res360,
|
|
|
|
},
|
|
|
|
want: settings{
|
2019-10-13 10:41:49 +03:00
|
|
|
vbr: "0",
|
|
|
|
res: res360,
|
2019-10-14 02:26:43 +03:00
|
|
|
cbrBitrate: "2048000",
|
2019-10-12 10:24:21 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
r: 500,
|
|
|
|
in: settings{
|
|
|
|
vbr: "0",
|
|
|
|
res: res720,
|
|
|
|
},
|
|
|
|
want: settings{
|
2019-10-13 10:41:49 +03:00
|
|
|
vbr: "0",
|
|
|
|
res: res720,
|
2019-10-14 02:26:43 +03:00
|
|
|
cbrBitrate: "1024000",
|
2019-10-12 10:24:21 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, test := range tests {
|
2019-10-14 02:26:43 +03:00
|
|
|
got, _ := CBRBitrate(test.r)(test.in)
|
2019-10-12 10:24:21 +03:00
|
|
|
if got != test.want {
|
|
|
|
t.Errorf("did not get expected result for test: %d\nGot: %v\nWant: %v", i, got, test.want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-12 10:37:32 +03:00
|
|
|
|
|
|
|
func TestRefresh(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
r float64
|
|
|
|
want settings
|
|
|
|
err error
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
r: 1.6,
|
|
|
|
want: settings{refresh: "1500"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
r: 2.4,
|
|
|
|
want: settings{refresh: "2500"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
r: 0,
|
|
|
|
want: settings{},
|
|
|
|
err: errors.New(""),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
r: 6,
|
|
|
|
want: settings{},
|
|
|
|
err: errors.New(""),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, test := range tests {
|
|
|
|
s := settings{}
|
|
|
|
got, err := Refresh(test.r)(s)
|
|
|
|
if test.err == nil && err != nil || test.err != nil && err == nil {
|
|
|
|
t.Errorf("did not get expected error: %v", test.err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if got != test.want {
|
|
|
|
t.Errorf("did not get expected result for test: %d\nGot: %v\nWant: %v", i, got, test.want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-13 05:12:31 +03:00
|
|
|
|
|
|
|
func TestPopulateForm(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
in settings
|
|
|
|
want string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
in: newSettings(),
|
2019-10-25 04:33:13 +03:00
|
|
|
want: "dwConnType=5&mpeg_type=10&dwflicker_hz=0&szResolution=6400360&dwFrameRate=25000&vbr_enable=0&max_bit_rate=512000&custom_rate_control_type=0&custom_bitrate=0&custom_qp_init=25&custom_qp_min=10&custom_qp_max=40&gop_N=2000&dwEncProfile=1&dwEncLevel=31&dwEntropy=0&u8PreAlarmBuf=1&u32PostAlarmBuf2Disk=1&u8SplitInterval=5&bEbIoIn=1&bEbIoIn1=1&bOSDFontSize=0&bCamNamePos=2&bDatePos=2&bTimePos=2&szOsdCamName=Camera&u16PostAlarmBuf=1&dwCameraId=1&LangCode=undefined&Recflag=0&submit=Apply",
|
2019-10-13 05:12:31 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
in: settings{
|
2019-10-13 10:55:36 +03:00
|
|
|
codec: CodecH265,
|
2019-10-13 10:41:49 +03:00
|
|
|
res: defaultRes,
|
|
|
|
frameRate: defaultFrameRate,
|
|
|
|
vbr: defaultVBR,
|
|
|
|
quality: defaultQuality,
|
2019-10-14 02:26:43 +03:00
|
|
|
vbrBitrate: defaultVBRBitrate,
|
|
|
|
cbrBitrate: defaultCBRBitrate,
|
2019-10-13 10:41:49 +03:00
|
|
|
refresh: defaultRefresh,
|
2019-10-25 04:33:13 +03:00
|
|
|
ch: 2,
|
2019-10-13 05:12:31 +03:00
|
|
|
},
|
2019-10-25 04:33:13 +03:00
|
|
|
want: "dwConnType=5&mpeg_type=28&dwflicker_hz=0&szResolution=6400360&dwFrameRate=25000&vbr_enable=0&max_bit_rate=512000&custom_rate_control_type=0&custom_bitrate=0&custom_qp_init=25&custom_qp_min=10&custom_qp_max=40&gop_N=2000&dwEncProfile=1&dwEncLevel=31&dwEntropy=0&u8PreAlarmBuf=1&u32PostAlarmBuf2Disk=1&u8SplitInterval=5&bEbIoIn=1&bEbIoIn1=1&bOSDFontSize=0&bCamNamePos=2&bDatePos=2&bTimePos=2&szOsdCamName=Camera&u16PostAlarmBuf=1&dwCameraId=1&LangCode=undefined&Recflag=0&submit=Apply",
|
2019-10-13 05:12:31 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
in: settings{
|
2019-10-13 10:55:36 +03:00
|
|
|
codec: CodecMJPEG,
|
2019-10-13 10:41:49 +03:00
|
|
|
res: defaultRes,
|
|
|
|
frameRate: defaultFrameRate,
|
|
|
|
vbr: defaultVBR,
|
|
|
|
quality: defaultQuality,
|
2019-10-14 02:26:43 +03:00
|
|
|
vbrBitrate: defaultVBRBitrate,
|
|
|
|
cbrBitrate: defaultCBRBitrate,
|
2019-10-13 10:41:49 +03:00
|
|
|
refresh: defaultRefresh,
|
2019-10-25 04:33:13 +03:00
|
|
|
ch: 2,
|
2019-10-13 05:12:31 +03:00
|
|
|
},
|
2019-10-25 04:33:13 +03:00
|
|
|
want: "dwConnType=5&mpeg_type=4&dwflicker_hz=0&szResolution=6400360&dwFrameRate=25000&vbr_enable=1&dwVbrQuality=2&vbrmaxbitrate=500000&custom_qp_init=25&gop_N=1500&u8PreAlarmBuf=1&u32PostAlarmBuf2Disk=1&u8SplitInterval=5&bEbIoIn=1&bEbIoIn1=1&bOSDFontSize=0&bCamNamePos=2&bDatePos=2&bTimePos=2&szOsdCamName=Camera&u16PostAlarmBuf=1&dwCameraId=1&LangCode=undefined&Recflag=0&submit=Apply",
|
2019-10-13 05:12:31 +03:00
|
|
|
},
|
2019-10-13 10:41:49 +03:00
|
|
|
{
|
|
|
|
in: settings{
|
2019-10-13 10:55:36 +03:00
|
|
|
codec: CodecH264,
|
2019-10-13 10:41:49 +03:00
|
|
|
res: defaultRes,
|
|
|
|
frameRate: defaultFrameRate,
|
|
|
|
vbr: "1",
|
|
|
|
quality: defaultQuality,
|
2019-10-14 02:26:43 +03:00
|
|
|
vbrBitrate: defaultVBRBitrate,
|
|
|
|
cbrBitrate: defaultCBRBitrate,
|
2019-10-13 10:41:49 +03:00
|
|
|
refresh: defaultRefresh,
|
2019-10-25 04:33:13 +03:00
|
|
|
ch: 2,
|
2019-10-13 10:41:49 +03:00
|
|
|
},
|
2019-10-25 04:33:13 +03:00
|
|
|
want: "dwConnType=5&mpeg_type=10&dwflicker_hz=0&szResolution=6400360&dwFrameRate=25000&vbr_enable=1&dwVbrQuality=2&vbrmaxbitrate=250000&custom_rate_control_type=0&custom_bitrate=0&custom_qp_init=25&custom_qp_min=10&custom_qp_max=40&gop_N=2000&dwEncProfile=1&dwEncLevel=31&dwEntropy=0&u8PreAlarmBuf=1&u32PostAlarmBuf2Disk=1&u8SplitInterval=5&bEbIoIn=1&bEbIoIn1=1&bOSDFontSize=0&bCamNamePos=2&bDatePos=2&bTimePos=2&szOsdCamName=Camera&u16PostAlarmBuf=1&dwCameraId=1&LangCode=undefined&Recflag=0&submit=Apply",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: settings{
|
|
|
|
codec: CodecH264,
|
|
|
|
res: res1080,
|
|
|
|
frameRate: defaultFrameRate,
|
|
|
|
vbr: "0",
|
|
|
|
quality: defaultQuality,
|
|
|
|
vbrBitrate: defaultVBRBitrate,
|
|
|
|
cbrBitrate: "2048000",
|
|
|
|
refresh: defaultRefresh,
|
|
|
|
ch: 1,
|
|
|
|
},
|
|
|
|
want: "dwConnType=5&mpeg_type=10&dwflicker_less=1&dwflicker_hz=0&szResolution=19201080&dwFrameRate=25000&vbr_enable=0&max_bit_rate=2048000&custom_rate_control_type=0&custom_bitrate=0&custom_qp_init=25&custom_qp_min=10&custom_qp_max=40&gop_N=2000&bSliceMode=4&dwEncProfile=3&dwEncLevel=31&dwEntropy=0&u8PreAlarmBuf=1&u32PostAlarmBuf2Disk=1&u8SplitInterval=5&szCamName=Camera&bEbIoIn=1&bEbIoIn1=1&szOsdCamName=Camera&bOSDFontSize=0&bCamNamePos=2&bDatePos=2&bTimePos=2&bAudioCodec=7&bTVoutFormat=2&bReadyLed=0&bLedLan=0&bLedWan=0&bLedMonitor=0&bAlarmLedAutoLevel=5&bAlarmLedAutoDuration=60&bAlarmLed=1&face_detect_level=1&bDayNight=0&bDayNightAutoLevel=3&bIRout=0&bAutoIris=0&IrisType=1&bBLC=0&bIR=1&bNSR=0&ReplaceHomePreset1=0&u16PostAlarmBuf=1&dwCameraId=0&LangCode=undefined&Recflag=0&webpageEncoding=windows-1252&submit=Apply",
|
2019-10-13 10:41:49 +03:00
|
|
|
},
|
2019-10-13 05:12:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for i, test := range tests {
|
|
|
|
got := populateForm(test.in)
|
|
|
|
want, err := url.ParseQuery(test.want)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("should not have got error: %v parsing want string for test: %d", err, i)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(got, want) {
|
|
|
|
t.Errorf("did not get expected result for test: %d\nGot: %v\nWant: %v", i, got, want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|