Replacing NULL with nullptr in core/
[ Merge of http://go/wvgerrit/84647 ] [ Merge of http://go/wvgerrit/84648 ] Replacing most instances of C's NULL with C++'s nullptr. Also changed how a NULL check is performed on smart pointers. They provided an implicit boolean operator for null checks, meaning the underlying pointer does not need to be compared directly (as it was in some places before). Note that clang-format has performed additional changes to some of the test files that have not yet been formatted. Bug: 120602075 Test: Linux and Android unittests Change-Id: I06ddebe34b0ea6dfecedb5527e7e808e32f5269a
This commit is contained in:
@@ -176,16 +176,16 @@ TEST_F(BufferReaderTest, InitializeGoodDataAndNoSize) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, InitializeNoDataNoSize) {
|
||||
BufferReader reader(NULL, 0);
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
BufferReader reader(nullptr, 0);
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, InitializeNoDataBadSize) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
// Buffer reader should default to a size of 0 when given
|
||||
// NULL data to ensure no reading of bad data
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, HasBytesWithBytes) {
|
||||
@@ -219,12 +219,12 @@ TEST_F(BufferReaderTest, HasBytesWithEmptyBuffer) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, HasBytesWithNullBuffer) {
|
||||
BufferReader reader(NULL, 8);
|
||||
BufferReader reader(nullptr, 8);
|
||||
|
||||
ASSERT_FALSE(reader.HasBytes(1));
|
||||
ASSERT_TRUE(reader.HasBytes(0));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, HasBytesAfterAllRead) {
|
||||
@@ -266,12 +266,12 @@ TEST_F(BufferReaderTest, Read1WithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read1WithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
uint8_t read;
|
||||
ASSERT_FALSE(reader.Read1(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read1WithNullReturn) {
|
||||
@@ -280,7 +280,7 @@ TEST_F(BufferReaderTest, Read1WithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read1(NULL));
|
||||
ASSERT_FALSE(reader.Read1(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -306,12 +306,12 @@ TEST_F(BufferReaderTest, Read2WithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read2WithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
uint16_t read;
|
||||
ASSERT_FALSE(reader.Read2(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read2WithNullReturn) {
|
||||
@@ -320,7 +320,7 @@ TEST_F(BufferReaderTest, Read2WithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read2(NULL));
|
||||
ASSERT_FALSE(reader.Read2(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -354,12 +354,12 @@ TEST_F(BufferReaderTest, Read2sWithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read2sWithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
int16_t read;
|
||||
ASSERT_FALSE(reader.Read2s(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read2sWithNullReturn) {
|
||||
@@ -368,7 +368,7 @@ TEST_F(BufferReaderTest, Read2sWithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read2s(NULL));
|
||||
ASSERT_FALSE(reader.Read2s(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -397,12 +397,12 @@ TEST_F(BufferReaderTest, Read4WithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4WithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
uint32_t read;
|
||||
ASSERT_FALSE(reader.Read4(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4WithNullReturn) {
|
||||
@@ -411,7 +411,7 @@ TEST_F(BufferReaderTest, Read4WithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read4(NULL));
|
||||
ASSERT_FALSE(reader.Read4(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -447,12 +447,12 @@ TEST_F(BufferReaderTest, Read4sWithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4sWithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
int32_t read;
|
||||
ASSERT_FALSE(reader.Read4s(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4sWithNullReturn) {
|
||||
@@ -461,7 +461,7 @@ TEST_F(BufferReaderTest, Read4sWithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read4s(NULL));
|
||||
ASSERT_FALSE(reader.Read4s(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -490,12 +490,12 @@ TEST_F(BufferReaderTest, Read8WithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read8WithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
uint64_t read;
|
||||
ASSERT_FALSE(reader.Read8(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read8WithNullReturn) {
|
||||
@@ -504,7 +504,7 @@ TEST_F(BufferReaderTest, Read8WithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read8(NULL));
|
||||
ASSERT_FALSE(reader.Read8(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -540,12 +540,12 @@ TEST_F(BufferReaderTest, Read8sWithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read8sWithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
int64_t read;
|
||||
ASSERT_FALSE(reader.Read8s(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read8sWithNullReturn) {
|
||||
@@ -554,7 +554,7 @@ TEST_F(BufferReaderTest, Read8sWithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read8s(NULL));
|
||||
ASSERT_FALSE(reader.Read8s(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -578,12 +578,12 @@ TEST_F(BufferReaderTest, ReadString) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, ReadStringNullSource) {
|
||||
BufferReader reader(NULL, 5);
|
||||
BufferReader reader(nullptr, 5);
|
||||
|
||||
std::string read;
|
||||
ASSERT_FALSE(reader.ReadString(&read, 5));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, ReadStringNullReturn) {
|
||||
@@ -592,7 +592,7 @@ TEST_F(BufferReaderTest, ReadStringNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.ReadString(NULL, 5));
|
||||
ASSERT_FALSE(reader.ReadString(nullptr, 5));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -662,13 +662,13 @@ TEST_F(BufferReaderTest, ReadVectorTooLarge) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, ReadVectorNullSource) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
std::vector<uint8_t> read;
|
||||
ASSERT_FALSE(reader.ReadVec(&read, 4));
|
||||
|
||||
ASSERT_TRUE(0 == read.size());
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, ReadVectorNullReturn) {
|
||||
@@ -677,7 +677,7 @@ TEST_F(BufferReaderTest, ReadVectorNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.ReadVec(NULL, 4));
|
||||
ASSERT_FALSE(reader.ReadVec(nullptr, 4));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -712,12 +712,12 @@ TEST_F(BufferReaderTest, Read4Into82Bytes) {
|
||||
TEST_F(BufferReaderTest, Read4Into8Zero) { ASSERT_TRUE(CheckRead4Into8(0)); }
|
||||
|
||||
TEST_F(BufferReaderTest, Read4Into8NullSource) {
|
||||
BufferReader reader(NULL, 4);
|
||||
BufferReader reader(nullptr, 4);
|
||||
|
||||
uint64_t read;
|
||||
ASSERT_FALSE(reader.Read4Into8(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4Into8TooLittleData) {
|
||||
@@ -739,7 +739,7 @@ TEST_F(BufferReaderTest, Read4Into8NoReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read4Into8(NULL));
|
||||
ASSERT_FALSE(reader.Read4Into8(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -770,12 +770,12 @@ TEST_F(BufferReaderTest, Read4sInto8sNegative) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4sInto8sNullSource) {
|
||||
BufferReader reader(NULL, 4);
|
||||
BufferReader reader(nullptr, 4);
|
||||
|
||||
int64_t read;
|
||||
ASSERT_FALSE(reader.Read4sInto8s(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4sInto8sTooLittleData) {
|
||||
@@ -797,7 +797,7 @@ TEST_F(BufferReaderTest, Read4sInto8sNoReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read4sInto8s(NULL));
|
||||
ASSERT_FALSE(reader.Read4sInto8s(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
|
||||
@@ -61,11 +61,11 @@ class WvCdmEnginePreProvTest : public WvCdmTestBase {
|
||||
}
|
||||
|
||||
virtual void OpenSession() {
|
||||
CdmResponseType status =
|
||||
cdm_engine_.OpenSession(config_.key_system(), NULL, NULL, &session_id_);
|
||||
CdmResponseType status = cdm_engine_.OpenSession(
|
||||
config_.key_system(), nullptr, nullptr, &session_id_);
|
||||
if (status == NEED_PROVISIONING) {
|
||||
Provision();
|
||||
status = cdm_engine_.OpenSession(config_.key_system(), NULL, NULL,
|
||||
status = cdm_engine_.OpenSession(config_.key_system(), nullptr, nullptr,
|
||||
&session_id_);
|
||||
}
|
||||
ASSERT_EQ(status, NO_ERROR);
|
||||
|
||||
@@ -111,7 +111,7 @@ const std::string kWrappedKey = a2bs_hex(
|
||||
|
||||
class MockDeviceFiles : public DeviceFiles {
|
||||
public:
|
||||
MockDeviceFiles() : DeviceFiles(NULL) {}
|
||||
MockDeviceFiles() : DeviceFiles(nullptr) {}
|
||||
|
||||
MOCK_METHOD1(Init, bool(CdmSecurityLevel));
|
||||
MOCK_METHOD4(RetrieveCertificate, bool(std::string*, std::string*,
|
||||
@@ -154,7 +154,7 @@ class MockCryptoSession : public TestCryptoSession {
|
||||
class MockPolicyEngine : public PolicyEngine {
|
||||
public:
|
||||
MockPolicyEngine(CryptoSession* crypto_session)
|
||||
: PolicyEngine("mock_session_id", NULL, crypto_session) {}
|
||||
: PolicyEngine("mock_session_id", nullptr, crypto_session) {}
|
||||
|
||||
// Leaving a place-holder for when PolicyEngine methods need to be mocked
|
||||
};
|
||||
@@ -177,7 +177,7 @@ class CdmSessionTest : public WvCdmTestBase {
|
||||
void SetUp() override {
|
||||
WvCdmTestBase::SetUp();
|
||||
metrics_.reset(new metrics::SessionMetrics);
|
||||
cdm_session_.reset(new CdmSession(NULL, metrics_));
|
||||
cdm_session_.reset(new CdmSession(nullptr, metrics_));
|
||||
// Inject testing mocks.
|
||||
license_parser_ = new MockCdmLicense(cdm_session_->session_id());
|
||||
cdm_session_->set_license_parser(license_parser_);
|
||||
@@ -230,7 +230,7 @@ TEST_F(CdmSessionTest, InitWithBuiltInCertificate) {
|
||||
Eq(policy_engine_)))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(NULL));
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, InitWithCertificate) {
|
||||
@@ -258,7 +258,7 @@ TEST_F(CdmSessionTest, InitWithCertificate) {
|
||||
Eq(policy_engine_)))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(NULL));
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, ReInitFail) {
|
||||
@@ -285,15 +285,15 @@ TEST_F(CdmSessionTest, ReInitFail) {
|
||||
Eq(kEmptyString), Eq(crypto_session_), Eq(policy_engine_)))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(NULL));
|
||||
ASSERT_NE(NO_ERROR, cdm_session_->Init(NULL));
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
ASSERT_NE(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, InitFailCryptoError) {
|
||||
EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault)))
|
||||
.WillOnce(Return(UNKNOWN_ERROR));
|
||||
|
||||
ASSERT_EQ(UNKNOWN_ERROR, cdm_session_->Init(NULL));
|
||||
ASSERT_EQ(UNKNOWN_ERROR, cdm_session_->Init(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, InitNeedsProvisioning) {
|
||||
@@ -312,7 +312,7 @@ TEST_F(CdmSessionTest, InitNeedsProvisioning) {
|
||||
NotNull(), _))
|
||||
.WillOnce(Return(false));
|
||||
|
||||
ASSERT_EQ(NEED_PROVISIONING, cdm_session_->Init(NULL));
|
||||
ASSERT_EQ(NEED_PROVISIONING, cdm_session_->Init(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, UpdateUsageEntry) {
|
||||
@@ -352,7 +352,7 @@ TEST_F(CdmSessionTest, UpdateUsageEntry) {
|
||||
EXPECT_CALL(usage_table_header_, UpdateEntry(NotNull(), NotNull()))
|
||||
.WillRepeatedly(Return(NO_ERROR));
|
||||
|
||||
EXPECT_EQ(NO_ERROR, cdm_session_->Init(NULL));
|
||||
EXPECT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
EXPECT_EQ(kUsageEntrySupport, cdm_session_->get_usage_support_type())
|
||||
<< "Usage support type: " << cdm_session_->get_usage_support_type();
|
||||
EXPECT_EQ(NO_ERROR, cdm_session_->UpdateUsageEntryInformation());
|
||||
|
||||
@@ -2637,7 +2637,7 @@ TEST_F(DeviceFilesUsageInfoTest, ListNullParam) {
|
||||
|
||||
DeviceFiles device_files(&file_system);
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
EXPECT_FALSE(device_files.ListUsageInfoFiles(NULL));
|
||||
EXPECT_FALSE(device_files.ListUsageInfoFiles(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(DeviceFilesUsageInfoTest, ListIdsNull) {
|
||||
@@ -2647,7 +2647,7 @@ TEST_F(DeviceFilesUsageInfoTest, ListIdsNull) {
|
||||
|
||||
DeviceFiles device_files(&file_system);
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
EXPECT_FALSE(device_files.ListUsageIds(app_id, NULL, NULL));
|
||||
EXPECT_FALSE(device_files.ListUsageIds(app_id, nullptr, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(DeviceFilesUsageInfoTest, ListUsageIds) {
|
||||
@@ -2873,7 +2873,7 @@ TEST_P(DeviceFilesUsageInfoTest, ListKeySetIds) {
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
|
||||
std::vector<std::string> key_set_ids;
|
||||
EXPECT_TRUE(device_files.ListUsageIds(app_id, &key_set_ids, NULL));
|
||||
EXPECT_TRUE(device_files.ListUsageIds(app_id, &key_set_ids, nullptr));
|
||||
|
||||
if (index >= 0) {
|
||||
for (size_t i = 0; i < key_set_ids.size(); ++i) {
|
||||
@@ -2925,7 +2925,7 @@ TEST_P(DeviceFilesUsageInfoTest, ListProviderSessionTokenIds) {
|
||||
|
||||
std::vector<std::string> provider_session_tokens;
|
||||
EXPECT_TRUE(
|
||||
device_files.ListUsageIds(app_id, NULL, &provider_session_tokens));
|
||||
device_files.ListUsageIds(app_id, nullptr, &provider_session_tokens));
|
||||
|
||||
if (index >= 0) {
|
||||
for (size_t i = 0; i < provider_session_tokens.size(); ++i) {
|
||||
|
||||
@@ -105,15 +105,15 @@ bool SocketWait(int fd, bool for_read, int timeout_in_ms) {
|
||||
tv.tv_sec = timeout_in_ms / 1000;
|
||||
tv.tv_usec = (timeout_in_ms % 1000) * 1000;
|
||||
|
||||
fd_set* read_fds = NULL;
|
||||
fd_set* write_fds = NULL;
|
||||
fd_set* read_fds = nullptr;
|
||||
fd_set* write_fds = nullptr;
|
||||
if (for_read) {
|
||||
read_fds = &fds;
|
||||
} else {
|
||||
write_fds = &fds;
|
||||
}
|
||||
|
||||
int ret = select(fd + 1, read_fds, write_fds, NULL, &tv);
|
||||
int ret = select(fd + 1, read_fds, write_fds, nullptr, &tv);
|
||||
if (ret == 0) {
|
||||
LOGE("socket timed out");
|
||||
return false;
|
||||
@@ -209,7 +209,7 @@ bool HttpSocket::ParseUrl(const std::string& url, std::string* scheme,
|
||||
}
|
||||
|
||||
HttpSocket::HttpSocket(const std::string& url)
|
||||
: socket_fd_(-1), ssl_(NULL), ssl_ctx_(NULL) {
|
||||
: socket_fd_(-1), ssl_(nullptr), ssl_ctx_(nullptr) {
|
||||
valid_url_ = ParseUrl(url, &scheme_, &secure_connect_, &domain_name_, &port_,
|
||||
&resource_path_);
|
||||
SSL_library_init();
|
||||
@@ -228,11 +228,11 @@ void HttpSocket::CloseSocket() {
|
||||
}
|
||||
if (ssl_) {
|
||||
SSL_free(ssl_);
|
||||
ssl_ = NULL;
|
||||
ssl_ = nullptr;
|
||||
}
|
||||
if (ssl_ctx_) {
|
||||
SSL_CTX_free(ssl_ctx_);
|
||||
ssl_ctx_ = NULL;
|
||||
ssl_ctx_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ bool HttpSocket::Connect(int timeout_in_ms) {
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_NUMERICSERV | AI_ADDRCONFIG;
|
||||
|
||||
struct addrinfo* addr_info = NULL;
|
||||
struct addrinfo* addr_info = nullptr;
|
||||
int ret = getaddrinfo(domain_name_.c_str(), port_.c_str(), &hints,
|
||||
&addr_info);
|
||||
if (ret != 0) {
|
||||
@@ -413,7 +413,7 @@ int HttpSocket::Read(char* data, int len, int timeout_in_ms) {
|
||||
if (ssl_error == SSL_ERROR_SYSCALL) {
|
||||
LOGE(" errno = %d = %s", GetError(), GetErrorString());
|
||||
}
|
||||
ERR_print_errors_cb(LogBoringSslError, NULL);
|
||||
ERR_print_errors_cb(LogBoringSslError, nullptr);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -108,62 +108,62 @@ struct ParseUrlTests {
|
||||
|
||||
ParseUrlTests parse_url_tests[] = {
|
||||
{
|
||||
"https://code.google.com/p/googletest/wiki/Primer", // url
|
||||
"https", // scheme
|
||||
true, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"443", // port
|
||||
"/p/googletest/wiki/Primer", // path
|
||||
"https://code.google.com/p/googletest/wiki/Primer", // url
|
||||
"https", // scheme
|
||||
true, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"443", // port
|
||||
"/p/googletest/wiki/Primer", // path
|
||||
},
|
||||
{
|
||||
"http://code.google.com/p/googletest/wiki/Primer/", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"80", // port
|
||||
"/p/googletest/wiki/Primer/", // path
|
||||
"http://code.google.com/p/googletest/wiki/Primer/", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"80", // port
|
||||
"/p/googletest/wiki/Primer/", // path
|
||||
},
|
||||
{
|
||||
"http://code.google.com/", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"80", // port
|
||||
"/", // path
|
||||
"http://code.google.com/", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"80", // port
|
||||
"/", // path
|
||||
},
|
||||
{
|
||||
"http://code.google.com", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"80", // port
|
||||
"/", // path
|
||||
"http://code.google.com", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"80", // port
|
||||
"/", // path
|
||||
},
|
||||
{
|
||||
"http://10.11.12.13:8888/drm", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"10.11.12.13", // domain_name
|
||||
"8888", // port
|
||||
"/drm", // path
|
||||
"http://10.11.12.13:8888/drm", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"10.11.12.13", // domain_name
|
||||
"8888", // port
|
||||
"/drm", // path
|
||||
},
|
||||
{
|
||||
"http://10.11.12.13:8888", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"10.11.12.13", // domain_name
|
||||
"8888", // port
|
||||
"/", // path
|
||||
"http://10.11.12.13:8888", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"10.11.12.13", // domain_name
|
||||
"8888", // port
|
||||
"/", // path
|
||||
},
|
||||
{
|
||||
"https://10.11.12.13:8888", // url
|
||||
"https", // scheme
|
||||
true, // secure_connect
|
||||
"10.11.12.13", // domain_name
|
||||
"8888", // port
|
||||
"/", // path
|
||||
"https://10.11.12.13:8888", // url
|
||||
"https", // scheme
|
||||
true, // secure_connect
|
||||
"10.11.12.13", // domain_name
|
||||
"8888", // port
|
||||
"/", // path
|
||||
},
|
||||
{NULL, NULL, false, NULL, 0, NULL} // list terminator
|
||||
{nullptr, nullptr, false, nullptr, 0, nullptr} // list terminator
|
||||
};
|
||||
|
||||
TEST_F(HttpSocketTest, ParseUrlTest) {
|
||||
@@ -172,9 +172,9 @@ TEST_F(HttpSocketTest, ParseUrlTest) {
|
||||
std::string domain_name;
|
||||
std::string port;
|
||||
std::string path;
|
||||
ParseUrlTests* test = NULL;
|
||||
ParseUrlTests* test = nullptr;
|
||||
|
||||
for (test = &parse_url_tests[0]; test->url != NULL; ++test) {
|
||||
for (test = &parse_url_tests[0]; test->url != nullptr; ++test) {
|
||||
bool ok = HttpSocket::ParseUrl(test->url, &scheme, &secure_connect,
|
||||
&domain_name, &port, &path);
|
||||
EXPECT_TRUE(ok);
|
||||
|
||||
@@ -107,10 +107,11 @@ class LicenseKeysTest : public ::testing::Test {
|
||||
virtual void AddContentKey(
|
||||
const KeyId& key_id, bool set_level = false,
|
||||
KeyContainer::SecurityLevel level = KeyContainer::SW_SECURE_CRYPTO,
|
||||
bool set_hdcp = false, KeyContainer::OutputProtection::HDCP hdcp_value =
|
||||
bool set_hdcp = false,
|
||||
KeyContainer::OutputProtection::HDCP hdcp_value =
|
||||
KeyContainer::OutputProtection::HDCP_NONE,
|
||||
bool set_constraints = false,
|
||||
std::vector<VideoResolutionConstraint>* constraints = NULL) {
|
||||
std::vector<VideoResolutionConstraint>* constraints = nullptr) {
|
||||
KeyContainer* key = license_.add_key();
|
||||
key->set_type(KeyContainer::CONTENT);
|
||||
if (set_level) {
|
||||
@@ -141,7 +142,7 @@ class LicenseKeysTest : public ::testing::Test {
|
||||
KeyContainer::OutputProtection::HDCP hdcp_value =
|
||||
KeyContainer::OutputProtection::HDCP_NONE,
|
||||
bool set_constraints = false,
|
||||
std::vector<VideoResolutionConstraint>* constraints = NULL) {
|
||||
std::vector<VideoResolutionConstraint>* constraints = nullptr) {
|
||||
AddContentKey(key_id, set_level, level, set_hdcp, hdcp_value,
|
||||
set_constraints, constraints);
|
||||
license_.mutable_key(license_.key_size() - 1)
|
||||
|
||||
@@ -155,7 +155,7 @@ class MockCryptoSession : public TestCryptoSession {
|
||||
class MockPolicyEngine : public PolicyEngine {
|
||||
public:
|
||||
MockPolicyEngine(CryptoSession* crypto)
|
||||
: PolicyEngine("mock_session_id", NULL, crypto) {}
|
||||
: PolicyEngine("mock_session_id", nullptr, crypto) {}
|
||||
MOCK_METHOD1(SetEntitledLicenseKeys,
|
||||
void(const std::vector<video_widevine::WidevinePsshData_EntitledKey>&));
|
||||
};
|
||||
@@ -234,7 +234,7 @@ class CdmLicenseTest : public WvCdmTestBase {
|
||||
|
||||
virtual void CreateCdmLicense() {
|
||||
cdm_license_ = new CdmLicenseTestPeer(kCdmSessionId, clock_);
|
||||
clock_ = NULL;
|
||||
clock_ = nullptr;
|
||||
}
|
||||
|
||||
CdmLicenseTestPeer* cdm_license_;
|
||||
@@ -265,7 +265,7 @@ TEST_F(CdmLicenseTest, InitFail_EmptyToken) {
|
||||
TEST_F(CdmLicenseTest, InitFail_CryptoSessionNull) {
|
||||
CreateCdmLicense();
|
||||
EXPECT_FALSE(cdm_license_->Init(kToken, kClientTokenDrmCert, "", false,
|
||||
kEmptyServiceCertificate, NULL,
|
||||
kEmptyServiceCertificate, nullptr,
|
||||
policy_engine_));
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ TEST_F(CdmLicenseTest, InitFail_PolicyEngineNull) {
|
||||
CreateCdmLicense();
|
||||
EXPECT_FALSE(cdm_license_->Init(kToken, kClientTokenDrmCert, "", false,
|
||||
kEmptyServiceCertificate, crypto_session_,
|
||||
NULL));
|
||||
nullptr));
|
||||
}
|
||||
|
||||
TEST_F(CdmLicenseTest, InitWithEmptyServiceCert) {
|
||||
|
||||
@@ -1974,7 +1974,8 @@ class PolicyEngineQueryTest : public PolicyEngineTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
PolicyEngineTest::SetUp();
|
||||
policy_engine_.reset(new PolicyEngine(kSessionId, NULL, &crypto_session_));
|
||||
policy_engine_.reset(
|
||||
new PolicyEngine(kSessionId, nullptr, &crypto_session_));
|
||||
InjectMockClock();
|
||||
|
||||
// Use a STREAMING license policy.
|
||||
|
||||
@@ -330,12 +330,12 @@ void WvCdmTestBase::EnsureProvisioned() {
|
||||
FileSystem file_system;
|
||||
CdmEngine cdm_engine(&file_system,
|
||||
std::shared_ptr<EngineMetrics>(new EngineMetrics));
|
||||
CdmResponseType status =
|
||||
cdm_engine.OpenSession(config_.key_system(), NULL, NULL, &session_id);
|
||||
CdmResponseType status = cdm_engine.OpenSession(config_.key_system(), nullptr,
|
||||
nullptr, &session_id);
|
||||
if (status == NEED_PROVISIONING) {
|
||||
Provision();
|
||||
status =
|
||||
cdm_engine.OpenSession(config_.key_system(), NULL, NULL, &session_id);
|
||||
status = cdm_engine.OpenSession(config_.key_system(), nullptr, nullptr,
|
||||
&session_id);
|
||||
}
|
||||
ASSERT_EQ(NO_ERROR, status);
|
||||
ASSERT_NE("", session_id) << "Could not open CDM session.";
|
||||
@@ -445,7 +445,7 @@ TestLicenseHolder::~TestLicenseHolder() {
|
||||
|
||||
void TestLicenseHolder::OpenSession(const std::string& key_system) {
|
||||
CdmResponseType status =
|
||||
cdm_engine_->OpenSession(key_system, NULL, NULL, &session_id_);
|
||||
cdm_engine_->OpenSession(key_system, nullptr, nullptr, &session_id_);
|
||||
ASSERT_EQ(status, NO_ERROR);
|
||||
ASSERT_NE("", session_id_) << "Could not open CDM session.";
|
||||
ASSERT_TRUE(cdm_engine_->IsOpenSession(session_id_));
|
||||
@@ -624,7 +624,7 @@ void TestLicenseHolder::DeriveKeysFromSessionKey() {
|
||||
bool TestLicenseHolder::DeriveKey(const std::vector<uint8_t>& key,
|
||||
const std::vector<uint8_t>& context,
|
||||
int counter, std::vector<uint8_t>* out) {
|
||||
if (key.empty() || counter > 4 || context.empty() || out == NULL) {
|
||||
if (key.empty() || counter > 4 || context.empty() || out == nullptr) {
|
||||
LOGE("DeriveKey(): bad context");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -333,9 +333,9 @@ class UsageTableHeaderTest : public WvCdmTestBase {
|
||||
// UsageTableHeaderTest maintains ownership of returned pointer
|
||||
MockUsageTableHeader* SetUpMock() {
|
||||
// Release non-mocked usage table header
|
||||
if (usage_table_header_ != NULL) {
|
||||
if (usage_table_header_ != nullptr) {
|
||||
delete usage_table_header_;
|
||||
usage_table_header_ = NULL;
|
||||
usage_table_header_ = nullptr;
|
||||
}
|
||||
|
||||
// Create new mock objects if using MockUsageTableHeader
|
||||
@@ -352,7 +352,7 @@ class UsageTableHeaderTest : public WvCdmTestBase {
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (usage_table_header_ != NULL) delete usage_table_header_;
|
||||
if (usage_table_header_ != nullptr) delete usage_table_header_;
|
||||
}
|
||||
|
||||
void Init(CdmSecurityLevel security_level,
|
||||
@@ -379,8 +379,8 @@ TEST_F(UsageTableHeaderTest, InitError) {
|
||||
EXPECT_FALSE(usage_table_header_->Init(kSecurityLevelL2, crypto_session_));
|
||||
EXPECT_FALSE(
|
||||
usage_table_header_->Init(kSecurityLevelUnknown, crypto_session_));
|
||||
EXPECT_FALSE(usage_table_header_->Init(kSecurityLevelL1, NULL));
|
||||
EXPECT_FALSE(usage_table_header_->Init(kSecurityLevelL2, NULL));
|
||||
EXPECT_FALSE(usage_table_header_->Init(kSecurityLevelL1, nullptr));
|
||||
EXPECT_FALSE(usage_table_header_->Init(kSecurityLevelL2, nullptr));
|
||||
}
|
||||
|
||||
class UsageTableHeaderInitializationTest
|
||||
|
||||
Reference in New Issue
Block a user