#include "src/block_parser.h"
#include <cstdint>
#include <memory>
#include <type_traits>
#include <vector>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "src/parser_utils.h"
#include "test_utils/element_parser_test.h"
#include "webm/id.h"
#include "webm/status.h"
using testing::_;
using testing::Between;
using testing::DoAll;
using testing::Exactly;
using testing::InSequence;
using testing::Invoke;
using testing::NotNull;
using testing::Return;
using testing::SetArgPointee;
using webm::Action;
using webm::Block;
using webm::BlockParser;
using webm::ElementParserTest;
using webm::FrameMetadata;
using webm::Id;
using webm::kUnknownElementSize;
using webm::Lacing;
using webm::ReadByte;
using webm::Reader;
using webm::SimpleBlock;
using webm::SimpleBlockParser;
using webm::Status;
namespace {
struct TestData {
std::vector<std::uint8_t> data;
std::uint64_t expected_track_number;
std::int16_t expected_timecode;
Lacing expected_lacing;
bool expected_is_visible;
bool expected_is_key_frame;
bool expected_is_discardable;
int expected_num_frames;
std::uint64_t expected_frame_start_position;
std::vector<std::uint64_t> expected_frame_sizes;
};
const TestData ebml_lacing_one_frame = {
{
0x81, 0x00,
0x00, 0x86, 0x00,
0x00,
},
1, 0, Lacing::kEbml, true, true, false, 1,
5, {1},
};
const TestData xiph_lacing_one_frame = {
{
0x81, 0x00,
0x00, 0x82, 0x00,
0x00,
},
1, 0, Lacing::kXiph, true, true, false, 1,
5, {1},
};
const TestData fixed_lacing_one_frame = {
{
0x81, 0x00,
0x00, 0x84, 0x00,
0x00,
},
1, 0, Lacing::kFixed, true, true, false, 1,
5, {1},
};
const TestData ebml_lacing = {
{
0x81, 0x00, 0x00, 0x86, 0x05,
0xFF, 0x5F, 0x81, 0xC0, 0xFF, 0x81,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01,
0x02, 0x02,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x04, 0x04, 0x04, 0x04,
0x05, 0x05, 0x05, 0x05, 0x05,
},
1, 0, Lacing::kEbml, true, true, false, 6,
11, {127, 1, 2, 66, 4, 5},
};
const TestData xiph_lacing = {
{
0x81, 0x00, 0x00, 0x82, 0x03,
0xFF, 0xFF, 0x00, 0xFF, 0x01, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01,
0x02, 0x02,
0x03, 0x03, 0x03,
},
1, 0, Lacing::kXiph, true, true, false, 4,
11, {510, 256, 2, 3},
};
const TestData fixed_lacing = {
{
0x81, 0x00, 0x00, 0x84, 0x03,
0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, },
1, 0, Lacing::kFixed, true, true, false, 4,
5, {2, 2, 2, 2},
};
const TestData no_lacing = {
{
0x40, 0x01, 0x00, 0x00, 0x80,
0x00, 0x00, 0x00, },
1, 0, Lacing::kNone, true, true, false, 1,
5, {3},
};
const TestData no_flags = {
{
0x81, 0x00,
0x00, 0x00,
0x00,
},
1, 0, Lacing::kNone, true, false, false, 1,
4, {1},
};
const TestData block_flags = {
{
0x82, 0xFE,
0xDC, 0x08,
0x00,
},
2, -292, Lacing::kNone, false, false, false, 1,
4, {1},
};
const TestData simple_block_flags = {
{
0x41,
0x23, 0x12,
0x34, 0x89,
0x00,
},
291, 4660, Lacing::kNone, false, true, true, 1,
5, {1},
};
void ValidateBlock(const TestData& test_data, const Block& actual) {
EXPECT_EQ(test_data.expected_track_number, actual.track_number);
EXPECT_EQ(test_data.expected_timecode, actual.timecode);
EXPECT_EQ(test_data.expected_is_visible, actual.is_visible);
EXPECT_EQ(test_data.expected_lacing, actual.lacing);
EXPECT_EQ(test_data.expected_num_frames, actual.num_frames);
}
void ValidateBlock(const TestData& test_data, const SimpleBlock& actual) {
ValidateBlock(test_data, static_cast<const Block&>(actual));
EXPECT_EQ(test_data.expected_is_key_frame, actual.is_key_frame);
EXPECT_EQ(test_data.expected_is_discardable, actual.is_discardable);
}
SimpleBlock ExpectedSimpleBlock(const TestData& test_data) {
SimpleBlock expected;
expected.track_number = test_data.expected_track_number;
expected.timecode = test_data.expected_timecode;
expected.lacing = test_data.expected_lacing;
expected.is_visible = test_data.expected_is_visible;
expected.is_key_frame = test_data.expected_is_key_frame;
expected.is_discardable = test_data.expected_is_discardable;
expected.num_frames = test_data.expected_num_frames;
return expected;
}
struct FrameHandler {
FrameMetadata expected_metadata;
std::uint8_t expected_frame_byte_value;
Status operator()(const FrameMetadata& metadata, Reader* reader,
std::uint64_t* bytes_remaining) const {
EXPECT_EQ(expected_metadata, metadata);
std::uint8_t frame_byte_value;
Status status;
do {
status = ReadByte(reader, &frame_byte_value);
if (!status.completed_ok()) {
break;
}
EXPECT_EQ(expected_frame_byte_value, frame_byte_value);
--*bytes_remaining;
} while (*bytes_remaining > 0);
return status;
}
};
template <typename T, Id id>
class BasicBlockParserTest : public ElementParserTest<T, id> {
public:
void SetExpectations(const TestData& test_data, bool incremental,
bool set_action) {
InSequence dummy;
const SimpleBlock expected_simple_block = ExpectedSimpleBlock(test_data);
const Block expected_block = ExpectedSimpleBlock(test_data);
FrameMetadata metadata = FirstFrameMetadata(test_data);
if (std::is_same<T, SimpleBlockParser>::value) {
auto& expectation = EXPECT_CALL(
callback_, OnSimpleBlockBegin(metadata.parent_element,
expected_simple_block, NotNull()));
if (set_action) {
expectation.Times(1);
} else {
expectation.WillOnce(Return(Status(Status::kOkCompleted)));
}
EXPECT_CALL(callback_, OnBlockBegin(_, _, _)).Times(0);
} else {
auto& expectation = EXPECT_CALL(
callback_,
OnBlockBegin(metadata.parent_element, expected_block, NotNull()));
if (set_action) {
expectation.Times(1);
} else {
expectation.WillOnce(Return(Status(Status::kOkCompleted)));
}
EXPECT_CALL(callback_, OnSimpleBlockBegin(_, _, _)).Times(0);
}
std::uint8_t expected_frame_byte_value = 0;
for (const std::uint64_t frame_size : test_data.expected_frame_sizes) {
metadata.size = frame_size;
const FrameHandler frame_handler = {metadata, expected_frame_byte_value};
const int this_frame_size = static_cast<int>(frame_size);
EXPECT_CALL(callback_, OnFrame(metadata, NotNull(), NotNull()))
.Times(incremental ? Between(this_frame_size, this_frame_size + 1)
: Exactly(1))
.WillRepeatedly(Invoke(frame_handler));
metadata.position += metadata.size;
++expected_frame_byte_value;
}
if (std::is_same<T, SimpleBlockParser>::value) {
EXPECT_CALL(callback_, OnSimpleBlockEnd(metadata.parent_element,
expected_simple_block))
.Times(1);
EXPECT_CALL(callback_, OnBlockEnd(_, _)).Times(0);
} else {
EXPECT_CALL(callback_,
OnBlockEnd(metadata.parent_element, expected_block))
.Times(1);
EXPECT_CALL(callback_, OnSimpleBlockEnd(_, _)).Times(0);
}
}
void RunTest(const TestData& test_data) {
SetReaderData(test_data.data);
SetExpectations(test_data, false, true);
ParseAndVerify();
ValidateBlock(test_data, parser_.value());
}
void RunIncrementalTest(const TestData& test_data) {
SetReaderData(test_data.data);
SetExpectations(test_data, true, true);
IncrementalParseAndVerify();
ValidateBlock(test_data, parser_.value());
}
void TestInvalidElementSize() {
TestInit(0, Status::kInvalidElementSize);
TestInit(4, Status::kInvalidElementSize);
TestInit(kUnknownElementSize, Status::kInvalidElementSize);
}
void TestInvalidHeaderOnly(const TestData& test_data) {
EXPECT_CALL(callback_, OnFrame(_, _, _)).Times(0);
EXPECT_CALL(callback_, OnBlockEnd(_, _)).Times(0);
EXPECT_CALL(callback_, OnSimpleBlockEnd(_, _)).Times(0);
SetReaderData(test_data.data);
ParseAndExpectResult(Status::kInvalidElementValue,
test_data.expected_frame_start_position);
}
void TestInvalidFixedLaceSizes() {
SetReaderData({
0x81, 0x00, 0x00, 0x84, 0x01,
0x00, 0x00, 0x01, });
EXPECT_CALL(callback_, OnFrame(_, _, _)).Times(0);
EXPECT_CALL(callback_, OnBlockEnd(_, _)).Times(0);
EXPECT_CALL(callback_, OnSimpleBlockEnd(_, _)).Times(0);
ParseAndExpectResult(Status::kInvalidElementValue);
}
void TestSimpleBlockSkip(const TestData& test_data) {
SetReaderData(test_data.data);
const SimpleBlock expected_simple_block = ExpectedSimpleBlock(test_data);
const FrameMetadata metadata = FirstFrameMetadata(test_data);
EXPECT_CALL(callback_, OnSimpleBlockBegin(metadata.parent_element,
expected_simple_block, NotNull()))
.WillOnce(Return(Status(Status::kOkPartial)))
.WillOnce(DoAll(SetArgPointee<2>(Action::kSkip),
Return(Status(Status::kOkCompleted))));
EXPECT_CALL(callback_, OnFrame(_, _, _)).Times(0);
EXPECT_CALL(callback_, OnBlockEnd(_, _)).Times(0);
EXPECT_CALL(callback_, OnSimpleBlockEnd(_, _)).Times(0);
IncrementalParseAndVerify();
}
protected:
using ElementParserTest<T, id>::callback_;
using ElementParserTest<T, id>::IncrementalParseAndVerify;
using ElementParserTest<T, id>::metadata_;
using ElementParserTest<T, id>::ParseAndExpectResult;
using ElementParserTest<T, id>::ParseAndVerify;
using ElementParserTest<T, id>::parser_;
using ElementParserTest<T, id>::SetReaderData;
using ElementParserTest<T, id>::TestInit;
private:
FrameMetadata FirstFrameMetadata(const TestData& test_data) {
FrameMetadata metadata;
metadata.parent_element = metadata_;
metadata.parent_element.size = test_data.data.size();
metadata.position = test_data.expected_frame_start_position +
metadata.parent_element.position +
metadata.parent_element.header_size;
metadata.size = test_data.expected_frame_sizes[0];
return metadata;
}
};
class BlockParserTest : public BasicBlockParserTest<BlockParser, Id::kBlock> {};
TEST_F(BlockParserTest, InvalidElementSize) { TestInvalidElementSize(); }
TEST_F(BlockParserTest, InvalidHeaderOnlyNoLacing) {
TestInvalidHeaderOnly(no_lacing);
}
TEST_F(BlockParserTest, InvalidHeaderOnlyFixedLacing) {
TestInvalidHeaderOnly(fixed_lacing);
}
TEST_F(BlockParserTest, InvalidFixedLaceSizes) { TestInvalidFixedLaceSizes(); }
TEST_F(BlockParserTest, BlockNoFlags) { RunTest(no_flags); }
TEST_F(BlockParserTest, BlockFlags) { RunTest(block_flags); }
TEST_F(BlockParserTest, EbmlLacingOneFrame) { RunTest(ebml_lacing_one_frame); }
TEST_F(BlockParserTest, EbmlLacing) { RunTest(ebml_lacing); }
TEST_F(BlockParserTest, XiphLacingOneFrame) { RunTest(xiph_lacing_one_frame); }
TEST_F(BlockParserTest, XiphLacing) { RunTest(xiph_lacing); }
TEST_F(BlockParserTest, FixedLacingOneFrame) {
RunTest(fixed_lacing_one_frame);
}
TEST_F(BlockParserTest, FixedLacing) { RunTest(fixed_lacing); }
TEST_F(BlockParserTest, NoLacing) { RunTest(no_lacing); }
TEST_F(BlockParserTest, BlockWithPositionAndHeaderSize) {
metadata_.position = 15;
metadata_.header_size = 3;
RunTest(no_lacing);
}
TEST_F(BlockParserTest, IncrementalBlockFlags) {
RunIncrementalTest(block_flags);
}
TEST_F(BlockParserTest, IncrementalEbmlLacingOneFrame) {
RunIncrementalTest(ebml_lacing_one_frame);
}
TEST_F(BlockParserTest, IncrementalEbmlLacing) {
RunIncrementalTest(ebml_lacing);
}
TEST_F(BlockParserTest, IncrementalXiphLacingOneFrame) {
RunIncrementalTest(xiph_lacing_one_frame);
}
TEST_F(BlockParserTest, IncrementalXiphLacing) {
RunIncrementalTest(xiph_lacing);
}
TEST_F(BlockParserTest, IncrementalFixedLacingOneFrame) {
RunIncrementalTest(fixed_lacing_one_frame);
}
TEST_F(BlockParserTest, IncrementalFixedLacing) {
RunIncrementalTest(fixed_lacing);
}
TEST_F(BlockParserTest, DefaultActionIsRead) {
SetReaderData(fixed_lacing_one_frame.data);
SetExpectations(fixed_lacing_one_frame, false, false);
ParseAndVerify();
ValidateBlock(fixed_lacing_one_frame, parser_.value());
}
TEST_F(BlockParserTest, IncrementalNoLacing) { RunIncrementalTest(no_lacing); }
class SimpleBlockParserTest
: public BasicBlockParserTest<SimpleBlockParser, Id::kSimpleBlock> {};
TEST_F(SimpleBlockParserTest, InvalidElementSize) { TestInvalidElementSize(); }
TEST_F(SimpleBlockParserTest, InvalidHeaderOnlyNoLacing) {
TestInvalidHeaderOnly(no_lacing);
}
TEST_F(SimpleBlockParserTest, InvalidHeaderOnlyFixedLacing) {
TestInvalidHeaderOnly(fixed_lacing);
}
TEST_F(SimpleBlockParserTest, InvalidFixedLaceSizes) {
TestInvalidFixedLaceSizes();
}
TEST_F(SimpleBlockParserTest, SimpleBlockSkip) {
TestSimpleBlockSkip(no_flags);
}
TEST_F(SimpleBlockParserTest, SimpleBlockNoFlags) { RunTest(no_flags); }
TEST_F(SimpleBlockParserTest, SimpleBlockFlags) { RunTest(simple_block_flags); }
TEST_F(SimpleBlockParserTest, EbmlLacingOneFrame) {
RunTest(ebml_lacing_one_frame);
}
TEST_F(SimpleBlockParserTest, EbmlLacing) { RunTest(ebml_lacing); }
TEST_F(SimpleBlockParserTest, XiphLacingOneFrame) {
RunTest(xiph_lacing_one_frame);
}
TEST_F(SimpleBlockParserTest, XiphLacing) { RunTest(xiph_lacing); }
TEST_F(SimpleBlockParserTest, FixedLacingOneFrame) {
RunTest(fixed_lacing_one_frame);
}
TEST_F(SimpleBlockParserTest, FixedLacing) { RunTest(fixed_lacing); }
TEST_F(SimpleBlockParserTest, NoLacing) { RunTest(no_lacing); }
TEST_F(BlockParserTest, SimpleBlockWithPositionAndHeaderSize) {
metadata_.position = 16;
metadata_.header_size = 4;
RunTest(no_lacing);
}
TEST_F(SimpleBlockParserTest, IncrementalSimpleBlockFlags) {
RunIncrementalTest(simple_block_flags);
}
TEST_F(SimpleBlockParserTest, IncrementalEbmlLacingOneFrame) {
RunIncrementalTest(ebml_lacing_one_frame);
}
TEST_F(SimpleBlockParserTest, IncrementalEbmlLacing) {
RunIncrementalTest(ebml_lacing);
}
TEST_F(SimpleBlockParserTest, IncrementalXiphLacingOneFrame) {
RunIncrementalTest(xiph_lacing_one_frame);
}
TEST_F(SimpleBlockParserTest, IncrementalXiphLacing) {
RunIncrementalTest(xiph_lacing);
}
TEST_F(SimpleBlockParserTest, IncrementalFixedLacingOneFrame) {
RunIncrementalTest(fixed_lacing_one_frame);
}
TEST_F(SimpleBlockParserTest, IncrementalFixedLacing) {
RunIncrementalTest(fixed_lacing);
}
TEST_F(SimpleBlockParserTest, IncrementalNoLacing) {
RunIncrementalTest(no_lacing);
}
TEST_F(SimpleBlockParserTest, DefaultActionIsRead) {
SetReaderData(fixed_lacing_one_frame.data);
SetExpectations(fixed_lacing_one_frame, false, false);
ParseAndVerify();
ValidateBlock(fixed_lacing_one_frame, parser_.value());
}
}