2014-02-14 23:21:05 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
2014-08-21 22:40:44 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/base/file_util.h"
|
|
|
|
#include "packager/base/path_service.h"
|
|
|
|
#include "packager/mpd/test/mpd_builder_test_helper.h"
|
|
|
|
#include "packager/mpd/util/mpd_writer.h"
|
2014-01-28 23:06:58 +00:00
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
2014-01-28 23:06:58 +00:00
|
|
|
|
2014-02-28 22:34:26 +00:00
|
|
|
// Note that these tests look very similar to MpdBuilder tests but these can
|
|
|
|
// only handle MediaInfos with 1 stream in each file.
|
|
|
|
TEST(MpdWriterTest, VideoMediaInfo) {
|
2014-01-28 23:06:58 +00:00
|
|
|
MpdWriter mpd_writer;
|
2014-02-05 02:32:46 +00:00
|
|
|
base::FilePath media_info_file = GetTestDataFilePath(kFileNameVideoMediaInfo1);
|
2014-01-28 23:06:58 +00:00
|
|
|
|
2015-02-02 17:26:09 +00:00
|
|
|
ASSERT_TRUE(mpd_writer.AddFile(media_info_file.value(), ""));
|
2014-01-28 23:06:58 +00:00
|
|
|
std::string generated_mpd;
|
|
|
|
ASSERT_TRUE(mpd_writer.WriteMpdToString(&generated_mpd));
|
2014-02-05 02:32:46 +00:00
|
|
|
ASSERT_TRUE(ValidateMpdSchema(generated_mpd));
|
2014-01-28 23:06:58 +00:00
|
|
|
|
2014-02-05 02:32:46 +00:00
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectMpdToEqualExpectedOutputFile(
|
2014-01-28 23:06:58 +00:00
|
|
|
generated_mpd,
|
2014-02-05 02:32:46 +00:00
|
|
|
kFileNameExpectedMpdOutputVideo1));
|
2014-01-28 23:06:58 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 22:34:26 +00:00
|
|
|
TEST(MpdWriterTest, TwoVideoMediaInfo) {
|
2014-01-28 23:06:58 +00:00
|
|
|
MpdWriter mpd_writer;
|
|
|
|
base::FilePath media_info_file1 =
|
2014-02-05 02:32:46 +00:00
|
|
|
GetTestDataFilePath(kFileNameVideoMediaInfo1);
|
2014-01-28 23:06:58 +00:00
|
|
|
base::FilePath media_info_file2 =
|
2014-02-05 02:32:46 +00:00
|
|
|
GetTestDataFilePath(kFileNameVideoMediaInfo2);
|
2014-01-28 23:06:58 +00:00
|
|
|
|
2015-02-02 17:26:09 +00:00
|
|
|
ASSERT_TRUE(mpd_writer.AddFile(media_info_file1.value(), ""));
|
|
|
|
ASSERT_TRUE(mpd_writer.AddFile(media_info_file2.value(), ""));
|
2014-01-28 23:06:58 +00:00
|
|
|
|
|
|
|
std::string generated_mpd;
|
|
|
|
ASSERT_TRUE(mpd_writer.WriteMpdToString(&generated_mpd));
|
2014-02-05 02:32:46 +00:00
|
|
|
ASSERT_TRUE(ValidateMpdSchema(generated_mpd));
|
2014-01-28 23:06:58 +00:00
|
|
|
|
2014-02-05 02:32:46 +00:00
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectMpdToEqualExpectedOutputFile(
|
2014-01-28 23:06:58 +00:00
|
|
|
generated_mpd,
|
2014-02-05 02:32:46 +00:00
|
|
|
kFileNameExpectedMpdOutputVideo1And2));
|
2014-01-28 23:06:58 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 22:34:26 +00:00
|
|
|
TEST(MpdWriterTest, AudioMediaInfo) {
|
2014-01-28 23:06:58 +00:00
|
|
|
MpdWriter mpd_writer;
|
2014-02-05 02:32:46 +00:00
|
|
|
base::FilePath media_info_file = GetTestDataFilePath(kFileNameAudioMediaInfo1);
|
2014-01-28 23:06:58 +00:00
|
|
|
|
2015-02-02 17:26:09 +00:00
|
|
|
ASSERT_TRUE(mpd_writer.AddFile(media_info_file.value(), ""));
|
2014-01-28 23:06:58 +00:00
|
|
|
std::string generated_mpd;
|
|
|
|
ASSERT_TRUE(mpd_writer.WriteMpdToString(&generated_mpd));
|
2014-02-05 02:32:46 +00:00
|
|
|
ASSERT_TRUE(ValidateMpdSchema(generated_mpd));
|
2014-01-28 23:06:58 +00:00
|
|
|
|
2014-02-05 02:32:46 +00:00
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectMpdToEqualExpectedOutputFile(
|
2014-01-28 23:06:58 +00:00
|
|
|
generated_mpd,
|
2014-02-05 02:32:46 +00:00
|
|
|
kFileNameExpectedMpdOutputAudio1));
|
2014-01-28 23:06:58 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 22:34:26 +00:00
|
|
|
TEST(MpdWriterTest, VideoAudioMediaInfo) {
|
2014-01-28 23:06:58 +00:00
|
|
|
MpdWriter mpd_writer;
|
|
|
|
base::FilePath audio_media_info =
|
2014-02-05 02:32:46 +00:00
|
|
|
GetTestDataFilePath(kFileNameAudioMediaInfo1);
|
2014-01-28 23:06:58 +00:00
|
|
|
base::FilePath video_media_info =
|
2014-02-05 02:32:46 +00:00
|
|
|
GetTestDataFilePath(kFileNameVideoMediaInfo1);
|
2014-01-28 23:06:58 +00:00
|
|
|
|
2015-02-02 17:26:09 +00:00
|
|
|
ASSERT_TRUE(mpd_writer.AddFile(audio_media_info.value(), ""));
|
|
|
|
ASSERT_TRUE(mpd_writer.AddFile(video_media_info.value(), ""));
|
2014-01-28 23:06:58 +00:00
|
|
|
|
|
|
|
std::string generated_mpd;
|
|
|
|
ASSERT_TRUE(mpd_writer.WriteMpdToString(&generated_mpd));
|
2014-02-05 02:32:46 +00:00
|
|
|
ASSERT_TRUE(ValidateMpdSchema(generated_mpd));
|
2014-01-28 23:06:58 +00:00
|
|
|
|
2014-02-05 02:32:46 +00:00
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectMpdToEqualExpectedOutputFile(
|
2014-01-28 23:06:58 +00:00
|
|
|
generated_mpd,
|
2014-02-05 02:32:46 +00:00
|
|
|
kFileNameExpectedMpdOutputAudio1AndVideo1));
|
2014-01-28 23:06:58 +00:00
|
|
|
}
|
|
|
|
|
2014-03-04 20:38:06 +00:00
|
|
|
TEST(MpdWriterTest, EncryptedAudioMediaInfo) {
|
2014-02-28 22:34:26 +00:00
|
|
|
MpdWriter mpd_writer;
|
|
|
|
base::FilePath encrypted_audio_media_info =
|
|
|
|
GetTestDataFilePath(kFileNameEncytpedAudioMediaInfo);
|
|
|
|
|
2015-02-02 17:26:09 +00:00
|
|
|
ASSERT_TRUE(mpd_writer.AddFile(encrypted_audio_media_info.value(), ""));
|
2014-02-28 22:34:26 +00:00
|
|
|
|
|
|
|
std::string generated_mpd;
|
|
|
|
ASSERT_TRUE(mpd_writer.WriteMpdToString(&generated_mpd));
|
|
|
|
ASSERT_TRUE(ValidateMpdSchema(generated_mpd));
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectMpdToEqualExpectedOutputFile(
|
|
|
|
generated_mpd, kFileNameExpectedMpdOutputEncryptedAudio));
|
|
|
|
}
|
|
|
|
|
2015-02-02 17:26:09 +00:00
|
|
|
TEST(MpdWriterTest, LanguageMediaInfo) {
|
|
|
|
MpdWriter mpd_writer;
|
|
|
|
base::FilePath audio_media_info1 =
|
|
|
|
GetTestDataFilePath(kFileNameLanguageAudioMediaInfo1);
|
|
|
|
base::FilePath audio_media_info2 =
|
|
|
|
GetTestDataFilePath(kFileNameLanguageAudioMediaInfo2);
|
|
|
|
base::FilePath audio_media_info3 =
|
|
|
|
GetTestDataFilePath(kFileNameLanguageAudioMediaInfo3);
|
|
|
|
base::FilePath video_media_info1 =
|
|
|
|
GetTestDataFilePath(kFileNameLanguageVideoMediaInfo1);
|
|
|
|
|
|
|
|
ASSERT_TRUE(mpd_writer.AddFile(audio_media_info1.value(), ""));
|
|
|
|
ASSERT_TRUE(mpd_writer.AddFile(audio_media_info2.value(), ""));
|
|
|
|
ASSERT_TRUE(mpd_writer.AddFile(audio_media_info3.value(), ""));
|
|
|
|
ASSERT_TRUE(mpd_writer.AddFile(video_media_info1.value(), ""));
|
|
|
|
|
|
|
|
std::string generated_mpd;
|
|
|
|
ASSERT_TRUE(mpd_writer.WriteMpdToString(&generated_mpd));
|
|
|
|
ASSERT_TRUE(ValidateMpdSchema(generated_mpd));
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectMpdToEqualExpectedOutputFile(
|
|
|
|
generated_mpd,
|
|
|
|
kFileNameExpectedMpdOutputLanguageAudio));
|
|
|
|
}
|
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|