summaryrefslogtreecommitdiffstats
path: root/drm
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-11-15 01:02:11 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-11-15 01:02:11 +0000
commit7c258c36cd049b3581af2e9a40a9e707cbe1fd3b (patch)
tree86cbc2fa61c36ca5a0f048ad52f5e5db0acfe000 /drm
parent218ff9cb2b1c87476bcb60e1cc69ce098d7aac9f (diff)
parent31a86d2847d14b52c940cceec9ca6ef0da5f05f6 (diff)
downloadandroid_hardware_interfaces-7c258c36cd049b3581af2e9a40a9e707cbe1fd3b.tar.gz
android_hardware_interfaces-7c258c36cd049b3581af2e9a40a9e707cbe1fd3b.tar.bz2
android_hardware_interfaces-7c258c36cd049b3581af2e9a40a9e707cbe1fd3b.zip
Merge "Cleanup drm_hal_clearkey_test."
Diffstat (limited to 'drm')
-rw-r--r--drm/1.0/vts/functional/drm_hal_clearkey_test.cpp64
1 files changed, 29 insertions, 35 deletions
diff --git a/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp b/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
index a110eb150..4a1892b8e 100644
--- a/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
+++ b/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
@@ -89,10 +89,6 @@ static const uint8_t kInvalidUUID[16] = {
0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80,
0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80};
-static const uint32_t k256SubSampleByteCount = 256;
-static const uint32_t k512SubSampleClearBytes = 512;
-static const uint32_t k512SubSampleEncryptedBytes = 512;
-
class DrmHalClearkeyFactoryTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
@@ -349,8 +345,7 @@ SessionId DrmHalClearkeyPluginTest::openSession() {
* Helper method to close a session
*/
void DrmHalClearkeyPluginTest::closeSession(const SessionId& sessionId) {
- auto result = drmPlugin->closeSession(sessionId);
- EXPECT_EQ(Status::OK, result);
+ EXPECT_TRUE(drmPlugin->closeSession(sessionId).isOk());
}
/**
@@ -793,7 +788,7 @@ TEST_F(DrmHalClearkeyPluginTest, SetMacAlgorithmNoSession) {
*/
TEST_F(DrmHalClearkeyPluginTest, GenericEncryptNotSupported) {
SessionId session = openSession();
- ;
+
hidl_vec<uint8_t> keyId = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
hidl_vec<uint8_t> input = {1, 2, 3, 4, 5};
hidl_vec<uint8_t> iv = std::vector<uint8_t>(AES_BLOCK_SIZE, 0);
@@ -822,7 +817,7 @@ TEST_F(DrmHalClearkeyPluginTest, GenericDecryptNotSupported) {
TEST_F(DrmHalClearkeyPluginTest, GenericSignNotSupported) {
SessionId session = openSession();
- ;
+
hidl_vec<uint8_t> keyId = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
hidl_vec<uint8_t> message = {1, 2, 3, 4, 5};
auto res = drmPlugin->sign(session, keyId, message,
@@ -836,7 +831,7 @@ TEST_F(DrmHalClearkeyPluginTest, GenericSignNotSupported) {
TEST_F(DrmHalClearkeyPluginTest, GenericVerifyNotSupported) {
SessionId session = openSession();
- ;
+
hidl_vec<uint8_t> keyId = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
hidl_vec<uint8_t> message = {1, 2, 3, 4, 5};
hidl_vec<uint8_t> signature = {0, 0, 0, 0, 0, 0, 0, 0,
@@ -926,8 +921,7 @@ sp<IMemory> DrmHalClearkeyPluginTest::getDecryptMemory(size_t size,
*/
TEST_F(DrmHalClearkeyPluginTest, SetMediaDrmSession) {
auto sessionId = openSession();
- Status status = cryptoPlugin->setMediaDrmSession(sessionId);
- EXPECT_EQ(Status::OK, status);
+ EXPECT_TRUE(cryptoPlugin->setMediaDrmSession(sessionId).isOk());
closeSession(sessionId);
}
@@ -948,8 +942,7 @@ TEST_F(DrmHalClearkeyPluginTest, SetMediaDrmSessionClosedSession) {
*/
TEST_F(DrmHalClearkeyPluginTest, SetMediaDrmSessionEmptySession) {
SessionId sessionId;
- Status status = cryptoPlugin->setMediaDrmSession(sessionId);
- EXPECT_EQ(Status::OK, status);
+ EXPECT_TRUE(cryptoPlugin->setMediaDrmSession(sessionId).isOk());
}
/**
@@ -1131,18 +1124,17 @@ TEST_F(DrmHalClearkeyDecryptTest, TestQueryKeyStatus) {
TEST_F(DrmHalClearkeyDecryptTest, ClearSegmentTest) {
vector<uint8_t> iv(AES_BLOCK_SIZE, 0);
const Pattern noPattern = {0, 0};
+ const uint32_t kByteCount = 256;
const vector<SubSample> subSamples = {
- {.numBytesOfClearData = k256SubSampleByteCount,
+ {.numBytesOfClearData = kByteCount,
.numBytesOfEncryptedData = 0}};
auto sessionId = openSession();
loadKeys(sessionId);
-
- Status status = cryptoPlugin->setMediaDrmSession(sessionId);
- EXPECT_EQ(Status::OK, status);
+ EXPECT_TRUE(cryptoPlugin->setMediaDrmSession(sessionId).isOk());
uint32_t byteCount = decrypt(Mode::UNENCRYPTED, &iv[0], subSamples,
noPattern, Status::OK);
- EXPECT_EQ(k256SubSampleByteCount, byteCount);
+ EXPECT_EQ(kByteCount, byteCount);
closeSession(sessionId);
}
@@ -1154,18 +1146,18 @@ TEST_F(DrmHalClearkeyDecryptTest, ClearSegmentTest) {
TEST_F(DrmHalClearkeyDecryptTest, EncryptedAesCtrSegmentTest) {
vector<uint8_t> iv(AES_BLOCK_SIZE, 0);
const Pattern noPattern = {0, 0};
+ const uint32_t kClearBytes = 512;
+ const uint32_t kEncryptedBytes = 512;
const vector<SubSample> subSamples = {
- {.numBytesOfClearData = k512SubSampleClearBytes,
- .numBytesOfEncryptedData = k512SubSampleEncryptedBytes}};
+ {.numBytesOfClearData = kClearBytes,
+ .numBytesOfEncryptedData = kEncryptedBytes}};
auto sessionId = openSession();
loadKeys(sessionId);
-
- Status status = cryptoPlugin->setMediaDrmSession(sessionId);
- EXPECT_EQ(Status::OK, status);
+ EXPECT_TRUE(cryptoPlugin->setMediaDrmSession(sessionId).isOk());
uint32_t byteCount = decrypt(Mode::AES_CTR, &iv[0], subSamples,
noPattern, Status::OK);
- EXPECT_EQ(k512SubSampleClearBytes + k512SubSampleEncryptedBytes, byteCount);
+ EXPECT_EQ(kClearBytes + kEncryptedBytes, byteCount);
closeSession(sessionId);
}
@@ -1177,12 +1169,10 @@ TEST_F(DrmHalClearkeyDecryptTest, EncryptedAesCtrSegmentTestNoKeys) {
vector<uint8_t> iv(AES_BLOCK_SIZE, 0);
const Pattern noPattern = {0, 0};
const vector<SubSample> subSamples = {
- {.numBytesOfClearData = k256SubSampleByteCount,
- .numBytesOfEncryptedData = k256SubSampleByteCount}};
+ {.numBytesOfClearData = 256,
+ .numBytesOfEncryptedData = 256}};
auto sessionId = openSession();
-
- Status status = cryptoPlugin->setMediaDrmSession(sessionId);
- EXPECT_EQ(Status::OK, status);
+ EXPECT_TRUE(cryptoPlugin->setMediaDrmSession(sessionId).isOk());
uint32_t byteCount = decrypt(Mode::AES_CTR, &iv[0], subSamples,
noPattern, Status::ERROR_DRM_NO_LICENSE);
@@ -1207,9 +1197,9 @@ void DrmHalClearkeyDecryptTest::decryptWithInvalidKeys(
EXPECT_EQ(Status::OK, status);
EXPECT_EQ(0u, myKeySetId.size());
});
- ASSERT_OK(res);
+ EXPECT_OK(res);
- ASSERT_TRUE(cryptoPlugin->setMediaDrmSession(sessionId).isOk());
+ EXPECT_TRUE(cryptoPlugin->setMediaDrmSession(sessionId).isOk());
uint32_t byteCount = decrypt(Mode::AES_CTR, &iv[0], subSamples,
noPattern, Status::ERROR_DRM_NO_LICENSE);
@@ -1224,9 +1214,11 @@ void DrmHalClearkeyDecryptTest::decryptWithInvalidKeys(
TEST_F(DrmHalClearkeyDecryptTest, DecryptWithEmptyKey) {
vector<uint8_t> iv(AES_BLOCK_SIZE, 0);
const Pattern noPattern = {0, 0};
+ const uint32_t kClearBytes = 512;
+ const uint32_t kEncryptedBytes = 512;
const vector<SubSample> subSamples = {
- {.numBytesOfClearData = k512SubSampleClearBytes,
- .numBytesOfEncryptedData = k512SubSampleEncryptedBytes}};
+ {.numBytesOfClearData = kClearBytes,
+ .numBytesOfEncryptedData = kEncryptedBytes}};
// base 64 encoded JSON response string, must not contain padding character '='
const hidl_string emptyKeyResponse =
@@ -1259,9 +1251,11 @@ TEST_F(DrmHalClearkeyDecryptTest, DecryptWithEmptyKey) {
TEST_F(DrmHalClearkeyDecryptTest, DecryptWithKeyTooLong) {
vector<uint8_t> iv(AES_BLOCK_SIZE, 0);
const Pattern noPattern = {0, 0};
+ const uint32_t kClearBytes = 512;
+ const uint32_t kEncryptedBytes = 512;
const vector<SubSample> subSamples = {
- {.numBytesOfClearData = k512SubSampleClearBytes,
- .numBytesOfEncryptedData = k512SubSampleEncryptedBytes}};
+ {.numBytesOfClearData = kClearBytes,
+ .numBytesOfEncryptedData = kEncryptedBytes}};
// base 64 encoded JSON response string, must not contain padding character '='
const hidl_string keyTooLongResponse =