diff --git a/mpd/mpd_read_write_test.go b/mpd/mpd_read_write_test.go
index 3213165..e3bae94 100644
--- a/mpd/mpd_read_write_test.go
+++ b/mpd/mpd_read_write_test.go
@@ -6,98 +6,72 @@ import (
"testing"
"time"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/suite"
+ "github.com/stretchr/testify/require"
"github.com/zencoder/go-dash/helpers/testfixtures"
)
-type MPDReadWriteSuite struct {
- suite.Suite
+func TestReadingManifests(t *testing.T) {
+ var testCases = []struct {
+ err, filepath string
+ }{
+ {filepath: "fixtures/live_profile.mpd", err: ""},
+ {filepath: "fixtures/ondemand_profile.mpd", err: ""},
+ {filepath: "fixtures/invalid.mpd", err: "XML syntax error on line 3: unexpected EOF"},
+ {filepath: "doesntexist.mpd", err: "open doesntexist.mpd: no such file or directory"},
+ }
+
+ for _, tc := range testCases {
+ // Test reading from manifest files
+ if m, err := ReadFromFile(tc.filepath); tc.err == "" {
+ require.NoError(t, err, "Error while reading "+tc.filepath)
+ require.NotNil(t, m, "Empty result from reading "+tc.filepath)
+ } else {
+ require.EqualError(t, err, tc.err)
+ }
+
+ // Test reading valid files from strings
+ if tc.err == "" {
+ xmlStr := testfixtures.LoadFixture(tc.filepath)
+ _, err := ReadFromString(xmlStr)
+ require.NotNil(t, xmlStr)
+ require.NoError(t, err)
+ }
+ }
}
-func TestMPDReadWriteSuite(t *testing.T) {
- suite.Run(t, new(MPDReadWriteSuite))
-}
-
-func (s *MPDReadWriteSuite) SetupTest() {
-
-}
-
-func (s *MPDReadWriteSuite) SetupSuite() {
-
-}
-
-func (s *MPDReadWriteSuite) TestReadFromFileLiveProfile() {
- m, err := ReadFromFile("fixtures/live_profile.mpd")
- assert.NotNil(s.T(), m)
- assert.Nil(s.T(), err)
-}
-
-func (s *MPDReadWriteSuite) TestReadFromFileOnDemandProfile() {
- m, err := ReadFromFile("fixtures/ondemand_profile.mpd")
- assert.NotNil(s.T(), m)
- assert.Nil(s.T(), err)
-}
-
-func (s *MPDReadWriteSuite) TestReadFromFileErrorInvalidMPD() {
- m, err := ReadFromFile("fixtures/invalid.mpd")
- assert.Nil(s.T(), m)
- assert.NotNil(s.T(), err)
-}
-
-func (s *MPDReadWriteSuite) TestReadFromFileErrorInvalidFilePath() {
- m, err := ReadFromFile("this is an invalid file path")
- assert.Nil(s.T(), m)
- assert.NotNil(s.T(), err)
-}
-
-func (s *MPDReadWriteSuite) TestReadFromStringLiveProfile() {
- xmlStr := testfixtures.LoadFixture("fixtures/live_profile.mpd")
- m, err := ReadFromString(xmlStr)
- assert.NotNil(s.T(), m)
- assert.Nil(s.T(), err)
-}
-
-func (s *MPDReadWriteSuite) TestReadFromStringOnDemandProfile() {
- xmlStr := testfixtures.LoadFixture("fixtures/ondemand_profile.mpd")
- m, err := ReadFromString(xmlStr)
- assert.NotNil(s.T(), m)
- assert.Nil(s.T(), err)
-}
-
-func (s *MPDReadWriteSuite) TestNewMPDLiveWriteToString() {
+func TestNewMPDLiveWriteToString(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
xmlStr, err := m.WriteToString()
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
expectedXML := `
`
- assert.Equal(s.T(), expectedXML, xmlStr)
+ require.Equal(t, expectedXML, xmlStr)
}
-func (s *MPDReadWriteSuite) TestNewMPDOnDemandWriteToString() {
+func TestNewMPDOnDemandWriteToString(t *testing.T) {
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
xmlStr, err := m.WriteToString()
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
expectedXML := `
`
- assert.Equal(s.T(), expectedXML, xmlStr)
+ require.Equal(t, expectedXML, xmlStr)
}
-func (s *MPDReadWriteSuite) TestAddNewAdaptationSetAudioWriteToString() {
+func TestAddNewAdaptationSetAudioWriteToString(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
xmlStr, err := m.WriteToString()
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
expectedXML := `
@@ -105,16 +79,16 @@ func (s *MPDReadWriteSuite) TestAddNewAdaptationSetAudioWriteToString() {
`
- assert.Equal(s.T(), expectedXML, xmlStr)
+ require.Equal(t, expectedXML, xmlStr)
}
-func (s *MPDReadWriteSuite) TestAddNewAdaptationSetVideoWriteToString() {
+func TestAddNewAdaptationSetVideoWriteToString(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
xmlStr, err := m.WriteToString()
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
expectedXML := `
@@ -122,16 +96,16 @@ func (s *MPDReadWriteSuite) TestAddNewAdaptationSetVideoWriteToString() {
`
- assert.Equal(s.T(), expectedXML, xmlStr)
+ require.Equal(t, expectedXML, xmlStr)
}
-func (s *MPDReadWriteSuite) TestAddNewAdaptationSetSubtitleWriteToString() {
+func TestAddNewAdaptationSetSubtitleWriteToString(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
m.AddNewAdaptationSetSubtitle(DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG)
xmlStr, err := m.WriteToString()
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
expectedXML := `
@@ -139,7 +113,7 @@ func (s *MPDReadWriteSuite) TestAddNewAdaptationSetSubtitleWriteToString() {
`
- assert.Equal(s.T(), expectedXML, xmlStr)
+ require.Equal(t, expectedXML, xmlStr)
}
func ExampleAddNewPeriod() {
@@ -223,21 +197,21 @@ func LiveProfile() *MPD {
return m
}
-func (s *MPDReadWriteSuite) TestFullLiveProfileWriteToString() {
+func TestFullLiveProfileWriteToString(t *testing.T) {
m := LiveProfile()
- assert.NotNil(s.T(), m)
+ require.NotNil(t, m)
xmlStr, err := m.WriteToString()
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
expectedXML := testfixtures.LoadFixture("fixtures/live_profile.mpd")
- assert.Equal(s.T(), expectedXML, xmlStr)
+ require.Equal(t, expectedXML, xmlStr)
}
-func (s *MPDReadWriteSuite) TestFullLiveProfileWriteToFile() {
+func TestFullLiveProfileWriteToFile(t *testing.T) {
m := LiveProfile()
- assert.NotNil(s.T(), m)
+ require.NotNil(t, m)
err := m.WriteToFile("test_live.mpd")
defer os.Remove("test_live.mpd")
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
}
func HbbTVProfile() *MPD {
@@ -276,21 +250,21 @@ func HbbTVProfile() *MPD {
return m
}
-func (s *MPDReadWriteSuite) TestFullHbbTVProfileWriteToString() {
+func TestFullHbbTVProfileWriteToString(t *testing.T) {
m := HbbTVProfile()
- assert.NotNil(s.T(), m)
+ require.NotNil(t, m)
xmlStr, err := m.WriteToString()
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
expectedXML := testfixtures.LoadFixture("fixtures/hbbtv_profile.mpd")
- assert.Equal(s.T(), expectedXML, xmlStr)
+ require.Equal(t, expectedXML, xmlStr)
}
-func (s *MPDReadWriteSuite) TestFullHbbTVProfileWriteToFile() {
+func TestFullHbbTVProfileWriteToFile(t *testing.T) {
m := HbbTVProfile()
- assert.NotNil(s.T(), m)
+ require.NotNil(t, m)
err := m.WriteToFile("test_hbbtv.mpd")
defer os.Remove("test_hbbtv.mpd")
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
}
func OnDemandProfile() *MPD {
@@ -327,26 +301,26 @@ func OnDemandProfile() *MPD {
return m
}
-func (s *MPDReadWriteSuite) TestFullOnDemandProfileWriteToString() {
+func TestFullOnDemandProfileWriteToString(t *testing.T) {
m := OnDemandProfile()
- assert.NotNil(s.T(), m)
+ require.NotNil(t, m)
xmlStr, err := m.WriteToString()
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
expectedXML := testfixtures.LoadFixture("fixtures/ondemand_profile.mpd")
- assert.Equal(s.T(), expectedXML, xmlStr)
+ require.Equal(t, expectedXML, xmlStr)
}
-func (s *MPDReadWriteSuite) TestFullOnDemandProfileWriteToFile() {
+func TestFullOnDemandProfileWriteToFile(t *testing.T) {
m := OnDemandProfile()
- assert.NotNil(s.T(), m)
+ require.NotNil(t, m)
err := m.WriteToFile("test-ondemand.mpd")
defer os.Remove("test-ondemand.mpd")
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
}
-func (s *MPDReadWriteSuite) TestWriteToFileInvalidFilePath() {
+func TestWriteToFileInvalidFilePath(t *testing.T) {
m := LiveProfile()
- assert.NotNil(s.T(), m)
+ require.NotNil(t, m)
err := m.WriteToFile("")
- assert.NotNil(s.T(), err)
+ require.NotNil(t, err)
}
diff --git a/mpd/mpd_test.go b/mpd/mpd_test.go
index ee9d8ab..0e95f66 100644
--- a/mpd/mpd_test.go
+++ b/mpd/mpd_test.go
@@ -5,27 +5,10 @@ import (
"encoding/xml"
"testing"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/suite"
+ "github.com/stretchr/testify/require"
. "github.com/zencoder/go-dash/helpers/ptrs"
)
-type MPDSuite struct {
- suite.Suite
-}
-
-func TestMPDSuite(t *testing.T) {
- suite.Run(t, new(MPDSuite))
-}
-
-func (s *MPDSuite) SetupTest() {
-
-}
-
-func (s *MPDSuite) SetupSuite() {
-
-}
-
const (
VALID_MEDIA_PRESENTATION_DURATION string = "PT6M16S"
VALID_MIN_BUFFER_TIME string = "PT1.97S"
@@ -65,9 +48,9 @@ const (
VALID_ROLE string = "main"
)
-func (s *MPDSuite) TestNewMPDLive() {
+func TestNewMPDLive(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- assert.NotNil(s.T(), m)
+ require.NotNil(t, m)
expectedMPD := &MPD{
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
Profiles: Strptr((string)(DASH_PROFILE_LIVE)),
@@ -77,37 +60,37 @@ func (s *MPDSuite) TestNewMPDLive() {
period: &Period{},
Periods: []*Period{{}},
}
- assert.Equal(s.T(), expectedMPD, m)
+ require.Equal(t, expectedMPD, m)
}
-func (s *MPDSuite) TestContentProtection_ImplementsInterface() {
+func TestContentProtection_ImplementsInterface(t *testing.T) {
cp := (*ContentProtectioner)(nil)
- s.Implements(cp, &ContentProtection{})
- s.Implements(cp, ContentProtection{})
+ require.Implements(t, cp, &ContentProtection{})
+ require.Implements(t, cp, ContentProtection{})
}
-func (s *MPDSuite) TestCENCContentProtection_ImplementsInterface() {
+func TestCENCContentProtection_ImplementsInterface(t *testing.T) {
cp := (*ContentProtectioner)(nil)
- s.Implements(cp, &CENCContentProtection{})
- s.Implements(cp, CENCContentProtection{})
+ require.Implements(t, cp, &CENCContentProtection{})
+ require.Implements(t, cp, CENCContentProtection{})
}
-func (s *MPDSuite) TestPlayreadyContentProtection_ImplementsInterface() {
+func TestPlayreadyContentProtection_ImplementsInterface(t *testing.T) {
cp := (*ContentProtectioner)(nil)
- s.Implements(cp, &PlayreadyContentProtection{})
- s.Implements(cp, PlayreadyContentProtection{})
+ require.Implements(t, cp, &PlayreadyContentProtection{})
+ require.Implements(t, cp, PlayreadyContentProtection{})
}
-func (s *MPDSuite) TestWidevineContentProtection_ImplementsInterface() {
+func TestWidevineContentProtection_ImplementsInterface(t *testing.T) {
cp := (*ContentProtectioner)(nil)
- s.Implements(cp, &WidevineContentProtection{})
- s.Implements(cp, WidevineContentProtection{})
+ require.Implements(t, cp, &WidevineContentProtection{})
+ require.Implements(t, cp, WidevineContentProtection{})
}
-func (s *MPDSuite) TestNewMPDLiveWithBaseURLInMPD() {
+func TestNewMPDLiveWithBaseURLInMPD(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
m.BaseURL = VALID_BASE_URL_VIDEO
- assert.NotNil(s.T(), m)
+ require.NotNil(t, m)
expectedMPD := &MPD{
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
Profiles: Strptr((string)(DASH_PROFILE_LIVE)),
@@ -118,13 +101,13 @@ func (s *MPDSuite) TestNewMPDLiveWithBaseURLInMPD() {
Periods: []*Period{{}},
BaseURL: VALID_BASE_URL_VIDEO,
}
- assert.Equal(s.T(), expectedMPD, m)
+ require.Equal(t, expectedMPD, m)
}
-func (s *MPDSuite) TestNewMPDLiveWithBaseURLInPeriod() {
+func TestNewMPDLiveWithBaseURLInPeriod(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
m.period.BaseURL = VALID_BASE_URL_VIDEO
- assert.NotNil(s.T(), m)
+ require.NotNil(t, m)
period := &Period{
BaseURL: VALID_BASE_URL_VIDEO,
}
@@ -137,12 +120,12 @@ func (s *MPDSuite) TestNewMPDLiveWithBaseURLInPeriod() {
period: period,
Periods: []*Period{period},
}
- assert.Equal(s.T(), expectedMPD, m)
+ require.Equal(t, expectedMPD, m)
}
-func (s *MPDSuite) TestNewMPDHbbTV() {
+func TestNewMPDHbbTV(t *testing.T) {
m := NewMPD(DASH_PROFILE_HBBTV_1_5_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- assert.NotNil(s.T(), m)
+ require.NotNil(t, m)
expectedMPD := &MPD{
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
Profiles: Strptr((string)(DASH_PROFILE_HBBTV_1_5_LIVE)),
@@ -152,12 +135,12 @@ func (s *MPDSuite) TestNewMPDHbbTV() {
period: &Period{},
Periods: []*Period{{}},
}
- assert.Equal(s.T(), expectedMPD, m)
+ require.Equal(t, expectedMPD, m)
}
-func (s *MPDSuite) TestNewMPDOnDemand() {
+func TestNewMPDOnDemand(t *testing.T) {
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- assert.NotNil(s.T(), m)
+ require.NotNil(t, m)
expectedMPD := &MPD{
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
Profiles: Strptr((string)(DASH_PROFILE_ONDEMAND)),
@@ -167,66 +150,66 @@ func (s *MPDSuite) TestNewMPDOnDemand() {
period: &Period{},
Periods: []*Period{{}},
}
- assert.Equal(s.T(), expectedMPD, m)
+ require.Equal(t, expectedMPD, m)
}
-func (s *MPDSuite) TestAddNewAdaptationSetAudio() {
+func TestAddNewAdaptationSetAudio(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
as, err := m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
- assert.NotNil(s.T(), as)
- assert.Nil(s.T(), err)
+ require.NotNil(t, as)
+ require.Nil(t, err)
expectedAS := &AdaptationSet{
MimeType: Strptr(VALID_MIME_TYPE_AUDIO),
SegmentAlignment: Boolptr(VALID_SEGMENT_ALIGNMENT),
StartWithSAP: Int64ptr(VALID_START_WITH_SAP),
Lang: Strptr(VALID_LANG),
}
- assert.Equal(s.T(), expectedAS, as)
+ require.Equal(t, expectedAS, as)
}
-func (s *MPDSuite) TestAddNewAdaptationSetVideo() {
+func TestAddNewAdaptationSetVideo(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
as, err := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
- assert.NotNil(s.T(), as)
- assert.Nil(s.T(), err)
+ require.NotNil(t, as)
+ require.Nil(t, err)
expectedAS := &AdaptationSet{
MimeType: Strptr(VALID_MIME_TYPE_VIDEO),
ScanType: Strptr(VALID_SCAN_TYPE),
SegmentAlignment: Boolptr(VALID_SEGMENT_ALIGNMENT),
StartWithSAP: Int64ptr(VALID_START_WITH_SAP),
}
- assert.Equal(s.T(), expectedAS, as)
+ require.Equal(t, expectedAS, as)
}
-func (s *MPDSuite) TestAddNewAdaptationSetSubtitle() {
+func TestAddNewAdaptationSetSubtitle(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
as, err := m.AddNewAdaptationSetSubtitle(DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG)
- assert.NotNil(s.T(), as)
- assert.Nil(s.T(), err)
+ require.NotNil(t, as)
+ require.Nil(t, err)
expectedAS := &AdaptationSet{
MimeType: Strptr(VALID_MIME_TYPE_SUBTITLE_VTT),
Lang: Strptr(VALID_LANG),
}
- assert.Equal(s.T(), expectedAS, as)
+ require.Equal(t, expectedAS, as)
}
-func (s *MPDSuite) TestAddAdaptationSetErrorNil() {
+func TestAddAdaptationSetErrorNil(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
err := m.period.addAdaptationSet(nil)
- assert.NotNil(s.T(), err)
- assert.Equal(s.T(), ErrAdaptationSetNil, err)
+ require.NotNil(t, err)
+ require.Equal(t, ErrAdaptationSetNil, err)
}
-func (s *MPDSuite) TestAddNewContentProtectionRoot() {
+func TestAddNewContentProtectionRoot(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
+ s, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
- cp, err := as.AddNewContentProtectionRoot(VALID_DEFAULT_KID_HEX)
- assert.Nil(s.T(), err)
- assert.NotNil(s.T(), cp)
+ cp, err := s.AddNewContentProtectionRoot(VALID_DEFAULT_KID_HEX)
+ require.Nil(t, err)
+ require.NotNil(t, cp)
expectedCP := &CENCContentProtection{
DefaultKID: Strptr(VALID_DEFAULT_KID),
Value: Strptr(CONTENT_PROTECTION_ROOT_VALUE),
@@ -234,7 +217,7 @@ func (s *MPDSuite) TestAddNewContentProtectionRoot() {
expectedCP.SchemeIDURI = Strptr(CONTENT_PROTECTION_ROOT_SCHEME_ID_URI)
expectedCP.XMLNS = Strptr(CENC_XMLNS)
- assert.Equal(s.T(), expectedCP, cp)
+ require.Equal(t, expectedCP, cp)
}
type TestProprietaryContentProtection struct {
@@ -245,7 +228,7 @@ type TestProprietaryContentProtection struct {
func (s *TestProprietaryContentProtection) ContentProtected() {}
-func (s *MPDSuite) TestAddNewContentProtection_Proprietary() {
+func TestAddNewContentProtection_Proprietary(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
@@ -255,117 +238,117 @@ func (s *MPDSuite) TestAddNewContentProtection_Proprietary() {
pcp := &TestProprietaryContentProtection{*cp, "foo", "bar"}
x, _ := xml.Marshal(pcp)
- s.Equal(``, string(x))
+ require.Equal(t, ``, string(x))
as.AddContentProtection(pcp)
- s.Equal(as.ContentProtection, []ContentProtectioner{pcp})
+ require.Equal(t, as.ContentProtection, []ContentProtectioner{pcp})
}
-func (s *MPDSuite) TestAddNewContentProtectionRootErrorInvalidLengthDefaultKID() {
+func TestAddNewContentProtectionRootErrorInvalidLengthDefaultKID(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
+ s, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
- cp, err := as.AddNewContentProtectionRoot("invalidkid")
- assert.NotNil(s.T(), err)
- assert.Equal(s.T(), ErrInvalidDefaultKID, err)
- assert.Nil(s.T(), cp)
+ cp, err := s.AddNewContentProtectionRoot("invalidkid")
+ require.NotNil(t, err)
+ require.Equal(t, ErrInvalidDefaultKID, err)
+ require.Nil(t, cp)
}
-func (s *MPDSuite) TestAddNewContentProtectionRootErrorEmptyDefaultKID() {
+func TestAddNewContentProtectionRootErrorEmptyDefaultKID(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
+ s, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
- cp, err := as.AddNewContentProtectionRoot("")
- assert.NotNil(s.T(), err)
- assert.Equal(s.T(), ErrInvalidDefaultKID, err)
- assert.Nil(s.T(), cp)
+ cp, err := s.AddNewContentProtectionRoot("")
+ require.NotNil(t, err)
+ require.Equal(t, ErrInvalidDefaultKID, err)
+ require.Nil(t, cp)
}
-func (s *MPDSuite) TestAddNewContentProtectionSchemeWidevineWithPSSH() {
+func TestAddNewContentProtectionSchemeWidevineWithPSSH(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
+ s, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
- cp, err := as.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes())
- assert.Nil(s.T(), err)
- assert.NotNil(s.T(), cp)
+ cp, err := s.AddNewContentProtectionSchemeWidevineWithPSSH(getValidWVHeaderBytes())
+ require.Nil(t, err)
+ require.NotNil(t, cp)
expectedCP := &WidevineContentProtection{
PSSH: Strptr("AAAAYXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAEEIARIQWr3VL1VKTyq40GH3YUJRVRoIY2FzdGxhYnMiGFdyM1ZMMVZLVHlxNDBHSDNZVUpSVlE9PTIHZGVmYXVsdA=="),
}
expectedCP.SchemeIDURI = Strptr(CONTENT_PROTECTION_WIDEVINE_SCHEME_ID)
expectedCP.XMLNS = Strptr(CENC_XMLNS)
- assert.Equal(s.T(), expectedCP, cp)
+ require.Equal(t, expectedCP, cp)
}
-func (s *MPDSuite) TestAddNewContentProtectionSchemeWidevine() {
+func TestAddNewContentProtectionSchemeWidevine(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
+ s, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
- cp, err := as.AddNewContentProtectionSchemeWidevine()
- assert.Nil(s.T(), err)
- assert.NotNil(s.T(), cp)
+ cp, err := s.AddNewContentProtectionSchemeWidevine()
+ require.Nil(t, err)
+ require.NotNil(t, cp)
expectedCP := &WidevineContentProtection{}
expectedCP.SchemeIDURI = Strptr(CONTENT_PROTECTION_WIDEVINE_SCHEME_ID)
- assert.Equal(s.T(), expectedCP, cp)
+ require.Equal(t, expectedCP, cp)
}
-func (s *MPDSuite) TestAddNewContentProtectionSchemePlayreadyErrorEmptyPRO() {
+func TestAddNewContentProtectionSchemePlayreadyErrorEmptyPRO(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
+ s, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
- cp, err := as.AddNewContentProtectionSchemePlayready("")
- assert.NotNil(s.T(), err)
- assert.Equal(s.T(), ErrPROEmpty, err)
- assert.Nil(s.T(), cp)
+ cp, err := s.AddNewContentProtectionSchemePlayready("")
+ require.NotNil(t, err)
+ require.Equal(t, ErrPROEmpty, err)
+ require.Nil(t, cp)
}
-func (s *MPDSuite) TestAddNewContentProtectionSchemePlayready() {
+func TestAddNewContentProtectionSchemePlayready(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
+ s, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
- cp, err := as.AddNewContentProtectionSchemePlayready(VALID_PLAYREADY_PRO)
- assert.Nil(s.T(), err)
- assert.NotNil(s.T(), cp)
+ cp, err := s.AddNewContentProtectionSchemePlayready(VALID_PLAYREADY_PRO)
+ require.Nil(t, err)
+ require.NotNil(t, cp)
expectedCP := &PlayreadyContentProtection{
PlayreadyXMLNS: Strptr(VALID_PLAYREADY_XMLNS),
PRO: Strptr(VALID_PLAYREADY_PRO),
}
expectedCP.SchemeIDURI = Strptr(CONTENT_PROTECTION_PLAYREADY_SCHEME_ID)
- assert.Equal(s.T(), expectedCP, cp)
+ require.Equal(t, expectedCP, cp)
}
-func (s *MPDSuite) TestAddNewContentProtectionSchemePlayreadyV10ErrorEmptyPRO() {
+func TestAddNewContentProtectionSchemePlayreadyV10ErrorEmptyPRO(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
+ s, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
- cp, err := as.AddNewContentProtectionSchemePlayreadyV10("")
- assert.NotNil(s.T(), err)
- assert.Equal(s.T(), ErrPROEmpty, err)
- assert.Nil(s.T(), cp)
+ cp, err := s.AddNewContentProtectionSchemePlayreadyV10("")
+ require.NotNil(t, err)
+ require.Equal(t, ErrPROEmpty, err)
+ require.Nil(t, cp)
}
-func (s *MPDSuite) TestAddNewContentProtectionSchemePlayreadyV10() {
+func TestAddNewContentProtectionSchemePlayreadyV10(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
+ s, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
- cp, err := as.AddNewContentProtectionSchemePlayreadyV10(VALID_PLAYREADY_PRO)
- assert.Nil(s.T(), err)
- assert.NotNil(s.T(), cp)
+ cp, err := s.AddNewContentProtectionSchemePlayreadyV10(VALID_PLAYREADY_PRO)
+ require.Nil(t, err)
+ require.NotNil(t, cp)
expectedCP := &PlayreadyContentProtection{
PlayreadyXMLNS: Strptr(VALID_PLAYREADY_XMLNS),
PRO: Strptr(VALID_PLAYREADY_PRO),
}
expectedCP.SchemeIDURI = Strptr(CONTENT_PROTECTION_PLAYREADY_SCHEME_V10_ID)
- assert.Equal(s.T(), expectedCP, cp)
+ require.Equal(t, expectedCP, cp)
}
-func (s *MPDSuite) TestAddNewContentProtectionSchemePlayreadyWithPSSH() {
+func TestAddNewContentProtectionSchemePlayreadyWithPSSH(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
+ s, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
- cp, err := as.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO)
- assert.Nil(s.T(), err)
- assert.NotNil(s.T(), cp)
+ cp, err := s.AddNewContentProtectionSchemePlayreadyWithPSSH(VALID_PLAYREADY_PRO)
+ require.Nil(t, err)
+ require.NotNil(t, cp)
expectedCP := &PlayreadyContentProtection{
PlayreadyXMLNS: Strptr(VALID_PLAYREADY_XMLNS),
PRO: Strptr(VALID_PLAYREADY_PRO),
@@ -374,16 +357,16 @@ func (s *MPDSuite) TestAddNewContentProtectionSchemePlayreadyWithPSSH() {
expectedCP.XMLNS = Strptr(CENC_XMLNS)
expectedCP.PSSH = Strptr("AAACJnBzc2gAAAAAmgTweZhAQoarkuZb4IhflQAAAgYGAgAAAQABAPwBPABXAFIATQBIAEUAQQBEAEUAUgAgAHgAbQBsAG4AcwA9ACIAaAB0AHQAcAA6AC8ALwBzAGMAaABlAG0AYQBzAC4AbQBpAGMAcgBvAHMAbwBmAHQALgBjAG8AbQAvAEQAUgBNAC8AMgAwADAANwAvADAAMwAvAFAAbABhAHkAUgBlAGEAZAB5AEgAZQBhAGQAZQByACIAIAB2AGUAcgBzAGkAbwBuAD0AIgA0AC4AMAAuADAALgAwACIAPgA8AEQAQQBUAEEAPgA8AFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBFAFkATABFAE4APgAxADYAPAAvAEsARQBZAEwARQBOAD4APABBAEwARwBJAEQAPgBBAEUAUwBDAFQAUgA8AC8AQQBMAEcASQBEAD4APAAvAFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBJAEQAPgBMADkAVwA5AFcAawBwAFYASwBrACsANAAwAEcASAAzAFkAVQBKAFIAVgBRAD0APQA8AC8ASwBJAEQAPgA8AEMASABFAEMASwBTAFUATQA+AEkASwB6AFkAMgBIAFoATABBAGwASQA9ADwALwBDAEgARQBDAEsAUwBVAE0APgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA==")
- assert.Equal(s.T(), expectedCP, cp)
+ require.Equal(t, expectedCP, cp)
}
-func (s *MPDSuite) TestAddNewContentProtectionSchemePlayreadyV10WithPSSH() {
+func TestAddNewContentProtectionSchemePlayreadyV10WithPSSH(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- as, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
+ s, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
- cp, err := as.AddNewContentProtectionSchemePlayreadyV10WithPSSH(VALID_PLAYREADY_PRO)
- assert.Nil(s.T(), err)
- assert.NotNil(s.T(), cp)
+ cp, err := s.AddNewContentProtectionSchemePlayreadyV10WithPSSH(VALID_PLAYREADY_PRO)
+ require.Nil(t, err)
+ require.NotNil(t, cp)
expectedCP := &PlayreadyContentProtection{
PlayreadyXMLNS: Strptr(VALID_PLAYREADY_XMLNS),
PRO: Strptr(VALID_PLAYREADY_PRO),
@@ -392,18 +375,18 @@ func (s *MPDSuite) TestAddNewContentProtectionSchemePlayreadyV10WithPSSH() {
expectedCP.XMLNS = Strptr(CENC_XMLNS)
expectedCP.PSSH = Strptr("AAACJnBzc2gAAAAAefAEmkCYhkKrkuZb4IhflQAAAgYGAgAAAQABAPwBPABXAFIATQBIAEUAQQBEAEUAUgAgAHgAbQBsAG4AcwA9ACIAaAB0AHQAcAA6AC8ALwBzAGMAaABlAG0AYQBzAC4AbQBpAGMAcgBvAHMAbwBmAHQALgBjAG8AbQAvAEQAUgBNAC8AMgAwADAANwAvADAAMwAvAFAAbABhAHkAUgBlAGEAZAB5AEgAZQBhAGQAZQByACIAIAB2AGUAcgBzAGkAbwBuAD0AIgA0AC4AMAAuADAALgAwACIAPgA8AEQAQQBUAEEAPgA8AFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBFAFkATABFAE4APgAxADYAPAAvAEsARQBZAEwARQBOAD4APABBAEwARwBJAEQAPgBBAEUAUwBDAFQAUgA8AC8AQQBMAEcASQBEAD4APAAvAFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBJAEQAPgBMADkAVwA5AFcAawBwAFYASwBrACsANAAwAEcASAAzAFkAVQBKAFIAVgBRAD0APQA8AC8ASwBJAEQAPgA8AEMASABFAEMASwBTAFUATQA+AEkASwB6AFkAMgBIAFoATABBAGwASQA9ADwALwBDAEgARQBDAEsAUwBVAE0APgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA==")
- assert.Equal(s.T(), expectedCP, cp)
+ require.Equal(t, expectedCP, cp)
}
-func (s *MPDSuite) TestSetNewSegmentTemplate() {
+func TestSetNewSegmentTemplate(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
audioAS, _ := m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
st, err := audioAS.SetNewSegmentTemplate(VALID_DURATION, VALID_INIT_PATH_AUDIO, VALID_MEDIA_PATH_AUDIO, VALID_START_NUMBER, VALID_TIMESCALE)
- assert.NotNil(s.T(), st)
- assert.Nil(s.T(), err)
+ require.NotNil(t, st)
+ require.Nil(t, err)
}
-func (s *MPDSuite) TestSetNewSegmentTemplateErrorNoDASHProfile() {
+func TestSetNewSegmentTemplateErrorNoDASHProfile(t *testing.T) {
m := &MPD{
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
Profiles: nil,
@@ -415,20 +398,20 @@ func (s *MPDSuite) TestSetNewSegmentTemplateErrorNoDASHProfile() {
audioAS, _ := m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
audioAS.SetNewSegmentTemplate(VALID_DURATION, VALID_INIT_PATH_AUDIO, VALID_MEDIA_PATH_AUDIO, VALID_START_NUMBER, VALID_TIMESCALE)
err := m.Validate()
- assert.Equal(s.T(), ErrNoDASHProfileSet, err)
+ require.Equal(t, ErrNoDASHProfileSet, err)
}
-func (s *MPDSuite) TestAddRepresentationAudio() {
+func TestAddRepresentationAudio(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
audioAS, _ := m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
r, err := audioAS.AddNewRepresentationAudio(VALID_AUDIO_SAMPLE_RATE, VALID_AUDIO_BITRATE, VALID_AUDIO_CODEC, VALID_AUDIO_ID)
- assert.NotNil(s.T(), r)
- assert.Nil(s.T(), err)
+ require.NotNil(t, r)
+ require.Nil(t, err)
}
-func (s *MPDSuite) TestAddAudioChannelConfiguration() {
+func TestAddAudioChannelConfiguration(t *testing.T) {
m := NewMPD(DASH_PROFILE_HBBTV_1_5_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
audioAS, _ := m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
@@ -436,59 +419,59 @@ func (s *MPDSuite) TestAddAudioChannelConfiguration() {
acc, err := r.AddNewAudioChannelConfiguration(AUDIO_CHANNEL_CONFIGURATION_MPEG_DASH, "2")
- assert.NotNil(s.T(), acc)
- assert.Nil(s.T(), err)
+ require.NotNil(t, acc)
+ require.Nil(t, err)
}
-func (s *MPDSuite) TestAddRepresentationVideo() {
+func TestAddRepresentationVideo(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
videoAS, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
r, err := videoAS.AddNewRepresentationVideo(VALID_VIDEO_BITRATE, VALID_VIDEO_CODEC, VALID_VIDEO_ID, VALID_VIDEO_FRAMERATE, VALID_VIDEO_WIDTH, VALID_VIDEO_HEIGHT)
- assert.NotNil(s.T(), r)
- assert.Nil(s.T(), err)
+ require.NotNil(t, r)
+ require.Nil(t, err)
}
-func (s *MPDSuite) TestAddRepresentationSubtitle() {
+func TestAddRepresentationSubtitle(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
subtitleAS, _ := m.AddNewAdaptationSetSubtitle(DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG)
r, err := subtitleAS.AddNewRepresentationSubtitle(VALID_SUBTITLE_BANDWIDTH, VALID_SUBTITLE_ID)
- assert.NotNil(s.T(), r)
- assert.Nil(s.T(), err)
+ require.NotNil(t, r)
+ require.Nil(t, err)
}
-func (s *MPDSuite) TestAddRepresentationErrorNil() {
+func TestAddRepresentationErrorNil(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
videoAS, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
err := videoAS.addRepresentation(nil)
- assert.NotNil(s.T(), err)
- assert.Equal(s.T(), ErrRepresentationNil, err)
+ require.NotNil(t, err)
+ require.Equal(t, ErrRepresentationNil, err)
}
-func (s *MPDSuite) TestAddRole() {
+func TestAddRole(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
audioAS, _ := m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
r, err := audioAS.AddNewRole("urn:mpeg:dash:role:2011", VALID_ROLE)
- assert.NotNil(s.T(), r)
- assert.Nil(s.T(), err)
+ require.NotNil(t, r)
+ require.Nil(t, err)
}
-func (s *MPDSuite) TestSetSegmentTemplateErrorNil() {
+func TestSetSegmentTemplateErrorNil(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
audioAS, _ := m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
err := audioAS.setSegmentTemplate(nil)
- assert.NotNil(s.T(), err)
- assert.Equal(s.T(), ErrSegmentTemplateNil, err)
+ require.NotNil(t, err)
+ require.Equal(t, ErrSegmentTemplateNil, err)
}
-func (s *MPDSuite) TestSetNewBaseURLVideo() {
+func TestSetNewBaseURLVideo(t *testing.T) {
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
videoAS, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
@@ -496,10 +479,10 @@ func (s *MPDSuite) TestSetNewBaseURLVideo() {
err := r.SetNewBaseURL(VALID_BASE_URL_VIDEO)
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
}
-func (s *MPDSuite) TestSetNewBaseURLSubtitle() {
+func TestSetNewBaseURLSubtitle(t *testing.T) {
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
subtitleAS, _ := m.AddNewAdaptationSetSubtitle(DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG)
@@ -507,10 +490,10 @@ func (s *MPDSuite) TestSetNewBaseURLSubtitle() {
err := r.SetNewBaseURL(VALID_SUBTITLE_URL)
- assert.Nil(s.T(), err)
+ require.Nil(t, err)
}
-func (s *MPDSuite) TestSetNewBaseURLErrorNoDASHProfile() {
+func TestSetNewBaseURLErrorNoDASHProfile(t *testing.T) {
m := &MPD{
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
Profiles: nil,
@@ -526,11 +509,11 @@ func (s *MPDSuite) TestSetNewBaseURLErrorNoDASHProfile() {
r.SetNewBaseURL(VALID_BASE_URL_VIDEO)
err := m.Validate()
- assert.NotNil(s.T(), err)
- assert.Equal(s.T(), ErrNoDASHProfileSet, err)
+ require.NotNil(t, err)
+ require.Equal(t, ErrNoDASHProfileSet, err)
}
-func (s *MPDSuite) TestSetNewBaseURLErrorEmpty() {
+func TestSetNewBaseURLErrorEmpty(t *testing.T) {
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
videoAS, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
@@ -538,22 +521,22 @@ func (s *MPDSuite) TestSetNewBaseURLErrorEmpty() {
err := r.SetNewBaseURL("")
- assert.NotNil(s.T(), err)
- assert.Equal(s.T(), ErrBaseURLEmpty, err)
+ require.NotNil(t, err)
+ require.Equal(t, ErrBaseURLEmpty, err)
}
-func (s *MPDSuite) TestSetNewSegmentBase() {
+func TestSetNewSegmentBase(t *testing.T) {
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
videoAS, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
r, _ := videoAS.AddNewRepresentationVideo(VALID_VIDEO_BITRATE, VALID_VIDEO_CODEC, VALID_VIDEO_ID, VALID_VIDEO_FRAMERATE, VALID_VIDEO_WIDTH, VALID_VIDEO_HEIGHT)
sb, err := r.AddNewSegmentBase(VALID_INDEX_RANGE, VALID_INIT_RANGE)
- assert.NotNil(s.T(), sb)
- assert.Nil(s.T(), err)
+ require.NotNil(t, sb)
+ require.Nil(t, err)
}
-func (s *MPDSuite) TestSetNewSegmentBaseErrorNoDASHProfile() {
+func TestSetNewSegmentBaseErrorNoDASHProfile(t *testing.T) {
m := &MPD{
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
Profiles: nil,
@@ -569,18 +552,18 @@ func (s *MPDSuite) TestSetNewSegmentBaseErrorNoDASHProfile() {
r.AddNewSegmentBase(VALID_INDEX_RANGE, VALID_INIT_RANGE)
err := m.Validate()
- assert.Equal(s.T(), ErrNoDASHProfileSet, err)
+ require.Equal(t, ErrNoDASHProfileSet, err)
}
-func (s *MPDSuite) TestSetSegmentBaseErrorNil() {
+func TestSetSegmentBaseErrorNil(t *testing.T) {
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
videoAS, _ := m.AddNewAdaptationSetVideo(DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
r, _ := videoAS.AddNewRepresentationVideo(VALID_VIDEO_BITRATE, VALID_VIDEO_CODEC, VALID_VIDEO_ID, VALID_VIDEO_FRAMERATE, VALID_VIDEO_WIDTH, VALID_VIDEO_HEIGHT)
err := r.setSegmentBase(nil)
- assert.NotNil(s.T(), err)
- assert.Equal(s.T(), ErrSegmentBaseNil, err)
+ require.NotNil(t, err)
+ require.Equal(t, ErrSegmentBaseNil, err)
}
func getValidWVHeaderBytes() []byte {
diff --git a/mpd/pssh_test.go b/mpd/pssh_test.go
index 892e5cb..76b5262 100644
--- a/mpd/pssh_test.go
+++ b/mpd/pssh_test.go
@@ -5,11 +5,10 @@ import (
"encoding/hex"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
)
func TestMakePSSHBox_Widevine(t *testing.T) {
- assert := assert.New(t)
expectedPSSH, err := base64.StdEncoding.DecodeString("AAAAYXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAEEIARIQWr3VL1VKTyq40GH3YUJRVRoIY2FzdGxhYnMiGFdyM1ZMMVZLVHlxNDBHSDNZVUpSVlE9PTIHZGVmYXVsdA==")
if err != nil {
panic(err.Error())
@@ -26,14 +25,12 @@ func TestMakePSSHBox_Widevine(t *testing.T) {
}
psshBox, err := makePSSHBox(wvSystemID, payload)
- assert.NoError(err)
+ require.NoError(t, err)
- assert.Equal(expectedPSSH, psshBox)
+ require.Equal(t, expectedPSSH, psshBox)
}
func TestMakePSSHBox_Playready(t *testing.T) {
- assert := assert.New(t)
-
expectedPSSH, err := base64.StdEncoding.DecodeString("AAACJnBzc2gAAAAAmgTweZhAQoarkuZb4IhflQAAAgYGAgAAAQABAPwBPABXAFIATQBIAEUAQQBEAEUAUgAgAHgAbQBsAG4AcwA9ACIAaAB0AHQAcAA6AC8ALwBzAGMAaABlAG0AYQBzAC4AbQBpAGMAcgBvAHMAbwBmAHQALgBjAG8AbQAvAEQAUgBNAC8AMgAwADAANwAvADAAMwAvAFAAbABhAHkAUgBlAGEAZAB5AEgAZQBhAGQAZQByACIAIAB2AGUAcgBzAGkAbwBuAD0AIgA0AC4AMAAuADAALgAwACIAPgA8AEQAQQBUAEEAPgA8AFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBFAFkATABFAE4APgAxADYAPAAvAEsARQBZAEwARQBOAD4APABBAEwARwBJAEQAPgBBAEUAUwBDAFQAUgA8AC8AQQBMAEcASQBEAD4APAAvAFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBJAEQAPgBMADkAVwA5AFcAawBwAFYASwBrACsANAAwAEcASAAzAFkAVQBKAFIAVgBRAD0APQA8AC8ASwBJAEQAPgA8AEMASABFAEMASwBTAFUATQA+AEkASwB6AFkAMgBIAFoATABBAGwASQA9ADwALwBDAEgARQBDAEsAUwBVAE0APgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA==")
if err != nil {
panic(err.Error())
@@ -51,19 +48,17 @@ func TestMakePSSHBox_Playready(t *testing.T) {
}
psshBox, err := makePSSHBox(wvSystemID, payload)
- assert.NoError(err)
+ require.NoError(t, err)
- assert.Equal(expectedPSSH, psshBox)
+ require.Equal(t, expectedPSSH, psshBox)
}
func TestMakePSSHBox_BadSystemID(t *testing.T) {
- assert := assert.New(t)
_, err := makePSSHBox([]byte("meaningless byte array"), nil)
- assert.Error(err)
+ require.Error(t, err)
}
func TestMakePSSHBox_NilSystemID(t *testing.T) {
- assert := assert.New(t)
_, err := makePSSHBox(nil, nil)
- assert.Error(err)
+ require.Error(t, err)
}
diff --git a/mpd/segment_list_test.go b/mpd/segment_list_test.go
index 6d944cc..b40eae4 100644
--- a/mpd/segment_list_test.go
+++ b/mpd/segment_list_test.go
@@ -3,64 +3,48 @@ package mpd
import (
"testing"
- "github.com/stretchr/testify/suite"
+ "github.com/stretchr/testify/require"
"github.com/zencoder/go-dash/helpers/ptrs"
"github.com/zencoder/go-dash/helpers/testfixtures"
)
-type SegmentListSuite struct {
- suite.Suite
-}
-
-func TestSegmentListSuite(t *testing.T) {
- suite.Run(t, new(SegmentListSuite))
-}
-
-func (s *SegmentListSuite) SetupTest() {
-
-}
-
-func (s *SegmentListSuite) SetupSuite() {
-
-}
-
-func (s *SegmentListSuite) TestSegmentListSerialization() {
+func TestSegmentListSerialization(t *testing.T) {
expectedXML := testfixtures.LoadFixture("fixtures/segment_list.mpd")
m := getSegmentListMPD()
xml, _ := m.WriteToString()
- s.Equal(expectedXML, xml)
+ require.Equal(t, expectedXML, xml)
}
-func (s *SegmentListSuite) TestSegmentListDeserialization() {
+func TestSegmentListDeserialization(t *testing.T) {
xml := testfixtures.LoadFixture("fixtures/segment_list.mpd")
m, err := ReadFromString(xml)
- s.Nil(err)
+ require.Nil(t, err)
if err == nil {
expected := getSegmentListMPD()
- s.Equal(expected.Periods[0].BaseURL, m.Periods[0].BaseURL)
+ require.Equal(t, expected.Periods[0].BaseURL, m.Periods[0].BaseURL)
expectedAudioSegList := expected.Periods[0].AdaptationSets[0].Representations[0].SegmentList
audioSegList := m.Periods[0].AdaptationSets[0].Representations[0].SegmentList
- s.Equal(expectedAudioSegList.Timescale, audioSegList.Timescale)
- s.Equal(expectedAudioSegList.Duration, audioSegList.Duration)
- s.Equal(expectedAudioSegList.Initialization, audioSegList.Initialization)
+ require.Equal(t, expectedAudioSegList.Timescale, audioSegList.Timescale)
+ require.Equal(t, expectedAudioSegList.Duration, audioSegList.Duration)
+ require.Equal(t, expectedAudioSegList.Initialization, audioSegList.Initialization)
for i := range expectedAudioSegList.SegmentURLs {
- s.Equal(expectedAudioSegList.SegmentURLs[i], audioSegList.SegmentURLs[i])
+ require.Equal(t, expectedAudioSegList.SegmentURLs[i], audioSegList.SegmentURLs[i])
}
expectedVideoSegList := expected.Periods[0].AdaptationSets[1].Representations[0].SegmentList
videoSegList := m.Periods[0].AdaptationSets[1].Representations[0].SegmentList
- s.Equal(expectedVideoSegList.Timescale, videoSegList.Timescale)
- s.Equal(expectedVideoSegList.Duration, videoSegList.Duration)
- s.Equal(expectedVideoSegList.Initialization, videoSegList.Initialization)
+ require.Equal(t, expectedVideoSegList.Timescale, videoSegList.Timescale)
+ require.Equal(t, expectedVideoSegList.Duration, videoSegList.Duration)
+ require.Equal(t, expectedVideoSegList.Initialization, videoSegList.Initialization)
for i := range expectedVideoSegList.SegmentURLs {
- s.Equal(expectedVideoSegList.SegmentURLs[i], videoSegList.SegmentURLs[i])
+ require.Equal(t, expectedVideoSegList.SegmentURLs[i], videoSegList.SegmentURLs[i])
}
}
}
diff --git a/mpd/segment_timeline_test.go b/mpd/segment_timeline_test.go
index 326b4a5..1ac525c 100644
--- a/mpd/segment_timeline_test.go
+++ b/mpd/segment_timeline_test.go
@@ -5,7 +5,6 @@ import (
"testing"
"time"
- "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/zencoder/go-dash/helpers/ptrs"
"github.com/zencoder/go-dash/helpers/testfixtures"
@@ -24,7 +23,7 @@ func TestSegmentTimelineSerialization(t *testing.T) {
found, err := tc.In.WriteToString()
require.NoError(t, err)
expected := testfixtures.LoadFixture("fixtures/" + tc.Out)
- assert.Equal(t, expected, found)
+ require.Equal(t, expected, found)
})
}
}
@@ -34,20 +33,20 @@ func TestSegmentTimelineDeserialization(t *testing.T) {
m, err := ReadFromString(xml)
require.NoError(t, err)
expected := getSegmentTimelineMPD()
- assert.Equal(t, expected.Periods[0].BaseURL, m.Periods[0].BaseURL)
+ require.Equal(t, expected.Periods[0].BaseURL, m.Periods[0].BaseURL)
expectedAudioSegTimeline := expected.Periods[0].AdaptationSets[0].Representations[0].SegmentTemplate.SegmentTimeline
audioSegTimeline := m.Periods[0].AdaptationSets[0].Representations[0].SegmentTemplate.SegmentTimeline
for i := range expectedAudioSegTimeline.Segments {
- assert.Equal(t, expectedAudioSegTimeline.Segments[i], audioSegTimeline.Segments[i])
+ require.Equal(t, expectedAudioSegTimeline.Segments[i], audioSegTimeline.Segments[i])
}
expectedVideoSegTimeline := expected.Periods[0].AdaptationSets[1].Representations[0].SegmentTemplate.SegmentTimeline
videoSegTimeline := m.Periods[0].AdaptationSets[1].Representations[0].SegmentTemplate.SegmentTimeline
for i := range expectedVideoSegTimeline.Segments {
- assert.Equal(t, expectedVideoSegTimeline.Segments[i], videoSegTimeline.Segments[i])
+ require.Equal(t, expectedVideoSegTimeline.Segments[i], videoSegTimeline.Segments[i])
}
}