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

Side by Side Diff: media/cdm/cdm_adapter_unittest.cc

Issue 2255943002: EME: Remove obsolete legacy APIs related to versions of prefixed EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build and add bug reference for obsoletes Created 4 years, 4 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cdm/cdm_adapter.h" 5 #include "media/cdm/cdm_adapter.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // or generates an error. 83 // or generates an error.
84 void InitializeAndExpect(base::FilePath library_path, 84 void InitializeAndExpect(base::FilePath library_path,
85 ExpectedResult expected_result) { 85 ExpectedResult expected_result) {
86 CdmConfig cdm_config; // default settings of false are sufficient. 86 CdmConfig cdm_config; // default settings of false are sufficient.
87 std::unique_ptr<CdmAllocator> allocator(new SimpleCdmAllocator()); 87 std::unique_ptr<CdmAllocator> allocator(new SimpleCdmAllocator());
88 CdmAdapter::Create( 88 CdmAdapter::Create(
89 helper_.KeySystemName(), library_path, cdm_config, std::move(allocator), 89 helper_.KeySystemName(), library_path, cdm_config, std::move(allocator),
90 base::Bind(&CdmAdapterTest::CreateCdmFileIO, base::Unretained(this)), 90 base::Bind(&CdmAdapterTest::CreateCdmFileIO, base::Unretained(this)),
91 base::Bind(&CdmAdapterTest::OnSessionMessage, base::Unretained(this)), 91 base::Bind(&CdmAdapterTest::OnSessionMessage, base::Unretained(this)),
92 base::Bind(&CdmAdapterTest::OnSessionClosed, base::Unretained(this)), 92 base::Bind(&CdmAdapterTest::OnSessionClosed, base::Unretained(this)),
93 base::Bind(&CdmAdapterTest::OnLegacySessionError,
94 base::Unretained(this)),
95 base::Bind(&CdmAdapterTest::OnSessionKeysChange, 93 base::Bind(&CdmAdapterTest::OnSessionKeysChange,
96 base::Unretained(this)), 94 base::Unretained(this)),
97 base::Bind(&CdmAdapterTest::OnSessionExpirationUpdate, 95 base::Bind(&CdmAdapterTest::OnSessionExpirationUpdate,
98 base::Unretained(this)), 96 base::Unretained(this)),
99 base::Bind(&CdmAdapterTest::OnCdmCreated, base::Unretained(this), 97 base::Bind(&CdmAdapterTest::OnCdmCreated, base::Unretained(this),
100 expected_result)); 98 expected_result));
101 RunUntilIdle(); 99 RunUntilIdle();
102 } 100 }
103 101
104 // Creates a new session using |key_id|. |session_id_| will be set 102 // Creates a new session using |key_id|. |session_id_| will be set
105 // when the promise is resolved. |expected_result| tests that 103 // when the promise is resolved. |expected_result| tests that
106 // CreateSessionAndGenerateRequest() succeeds or generates an error. 104 // CreateSessionAndGenerateRequest() succeeds or generates an error.
107 void CreateSessionAndExpect(EmeInitDataType data_type, 105 void CreateSessionAndExpect(EmeInitDataType data_type,
108 const std::vector<uint8_t>& key_id, 106 const std::vector<uint8_t>& key_id,
109 ExpectedResult expected_result) { 107 ExpectedResult expected_result) {
110 DCHECK(!key_id.empty()); 108 DCHECK(!key_id.empty());
111 109
112 if (expected_result == SUCCESS) { 110 if (expected_result == SUCCESS) {
113 EXPECT_CALL(*this, 111 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, _));
114 OnSessionMessage(IsNotEmpty(), _, _, GURL::EmptyGURL()));
115 } 112 }
116 113
117 adapter_->CreateSessionAndGenerateRequest( 114 adapter_->CreateSessionAndGenerateRequest(
118 MediaKeys::TEMPORARY_SESSION, data_type, key_id, 115 MediaKeys::TEMPORARY_SESSION, data_type, key_id,
119 CreateSessionPromise(expected_result)); 116 CreateSessionPromise(expected_result));
120 RunUntilIdle(); 117 RunUntilIdle();
121 } 118 }
122 119
123 // Loads the session specified by |session_id|. |expected_result| tests 120 // Loads the session specified by |session_id|. |expected_result| tests
124 // that LoadSession() succeeds or generates an error. 121 // that LoadSession() succeeds or generates an error.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 211
215 // Methods used for promise resolved/rejected. 212 // Methods used for promise resolved/rejected.
216 MOCK_METHOD0(OnResolve, void()); 213 MOCK_METHOD0(OnResolve, void());
217 MOCK_METHOD1(OnResolveWithSession, void(const std::string& session_id)); 214 MOCK_METHOD1(OnResolveWithSession, void(const std::string& session_id));
218 MOCK_METHOD3(OnReject, 215 MOCK_METHOD3(OnReject,
219 void(MediaKeys::Exception exception_code, 216 void(MediaKeys::Exception exception_code,
220 uint32_t system_code, 217 uint32_t system_code,
221 const std::string& error_message)); 218 const std::string& error_message));
222 219
223 // Methods used for the events possibly generated by CdmAdapater. 220 // Methods used for the events possibly generated by CdmAdapater.
224 MOCK_METHOD4(OnSessionMessage, 221 MOCK_METHOD3(OnSessionMessage,
225 void(const std::string& session_id, 222 void(const std::string& session_id,
226 MediaKeys::MessageType message_type, 223 MediaKeys::MessageType message_type,
227 const std::vector<uint8_t>& message, 224 const std::vector<uint8_t>& message));
228 const GURL& legacy_destination_url));
229 MOCK_METHOD1(OnSessionClosed, void(const std::string& session_id)); 225 MOCK_METHOD1(OnSessionClosed, void(const std::string& session_id));
230 MOCK_METHOD4(OnLegacySessionError,
231 void(const std::string& session_id,
232 MediaKeys::Exception exception,
233 uint32_t system_code,
234 const std::string& error_message));
235 MOCK_METHOD2(OnSessionKeysChangeCalled, 226 MOCK_METHOD2(OnSessionKeysChangeCalled,
236 void(const std::string& session_id, 227 void(const std::string& session_id,
237 bool has_additional_usable_key)); 228 bool has_additional_usable_key));
238 void OnSessionKeysChange(const std::string& session_id, 229 void OnSessionKeysChange(const std::string& session_id,
239 bool has_additional_usable_key, 230 bool has_additional_usable_key,
240 CdmKeysInfo keys_info) { 231 CdmKeysInfo keys_info) {
241 // MOCK methods don't like CdmKeysInfo. 232 // MOCK methods don't like CdmKeysInfo.
242 OnSessionKeysChangeCalled(session_id, has_additional_usable_key); 233 OnSessionKeysChangeCalled(session_id, has_additional_usable_key);
243 } 234 }
244 MOCK_METHOD2(OnSessionExpirationUpdate, 235 MOCK_METHOD2(OnSessionExpirationUpdate,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) { 315 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) {
325 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); 316 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS);
326 317
327 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId)); 318 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId));
328 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS); 319 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS);
329 320
330 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true); 321 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true);
331 } 322 }
332 323
333 } // namespace media 324 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698