Skip to content

Commit d5bdaa7

Browse files
committed
add test for MPD@Location
1 parent 7a8b5b3 commit d5bdaa7

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

mpd/fixtures/location.mpd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="dynamic" availabilityStartTime="1970-01-01T00:00:00Z" minimumUpdatePeriod="PT5S" publishTime="1970-01-01T00:00:00Z">
3+
<Location>https://example.com/location.mpd</Location>
4+
</MPD>

mpd/mpd_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import (
44
"encoding/base64"
55
"testing"
66

7+
"github.com/zencoder/go-dash/helpers/ptrs"
78
. "github.com/zencoder/go-dash/helpers/ptrs"
89
"github.com/zencoder/go-dash/helpers/require"
10+
"github.com/zencoder/go-dash/helpers/testfixtures"
911
)
1012

1113
const (
@@ -41,6 +43,7 @@ const (
4143
VALID_SUBTITLE_ID string = "subtitle_en"
4244
VALID_SUBTITLE_URL string = "http://example.com/content/sintel/subtitles/subtitles_en.vtt"
4345
VALID_ROLE string = "main"
46+
VALID_LOCATION string = "https://example.com/location.mpd"
4447
)
4548

4649
func TestNewMPDLive(t *testing.T) {
@@ -484,3 +487,30 @@ func TestAddNewAccessibilityElement(t *testing.T) {
484487
require.EqualStringPtr(t, Strptr((string)(ACCESSIBILITY_ELEMENT_SCHEME_DESCRIPTIVE_AUDIO)), elem.SchemeIdUri)
485488
require.EqualStringPtr(t, Strptr("1"), elem.Value)
486489
}
490+
491+
func TestLocationWriteToString(t *testing.T) {
492+
m := &MPD{
493+
XMLNs: ptrs.Strptr("urn:mpeg:dash:schema:mpd:2011"),
494+
Profiles: ptrs.Strptr((string)(DASH_PROFILE_LIVE)),
495+
Type: ptrs.Strptr("dynamic"),
496+
AvailabilityStartTime: ptrs.Strptr(VALID_AVAILABILITY_START_TIME),
497+
MinimumUpdatePeriod: ptrs.Strptr(VALID_MINIMUM_UPDATE_PERIOD),
498+
PublishTime: ptrs.Strptr(VALID_AVAILABILITY_START_TIME),
499+
Location: VALID_LOCATION,
500+
}
501+
502+
got, err := m.WriteToString()
503+
require.NoError(t, err)
504+
505+
testfixtures.CompareFixture(t, "fixtures/location.mpd", got)
506+
}
507+
508+
func TestReadLocation(t *testing.T) {
509+
m, err := ReadFromFile("fixtures/location.mpd")
510+
require.NoError(t, err)
511+
512+
got, err := m.WriteToString()
513+
require.NoError(t, err)
514+
515+
testfixtures.CompareFixture(t, "fixtures/location.mpd", got)
516+
}

0 commit comments

Comments
 (0)