Updated StreamData Matchers to Use Matchers
Updated all the stream data matcher we use in our unit tests to allow us to use matchers in them. We are now able to use "_" to ignore specific parameters. With this we were able to replace the different version of matchers for each stream data type with a single instance for each type. Includes updates to printing strings to the listener. Strings now go through a "pretty" function to help make it easier to read them in the output. Change-Id: I146351b54fccd63ab9ec936877e6c6b30f9aa9fc
This commit is contained in:
parent
440adb3086
commit
fbc4952e21
|
@ -66,6 +66,49 @@ std::string BoolToString(bool value) {
|
|||
return value ? "true" : "false";
|
||||
}
|
||||
|
||||
bool TryMatchStreamDataType(const StreamDataType& actual,
|
||||
const StreamDataType& expected,
|
||||
::testing::MatchResultListener* listener) {
|
||||
if (actual != expected) {
|
||||
std::string expected_as_string = StreamDataTypeToString(expected);
|
||||
std::string actual_as_string = StreamDataTypeToString(actual);
|
||||
|
||||
*listener << "which is " << actual_as_string << " (expected "
|
||||
<< expected_as_string << ")";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string ToPrettyString(const std::string& str) {
|
||||
std::string out;
|
||||
|
||||
// Opening quotation.
|
||||
out.push_back('"');
|
||||
|
||||
for (char c : str) {
|
||||
if (isspace(c)) {
|
||||
// Make all white space characters spaces to avoid print issues in
|
||||
// the terminal.
|
||||
out.push_back(' ');
|
||||
} else if (isalnum(c)) {
|
||||
// If the character is alpha-numeric, then print it as is. Just using
|
||||
// these characters, it should be enough to understand the string.
|
||||
out.push_back(c);
|
||||
} else {
|
||||
// Replace all other characters with '.'. This is to avoid print issues
|
||||
// (e.g. \n) or readability issues (e.g. ").
|
||||
out.push_back('.');
|
||||
}
|
||||
}
|
||||
|
||||
// Closing quotation.
|
||||
out.push_back('"');
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
bool FakeInputMediaHandler::ValidateOutputStreamIndex(size_t index) const {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -17,42 +17,49 @@ namespace shaka {
|
|||
namespace media {
|
||||
|
||||
std::string BoolToString(bool value);
|
||||
std::string ToPrettyString(const std::string& str);
|
||||
|
||||
MATCHER_P(IsStreamInfo, stream_index, "") {
|
||||
return arg->stream_index == stream_index &&
|
||||
arg->stream_data_type == StreamDataType::kStreamInfo;
|
||||
}
|
||||
bool TryMatchStreamDataType(const StreamDataType& actual,
|
||||
const StreamDataType& expected,
|
||||
::testing::MatchResultListener* listener);
|
||||
|
||||
MATCHER_P3(IsStreamInfo, stream_index, time_scale, encrypted, "") {
|
||||
if (arg->stream_data_type != StreamDataType::kStreamInfo) {
|
||||
*result_listener << "which is "
|
||||
<< StreamDataTypeToString(arg->stream_data_type);
|
||||
template <typename T, typename M>
|
||||
bool TryMatch(const T& value,
|
||||
const M& matcher,
|
||||
::testing::MatchResultListener* listener,
|
||||
const char* value_name) {
|
||||
if (!ExplainMatchResult(matcher, value, listener)) {
|
||||
// Need a space at the start of the string in the case that
|
||||
// it gets combined with another string.
|
||||
*listener << " Mismatch on " << value_name;
|
||||
return false;
|
||||
}
|
||||
|
||||
*result_listener << "which is (" << arg->stream_index << ","
|
||||
<< arg->stream_info->time_scale() << ","
|
||||
<< BoolToString(arg->stream_info->is_encrypted()) << ")";
|
||||
return arg->stream_index == stream_index &&
|
||||
arg->stream_info->time_scale() == time_scale &&
|
||||
arg->stream_info->is_encrypted() == encrypted;
|
||||
return true;
|
||||
}
|
||||
|
||||
MATCHER_P4(IsStreamInfo, stream_index, time_scale, encrypted, language, "") {
|
||||
if (arg->stream_data_type != StreamDataType::kStreamInfo) {
|
||||
*result_listener << "which is "
|
||||
<< StreamDataTypeToString(arg->stream_data_type);
|
||||
if (!TryMatchStreamDataType(arg->stream_data_type,
|
||||
StreamDataType::kStreamInfo, result_listener)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string is_encrypted_string =
|
||||
BoolToString(arg->stream_info->is_encrypted());
|
||||
|
||||
*result_listener << "which is (" << arg->stream_index << ", "
|
||||
<< arg->stream_info->time_scale() << ", "
|
||||
<< BoolToString(arg->stream_info->is_encrypted()) << ","
|
||||
<< is_encrypted_string << ", "
|
||||
<< arg->stream_info->language() << ")";
|
||||
return arg->stream_index == stream_index &&
|
||||
arg->stream_info->time_scale() == time_scale &&
|
||||
arg->stream_info->is_encrypted() == encrypted &&
|
||||
arg->stream_info->language() == language;
|
||||
|
||||
return TryMatch(arg->stream_index, stream_index, result_listener,
|
||||
"stream_index") &&
|
||||
TryMatch(arg->stream_info->time_scale(), time_scale, result_listener,
|
||||
"time_scale") &&
|
||||
TryMatch(arg->stream_info->is_encrypted(), encrypted, result_listener,
|
||||
"is_encrypted") &&
|
||||
TryMatch(arg->stream_info->language(), language, result_listener,
|
||||
"language");
|
||||
}
|
||||
|
||||
MATCHER_P5(IsSegmentInfo,
|
||||
|
@ -62,22 +69,32 @@ MATCHER_P5(IsSegmentInfo,
|
|||
subsegment,
|
||||
encrypted,
|
||||
"") {
|
||||
if (arg->stream_data_type != StreamDataType::kSegmentInfo) {
|
||||
*result_listener << "which is "
|
||||
<< StreamDataTypeToString(arg->stream_data_type);
|
||||
if (!TryMatchStreamDataType(arg->stream_data_type,
|
||||
StreamDataType::kSegmentInfo, result_listener)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string is_subsegment_string =
|
||||
BoolToString(arg->segment_info->is_subsegment);
|
||||
const std::string is_encrypted_string =
|
||||
BoolToString(arg->segment_info->is_encrypted);
|
||||
|
||||
*result_listener << "which is (" << arg->stream_index << ", "
|
||||
<< arg->segment_info->start_timestamp << ", "
|
||||
<< arg->segment_info->duration << ", "
|
||||
<< BoolToString(arg->segment_info->is_subsegment) << ","
|
||||
<< BoolToString(arg->segment_info->is_encrypted) << ")";
|
||||
return arg->stream_index == stream_index &&
|
||||
arg->segment_info->start_timestamp == start_timestamp &&
|
||||
arg->segment_info->duration == duration &&
|
||||
arg->segment_info->is_subsegment == subsegment &&
|
||||
arg->segment_info->is_encrypted == encrypted;
|
||||
<< is_subsegment_string << ", " << is_encrypted_string
|
||||
<< ")";
|
||||
|
||||
return TryMatch(arg->stream_index, stream_index, result_listener,
|
||||
"stream_index") &&
|
||||
TryMatch(arg->segment_info->start_timestamp, start_timestamp,
|
||||
result_listener, "start_timestamp") &&
|
||||
TryMatch(arg->segment_info->duration, duration, result_listener,
|
||||
"duration") &&
|
||||
TryMatch(arg->segment_info->is_subsegment, subsegment, result_listener,
|
||||
"is_subsegment") &&
|
||||
TryMatch(arg->segment_info->is_encrypted, encrypted, result_listener,
|
||||
"is_encrypted");
|
||||
}
|
||||
|
||||
MATCHER_P6(MatchEncryptionConfig,
|
||||
|
@ -88,66 +105,105 @@ MATCHER_P6(MatchEncryptionConfig,
|
|||
constant_iv,
|
||||
key_id,
|
||||
"") {
|
||||
*result_listener << "which is (" << FourCCToString(arg.protection_scheme)
|
||||
<< "," << static_cast<int>(arg.crypt_byte_block) << ","
|
||||
<< static_cast<int>(arg.skip_byte_block) << ","
|
||||
<< static_cast<int>(arg.per_sample_iv_size) << ","
|
||||
<< base::HexEncode(arg.constant_iv.data(),
|
||||
arg.constant_iv.size())
|
||||
<< ","
|
||||
<< base::HexEncode(arg.key_id.data(), arg.key_id.size())
|
||||
<< ")";
|
||||
return arg.protection_scheme == protection_scheme &&
|
||||
arg.crypt_byte_block == crypt_byte_block &&
|
||||
arg.skip_byte_block == skip_byte_block &&
|
||||
arg.per_sample_iv_size == per_sample_iv_size &&
|
||||
arg.constant_iv == constant_iv && arg.key_id == key_id;
|
||||
const std::string constant_iv_hex =
|
||||
base::HexEncode(arg.constant_iv.data(), arg.constant_iv.size());
|
||||
const std::string key_id_hex =
|
||||
base::HexEncode(arg.key_id.data(), arg.key_id.size());
|
||||
const std::string protection_scheme_as_string =
|
||||
FourCCToString(arg.protection_scheme);
|
||||
// Convert to integers so that they will print as a number and not a uint8_t
|
||||
// (char).
|
||||
const int crypt_byte_as_int = static_cast<int>(arg.crypt_byte_block);
|
||||
const int skip_byte_as_int = static_cast<int>(arg.skip_byte_block);
|
||||
|
||||
*result_listener << "which is (" << protection_scheme_as_string << ", "
|
||||
<< crypt_byte_as_int << ", " << skip_byte_as_int << ", "
|
||||
<< arg.per_sample_iv_size << ", " << constant_iv_hex << ", "
|
||||
<< key_id_hex << ")";
|
||||
|
||||
return TryMatch(arg.protection_scheme, protection_scheme, result_listener,
|
||||
"protection_scheme") &&
|
||||
TryMatch(arg.crypt_byte_block, crypt_byte_block, result_listener,
|
||||
"crypt_byte_block") &&
|
||||
TryMatch(arg.skip_byte_block, skip_byte_block, result_listener,
|
||||
"skip_byte_block") &&
|
||||
TryMatch(arg.per_sample_iv_size, per_sample_iv_size, result_listener,
|
||||
"per_sample_iv_size") &&
|
||||
TryMatch(arg.constant_iv, constant_iv, result_listener,
|
||||
"constant_iv") &&
|
||||
TryMatch(arg.key_id, key_id, result_listener, "key_id");
|
||||
}
|
||||
|
||||
MATCHER_P4(IsMediaSample, stream_index, timestamp, duration, encrypted, "") {
|
||||
if (arg->stream_data_type != StreamDataType::kMediaSample) {
|
||||
*result_listener << "which is "
|
||||
<< StreamDataTypeToString(arg->stream_data_type);
|
||||
if (!TryMatchStreamDataType(arg->stream_data_type,
|
||||
StreamDataType::kMediaSample, result_listener)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string is_encrypted_string =
|
||||
BoolToString(arg->media_sample->is_encrypted());
|
||||
|
||||
*result_listener << "which is (" << arg->stream_index << ", "
|
||||
<< arg->media_sample->dts() << ", "
|
||||
<< arg->media_sample->duration() << ", "
|
||||
<< BoolToString(arg->media_sample->is_encrypted()) << ")";
|
||||
return arg->stream_index == stream_index &&
|
||||
arg->media_sample->dts() == static_cast<int64_t>(timestamp) &&
|
||||
arg->media_sample->duration() == static_cast<int64_t>(duration) &&
|
||||
arg->media_sample->is_encrypted() == encrypted;
|
||||
<< is_encrypted_string << ")";
|
||||
|
||||
return TryMatch(arg->stream_index, stream_index, result_listener,
|
||||
"stream_index") &&
|
||||
TryMatch(arg->media_sample->dts(), timestamp, result_listener,
|
||||
"dts") &&
|
||||
TryMatch(arg->media_sample->duration(), duration, result_listener,
|
||||
"duration") &&
|
||||
TryMatch(arg->media_sample->is_encrypted(), encrypted, result_listener,
|
||||
"is_encrypted");
|
||||
}
|
||||
|
||||
MATCHER_P5(IsTextSample, id, start_time, end_time, settings, payload, "") {
|
||||
if (arg->stream_data_type != StreamDataType::kTextSample) {
|
||||
*result_listener << "which is "
|
||||
<< StreamDataTypeToString(arg->stream_data_type);
|
||||
MATCHER_P6(IsTextSample,
|
||||
stream_index,
|
||||
id,
|
||||
start_time,
|
||||
end_time,
|
||||
settings,
|
||||
payload,
|
||||
"") {
|
||||
if (!TryMatchStreamDataType(arg->stream_data_type,
|
||||
StreamDataType::kTextSample, result_listener)) {
|
||||
return false;
|
||||
}
|
||||
*result_listener << "which is (" << arg->text_sample->id() << ","
|
||||
|
||||
*result_listener << "which is (" << arg->stream_index << ", "
|
||||
<< ToPrettyString(arg->text_sample->id()) << ", "
|
||||
<< arg->text_sample->start_time() << ", "
|
||||
<< arg->text_sample->EndTime() << ", "
|
||||
<< arg->text_sample->settings() << ","
|
||||
<< arg->text_sample->payload() << ")";
|
||||
return arg->text_sample->id() == id &&
|
||||
arg->text_sample->start_time() == start_time &&
|
||||
arg->text_sample->EndTime() == end_time &&
|
||||
arg->text_sample->settings() == settings &&
|
||||
arg->text_sample->payload() == payload;
|
||||
<< ToPrettyString(arg->text_sample->settings()) << ", "
|
||||
<< ToPrettyString(arg->text_sample->payload()) << ")";
|
||||
|
||||
return TryMatch(arg->stream_index, stream_index, result_listener,
|
||||
"stream_index") &&
|
||||
TryMatch(arg->text_sample->id(), id, result_listener, "id") &&
|
||||
TryMatch(arg->text_sample->start_time(), start_time, result_listener,
|
||||
"start_time") &&
|
||||
TryMatch(arg->text_sample->EndTime(), end_time, result_listener,
|
||||
"EndTime") &&
|
||||
TryMatch(arg->text_sample->settings(), settings, result_listener,
|
||||
"settings") &&
|
||||
TryMatch(arg->text_sample->payload(), payload, result_listener,
|
||||
"payload");
|
||||
}
|
||||
|
||||
MATCHER_P2(IsCueEvent, stream_index, time_in_seconds, "") {
|
||||
if (arg->stream_data_type != StreamDataType::kCueEvent) {
|
||||
*result_listener << "which is "
|
||||
<< StreamDataTypeToString(arg->stream_data_type);
|
||||
if (!TryMatchStreamDataType(arg->stream_data_type, StreamDataType::kCueEvent,
|
||||
result_listener)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*result_listener << "which is (" << arg->stream_index << ", "
|
||||
<< arg->cue_event->time_in_seconds << ")";
|
||||
return arg->stream_index == stream_index &&
|
||||
arg->cue_event->time_in_seconds == time_in_seconds;
|
||||
|
||||
return TryMatch(arg->stream_index, stream_index, result_listener,
|
||||
"stream_index") &&
|
||||
TryMatch(arg->cue_event->time_in_seconds, time_in_seconds,
|
||||
result_listener, "time_in_seconds");
|
||||
}
|
||||
|
||||
class FakeInputMediaHandler : public MediaHandler {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "packager/media/base/media_handler_test_base.h"
|
||||
#include "packager/status_test_util.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::IsEmpty;
|
||||
|
||||
|
@ -58,7 +59,7 @@ TEST_F(ChunkingHandlerTest, AudioNoSubsegmentsThenFlush) {
|
|||
kStreamIndex, GetAudioStreamInfo(kTimeScale0))));
|
||||
EXPECT_THAT(
|
||||
GetOutputStreamDataVector(),
|
||||
ElementsAre(IsStreamInfo(kStreamIndex, kTimeScale0, !kEncrypted)));
|
||||
ElementsAre(IsStreamInfo(kStreamIndex, kTimeScale0, !kEncrypted, _)));
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
ClearOutputStreamDataVector();
|
||||
|
@ -101,7 +102,7 @@ TEST_F(ChunkingHandlerTest, AudioWithSubsegments) {
|
|||
EXPECT_THAT(
|
||||
GetOutputStreamDataVector(),
|
||||
ElementsAre(
|
||||
IsStreamInfo(kStreamIndex, kTimeScale0, !kEncrypted),
|
||||
IsStreamInfo(kStreamIndex, kTimeScale0, !kEncrypted, _),
|
||||
IsMediaSample(kStreamIndex, 0, kDuration, !kEncrypted),
|
||||
IsMediaSample(kStreamIndex, kDuration, kDuration, !kEncrypted),
|
||||
IsSegmentInfo(kStreamIndex, 0, kDuration * 2, kIsSubsegment,
|
||||
|
@ -132,7 +133,7 @@ TEST_F(ChunkingHandlerTest, VideoAndSubsegmentAndNonzeroStart) {
|
|||
EXPECT_THAT(
|
||||
GetOutputStreamDataVector(),
|
||||
ElementsAre(
|
||||
IsStreamInfo(kStreamIndex, kTimeScale1, !kEncrypted),
|
||||
IsStreamInfo(kStreamIndex, kTimeScale1, !kEncrypted, _),
|
||||
// The first samples @ kStartTimestamp is discarded - not key frame.
|
||||
IsMediaSample(kStreamIndex, kVideoStartTimestamp + kDuration,
|
||||
kDuration, !kEncrypted),
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "packager/status_macros.h"
|
||||
#include "packager/status_test_util.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::IsEmpty;
|
||||
|
||||
|
@ -30,7 +31,7 @@ const size_t kThreeOutput = 3;
|
|||
const bool kEncrypted = true;
|
||||
const bool kKeyFrame = true;
|
||||
|
||||
const uint64_t kMsTimeScale = 1000;
|
||||
const uint32_t kMsTimeScale = 1000;
|
||||
|
||||
const char* kNoId = "";
|
||||
const char* kNoSettings = "";
|
||||
|
@ -87,7 +88,7 @@ TEST_F(CueAlignmentHandlerTest, VideoInputWithNoCues) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kVideoStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kVideoStream),
|
||||
OnProcess(IsMediaSample(kParent, kSample0Start, kSampleDuration,
|
||||
!kEncrypted)));
|
||||
|
@ -131,7 +132,7 @@ TEST_F(CueAlignmentHandlerTest, AudioInputWithNoCues) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kAudioStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kAudioStream),
|
||||
OnProcess(IsMediaSample(kParent, kSample0Start, kSampleDuration,
|
||||
!kEncrypted)));
|
||||
|
@ -179,15 +180,15 @@ TEST_F(CueAlignmentHandlerTest, TextInputWithNoCues) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample0Start, kSample0End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample0Start, kSample0End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample1Start, kSample1End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample1Start, kSample1End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample2Start, kSample2End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample2Start, kSample2End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream), OnFlush(kParent));
|
||||
}
|
||||
|
@ -229,15 +230,15 @@ TEST_F(CueAlignmentHandlerTest, TextAudioVideoInputWithNoCues) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample0Start, kSample0End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample0Start, kSample0End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample1Start, kSample1End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample1Start, kSample1End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample2Start, kSample2End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample2Start, kSample2End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream), OnFlush(kParent));
|
||||
}
|
||||
|
@ -246,7 +247,7 @@ TEST_F(CueAlignmentHandlerTest, TextAudioVideoInputWithNoCues) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kAudioStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kAudioStream),
|
||||
OnProcess(IsMediaSample(kParent, kSample0Start, kSampleDuration,
|
||||
!kEncrypted)));
|
||||
|
@ -263,7 +264,7 @@ TEST_F(CueAlignmentHandlerTest, TextAudioVideoInputWithNoCues) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kVideoStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kVideoStream),
|
||||
OnProcess(IsMediaSample(kParent, kSample0Start, kSampleDuration,
|
||||
!kEncrypted)));
|
||||
|
@ -353,7 +354,7 @@ TEST_F(CueAlignmentHandlerTest, VideoInputWithCues) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kVideoStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kVideoStream),
|
||||
OnProcess(IsMediaSample(kParent, kSample0Start, kSampleDuration,
|
||||
!kEncrypted)));
|
||||
|
@ -407,7 +408,7 @@ TEST_F(CueAlignmentHandlerTest, AudioInputWithCues) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kAudioStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kAudioStream),
|
||||
OnProcess(IsMediaSample(kParent, kSample0Start, kSampleDuration,
|
||||
!kEncrypted)));
|
||||
|
@ -465,17 +466,17 @@ TEST_F(CueAlignmentHandlerTest, TextInputWithCues) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample0Start, kSample0End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample0Start, kSample0End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsCueEvent(kParent, kSample1StartInSeconds)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample1Start, kSample1End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample1Start, kSample1End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample2Start, kSample2End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample2Start, kSample2End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream), OnFlush(kParent));
|
||||
}
|
||||
|
@ -524,15 +525,15 @@ TEST_F(CueAlignmentHandlerTest, TextInputWithCueAfterLastStart) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample0Start, kSample0End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample0Start, kSample0End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample1Start, kSample1End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample1Start, kSample1End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample2Start, kSample2End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample2Start, kSample2End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsCueEvent(kParent, kCueTimeInSeconds)));
|
||||
|
@ -585,17 +586,17 @@ TEST_F(CueAlignmentHandlerTest, TextAudioVideoInputWithCues) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample0Start, kSample0End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample0Start, kSample0End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample1Start, kSample1End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample1Start, kSample1End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsCueEvent(kParent, kSample2StartInSeconds)));
|
||||
EXPECT_CALL(*Output(kTextStream),
|
||||
OnProcess(IsTextSample(kNoId, kSample2Start, kSample2End,
|
||||
OnProcess(IsTextSample(_, kNoId, kSample2Start, kSample2End,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kTextStream), OnFlush(kParent));
|
||||
}
|
||||
|
@ -604,7 +605,7 @@ TEST_F(CueAlignmentHandlerTest, TextAudioVideoInputWithCues) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kAudioStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kAudioStream),
|
||||
OnProcess(IsMediaSample(kParent, kSample0Start, kSampleDuration,
|
||||
!kEncrypted)));
|
||||
|
@ -623,7 +624,7 @@ TEST_F(CueAlignmentHandlerTest, TextAudioVideoInputWithCues) {
|
|||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kVideoStream),
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(kParent, kMsTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kVideoStream),
|
||||
OnProcess(IsMediaSample(kParent, kSample0Start, kSampleDuration,
|
||||
!kEncrypted)));
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "packager/media/chunking/text_chunker.h"
|
||||
#include "packager/status_test_util.h"
|
||||
|
||||
using ::testing::_;
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
|
@ -67,10 +69,11 @@ TEST_F(TextChunkerTest, SampleEndingOnSegmentStart) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kOutput), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
||||
|
@ -117,11 +120,12 @@ TEST_F(TextChunkerTest, CreatesSegmentsForSamples) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kOutput), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Segment One
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
||||
|
@ -130,7 +134,7 @@ TEST_F(TextChunkerTest, CreatesSegmentsForSamples) {
|
|||
|
||||
// Segment Two
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleBStart, kSampleBEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleBStart, kSampleBEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
||||
|
@ -182,11 +186,12 @@ TEST_F(TextChunkerTest, OutputsEmptySegments) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kOutput), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Segment One
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
||||
|
@ -201,7 +206,7 @@ TEST_F(TextChunkerTest, OutputsEmptySegments) {
|
|||
|
||||
// Segment Three
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleBStart, kSampleBEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleBStart, kSampleBEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment2Start,
|
||||
|
@ -248,11 +253,12 @@ TEST_F(TextChunkerTest, SampleCrossesSegments) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kOutput), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Segment One
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
||||
|
@ -261,7 +267,7 @@ TEST_F(TextChunkerTest, SampleCrossesSegments) {
|
|||
|
||||
// Segment Two
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
||||
|
@ -318,18 +324,19 @@ TEST_F(TextChunkerTest, PreservesOrder) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kOutput), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Segment One
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kSampleAId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
OnProcess(IsTextSample(_, kSampleAId, kSampleAStart,
|
||||
kSampleAEnd, kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kSampleBId, kSampleBStart, kSampleBEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
OnProcess(IsTextSample(_, kSampleBId, kSampleBStart,
|
||||
kSampleBEnd, kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kSampleCId, kSampleCStart, kSampleCEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
OnProcess(IsTextSample(_, kSampleCId, kSampleCStart,
|
||||
kSampleCEnd, kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
||||
kSegmentDurationMs, !kSubSegment,
|
||||
|
@ -337,14 +344,14 @@ TEST_F(TextChunkerTest, PreservesOrder) {
|
|||
|
||||
// Segment Two
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kSampleAId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
OnProcess(IsTextSample(_, kSampleAId, kSampleAStart,
|
||||
kSampleAEnd, kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kSampleBId, kSampleBStart, kSampleBEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
OnProcess(IsTextSample(_, kSampleBId, kSampleBStart,
|
||||
kSampleBEnd, kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kSampleCId, kSampleCStart, kSampleCEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
OnProcess(IsTextSample(_, kSampleCId, kSampleCStart,
|
||||
kSampleCEnd, kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
||||
kSegmentDurationMs, !kSubSegment,
|
||||
|
@ -352,8 +359,8 @@ TEST_F(TextChunkerTest, PreservesOrder) {
|
|||
|
||||
// Segment Two
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kSampleCId, kSampleCStart, kSampleCEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
OnProcess(IsTextSample(_, kSampleCId, kSampleCStart,
|
||||
kSampleCEnd, kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment2Start,
|
||||
kSegmentDurationMs, !kSubSegment,
|
||||
|
@ -409,11 +416,12 @@ TEST_F(TextChunkerTest, NestedSamples) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kOutput), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Segment 0
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
||||
|
@ -422,10 +430,10 @@ TEST_F(TextChunkerTest, NestedSamples) {
|
|||
|
||||
// Segment 1
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleBStart, kSampleBEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleBStart, kSampleBEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
||||
|
@ -434,10 +442,10 @@ TEST_F(TextChunkerTest, NestedSamples) {
|
|||
|
||||
// Segment 2
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleBStart, kSampleBEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleBStart, kSampleBEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment2Start,
|
||||
|
@ -446,10 +454,10 @@ TEST_F(TextChunkerTest, NestedSamples) {
|
|||
|
||||
// Segment 3
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleBStart, kSampleBEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleBStart, kSampleBEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment3Start,
|
||||
|
@ -458,7 +466,7 @@ TEST_F(TextChunkerTest, NestedSamples) {
|
|||
|
||||
// Segment 4
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment4Start,
|
||||
|
@ -510,11 +518,12 @@ TEST_F(TextChunkerTest, SecondSampleStartsAfterMultiSegmentSampleEnds) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kOutput), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Segment One
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
||||
|
@ -523,7 +532,7 @@ TEST_F(TextChunkerTest, SecondSampleStartsAfterMultiSegmentSampleEnds) {
|
|||
|
||||
// Segment Two
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
||||
|
@ -532,7 +541,7 @@ TEST_F(TextChunkerTest, SecondSampleStartsAfterMultiSegmentSampleEnds) {
|
|||
|
||||
// Segment Three
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleBStart, kSampleBEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleBStart, kSampleBEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment2Start,
|
||||
|
@ -589,11 +598,12 @@ TEST_F(TextChunkerTest, SampleSpanningMultipleCues) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Output(kOutput), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Segment 0 and Cue 0
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
||||
|
@ -603,7 +613,7 @@ TEST_F(TextChunkerTest, SampleSpanningMultipleCues) {
|
|||
|
||||
// Segment 1 and Cue 1
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
||||
|
@ -613,7 +623,7 @@ TEST_F(TextChunkerTest, SampleSpanningMultipleCues) {
|
|||
|
||||
// Segment 2
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsTextSample(kNoId, kSampleAStart, kSampleAEnd,
|
||||
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
||||
kNoSettings, kNoPayload)));
|
||||
EXPECT_CALL(*Output(kOutput),
|
||||
OnProcess(IsSegmentInfo(kStreamIndex, kSegment2Start,
|
||||
|
|
|
@ -480,8 +480,9 @@ TEST_P(EncryptionHandlerEncryptionTest, ClearLeadWithNoKeyRotation) {
|
|||
kStreamIndex, GetAudioStreamInfo(kTimeScale, codec_))));
|
||||
}
|
||||
|
||||
EXPECT_THAT(GetOutputStreamDataVector(),
|
||||
ElementsAre(IsStreamInfo(kStreamIndex, kTimeScale, kEncrypted)));
|
||||
EXPECT_THAT(
|
||||
GetOutputStreamDataVector(),
|
||||
ElementsAre(IsStreamInfo(kStreamIndex, kTimeScale, kEncrypted, _)));
|
||||
const StreamInfo* stream_info =
|
||||
GetOutputStreamDataVector().back()->stream_info.get();
|
||||
ASSERT_TRUE(stream_info);
|
||||
|
@ -503,8 +504,8 @@ TEST_P(EncryptionHandlerEncryptionTest, ClearLeadWithNoKeyRotation) {
|
|||
kStreamIndex, GetMediaSample(i * kSegmentDuration, kSegmentDuration,
|
||||
kIsKeyFrame, kData, kDataSize))));
|
||||
ASSERT_OK(Process(StreamData::FromSegmentInfo(
|
||||
kStreamIndex,
|
||||
GetSegmentInfo(i * kSegmentDuration, kSegmentDuration, !kIsSubsegment))));
|
||||
kStreamIndex, GetSegmentInfo(i * kSegmentDuration, kSegmentDuration,
|
||||
!kIsSubsegment))));
|
||||
const bool is_encrypted = i == 2;
|
||||
const auto& output_stream_data = GetOutputStreamDataVector();
|
||||
EXPECT_THAT(output_stream_data,
|
||||
|
@ -540,8 +541,9 @@ TEST_P(EncryptionHandlerEncryptionTest, ClearLeadWithKeyRotation) {
|
|||
kStreamIndex, GetAudioStreamInfo(kTimeScale, codec_))));
|
||||
}
|
||||
|
||||
EXPECT_THAT(GetOutputStreamDataVector(),
|
||||
ElementsAre(IsStreamInfo(kStreamIndex, kTimeScale, kEncrypted)));
|
||||
EXPECT_THAT(
|
||||
GetOutputStreamDataVector(),
|
||||
ElementsAre(IsStreamInfo(kStreamIndex, kTimeScale, kEncrypted, _)));
|
||||
const StreamInfo* stream_info =
|
||||
GetOutputStreamDataVector().back()->stream_info.get();
|
||||
ASSERT_TRUE(stream_info);
|
||||
|
@ -570,8 +572,8 @@ TEST_P(EncryptionHandlerEncryptionTest, ClearLeadWithKeyRotation) {
|
|||
kStreamIndex, GetMediaSample(i * kSegmentDuration, kSegmentDuration,
|
||||
kIsKeyFrame, kData, kDataSize))));
|
||||
ASSERT_OK(Process(StreamData::FromSegmentInfo(
|
||||
kStreamIndex,
|
||||
GetSegmentInfo(i * kSegmentDuration, kSegmentDuration, !kIsSubsegment))));
|
||||
kStreamIndex, GetSegmentInfo(i * kSegmentDuration, kSegmentDuration,
|
||||
!kIsSubsegment))));
|
||||
const bool is_encrypted = i >= 2;
|
||||
const auto& output_stream_data = GetOutputStreamDataVector();
|
||||
EXPECT_THAT(output_stream_data,
|
||||
|
@ -610,8 +612,9 @@ TEST_P(EncryptionHandlerEncryptionTest, Encrypt) {
|
|||
kStreamIndex, GetAudioStreamInfo(kTimeScale, codec_))));
|
||||
}
|
||||
|
||||
EXPECT_THAT(GetOutputStreamDataVector(),
|
||||
ElementsAre(IsStreamInfo(kStreamIndex, kTimeScale, kEncrypted)));
|
||||
EXPECT_THAT(
|
||||
GetOutputStreamDataVector(),
|
||||
ElementsAre(IsStreamInfo(kStreamIndex, kTimeScale, kEncrypted, _)));
|
||||
const StreamInfo* stream_info =
|
||||
GetOutputStreamDataVector().back()->stream_info.get();
|
||||
ASSERT_TRUE(stream_info);
|
||||
|
@ -697,8 +700,7 @@ INSTANTIATE_TEST_CASE_P(AppleSampleAes,
|
|||
|
||||
class EncryptionHandlerTrackTypeTest : public EncryptionHandlerTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
}
|
||||
void SetUp() override {}
|
||||
};
|
||||
|
||||
TEST_F(EncryptionHandlerTrackTypeTest, AudioTrackType) {
|
||||
|
@ -716,8 +718,7 @@ TEST_F(EncryptionHandlerTrackTypeTest, AudioTrackType) {
|
|||
.WillOnce(
|
||||
DoAll(SetArgPointee<1>(GetMockEncryptionKey()), Return(Status::OK)));
|
||||
ASSERT_OK(Process(StreamData::FromStreamInfo(
|
||||
kStreamIndex,
|
||||
GetAudioStreamInfo(kTimeScale))));
|
||||
kStreamIndex, GetAudioStreamInfo(kTimeScale))));
|
||||
EXPECT_EQ(EncryptionParams::EncryptedStreamAttributes::kAudio,
|
||||
captured_stream_attributes.stream_type);
|
||||
}
|
||||
|
@ -739,8 +740,7 @@ TEST_F(EncryptionHandlerTrackTypeTest, VideoTrackType) {
|
|||
.WillOnce(
|
||||
DoAll(SetArgPointee<1>(GetMockEncryptionKey()), Return(Status::OK)));
|
||||
ASSERT_OK(Process(StreamData::FromStreamInfo(
|
||||
kStreamIndex,
|
||||
GetVideoStreamInfo(kTimeScale, kWidth, kHeight))));
|
||||
kStreamIndex, GetVideoStreamInfo(kTimeScale, kWidth, kHeight))));
|
||||
EXPECT_EQ(EncryptionParams::EncryptedStreamAttributes::kVideo,
|
||||
captured_stream_attributes.stream_type);
|
||||
EXPECT_EQ(captured_stream_attributes.oneof.video.width, kWidth);
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "packager/media/formats/webvtt/webvtt_parser.h"
|
||||
#include "packager/status_test_util.h"
|
||||
|
||||
using ::testing::_;
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
namespace {
|
||||
|
@ -21,8 +23,7 @@ const size_t kInputCount = 0;
|
|||
const size_t kOutputCount = 1;
|
||||
const size_t kOutputIndex = 0;
|
||||
|
||||
const size_t kStreamIndex = 0;
|
||||
const size_t kTimeScale = 1000;
|
||||
const uint32_t kTimeScale = 1000;
|
||||
const bool kEncrypted = true;
|
||||
|
||||
const char* kNoId = "";
|
||||
|
@ -71,9 +72,8 @@ TEST_F(WebVttParserTest, ParseOnlyHeader) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, kTimeScale, !kEncrypted,
|
||||
kLanguage)));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||
OnProcess(IsStreamInfo(_, kTimeScale, !kEncrypted, kLanguage)));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(_));
|
||||
}
|
||||
|
||||
ASSERT_OK(parser_->Run());
|
||||
|
@ -89,8 +89,8 @@ TEST_F(WebVttParserTest, ParseHeaderWithBOM) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, kTimeScale, !kEncrypted)));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||
OnProcess(IsStreamInfo(_, kTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(_));
|
||||
}
|
||||
|
||||
ASSERT_OK(parser_->Run());
|
||||
|
@ -142,8 +142,8 @@ TEST_F(WebVttParserTest, ParserDoesNotDieOnRegionBlock) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, kTimeScale, !kEncrypted)));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||
OnProcess(IsStreamInfo(_, kTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(_));
|
||||
}
|
||||
|
||||
ASSERT_OK(parser_->Run());
|
||||
|
@ -166,8 +166,8 @@ TEST_F(WebVttParserTest, ParserDoesNotDieOnStyleBlock) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, kTimeScale, !kEncrypted)));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||
OnProcess(IsStreamInfo(_, kTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(_));
|
||||
}
|
||||
|
||||
ASSERT_OK(parser_->Run());
|
||||
|
@ -185,8 +185,8 @@ TEST_F(WebVttParserTest, IngoresZeroDurationCues) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, kTimeScale, !kEncrypted)));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||
OnProcess(IsStreamInfo(_, kTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(_));
|
||||
}
|
||||
|
||||
ASSERT_OK(parser_->Run());
|
||||
|
@ -204,11 +204,11 @@ TEST_F(WebVttParserTest, ParseOneCue) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, kTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(_, kTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsTextSample(kNoId, 60000u, 3600000u, kNoSettings,
|
||||
OnProcess(IsTextSample(_, kNoId, 60000u, 3600000u, kNoSettings,
|
||||
"subtitle")));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(_));
|
||||
}
|
||||
|
||||
ASSERT_OK(parser_->Run());
|
||||
|
@ -240,11 +240,11 @@ TEST_F(WebVttParserTest, ParseOneCueWithId) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, kTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(_, kTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsTextSample("id", 60000u, 3600000u, kNoSettings,
|
||||
OnProcess(IsTextSample(_, "id", 60000u, 3600000u, kNoSettings,
|
||||
"subtitle")));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(_));
|
||||
}
|
||||
|
||||
ASSERT_OK(parser_->Run());
|
||||
|
@ -262,11 +262,11 @@ TEST_F(WebVttParserTest, ParseOneCueWithSettings) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, kTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(_, kTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsTextSample(kNoId, 60000u, 3600000u, "size:50%",
|
||||
OnProcess(IsTextSample(_, kNoId, 60000u, 3600000u, "size:50%",
|
||||
"subtitle")));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(_));
|
||||
}
|
||||
|
||||
ASSERT_OK(parser_->Run());
|
||||
|
@ -291,17 +291,17 @@ TEST_F(WebVttParserTest, ParseMultipleCues) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, kTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(_, kTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsTextSample(kNoId, 1000u, 5200u, kNoSettings,
|
||||
OnProcess(IsTextSample(_, kNoId, 1000u, 5200u, kNoSettings,
|
||||
"subtitle A")));
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsTextSample(kNoId, 2321u, 7000u, kNoSettings,
|
||||
OnProcess(IsTextSample(_, kNoId, 2321u, 7000u, kNoSettings,
|
||||
"subtitle B")));
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsTextSample(kNoId, 5800u, 8000u, kNoSettings,
|
||||
OnProcess(IsTextSample(_, kNoId, 5800u, 8000u, kNoSettings,
|
||||
"subtitle C")));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(_));
|
||||
}
|
||||
|
||||
ASSERT_OK(parser_->Run());
|
||||
|
@ -337,17 +337,17 @@ TEST_F(WebVttParserTest, ParseWithComments) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsStreamInfo(kStreamIndex, kTimeScale, !kEncrypted)));
|
||||
OnProcess(IsStreamInfo(_, kTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsTextSample(kNoId, 1000u, 5200u, kNoSettings,
|
||||
OnProcess(IsTextSample(_, kNoId, 1000u, 5200u, kNoSettings,
|
||||
"subtitle A")));
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsTextSample(kNoId, 2321u, 7000u, kNoSettings,
|
||||
OnProcess(IsTextSample(_, kNoId, 2321u, 7000u, kNoSettings,
|
||||
"subtitle B")));
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsTextSample(kNoId, 5800u, 8000u, kNoSettings,
|
||||
OnProcess(IsTextSample(_, kNoId, 5800u, 8000u, kNoSettings,
|
||||
"subtitle C")));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(_));
|
||||
}
|
||||
|
||||
ASSERT_OK(parser_->Run());
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "packager/media/formats/webvtt/webvtt_to_mp4_handler.h"
|
||||
#include "packager/status_test_util.h"
|
||||
|
||||
using testing::_;
|
||||
using testing::AllOf;
|
||||
using testing::Not;
|
||||
|
||||
|
@ -122,7 +123,7 @@ TEST_F(WebVttToMp4HandlerTest, IngoresEmptyPayloadSamples) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Gap - The gap and sample should be combines into a new gap that spans
|
||||
// the while segment.
|
||||
|
@ -170,7 +171,7 @@ TEST_F(WebVttToMp4HandlerTest, NonZeroStartTime) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Gap
|
||||
EXPECT_CALL(*Out(),
|
||||
|
@ -227,7 +228,7 @@ TEST_F(WebVttToMp4HandlerTest, NoOverlap) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Sample 1
|
||||
EXPECT_CALL(*Out(),
|
||||
|
@ -300,7 +301,7 @@ TEST_F(WebVttToMp4HandlerTest, Overlap) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Sample 1
|
||||
EXPECT_CALL(*Out(), OnProcess(AllOf(
|
||||
|
@ -375,7 +376,7 @@ TEST_F(WebVttToMp4HandlerTest, Contains) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Sample 1
|
||||
EXPECT_CALL(*Out(), OnProcess(AllOf(
|
||||
|
@ -434,7 +435,7 @@ TEST_F(WebVttToMp4HandlerTest, ExactOverlap) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Both Samples
|
||||
EXPECT_CALL(*Out(),
|
||||
|
@ -496,7 +497,7 @@ TEST_F(WebVttToMp4HandlerTest, OverlapStartWithStaggerEnd) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Three Samples
|
||||
EXPECT_CALL(*Out(),
|
||||
|
@ -576,7 +577,7 @@ TEST_F(WebVttToMp4HandlerTest, StaggerStartWithOverlapEnd) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// One Sample
|
||||
EXPECT_CALL(*Out(),
|
||||
|
@ -652,7 +653,7 @@ TEST_F(WebVttToMp4HandlerTest, CrossSegmentSamples) {
|
|||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
||||
|
||||
// Gap, Sample, Segment
|
||||
EXPECT_CALL(*Out(),
|
||||
|
|
Loading…
Reference in New Issue