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

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

Issue 604283003: Refactor CdmPromise and related classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + override Created 6 years, 2 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
« no previous file with comments | « media/base/media_keys.h ('k') | media/cdm/ppapi/external_clear_key/clear_key_cdm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "media/base/cdm_promise.h" 12 #include "media/base/cdm_callback_promise.h"
13 #include "media/base/decoder_buffer.h" 13 #include "media/base/decoder_buffer.h"
14 #include "media/base/decrypt_config.h" 14 #include "media/base/decrypt_config.h"
15 #include "media/base/mock_filters.h" 15 #include "media/base/mock_filters.h"
16 #include "media/cdm/aes_decryptor.h" 16 #include "media/cdm/aes_decryptor.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 using ::testing::_; 20 using ::testing::_;
21 using ::testing::Gt; 21 using ::testing::Gt;
22 using ::testing::IsNull; 22 using ::testing::IsNull;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 void OnReject(PromiseResult expected_result, 252 void OnReject(PromiseResult expected_result,
253 MediaKeys::Exception exception_code, 253 MediaKeys::Exception exception_code,
254 uint32 system_code, 254 uint32 system_code,
255 const std::string& error_message) { 255 const std::string& error_message) {
256 EXPECT_EQ(expected_result, REJECTED) << "Unexpectedly rejected."; 256 EXPECT_EQ(expected_result, REJECTED) << "Unexpectedly rejected.";
257 } 257 }
258 258
259 scoped_ptr<SimpleCdmPromise> CreatePromise(PromiseResult expected_result) { 259 scoped_ptr<SimpleCdmPromise> CreatePromise(PromiseResult expected_result) {
260 scoped_ptr<SimpleCdmPromise> promise( 260 scoped_ptr<SimpleCdmPromise> promise(
261 new SimpleCdmPromise(base::Bind(&AesDecryptorTest::OnResolve, 261 new CdmCallbackPromise<>(base::Bind(&AesDecryptorTest::OnResolve,
262 base::Unretained(this), 262 base::Unretained(this),
263 expected_result), 263 expected_result),
264 base::Bind(&AesDecryptorTest::OnReject, 264 base::Bind(&AesDecryptorTest::OnReject,
265 base::Unretained(this), 265 base::Unretained(this),
266 expected_result))); 266 expected_result)));
267 return promise.Pass(); 267 return promise.Pass();
268 } 268 }
269 269
270 scoped_ptr<NewSessionCdmPromise> CreateSessionPromise( 270 scoped_ptr<NewSessionCdmPromise> CreateSessionPromise(
271 PromiseResult expected_result) { 271 PromiseResult expected_result) {
272 scoped_ptr<NewSessionCdmPromise> promise(new NewSessionCdmPromise( 272 scoped_ptr<NewSessionCdmPromise> promise(
273 base::Bind(&AesDecryptorTest::OnResolveWithSession, 273 new CdmCallbackPromise<std::string>(
274 base::Unretained(this), 274 base::Bind(&AesDecryptorTest::OnResolveWithSession,
275 expected_result), 275 base::Unretained(this),
276 base::Bind(&AesDecryptorTest::OnReject, 276 expected_result),
277 base::Unretained(this), 277 base::Bind(&AesDecryptorTest::OnReject,
278 expected_result))); 278 base::Unretained(this),
279 expected_result)));
279 return promise.Pass(); 280 return promise.Pass();
280 } 281 }
281 282
282 scoped_ptr<KeyIdsPromise> CreateUsableKeyIdsPromise( 283 scoped_ptr<KeyIdsPromise> CreateUsableKeyIdsPromise(
283 PromiseResult expected_result, 284 PromiseResult expected_result,
284 uint32 expected_count) { 285 uint32 expected_count) {
285 scoped_ptr<KeyIdsPromise> promise(new KeyIdsPromise( 286 scoped_ptr<KeyIdsPromise> promise(new CdmCallbackPromise<KeyIdsVector>(
286 base::Bind(&AesDecryptorTest::OnResolveWithUsableKeyIds, 287 base::Bind(&AesDecryptorTest::OnResolveWithUsableKeyIds,
287 base::Unretained(this), 288 base::Unretained(this),
288 expected_result, 289 expected_result,
289 expected_count), 290 expected_count),
290 base::Bind(&AesDecryptorTest::OnReject, 291 base::Bind(&AesDecryptorTest::OnReject,
291 base::Unretained(this), 292 base::Unretained(this),
292 expected_result))); 293 expected_result)));
293 return promise.Pass(); 294 return promise.Pass();
294 } 295 }
295 296
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 EXPECT_FALSE(UsableKeyIdsContains(key_id2)); 895 EXPECT_FALSE(UsableKeyIdsContains(key_id2));
895 896
896 // Add second key, verify both IDs returned. 897 // Add second key, verify both IDs returned.
897 UpdateSessionAndExpect(session_id, kKey2AsJWK, RESOLVED); 898 UpdateSessionAndExpect(session_id, kKey2AsJWK, RESOLVED);
898 GetUsableKeyIdsAndExpect(session_id, RESOLVED, 2); 899 GetUsableKeyIdsAndExpect(session_id, RESOLVED, 2);
899 EXPECT_TRUE(UsableKeyIdsContains(key_id1)); 900 EXPECT_TRUE(UsableKeyIdsContains(key_id1));
900 EXPECT_TRUE(UsableKeyIdsContains(key_id2)); 901 EXPECT_TRUE(UsableKeyIdsContains(key_id2));
901 } 902 }
902 903
903 } // namespace media 904 } // namespace media
OLDNEW
« no previous file with comments | « media/base/media_keys.h ('k') | media/cdm/ppapi/external_clear_key/clear_key_cdm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698