Created an ArraySize utility function.
[ Merge of http://go/wvgerrit/82232 ] The new function `ArraySize` will only work for compile-time fixed-length arrays, and will provide compiler errors if the provided argument is not an array. This will replace the commonly used macro `N_ELEM()` which uses `sizeof()`. Test: Linux unittest Bug: 137041745 Change-Id: I0f5c268197a8062a99ccba43c73349e97f66eb02
This commit is contained in:
@@ -2,12 +2,15 @@
|
|||||||
// source code may only be used and distributed under the Widevine Master
|
// source code may only be used and distributed under the Widevine Master
|
||||||
// License Agreement.
|
// License Agreement.
|
||||||
|
|
||||||
|
#include "device_files.h"
|
||||||
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "device_files.h"
|
#include "arraysize.h"
|
||||||
#include "file_store.h"
|
#include "file_store.h"
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
#include "string_conversions.h"
|
#include "string_conversions.h"
|
||||||
@@ -2513,8 +2516,7 @@ TEST_F(DeviceFilesTest, UpdateLicenseState) {
|
|||||||
DeviceFiles device_files(&file_system);
|
DeviceFiles device_files(&file_system);
|
||||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(license_update_test_data) / sizeof(LicenseInfo);
|
for (size_t i = 0; i < ArraySize(license_update_test_data); i++) {
|
||||||
i++) {
|
|
||||||
// Call to Open will return a unique_ptr, freeing this object.
|
// Call to Open will return a unique_ptr, freeing this object.
|
||||||
MockFile* file = new MockFile();
|
MockFile* file = new MockFile();
|
||||||
EXPECT_CALL(file_system, DoOpen(StrEq(license_path), IsCreateFileFlagSet()))
|
EXPECT_CALL(file_system, DoOpen(StrEq(license_path), IsCreateFileFlagSet()))
|
||||||
@@ -2954,7 +2956,7 @@ TEST_P(DeviceFilesUsageInfoTest, RetrieveByProviderSessionToken) {
|
|||||||
std::string path = device_base_path_ + file_name;
|
std::string path = device_base_path_ + file_name;
|
||||||
|
|
||||||
size_t max_index_by_app_id = 0;
|
size_t max_index_by_app_id = 0;
|
||||||
for (size_t i = 0; i < sizeof(kUsageInfoTestData) / sizeof(UsageInfo); ++i) {
|
for (size_t i = 0; i < ArraySize(kUsageInfoTestData); ++i) {
|
||||||
if (app_id == kUsageInfoTestData[i].app_id) max_index_by_app_id = i;
|
if (app_id == kUsageInfoTestData[i].app_id) max_index_by_app_id = i;
|
||||||
}
|
}
|
||||||
std::string file_data =
|
std::string file_data =
|
||||||
@@ -3014,7 +3016,7 @@ TEST_P(DeviceFilesUsageInfoTest, UpdateUsageInfo) {
|
|||||||
std::vector<std::string> usage_data_fields;
|
std::vector<std::string> usage_data_fields;
|
||||||
|
|
||||||
size_t max_index_by_app_id = 0;
|
size_t max_index_by_app_id = 0;
|
||||||
for (size_t i = 0; i < sizeof(kUsageInfoTestData) / sizeof(UsageInfo); ++i) {
|
for (size_t i = 0; i < ArraySize(kUsageInfoTestData); ++i) {
|
||||||
if (app_id == kUsageInfoTestData[i].app_id) {
|
if (app_id == kUsageInfoTestData[i].app_id) {
|
||||||
max_index_by_app_id = i;
|
max_index_by_app_id = i;
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,10 @@
|
|||||||
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "arraysize.h"
|
||||||
#include "crypto_session.h"
|
#include "crypto_session.h"
|
||||||
#include "device_files.h"
|
#include "device_files.h"
|
||||||
#include "file_store.h"
|
#include "file_store.h"
|
||||||
@@ -103,8 +105,7 @@ const std::string kLicenseArray[] = {
|
|||||||
kUsageEntryInfoOfflineLicense2.key_set_id,
|
kUsageEntryInfoOfflineLicense2.key_set_id,
|
||||||
kUsageEntryInfoOfflineLicense3.key_set_id,
|
kUsageEntryInfoOfflineLicense3.key_set_id,
|
||||||
};
|
};
|
||||||
const size_t kLicenseArraySize = sizeof(kLicenseArray)/
|
const size_t kLicenseArraySize = ArraySize(kLicenseArray);
|
||||||
sizeof(kLicenseArray[0]);
|
|
||||||
std::vector<std::string> kLicenseList;
|
std::vector<std::string> kLicenseList;
|
||||||
|
|
||||||
const std::vector<std::string> kEmptyUsageInfoFilesList;
|
const std::vector<std::string> kEmptyUsageInfoFilesList;
|
||||||
@@ -114,8 +115,7 @@ const std::string kUsageInfoFileArray[] = {
|
|||||||
kUsageEntryInfoSecureStop2.usage_info_file_name,
|
kUsageEntryInfoSecureStop2.usage_info_file_name,
|
||||||
kUsageEntryInfoSecureStop3.usage_info_file_name,
|
kUsageEntryInfoSecureStop3.usage_info_file_name,
|
||||||
};
|
};
|
||||||
const size_t kUsageInfoFileArraySize = sizeof(kUsageInfoFileArray)/
|
const size_t kUsageInfoFileArraySize = ArraySize(kUsageInfoFileArray);
|
||||||
sizeof(kUsageInfoFileArray[0]);
|
|
||||||
std::vector<std::string> kUsageInfoFileList;
|
std::vector<std::string> kUsageInfoFileList;
|
||||||
|
|
||||||
const DeviceFiles::CdmUsageData kCdmUsageData1 = {
|
const DeviceFiles::CdmUsageData kCdmUsageData1 = {
|
||||||
@@ -322,6 +322,7 @@ class UsageTableHeaderTest : public WvCdmTestBase {
|
|||||||
// UsageTableHeader will take ownership of the pointer
|
// UsageTableHeader will take ownership of the pointer
|
||||||
device_files_ = new MockDeviceFiles();
|
device_files_ = new MockDeviceFiles();
|
||||||
crypto_session_ = new MockCryptoSession(&crypto_metrics_);
|
crypto_session_ = new MockCryptoSession(&crypto_metrics_);
|
||||||
|
|
||||||
usage_table_header_ = new UsageTableHeader();
|
usage_table_header_ = new UsageTableHeader();
|
||||||
|
|
||||||
// usage_table_header_ object takes ownership of these objects
|
// usage_table_header_ object takes ownership of these objects
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "OEMCryptoCENC.h"
|
#include "OEMCryptoCENC.h"
|
||||||
|
#include "arraysize.h"
|
||||||
#include "config_test_env.h"
|
#include "config_test_env.h"
|
||||||
#include "license_protocol.pb.h"
|
#include "license_protocol.pb.h"
|
||||||
#include "license_request.h"
|
#include "license_request.h"
|
||||||
@@ -50,8 +51,6 @@ using ::testing::StrictMock;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#define N_ELEM(a) (sizeof(a) / sizeof(a[0]))
|
|
||||||
|
|
||||||
// HTTP response codes.
|
// HTTP response codes.
|
||||||
const int kHttpOk = 200;
|
const int kHttpOk = 200;
|
||||||
// The following two responses are unused, but left here for human debuggers.
|
// The following two responses are unused, but left here for human debuggers.
|
||||||
@@ -535,7 +534,7 @@ TEST_P(WvCdmSrmTest, Srm) {
|
|||||||
INSTANTIATE_TEST_CASE_P(
|
INSTANTIATE_TEST_CASE_P(
|
||||||
Cdm, WvCdmSrmTest,
|
Cdm, WvCdmSrmTest,
|
||||||
::testing::Range(&kSrmTestConfiguration[0],
|
::testing::Range(&kSrmTestConfiguration[0],
|
||||||
&kSrmTestConfiguration[N_ELEM(kSrmTestConfiguration)]));
|
&kSrmTestConfiguration[ArraySize(kSrmTestConfiguration)]));
|
||||||
|
|
||||||
// These parameterized tests validate SRM scenarios described in
|
// These parameterized tests validate SRM scenarios described in
|
||||||
// SRM End-to-End Test Plan doc
|
// SRM End-to-End Test Plan doc
|
||||||
@@ -585,6 +584,6 @@ TEST_P(WvCdmSrmNotSupportedTest, Srm) {
|
|||||||
INSTANTIATE_TEST_CASE_P(
|
INSTANTIATE_TEST_CASE_P(
|
||||||
Cdm, WvCdmSrmNotSupportedTest,
|
Cdm, WvCdmSrmNotSupportedTest,
|
||||||
::testing::Range(&kSrmNotSupportedTestConfiguration[0],
|
::testing::Range(&kSrmNotSupportedTestConfiguration[0],
|
||||||
&kSrmNotSupportedTestConfiguration[N_ELEM(
|
&kSrmNotSupportedTestConfiguration[ArraySize(
|
||||||
kSrmNotSupportedTestConfiguration)]));
|
kSrmNotSupportedTestConfiguration)]));
|
||||||
} // namespace wvcdm
|
} // namespace wvcdm
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "OEMCryptoCENC.h"
|
||||||
|
#include "arraysize.h"
|
||||||
#include "cdm_identifier.h"
|
#include "cdm_identifier.h"
|
||||||
#include "config_test_env.h"
|
#include "config_test_env.h"
|
||||||
#include "device_files.h"
|
#include "device_files.h"
|
||||||
@@ -23,7 +25,6 @@
|
|||||||
#include "license_request.h"
|
#include "license_request.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "oemcrypto_adapter.h"
|
#include "oemcrypto_adapter.h"
|
||||||
#include "OEMCryptoCENC.h"
|
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
#include "string_conversions.h"
|
#include "string_conversions.h"
|
||||||
#include "test_base.h"
|
#include "test_base.h"
|
||||||
@@ -47,8 +48,6 @@ using ::testing::UnorderedElementsAreArray;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#define N_ELEM(a) (sizeof(a)/sizeof(a[0]))
|
|
||||||
|
|
||||||
// HTTP response codes.
|
// HTTP response codes.
|
||||||
const int kHttpOk = 200;
|
const int kHttpOk = 200;
|
||||||
|
|
||||||
@@ -3776,7 +3775,7 @@ TEST_F(WvCdmRequestLicenseTest, UsageRemoveAllTest) {
|
|||||||
EXPECT_TRUE(handle.DeleteAllUsageInfoForApp(
|
EXPECT_TRUE(handle.DeleteAllUsageInfoForApp(
|
||||||
DeviceFiles::GetUsageInfoFileName(""), &psts));
|
DeviceFiles::GetUsageInfoFileName(""), &psts));
|
||||||
|
|
||||||
for (size_t i = 0; i < N_ELEM(usage_info_sub_samples_icp); ++i) {
|
for (size_t i = 0; i < ArraySize(usage_info_sub_samples_icp); ++i) {
|
||||||
SubSampleInfo* data = usage_info_sub_samples_icp + i;
|
SubSampleInfo* data = usage_info_sub_samples_icp + i;
|
||||||
property_set.set_app_id(i % 2 == 0 ? app_id_empty : app_id_not_empty);
|
property_set.set_app_id(i % 2 == 0 ? app_id_empty : app_id_not_empty);
|
||||||
decryptor_->OpenSession(config_.key_system(), &property_set,
|
decryptor_->OpenSession(config_.key_system(), &property_set,
|
||||||
@@ -3874,7 +3873,7 @@ TEST_F(WvCdmRequestLicenseTest, RemoveCorruptedUsageInfoTest) {
|
|||||||
EXPECT_TRUE(handle.DeleteAllUsageInfoForApp(
|
EXPECT_TRUE(handle.DeleteAllUsageInfoForApp(
|
||||||
DeviceFiles::GetUsageInfoFileName(""), &psts));
|
DeviceFiles::GetUsageInfoFileName(""), &psts));
|
||||||
|
|
||||||
for (size_t i = 0; i < N_ELEM(usage_info_sub_samples_icp); ++i) {
|
for (size_t i = 0; i < ArraySize(usage_info_sub_samples_icp); ++i) {
|
||||||
SubSampleInfo* data = usage_info_sub_samples_icp + i;
|
SubSampleInfo* data = usage_info_sub_samples_icp + i;
|
||||||
property_set.set_app_id(i % 2 == 0 ? app_id_empty : app_id_not_empty);
|
property_set.set_app_id(i % 2 == 0 ? app_id_empty : app_id_not_empty);
|
||||||
decryptor_->OpenSession(config_.key_system(), &property_set,
|
decryptor_->OpenSession(config_.key_system(), &property_set,
|
||||||
@@ -4020,7 +4019,7 @@ TEST_F(WvCdmRequestLicenseTest, RemoveCorruptedUsageInfoTest2) {
|
|||||||
EXPECT_TRUE(handle.DeleteAllUsageInfoForApp(
|
EXPECT_TRUE(handle.DeleteAllUsageInfoForApp(
|
||||||
DeviceFiles::GetUsageInfoFileName(""), &psts));
|
DeviceFiles::GetUsageInfoFileName(""), &psts));
|
||||||
|
|
||||||
for (size_t i = 0; i < N_ELEM(usage_info_sub_samples_icp); ++i) {
|
for (size_t i = 0; i < ArraySize(usage_info_sub_samples_icp); ++i) {
|
||||||
SubSampleInfo* data = usage_info_sub_samples_icp + i;
|
SubSampleInfo* data = usage_info_sub_samples_icp + i;
|
||||||
property_set.set_app_id(i % 2 == 0 ? app_id_empty : app_id_not_empty);
|
property_set.set_app_id(i % 2 == 0 ? app_id_empty : app_id_not_empty);
|
||||||
decryptor_->OpenSession(config_.key_system(), &property_set,
|
decryptor_->OpenSession(config_.key_system(), &property_set,
|
||||||
@@ -4187,7 +4186,7 @@ TEST_F(WvCdmRequestLicenseTest, GetSecureStopIdsTest) {
|
|||||||
EXPECT_TRUE(retrieved_secure_stop_ids.empty());
|
EXPECT_TRUE(retrieved_secure_stop_ids.empty());
|
||||||
|
|
||||||
// First fetch licenses for the default app
|
// First fetch licenses for the default app
|
||||||
for (size_t i = 0; i < N_ELEM(kUsageLicenseTestVector1); ++i) {
|
for (size_t i = 0; i < ArraySize(kUsageLicenseTestVector1); ++i) {
|
||||||
SubSampleInfo* data = kUsageLicenseTestVector1[i].sub_sample;
|
SubSampleInfo* data = kUsageLicenseTestVector1[i].sub_sample;
|
||||||
|
|
||||||
property_set.set_app_id(app_id_empty);
|
property_set.set_app_id(app_id_empty);
|
||||||
@@ -4219,7 +4218,7 @@ TEST_F(WvCdmRequestLicenseTest, GetSecureStopIdsTest) {
|
|||||||
// Verify that there are usage records for the default identifier but
|
// Verify that there are usage records for the default identifier but
|
||||||
// none yet for the non-default one
|
// none yet for the non-default one
|
||||||
std::vector<CdmSecureStopId> expected_provider_session_tokens;
|
std::vector<CdmSecureStopId> expected_provider_session_tokens;
|
||||||
for (size_t i = 0; i < N_ELEM(kUsageLicenseTestVector1); ++i) {
|
for (size_t i = 0; i < ArraySize(kUsageLicenseTestVector1); ++i) {
|
||||||
expected_provider_session_tokens.push_back(
|
expected_provider_session_tokens.push_back(
|
||||||
kUsageLicenseTestVector1[i].provider_session_token);
|
kUsageLicenseTestVector1[i].provider_session_token);
|
||||||
}
|
}
|
||||||
@@ -4228,7 +4227,8 @@ TEST_F(WvCdmRequestLicenseTest, GetSecureStopIdsTest) {
|
|||||||
NO_ERROR,
|
NO_ERROR,
|
||||||
decryptor_->GetSecureStopIds(app_id_empty, kDefaultCdmIdentifier,
|
decryptor_->GetSecureStopIds(app_id_empty, kDefaultCdmIdentifier,
|
||||||
&retrieved_secure_stop_ids));
|
&retrieved_secure_stop_ids));
|
||||||
EXPECT_EQ(N_ELEM(kUsageLicenseTestVector1), retrieved_secure_stop_ids.size());
|
EXPECT_EQ(ArraySize(kUsageLicenseTestVector1),
|
||||||
|
retrieved_secure_stop_ids.size());
|
||||||
EXPECT_THAT(retrieved_secure_stop_ids,
|
EXPECT_THAT(retrieved_secure_stop_ids,
|
||||||
UnorderedElementsAreArray(expected_provider_session_tokens));
|
UnorderedElementsAreArray(expected_provider_session_tokens));
|
||||||
|
|
||||||
@@ -4240,7 +4240,7 @@ TEST_F(WvCdmRequestLicenseTest, GetSecureStopIdsTest) {
|
|||||||
EXPECT_TRUE(retrieved_secure_stop_ids.empty());
|
EXPECT_TRUE(retrieved_secure_stop_ids.empty());
|
||||||
|
|
||||||
// Now fetch licenses for the other identifier
|
// Now fetch licenses for the other identifier
|
||||||
for (size_t i = 0; i < N_ELEM(kUsageLicenseTestVector2); ++i) {
|
for (size_t i = 0; i < ArraySize(kUsageLicenseTestVector2); ++i) {
|
||||||
SubSampleInfo* data = kUsageLicenseTestVector2[i].sub_sample;
|
SubSampleInfo* data = kUsageLicenseTestVector2[i].sub_sample;
|
||||||
|
|
||||||
property_set.set_app_id(kExampleIdentifier.app_package_name);
|
property_set.set_app_id(kExampleIdentifier.app_package_name);
|
||||||
@@ -4278,14 +4278,15 @@ TEST_F(WvCdmRequestLicenseTest, GetSecureStopIdsTest) {
|
|||||||
decryptor_->GetSecureStopIds(kDefaultCdmIdentifier.app_package_name,
|
decryptor_->GetSecureStopIds(kDefaultCdmIdentifier.app_package_name,
|
||||||
kDefaultCdmIdentifier,
|
kDefaultCdmIdentifier,
|
||||||
&retrieved_secure_stop_ids));
|
&retrieved_secure_stop_ids));
|
||||||
EXPECT_EQ(N_ELEM(kUsageLicenseTestVector1), retrieved_secure_stop_ids.size());
|
EXPECT_EQ(ArraySize(kUsageLicenseTestVector1),
|
||||||
|
retrieved_secure_stop_ids.size());
|
||||||
EXPECT_THAT(retrieved_secure_stop_ids,
|
EXPECT_THAT(retrieved_secure_stop_ids,
|
||||||
UnorderedElementsAreArray(expected_provider_session_tokens));
|
UnorderedElementsAreArray(expected_provider_session_tokens));
|
||||||
|
|
||||||
retrieved_secure_stop_ids.clear();
|
retrieved_secure_stop_ids.clear();
|
||||||
expected_provider_session_tokens.clear();
|
expected_provider_session_tokens.clear();
|
||||||
|
|
||||||
for (size_t i = 0; i < N_ELEM(kUsageLicenseTestVector2); ++i) {
|
for (size_t i = 0; i < ArraySize(kUsageLicenseTestVector2); ++i) {
|
||||||
expected_provider_session_tokens.push_back(
|
expected_provider_session_tokens.push_back(
|
||||||
kUsageLicenseTestVector2[i].provider_session_token);
|
kUsageLicenseTestVector2[i].provider_session_token);
|
||||||
}
|
}
|
||||||
@@ -4295,7 +4296,8 @@ TEST_F(WvCdmRequestLicenseTest, GetSecureStopIdsTest) {
|
|||||||
decryptor_->GetSecureStopIds(kExampleIdentifier.app_package_name,
|
decryptor_->GetSecureStopIds(kExampleIdentifier.app_package_name,
|
||||||
kExampleIdentifier,
|
kExampleIdentifier,
|
||||||
&retrieved_secure_stop_ids));
|
&retrieved_secure_stop_ids));
|
||||||
EXPECT_EQ(N_ELEM(kUsageLicenseTestVector2), retrieved_secure_stop_ids.size());
|
EXPECT_EQ(ArraySize(kUsageLicenseTestVector2),
|
||||||
|
retrieved_secure_stop_ids.size());
|
||||||
EXPECT_THAT(retrieved_secure_stop_ids,
|
EXPECT_THAT(retrieved_secure_stop_ids,
|
||||||
UnorderedElementsAreArray(expected_provider_session_tokens));
|
UnorderedElementsAreArray(expected_provider_session_tokens));
|
||||||
|
|
||||||
@@ -4447,7 +4449,7 @@ TEST_F(WvCdmRequestLicenseTest, UsageRemoveSecureStopTest) {
|
|||||||
DeviceFiles::GetUsageInfoFileName(""), &psts));
|
DeviceFiles::GetUsageInfoFileName(""), &psts));
|
||||||
|
|
||||||
// First fetch licenses for the default app
|
// First fetch licenses for the default app
|
||||||
for (size_t i = 0; i < N_ELEM(kUsageLicenseTestVector1); ++i) {
|
for (size_t i = 0; i < ArraySize(kUsageLicenseTestVector1); ++i) {
|
||||||
SubSampleInfo* data = kUsageLicenseTestVector1[i].sub_sample;
|
SubSampleInfo* data = kUsageLicenseTestVector1[i].sub_sample;
|
||||||
|
|
||||||
property_set.set_app_id(app_id_empty);
|
property_set.set_app_id(app_id_empty);
|
||||||
@@ -4476,7 +4478,7 @@ TEST_F(WvCdmRequestLicenseTest, UsageRemoveSecureStopTest) {
|
|||||||
// Provision and fetch licenses for the other identifier
|
// Provision and fetch licenses for the other identifier
|
||||||
Provision(kExampleIdentifier, kLevelDefault);
|
Provision(kExampleIdentifier, kLevelDefault);
|
||||||
|
|
||||||
for (size_t i = 0; i < N_ELEM(kUsageLicenseTestVector2); ++i) {
|
for (size_t i = 0; i < ArraySize(kUsageLicenseTestVector2); ++i) {
|
||||||
SubSampleInfo* data = kUsageLicenseTestVector2[i].sub_sample;
|
SubSampleInfo* data = kUsageLicenseTestVector2[i].sub_sample;
|
||||||
|
|
||||||
property_set.set_app_id(kExampleIdentifier.app_package_name);
|
property_set.set_app_id(kExampleIdentifier.app_package_name);
|
||||||
@@ -4513,9 +4515,9 @@ TEST_F(WvCdmRequestLicenseTest, UsageRemoveSecureStopTest) {
|
|||||||
NO_ERROR,
|
NO_ERROR,
|
||||||
decryptor_->GetSecureStopIds(kDefaultCdmIdentifier.app_package_name,
|
decryptor_->GetSecureStopIds(kDefaultCdmIdentifier.app_package_name,
|
||||||
kDefaultCdmIdentifier, &secure_stop_ids));
|
kDefaultCdmIdentifier, &secure_stop_ids));
|
||||||
EXPECT_EQ(N_ELEM(kUsageLicenseTestVector1), secure_stop_ids.size());
|
EXPECT_EQ(ArraySize(kUsageLicenseTestVector1), secure_stop_ids.size());
|
||||||
|
|
||||||
for (size_t i = 0; i < N_ELEM(kUsageLicenseTestVector1); ++i) {
|
for (size_t i = 0; i < ArraySize(kUsageLicenseTestVector1); ++i) {
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
NO_ERROR,
|
NO_ERROR,
|
||||||
decryptor_->RemoveUsageInfo(kDefaultCdmIdentifier.app_package_name,
|
decryptor_->RemoveUsageInfo(kDefaultCdmIdentifier.app_package_name,
|
||||||
@@ -4532,9 +4534,9 @@ TEST_F(WvCdmRequestLicenseTest, UsageRemoveSecureStopTest) {
|
|||||||
NO_ERROR,
|
NO_ERROR,
|
||||||
decryptor_->GetSecureStopIds(kExampleIdentifier.app_package_name,
|
decryptor_->GetSecureStopIds(kExampleIdentifier.app_package_name,
|
||||||
kExampleIdentifier, &secure_stop_ids));
|
kExampleIdentifier, &secure_stop_ids));
|
||||||
EXPECT_EQ(N_ELEM(kUsageLicenseTestVector2), secure_stop_ids.size());
|
EXPECT_EQ(ArraySize(kUsageLicenseTestVector2), secure_stop_ids.size());
|
||||||
|
|
||||||
for (size_t i = 0; i < N_ELEM(kUsageLicenseTestVector2); ++i) {
|
for (size_t i = 0; i < ArraySize(kUsageLicenseTestVector2); ++i) {
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
NO_ERROR,
|
NO_ERROR,
|
||||||
decryptor_->RemoveUsageInfo(kExampleIdentifier.app_package_name,
|
decryptor_->RemoveUsageInfo(kExampleIdentifier.app_package_name,
|
||||||
@@ -5807,7 +5809,7 @@ TEST_P(WvCenc30SwitchCipherModeTest, DecryptionTest) {
|
|||||||
CdmKeyStatusMap key_status_map = listener.GetKeyStatusMap();
|
CdmKeyStatusMap key_status_map = listener.GetKeyStatusMap();
|
||||||
EXPECT_EQ(8u, key_status_map.size());
|
EXPECT_EQ(8u, key_status_map.size());
|
||||||
|
|
||||||
for (size_t i = 0; i < N_ELEM(info->sample_info); ++i) {
|
for (size_t i = 0; i < ArraySize(info->sample_info); ++i) {
|
||||||
Cenc30SampleInfo* data = &info->sample_info[i];
|
Cenc30SampleInfo* data = &info->sample_info[i];
|
||||||
std::vector<uint8_t> output_buffer(data->encrypted_data.size(), 0);
|
std::vector<uint8_t> output_buffer(data->encrypted_data.size(), 0);
|
||||||
std::vector<uint8_t> iv(data->iv.begin(), data->iv.end());
|
std::vector<uint8_t> iv(data->iv.begin(), data->iv.end());
|
||||||
|
|||||||
20
libwvdrmengine/cdm/util/include/arraysize.h
Normal file
20
libwvdrmengine/cdm/util/include/arraysize.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2019 Google LLC. All Rights Reserved. This file and proprietary
|
||||||
|
// source code may only be used and distributed under the Widevine Master
|
||||||
|
// License Agreement.
|
||||||
|
|
||||||
|
#ifndef WVCDM_UTIL_ARRAYSIZE_H_
|
||||||
|
#define WVCDM_UTIL_ARRAYSIZE_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace wvcdm {
|
||||||
|
|
||||||
|
// Returns the size of a fixed-length array.
|
||||||
|
template <typename T, size_t N>
|
||||||
|
constexpr size_t ArraySize(const T (&)[N]) {
|
||||||
|
return N;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace wvcdm
|
||||||
|
|
||||||
|
#endif // WVCDM_UTIL_ARRAYSIZE_H_
|
||||||
Reference in New Issue
Block a user