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