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

Unified Diff: media/cdm/cdm_adapter_unittest.cc

Issue 2554163002: media: Add MockCdmClient (Closed)
Patch Set: Created 4 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
« media/cdm/aes_decryptor_unittest.cc ('K') | « media/cdm/aes_decryptor_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cdm/cdm_adapter_unittest.cc
diff --git a/media/cdm/cdm_adapter_unittest.cc b/media/cdm/cdm_adapter_unittest.cc
index 560225510c306cbc838e4c5fdbfd5e87419820ef..57294cd7fe6c4b5e0c692d309a799548040d7c02 100644
--- a/media/cdm/cdm_adapter_unittest.cc
+++ b/media/cdm/cdm_adapter_unittest.cc
@@ -14,6 +14,7 @@
#include "media/base/cdm_callback_promise.h"
#include "media/base/cdm_key_information.h"
#include "media/base/media_keys.h"
+#include "media/base/mock_filters.h"
#include "media/cdm/cdm_file_io.h"
#include "media/cdm/external_clear_key_test_helper.h"
#include "media/cdm/simple_cdm_allocator.h"
@@ -22,6 +23,8 @@
using ::testing::_;
using ::testing::SaveArg;
+using ::testing::StrictMock;
+
MATCHER(IsNotEmpty, "") {
return !arg.empty();
}
@@ -88,12 +91,14 @@ class CdmAdapterTest : public testing::Test {
CdmAdapter::Create(
helper_.KeySystemName(), library_path, cdm_config, std::move(allocator),
base::Bind(&CdmAdapterTest::CreateCdmFileIO, base::Unretained(this)),
- base::Bind(&CdmAdapterTest::OnSessionMessage, base::Unretained(this)),
- base::Bind(&CdmAdapterTest::OnSessionClosed, base::Unretained(this)),
- base::Bind(&CdmAdapterTest::OnSessionKeysChange,
- base::Unretained(this)),
- base::Bind(&CdmAdapterTest::OnSessionExpirationUpdate,
- base::Unretained(this)),
+ base::Bind(&MockCdmClient::OnSessionMessage,
+ base::Unretained(&cdm_client_)),
+ base::Bind(&MockCdmClient::OnSessionClosed,
+ base::Unretained(&cdm_client_)),
+ base::Bind(&MockCdmClient::OnSessionKeysChange,
+ base::Unretained(&cdm_client_)),
+ base::Bind(&MockCdmClient::OnSessionExpirationUpdate,
+ base::Unretained(&cdm_client_)),
base::Bind(&CdmAdapterTest::OnCdmCreated, base::Unretained(this),
expected_result));
RunUntilIdle();
@@ -108,7 +113,7 @@ class CdmAdapterTest : public testing::Test {
DCHECK(!key_id.empty());
if (expected_result == SUCCESS) {
- EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, _));
+ EXPECT_CALL(cdm_client_, OnSessionMessage(IsNotEmpty(), _, _));
}
adapter_->CreateSessionAndGenerateRequest(
@@ -139,10 +144,10 @@ class CdmAdapterTest : public testing::Test {
DCHECK(!key.empty());
if (expected_result == SUCCESS) {
- EXPECT_CALL(*this,
+ EXPECT_CALL(cdm_client_,
OnSessionKeysChangeCalled(session_id, new_key_expected));
} else {
- EXPECT_CALL(*this, OnSessionKeysChangeCalled(_, _)).Times(0);
+ EXPECT_CALL(cdm_client_, OnSessionKeysChangeCalled(_, _)).Times(0);
}
adapter_->UpdateSession(session_id,
@@ -217,23 +222,7 @@ class CdmAdapterTest : public testing::Test {
uint32_t system_code,
const std::string& error_message));
- // Methods used for the events possibly generated by CdmAdapater.
- MOCK_METHOD3(OnSessionMessage,
- void(const std::string& session_id,
- MediaKeys::MessageType message_type,
- const std::vector<uint8_t>& message));
- MOCK_METHOD1(OnSessionClosed, void(const std::string& session_id));
- MOCK_METHOD2(OnSessionKeysChangeCalled,
- void(const std::string& session_id,
- bool has_additional_usable_key));
- void OnSessionKeysChange(const std::string& session_id,
- bool has_additional_usable_key,
- CdmKeysInfo keys_info) {
- // MOCK methods don't like CdmKeysInfo.
- OnSessionKeysChangeCalled(session_id, has_additional_usable_key);
- }
- MOCK_METHOD2(OnSessionExpirationUpdate,
- void(const std::string& session_id, base::Time new_expiry_time));
+ StrictMock<MockCdmClient> cdm_client_;
// Helper class to load/unload External Clear Key Library.
ExternalClearKeyTestHelper helper_;
« media/cdm/aes_decryptor_unittest.cc ('K') | « media/cdm/aes_decryptor_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698