Skip to content

Commit

Permalink
Changing unit tests as per previous changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sr1990 committed Jun 12, 2020
1 parent 07e1e0d commit f522c01
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions packager/media/formats/mp2t/ts_segmenter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class MockTsWriter : public TsWriter {
// Create a bogus pmt writer, which we don't really care.
new VideoProgramMapTableWriter(kUnknownCodec))) {}

MOCK_METHOD1(CreateFileAndFlushBuffer, bool(const std::string& file_name));
MOCK_METHOD0(NewSegment, bool());
MOCK_METHOD0(SignalEncrypted, void());
MOCK_METHOD0(FinalizeSegment, bool());
Expand Down
14 changes: 14 additions & 0 deletions packager/media/formats/mp2t/ts_writer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ TEST_F(TsWriterTest, ClearH264Psi) {

TsWriter ts_writer(std::move(mock_pmt_writer));
EXPECT_TRUE(ts_writer.NewSegment());
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));

ASSERT_TRUE(ts_writer.FinalizeSegment());

std::vector<uint8_t> content;
Expand Down Expand Up @@ -193,6 +195,7 @@ TEST_F(TsWriterTest, ClearAacPmt) {

TsWriter ts_writer(std::move(mock_pmt_writer));
EXPECT_TRUE(ts_writer.NewSegment());
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));
ASSERT_TRUE(ts_writer.FinalizeSegment());

std::vector<uint8_t> content;
Expand All @@ -214,6 +217,7 @@ TEST_F(TsWriterTest, ClearLeadH264Pmt) {

TsWriter ts_writer(std::move(mock_pmt_writer));
EXPECT_TRUE(ts_writer.NewSegment());
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));
EXPECT_TRUE(ts_writer.FinalizeSegment());

std::vector<uint8_t> content;
Expand Down Expand Up @@ -246,11 +250,13 @@ TEST_F(TsWriterTest, EncryptedSegmentsH264Pmt) {

TsWriter ts_writer(std::move(mock_pmt_writer));
EXPECT_TRUE(ts_writer.NewSegment());
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));
EXPECT_TRUE(ts_writer.FinalizeSegment());

// Overwrite the file but as encrypted segment.
ts_writer.SignalEncrypted();
EXPECT_TRUE(ts_writer.NewSegment());
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));
EXPECT_TRUE(ts_writer.FinalizeSegment());

std::vector<uint8_t> content;
Expand All @@ -271,6 +277,7 @@ TEST_F(TsWriterTest, EncryptedSegmentPmtFailure) {

TsWriter ts_writer(std::move(mock_pmt_writer));
EXPECT_TRUE(ts_writer.NewSegment());
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));
EXPECT_TRUE(ts_writer.FinalizeSegment());

ts_writer.SignalEncrypted();
Expand All @@ -286,6 +293,7 @@ TEST_F(TsWriterTest, ClearLeadAacPmt) {

TsWriter ts_writer(std::move(mock_pmt_writer));
EXPECT_TRUE(ts_writer.NewSegment());
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));
ASSERT_TRUE(ts_writer.FinalizeSegment());

std::vector<uint8_t> content;
Expand All @@ -309,11 +317,13 @@ TEST_F(TsWriterTest, EncryptedSegmentsAacPmt) {

TsWriter ts_writer(std::move(mock_pmt_writer));
EXPECT_TRUE(ts_writer.NewSegment());
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));
EXPECT_TRUE(ts_writer.FinalizeSegment());

// Overwrite the file but as encrypted segment.
ts_writer.SignalEncrypted();
EXPECT_TRUE(ts_writer.NewSegment());
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));
EXPECT_TRUE(ts_writer.FinalizeSegment());

std::vector<uint8_t> content;
Expand Down Expand Up @@ -341,6 +351,7 @@ TEST_F(TsWriterTest, AddPesPacket) {
pes->mutable_data()->assign(kAnyData, kAnyData + arraysize(kAnyData));

EXPECT_TRUE(ts_writer.AddPesPacket(std::move(pes)));
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));
ASSERT_TRUE(ts_writer.FinalizeSegment());

std::vector<uint8_t> content;
Expand Down Expand Up @@ -401,6 +412,7 @@ TEST_F(TsWriterTest, BigPesPacket) {
*pes->mutable_data() = big_data;

EXPECT_TRUE(ts_writer.AddPesPacket(std::move(pes)));
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));
ASSERT_TRUE(ts_writer.FinalizeSegment());

std::vector<uint8_t> content;
Expand Down Expand Up @@ -435,6 +447,7 @@ TEST_F(TsWriterTest, PesPtsZeroNoDts) {
pes->mutable_data()->assign(kAnyData, kAnyData + arraysize(kAnyData));

EXPECT_TRUE(ts_writer.AddPesPacket(std::move(pes)));
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));
ASSERT_TRUE(ts_writer.FinalizeSegment());

std::vector<uint8_t> content;
Expand Down Expand Up @@ -496,6 +509,7 @@ TEST_F(TsWriterTest, TsPacketPayload183Bytes) {
*pes->mutable_data() = pes_payload;

EXPECT_TRUE(ts_writer.AddPesPacket(std::move(pes)));
EXPECT_TRUE(ts_writer.CreateFileAndFlushBuffer(test_file_name_));
ASSERT_TRUE(ts_writer.FinalizeSegment());

const uint8_t kExpectedOutputPrefix[] = {
Expand Down

0 comments on commit f522c01

Please sign in to comment.