From 3d4872ec77b51c240ae023078e3ac4d0b475d2c2 Mon Sep 17 00:00:00 2001 From: Rintaro Kuroiwa Date: Wed, 5 Aug 2015 15:34:46 -0700 Subject: [PATCH] Add test that adds Role and ContentProtection elements - ContentProtection elements must appear before Role elements. Change-Id: If517a91c977487c1bd42cfe0b973aa0cfb8223f7 --- packager/mpd/base/mpd_builder_unittest.cc | 39 ++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/packager/mpd/base/mpd_builder_unittest.cc b/packager/mpd/base/mpd_builder_unittest.cc index 9624e346c9..5b56af448c 100644 --- a/packager/mpd/base/mpd_builder_unittest.cc +++ b/packager/mpd/base/mpd_builder_unittest.cc @@ -601,8 +601,45 @@ TEST_F(CommonMpdBuilderTest, AdaptationAddRoleElementMain) { ""; std::string mpd_output; EXPECT_TRUE(mpd_builder.ToString(&mpd_output)); + ASSERT_TRUE(ValidateMpdSchema(mpd_output)); EXPECT_TRUE(XmlEqual(kExpectedOutput, mpd_output)) - << "Expected " << kExpectedOutput << std::endl << "Actual: " << mpd_output; + << "Expected " << kExpectedOutput << std::endl + << "Actual: " << mpd_output; +} + +// Add Role and ContentProtection elements. Verify that ContentProtection appear +// before Role. +TEST_F(CommonMpdBuilderTest, AddContentProtectionAndRole) { + MpdBuilder mpd_builder(MpdBuilder::kStatic, MpdOptions()); + AdaptationSet* adaptation_set = mpd_builder.AddAdaptationSet(""); + adaptation_set->AddRole(AdaptationSet::kRoleMain); + ContentProtectionElement any_content_protection; + any_content_protection.scheme_id_uri = "any_scheme"; + adaptation_set->AddContentProtectionElement(any_content_protection); + + xml::ScopedXmlPtr::type adaptation_set_xml(adaptation_set->GetXml()); + const char kExpectedOutput[] = + "\n" + "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + ""; + std::string mpd_output; + EXPECT_TRUE(mpd_builder.ToString(&mpd_output)); + ASSERT_TRUE(ValidateMpdSchema(mpd_output)); + EXPECT_TRUE(XmlEqual(kExpectedOutput, mpd_output)) + << "Expected " << kExpectedOutput << std::endl + << "Actual: " << mpd_output; } // Verify that if all video Representations in an AdaptationSet have the same