Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: media/formats/mp4/box_reader_unittest.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/formats/mp4/box_reader_unittest.cc
diff --git a/media/formats/mp4/box_reader_unittest.cc b/media/formats/mp4/box_reader_unittest.cc
index 6f08763989b607b96bf0874921e24ea4f6829cc8..fdcec611dc3ab3975de403d29cd46edcb4cef157 100644
--- a/media/formats/mp4/box_reader_unittest.cc
+++ b/media/formats/mp4/box_reader_unittest.cc
@@ -4,7 +4,6 @@
#include <string.h>
-#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "media/base/mock_media_log.h"
@@ -20,21 +19,19 @@ using ::testing::StrictMock;
namespace media {
namespace mp4 {
-static const uint8 kSkipBox[] = {
- // Top-level test box containing three children
- 0x00, 0x00, 0x00, 0x40, 's', 'k', 'i', 'p',
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0xf9, 0x0a, 0x0b, 0x0c, 0xfd, 0x0e, 0x0f, 0x10,
- // Ordinary (8-byte header) child box
- 0x00, 0x00, 0x00, 0x0c, 'p', 's', 's', 'h', 0xde, 0xad, 0xbe, 0xef,
- // Extended-size header child box
- 0x00, 0x00, 0x00, 0x01, 'p', 's', 's', 'h',
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14,
- 0xfa, 0xce, 0xca, 0xfe,
- // Empty free box
- 0x00, 0x00, 0x00, 0x08, 'f', 'r', 'e', 'e',
- // Trailing garbage
- 0x00 };
+static const uint8_t kSkipBox[] = {
+ // Top-level test box containing three children
+ 0x00, 0x00, 0x00, 0x40, 's', 'k', 'i', 'p', 0x01, 0x02, 0x03, 0x04, 0x05,
+ 0x06, 0x07, 0x08, 0xf9, 0x0a, 0x0b, 0x0c, 0xfd, 0x0e, 0x0f, 0x10,
+ // Ordinary (8-byte header) child box
+ 0x00, 0x00, 0x00, 0x0c, 'p', 's', 's', 'h', 0xde, 0xad, 0xbe, 0xef,
+ // Extended-size header child box
+ 0x00, 0x00, 0x00, 0x01, 'p', 's', 's', 'h', 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x14, 0xfa, 0xce, 0xca, 0xfe,
+ // Empty free box
+ 0x00, 0x00, 0x00, 0x08, 'f', 'r', 'e', 'e',
+ // Trailing garbage
+ 0x00};
struct FreeBox : Box {
bool Parse(BoxReader* reader) override {
@@ -44,7 +41,7 @@ struct FreeBox : Box {
};
struct PsshBox : Box {
- uint32 val;
+ uint32_t val;
bool Parse(BoxReader* reader) override {
return reader->Read4(&val);
@@ -53,10 +50,10 @@ struct PsshBox : Box {
};
struct SkipBox : Box {
- uint8 a, b;
- uint16 c;
- int32 d;
- int64 e;
+ uint8_t a, b;
+ uint16_t c;
+ int32_t d;
+ int64_t e;
std::vector<PsshBox> kids;
FreeBox mpty;
@@ -86,12 +83,12 @@ class BoxReaderTest : public testing::Test {
BoxReaderTest() : media_log_(new StrictMock<MockMediaLog>()) {}
protected:
- std::vector<uint8> GetBuf() {
- return std::vector<uint8>(kSkipBox, kSkipBox + sizeof(kSkipBox));
+ std::vector<uint8_t> GetBuf() {
+ return std::vector<uint8_t>(kSkipBox, kSkipBox + sizeof(kSkipBox));
}
- void TestTopLevelBox(const uint8* data, int size, uint32 fourCC) {
- std::vector<uint8> buf(data, data + size);
+ void TestTopLevelBox(const uint8_t* data, int size, uint32_t fourCC) {
+ std::vector<uint8_t> buf(data, data + size);
bool err;
scoped_ptr<BoxReader> reader(
@@ -100,14 +97,14 @@ class BoxReaderTest : public testing::Test {
EXPECT_FALSE(err);
EXPECT_TRUE(reader);
EXPECT_EQ(fourCC, reader->type());
- EXPECT_EQ(reader->size(), static_cast<uint64>(size));
+ EXPECT_EQ(reader->size(), static_cast<uint64_t>(size));
}
scoped_refptr<StrictMock<MockMediaLog>> media_log_;
};
TEST_F(BoxReaderTest, ExpectedOperationTest) {
- std::vector<uint8> buf = GetBuf();
+ std::vector<uint8_t> buf = GetBuf();
bool err;
scoped_ptr<BoxReader> reader(
BoxReader::ReadTopLevelBox(&buf[0], buf.size(), media_log_, &err));
@@ -121,19 +118,19 @@ TEST_F(BoxReaderTest, ExpectedOperationTest) {
EXPECT_EQ(0x05, box.a);
EXPECT_EQ(0x06, box.b);
EXPECT_EQ(0x0708, box.c);
- EXPECT_EQ(static_cast<int32>(0xf90a0b0c), box.d);
- EXPECT_EQ(static_cast<int32>(0xfd0e0f10), box.e);
+ EXPECT_EQ(static_cast<int32_t>(0xf90a0b0c), box.d);
+ EXPECT_EQ(static_cast<int32_t>(0xfd0e0f10), box.e);
EXPECT_EQ(2u, box.kids.size());
EXPECT_EQ(0xdeadbeef, box.kids[0].val);
EXPECT_EQ(0xfacecafe, box.kids[1].val);
// Accounting for the extra byte outside of the box above
- EXPECT_EQ(buf.size(), static_cast<uint64>(reader->size() + 1));
+ EXPECT_EQ(buf.size(), static_cast<uint64_t>(reader->size() + 1));
}
TEST_F(BoxReaderTest, OuterTooShortTest) {
- std::vector<uint8> buf = GetBuf();
+ std::vector<uint8_t> buf = GetBuf();
bool err;
// Create a soft failure by truncating the outer box.
@@ -145,7 +142,7 @@ TEST_F(BoxReaderTest, OuterTooShortTest) {
}
TEST_F(BoxReaderTest, InnerTooLongTest) {
- std::vector<uint8> buf = GetBuf();
+ std::vector<uint8_t> buf = GetBuf();
bool err;
// Make an inner box too big for its outer box.
@@ -158,7 +155,7 @@ TEST_F(BoxReaderTest, InnerTooLongTest) {
}
TEST_F(BoxReaderTest, WrongFourCCTest) {
- std::vector<uint8> buf = GetBuf();
+ std::vector<uint8_t> buf = GetBuf();
bool err;
// Set an unrecognized top-level FourCC.
@@ -173,7 +170,7 @@ TEST_F(BoxReaderTest, WrongFourCCTest) {
}
TEST_F(BoxReaderTest, ScanChildrenTest) {
- std::vector<uint8> buf = GetBuf();
+ std::vector<uint8_t> buf = GetBuf();
bool err;
scoped_ptr<BoxReader> reader(
BoxReader::ReadTopLevelBox(&buf[0], buf.size(), media_log_, &err));
@@ -195,7 +192,7 @@ TEST_F(BoxReaderTest, ScanChildrenTest) {
}
TEST_F(BoxReaderTest, ReadAllChildrenTest) {
- std::vector<uint8> buf = GetBuf();
+ std::vector<uint8_t> buf = GetBuf();
// Modify buffer to exclude its last 'free' box
buf[3] = 0x38;
bool err;
@@ -209,36 +206,35 @@ TEST_F(BoxReaderTest, ReadAllChildrenTest) {
}
TEST_F(BoxReaderTest, SkippingBloc) {
- static const uint8 kData[] = {
- 0x00, 0x00, 0x00, 0x09, 'b', 'l', 'o', 'c', 0x00
- };
+ static const uint8_t kData[] = {0x00, 0x00, 0x00, 0x09, 'b',
+ 'l', 'o', 'c', 0x00};
TestTopLevelBox(kData, sizeof(kData), FOURCC_BLOC);
}
TEST_F(BoxReaderTest, SkippingEmsg) {
- static const uint8 kData[] = {
- 0x00, 0x00, 0x00, 0x24, 'e', 'm', 's', 'g',
- 0x00, // version = 0
- 0x00, 0x00, 0x00, // flags = 0
- 0x61, 0x00, // scheme_id_uri = "a"
- 0x61, 0x00, // value = "a"
- 0x00, 0x00, 0x00, 0x01, // timescale = 1
- 0x00, 0x00, 0x00, 0x02, // presentation_time_delta = 2
- 0x00, 0x00, 0x00, 0x03, // event_duration = 3
- 0x00, 0x00, 0x00, 0x04, // id = 4
- 0x05, 0x06, 0x07, 0x08, // message_data[4] = 0x05060708
+ static const uint8_t kData[] = {
+ 0x00, 0x00, 0x00, 0x24, 'e', 'm', 's', 'g',
+ 0x00, // version = 0
+ 0x00, 0x00, 0x00, // flags = 0
+ 0x61, 0x00, // scheme_id_uri = "a"
+ 0x61, 0x00, // value = "a"
+ 0x00, 0x00, 0x00, 0x01, // timescale = 1
+ 0x00, 0x00, 0x00, 0x02, // presentation_time_delta = 2
+ 0x00, 0x00, 0x00, 0x03, // event_duration = 3
+ 0x00, 0x00, 0x00, 0x04, // id = 4
+ 0x05, 0x06, 0x07, 0x08, // message_data[4] = 0x05060708
};
TestTopLevelBox(kData, sizeof(kData), FOURCC_EMSG);
}
TEST_F(BoxReaderTest, SkippingUuid) {
- static const uint8 kData[] = {
- 0x00, 0x00, 0x00, 0x19, 'u', 'u', 'i', 'd',
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, // usertype
- 0x00,
+ static const uint8_t kData[] = {
+ 0x00, 0x00, 0x00, 0x19, 'u', 'u', 'i', 'd',
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, // usertype
+ 0x00,
};
TestTopLevelBox(kData, sizeof(kData), FOURCC_UUID);
@@ -251,7 +247,7 @@ TEST_F(BoxReaderTest, NestedBoxWithHugeSize) {
// The nested box ('junk') has a large size that was chosen to catch
// integer overflows. The nested box should not specify more than the
// number of remaining bytes in the enclosing box.
- static const uint8 kData[] = {
+ static const uint8_t kData[] = {
0x00, 0x00, 0x00, 0x24, 'e', 'm', 's', 'g', // outer box
0x7f, 0xff, 0xff, 0xff, 'j', 'u', 'n', 'k', // nested box
0x00, 0x01, 0x00, 0xff, 0xff, 0x00, 0x3b, 0x03, // random data for rest
@@ -274,9 +270,9 @@ TEST_F(BoxReaderTest, ScanChildrenWithInvalidChild) {
// The sample specifies a large number of EditListEntry's, but only 1 is
// actually included in the box. This test verifies that the code checks
// properly that the buffer contains the specified number of EditListEntry's
- // (does not cause an int32 overflow when checking that the bytes are
+ // (does not cause an int32_t overflow when checking that the bytes are
// available, and does not read past the end of the buffer).
- static const uint8 kData[] = {
+ static const uint8_t kData[] = {
0x00, 0x00, 0x00, 0x2c, 'e', 'm', 's', 'g', // outer box
0x00, 0x00, 0x00, 0x24, 'e', 'l', 's', 't', // nested box
0x01, 0x00, 0x00, 0x00, // version = 1, flags = 0
@@ -305,9 +301,9 @@ TEST_F(BoxReaderTest, ReadAllChildrenWithInvalidChild) {
// The nested 'trun' box is used as it includes a count of the number
// of samples. The data specifies a large number of samples, but only 1
// is actually included in the box. Verifying that the large count does not
- // cause an int32 overflow which would allow parsing of TrackFragmentRun
+ // cause an int32_t overflow which would allow parsing of TrackFragmentRun
// to read past the end of the buffer.
- static const uint8 kData[] = {
+ static const uint8_t kData[] = {
0x00, 0x00, 0x00, 0x28, 'e', 'm', 's', 'g', // outer box
0x00, 0x00, 0x00, 0x20, 't', 'r', 'u', 'n', // nested box
0x00, 0x00, 0x0f, 0x00, // version = 0, flags = samples present

Powered by Google App Engine
This is Rietveld 408576698