| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 60 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 61 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, | 61 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 } // namespace | 64 } // namespace |
| 65 | 65 |
| 66 class MojoCdmTest : public ::testing::Test { | 66 class MojoCdmTest : public ::testing::Test { |
| 67 public: | 67 public: |
| 68 enum ExpectedResult { | 68 enum ExpectedResult { |
| 69 SUCCESS, | 69 SUCCESS, |
| 70 CONNECTION_ERROR_BEFORE, | 70 FAILURE, // Operation fails immediately. |
| 71 CONNECTION_ERROR_DURING, | 71 PENDING, // Operation never completes. |
| 72 FAILURE | 72 CONNECTION_ERROR_BEFORE, // Connection error happened before operation. |
| 73 CONNECTION_ERROR_DURING, // Connection error happens during operation. |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 MojoCdmTest() | 76 MojoCdmTest() |
| 76 : mojo_cdm_service_(base::MakeUnique<MojoCdmService>( | 77 : mojo_cdm_service_(base::MakeUnique<MojoCdmService>( |
| 77 mojo_cdm_service_context_.GetWeakPtr(), | 78 mojo_cdm_service_context_.GetWeakPtr(), |
| 78 &cdm_factory_)), | 79 &cdm_factory_)), |
| 79 cdm_binding_(mojo_cdm_service_.get()) {} | 80 cdm_binding_(mojo_cdm_service_.get()) {} |
| 80 | 81 |
| 81 virtual ~MojoCdmTest() {} | 82 virtual ~MojoCdmTest() {} |
| 82 | 83 |
| 83 void Initialize(ExpectedResult expected_result) { | 84 void Initialize(ExpectedResult expected_result) { |
| 85 // TODO(xhwang): Add pending init support. |
| 86 DCHECK_NE(PENDING, expected_result); |
| 87 |
| 84 mojom::ContentDecryptionModulePtr remote_cdm; | 88 mojom::ContentDecryptionModulePtr remote_cdm; |
| 85 auto cdm_request = mojo::MakeRequest(&remote_cdm); | 89 auto cdm_request = mojo::MakeRequest(&remote_cdm); |
| 86 | 90 |
| 87 cdm_binding_.Bind(std::move(cdm_request)); | 91 cdm_binding_.Bind(std::move(cdm_request)); |
| 88 | 92 |
| 89 std::string key_system; | 93 std::string key_system; |
| 90 if (expected_result == CONNECTION_ERROR_BEFORE) { | 94 if (expected_result == CONNECTION_ERROR_BEFORE) { |
| 91 // Break the connection before the call. | 95 // Break the connection before the call. |
| 92 ForceConnectionError(); | 96 ForceConnectionError(); |
| 93 } else if (expected_result != FAILURE) { | 97 } else if (expected_result != FAILURE) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 mojo_cdm_->CreateSessionAndGenerateRequest( | 184 mojo_cdm_->CreateSessionAndGenerateRequest( |
| 181 session_type, data_type, key_id, | 185 session_type, data_type, key_id, |
| 182 base::MakeUnique<MockCdmSessionPromise>(expected_result == SUCCESS, | 186 base::MakeUnique<MockCdmSessionPromise>(expected_result == SUCCESS, |
| 183 &created_session_id)); | 187 &created_session_id)); |
| 184 base::RunLoop().RunUntilIdle(); | 188 base::RunLoop().RunUntilIdle(); |
| 185 | 189 |
| 186 // If the session was "created" ... | 190 // If the session was "created" ... |
| 187 if (expected_result == SUCCESS) { | 191 if (expected_result == SUCCESS) { |
| 188 // Returned session ID must match the session ID provided. | 192 // Returned session ID must match the session ID provided. |
| 189 EXPECT_EQ(session_id, created_session_id); | 193 EXPECT_EQ(session_id, created_session_id); |
| 190 | |
| 191 // MojoCdm expects the session to be closed, so invoke SessionClosedCB | |
| 192 // to "close" it. | |
| 193 EXPECT_CALL(cdm_client_, OnSessionClosed(session_id)); | |
| 194 remote_cdm_->CallSessionClosedCB(session_id); | |
| 195 base::RunLoop().RunUntilIdle(); | 194 base::RunLoop().RunUntilIdle(); |
| 196 } | 195 } |
| 197 } | 196 } |
| 198 | 197 |
| 199 void LoadSessionAndExpect(const std::string& session_id, | 198 void LoadSessionAndExpect(const std::string& session_id, |
| 200 ExpectedResult expected_result) { | 199 ExpectedResult expected_result) { |
| 201 const CdmSessionType session_type = | 200 const CdmSessionType session_type = |
| 202 CdmSessionType::PERSISTENT_LICENSE_SESSION; | 201 CdmSessionType::PERSISTENT_LICENSE_SESSION; |
| 203 std::string loaded_session_id; | 202 std::string loaded_session_id; |
| 204 | 203 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 switch (expected_result) { | 290 switch (expected_result) { |
| 292 case SUCCESS: | 291 case SUCCESS: |
| 293 promise->resolve(); | 292 promise->resolve(); |
| 294 break; | 293 break; |
| 295 | 294 |
| 296 case FAILURE: | 295 case FAILURE: |
| 297 promise->reject(media::CdmPromise::UNKNOWN_ERROR, 0, | 296 promise->reject(media::CdmPromise::UNKNOWN_ERROR, 0, |
| 298 "Promise rejected"); | 297 "Promise rejected"); |
| 299 break; | 298 break; |
| 300 | 299 |
| 300 case PENDING: |
| 301 // Store the promise and never fulfill it. |
| 302 pending_simple_cdm_promise_ = std::move(promise); |
| 303 break; |
| 304 |
| 301 case CONNECTION_ERROR_BEFORE: | 305 case CONNECTION_ERROR_BEFORE: |
| 302 // Connection should be broken before this is called. | 306 // Connection should be broken before this is called. |
| 303 NOTREACHED(); | 307 NOTREACHED(); |
| 304 break; | 308 break; |
| 305 | 309 |
| 306 case CONNECTION_ERROR_DURING: | 310 case CONNECTION_ERROR_DURING: |
| 307 ForceConnectionError(); | 311 ForceConnectionError(); |
| 308 | 312 |
| 309 // Now that the connection is broken the promise result won't be passed | 313 // Now that the connection is broken the promise result won't be passed |
| 310 // back. However, since we check that every promise is fulfilled, we | 314 // back. However, since we check that every promise is fulfilled, we |
| (...skipping 11 matching lines...) Expand all Loading... |
| 322 switch (expected_result) { | 326 switch (expected_result) { |
| 323 case SUCCESS: | 327 case SUCCESS: |
| 324 promise->resolve(session_id); | 328 promise->resolve(session_id); |
| 325 break; | 329 break; |
| 326 | 330 |
| 327 case FAILURE: | 331 case FAILURE: |
| 328 promise->reject(media::CdmPromise::UNKNOWN_ERROR, 0, | 332 promise->reject(media::CdmPromise::UNKNOWN_ERROR, 0, |
| 329 "Promise rejected"); | 333 "Promise rejected"); |
| 330 break; | 334 break; |
| 331 | 335 |
| 336 case PENDING: |
| 337 // Store the promise and never fulfill it. |
| 338 pending_new_session_cdm_promise_ = std::move(promise); |
| 339 break; |
| 340 |
| 332 case CONNECTION_ERROR_BEFORE: | 341 case CONNECTION_ERROR_BEFORE: |
| 333 // Connection should be broken before this is called. | 342 // Connection should be broken before this is called. |
| 334 NOTREACHED(); | 343 NOTREACHED(); |
| 335 break; | 344 break; |
| 336 | 345 |
| 337 case CONNECTION_ERROR_DURING: | 346 case CONNECTION_ERROR_DURING: |
| 338 ForceConnectionError(); | 347 ForceConnectionError(); |
| 339 | 348 |
| 340 // Now that the connection is broken the promise result won't be passed | 349 // Now that the connection is broken the promise result won't be passed |
| 341 // back. However, since we check that every promise is fulfilled, we | 350 // back. However, since we check that every promise is fulfilled, we |
| 342 // need to do something with this promise. Resolve the promise to | 351 // need to do something with this promise. Resolve the promise to |
| 343 // fulfill it, but note that the original caller will get back a | 352 // fulfill it, but note that the original caller will get back a |
| 344 // failed promise due to the connection being broken. | 353 // failed promise due to the connection being broken. |
| 345 promise->resolve(session_id); | 354 promise->resolve(session_id); |
| 346 break; | 355 break; |
| 347 } | 356 } |
| 348 } | 357 } |
| 349 | 358 |
| 350 // Fixture members. | 359 // Fixture members. |
| 351 base::TestMessageLoop message_loop_; | 360 base::TestMessageLoop message_loop_; |
| 352 | 361 |
| 353 // |remote_cdm_| represents the CDM at the end of the mojo message pipe. | 362 // |remote_cdm_| represents the CDM at the end of the mojo message pipe. |
| 354 MockCdm* remote_cdm_; | 363 MockCdm* remote_cdm_; |
| 355 MockCdmFactory cdm_factory_; | 364 MockCdmFactory cdm_factory_; |
| 356 | 365 |
| 357 MojoCdmServiceContext mojo_cdm_service_context_; | 366 MojoCdmServiceContext mojo_cdm_service_context_; |
| 358 StrictMock<MockCdmClient> cdm_client_; | 367 StrictMock<MockCdmClient> cdm_client_; |
| 359 | 368 |
| 369 // Declared before |mojo_cdm_| so they are destroyed after it. |
| 370 std::unique_ptr<SimpleCdmPromise> pending_simple_cdm_promise_; |
| 371 std::unique_ptr<NewSessionCdmPromise> pending_new_session_cdm_promise_; |
| 372 |
| 360 std::unique_ptr<MojoCdmService> mojo_cdm_service_; | 373 std::unique_ptr<MojoCdmService> mojo_cdm_service_; |
| 361 mojo::Binding<mojom::ContentDecryptionModule> cdm_binding_; | 374 mojo::Binding<mojom::ContentDecryptionModule> cdm_binding_; |
| 362 scoped_refptr<ContentDecryptionModule> mojo_cdm_; | 375 scoped_refptr<ContentDecryptionModule> mojo_cdm_; |
| 363 | 376 |
| 364 private: | 377 private: |
| 365 DISALLOW_COPY_AND_ASSIGN(MojoCdmTest); | 378 DISALLOW_COPY_AND_ASSIGN(MojoCdmTest); |
| 366 }; | 379 }; |
| 367 | 380 |
| 368 TEST_F(MojoCdmTest, Create_Success) { | 381 TEST_F(MojoCdmTest, Create_Success) { |
| 369 Initialize(SUCCESS); | 382 Initialize(SUCCESS); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 386 Initialize(SUCCESS); | 399 Initialize(SUCCESS); |
| 387 SetServerCertificateAndExpect(certificate, SUCCESS); | 400 SetServerCertificateAndExpect(certificate, SUCCESS); |
| 388 } | 401 } |
| 389 | 402 |
| 390 TEST_F(MojoCdmTest, SetServerCertificate_Failure) { | 403 TEST_F(MojoCdmTest, SetServerCertificate_Failure) { |
| 391 const std::vector<uint8_t> certificate = {1, 2, 3, 4, 5}; | 404 const std::vector<uint8_t> certificate = {1, 2, 3, 4, 5}; |
| 392 Initialize(SUCCESS); | 405 Initialize(SUCCESS); |
| 393 SetServerCertificateAndExpect(certificate, FAILURE); | 406 SetServerCertificateAndExpect(certificate, FAILURE); |
| 394 } | 407 } |
| 395 | 408 |
| 409 TEST_F(MojoCdmTest, SetServerCertificate_Pending) { |
| 410 const std::vector<uint8_t> certificate = {1, 2, 3, 4, 5}; |
| 411 Initialize(SUCCESS); |
| 412 SetServerCertificateAndExpect(certificate, PENDING); |
| 413 } |
| 414 |
| 396 TEST_F(MojoCdmTest, SetServerCertificate_ConnectionErrorBefore) { | 415 TEST_F(MojoCdmTest, SetServerCertificate_ConnectionErrorBefore) { |
| 397 const std::vector<uint8_t> certificate = {3, 4}; | 416 const std::vector<uint8_t> certificate = {3, 4}; |
| 398 Initialize(SUCCESS); | 417 Initialize(SUCCESS); |
| 399 SetServerCertificateAndExpect(certificate, CONNECTION_ERROR_BEFORE); | 418 SetServerCertificateAndExpect(certificate, CONNECTION_ERROR_BEFORE); |
| 400 } | 419 } |
| 401 | 420 |
| 402 TEST_F(MojoCdmTest, SetServerCertificate_ConnectionErrorDuring) { | 421 TEST_F(MojoCdmTest, SetServerCertificate_ConnectionErrorDuring) { |
| 403 const std::vector<uint8_t> certificate = {10, 11, 12}; | 422 const std::vector<uint8_t> certificate = {10, 11, 12}; |
| 404 Initialize(SUCCESS); | 423 Initialize(SUCCESS); |
| 405 SetServerCertificateAndExpect(certificate, CONNECTION_ERROR_DURING); | 424 SetServerCertificateAndExpect(certificate, CONNECTION_ERROR_DURING); |
| 406 } | 425 } |
| 407 | 426 |
| 408 TEST_F(MojoCdmTest, CreateSession_Success) { | 427 TEST_F(MojoCdmTest, CreateSession_Success) { |
| 409 const std::string session_id = "create1"; | 428 const std::string session_id = "create1"; |
| 410 Initialize(SUCCESS); | 429 Initialize(SUCCESS); |
| 411 CreateSessionAndExpect(session_id, SUCCESS); | 430 CreateSessionAndExpect(session_id, SUCCESS); |
| 431 |
| 432 // Created session should always be closed! |
| 433 EXPECT_CALL(cdm_client_, OnSessionClosed(session_id)); |
| 412 } | 434 } |
| 413 | 435 |
| 414 TEST_F(MojoCdmTest, CreateSession_Failure) { | 436 TEST_F(MojoCdmTest, CreateSession_Failure) { |
| 415 const std::string session_id = "create2"; | 437 const std::string session_id = "create2"; |
| 416 Initialize(SUCCESS); | 438 Initialize(SUCCESS); |
| 417 CreateSessionAndExpect(session_id, FAILURE); | 439 CreateSessionAndExpect(session_id, FAILURE); |
| 418 } | 440 } |
| 419 | 441 |
| 442 TEST_F(MojoCdmTest, CreateSession_Pending) { |
| 443 const std::string session_id = "create2"; |
| 444 Initialize(SUCCESS); |
| 445 CreateSessionAndExpect(session_id, PENDING); |
| 446 } |
| 447 |
| 420 TEST_F(MojoCdmTest, CreateSession_ConnectionErrorBefore) { | 448 TEST_F(MojoCdmTest, CreateSession_ConnectionErrorBefore) { |
| 421 const std::string session_id = "create3"; | 449 const std::string session_id = "create3"; |
| 422 Initialize(SUCCESS); | 450 Initialize(SUCCESS); |
| 423 CreateSessionAndExpect(session_id, CONNECTION_ERROR_BEFORE); | 451 CreateSessionAndExpect(session_id, CONNECTION_ERROR_BEFORE); |
| 424 } | 452 } |
| 425 | 453 |
| 426 TEST_F(MojoCdmTest, CreateSession_ConnectionErrorDuring) { | 454 TEST_F(MojoCdmTest, CreateSession_ConnectionErrorDuring) { |
| 427 const std::string session_id = "create4"; | 455 const std::string session_id = "create4"; |
| 428 Initialize(SUCCESS); | 456 Initialize(SUCCESS); |
| 429 CreateSessionAndExpect(session_id, CONNECTION_ERROR_DURING); | 457 CreateSessionAndExpect(session_id, CONNECTION_ERROR_DURING); |
| 430 } | 458 } |
| 431 | 459 |
| 432 TEST_F(MojoCdmTest, LoadSession_Success) { | 460 TEST_F(MojoCdmTest, LoadSession_Success) { |
| 433 const std::string session_id = "load1"; | 461 const std::string session_id = "load1"; |
| 434 Initialize(SUCCESS); | 462 Initialize(SUCCESS); |
| 435 LoadSessionAndExpect(session_id, SUCCESS); | 463 LoadSessionAndExpect(session_id, SUCCESS); |
| 436 } | 464 } |
| 437 | 465 |
| 438 TEST_F(MojoCdmTest, LoadSession_Failure) { | 466 TEST_F(MojoCdmTest, LoadSession_Failure) { |
| 439 const std::string session_id = "load2"; | 467 const std::string session_id = "load2"; |
| 440 Initialize(SUCCESS); | 468 Initialize(SUCCESS); |
| 441 LoadSessionAndExpect(session_id, FAILURE); | 469 LoadSessionAndExpect(session_id, FAILURE); |
| 442 } | 470 } |
| 443 | 471 |
| 472 TEST_F(MojoCdmTest, LoadSession_Pending) { |
| 473 const std::string session_id = "load2"; |
| 474 Initialize(SUCCESS); |
| 475 LoadSessionAndExpect(session_id, PENDING); |
| 476 } |
| 477 |
| 444 TEST_F(MojoCdmTest, LoadSession_ConnectionErrorBefore) { | 478 TEST_F(MojoCdmTest, LoadSession_ConnectionErrorBefore) { |
| 445 const std::string session_id = "load3"; | 479 const std::string session_id = "load3"; |
| 446 Initialize(SUCCESS); | 480 Initialize(SUCCESS); |
| 447 LoadSessionAndExpect(session_id, CONNECTION_ERROR_BEFORE); | 481 LoadSessionAndExpect(session_id, CONNECTION_ERROR_BEFORE); |
| 448 } | 482 } |
| 449 | 483 |
| 450 TEST_F(MojoCdmTest, LoadSession_ConnectionErrorDuring) { | 484 TEST_F(MojoCdmTest, LoadSession_ConnectionErrorDuring) { |
| 451 const std::string session_id = "load4"; | 485 const std::string session_id = "load4"; |
| 452 Initialize(SUCCESS); | 486 Initialize(SUCCESS); |
| 453 LoadSessionAndExpect(session_id, CONNECTION_ERROR_DURING); | 487 LoadSessionAndExpect(session_id, CONNECTION_ERROR_DURING); |
| 454 } | 488 } |
| 455 | 489 |
| 456 TEST_F(MojoCdmTest, UpdateSession_Success) { | 490 TEST_F(MojoCdmTest, UpdateSession_Success) { |
| 457 const std::string session_id = "update1"; | 491 const std::string session_id = "update1"; |
| 458 Initialize(SUCCESS); | 492 Initialize(SUCCESS); |
| 459 UpdateSessionAndExpect(session_id, SUCCESS); | 493 UpdateSessionAndExpect(session_id, SUCCESS); |
| 460 } | 494 } |
| 461 | 495 |
| 462 TEST_F(MojoCdmTest, UpdateSession_Failure) { | 496 TEST_F(MojoCdmTest, UpdateSession_Failure) { |
| 463 const std::string session_id = "update2"; | 497 const std::string session_id = "update2"; |
| 464 Initialize(SUCCESS); | 498 Initialize(SUCCESS); |
| 465 UpdateSessionAndExpect(session_id, FAILURE); | 499 UpdateSessionAndExpect(session_id, FAILURE); |
| 466 } | 500 } |
| 467 | 501 |
| 502 TEST_F(MojoCdmTest, UpdateSession_Pending) { |
| 503 const std::string session_id = "update2"; |
| 504 Initialize(SUCCESS); |
| 505 UpdateSessionAndExpect(session_id, PENDING); |
| 506 } |
| 507 |
| 468 TEST_F(MojoCdmTest, UpdateSession_ConnectionErrorBefore) { | 508 TEST_F(MojoCdmTest, UpdateSession_ConnectionErrorBefore) { |
| 469 const std::string session_id = "update3"; | 509 const std::string session_id = "update3"; |
| 470 Initialize(SUCCESS); | 510 Initialize(SUCCESS); |
| 471 UpdateSessionAndExpect(session_id, CONNECTION_ERROR_BEFORE); | 511 UpdateSessionAndExpect(session_id, CONNECTION_ERROR_BEFORE); |
| 472 } | 512 } |
| 473 | 513 |
| 474 TEST_F(MojoCdmTest, UpdateSession_ConnectionErrorDuring) { | 514 TEST_F(MojoCdmTest, UpdateSession_ConnectionErrorDuring) { |
| 475 const std::string session_id = "update4"; | 515 const std::string session_id = "update4"; |
| 476 Initialize(SUCCESS); | 516 Initialize(SUCCESS); |
| 477 UpdateSessionAndExpect(session_id, CONNECTION_ERROR_DURING); | 517 UpdateSessionAndExpect(session_id, CONNECTION_ERROR_DURING); |
| 478 } | 518 } |
| 479 | 519 |
| 480 TEST_F(MojoCdmTest, CloseSession_Success) { | 520 TEST_F(MojoCdmTest, CloseSession_Success) { |
| 481 const std::string session_id = "close1"; | 521 const std::string session_id = "close1"; |
| 482 Initialize(SUCCESS); | 522 Initialize(SUCCESS); |
| 483 CloseSessionAndExpect(session_id, SUCCESS); | 523 CloseSessionAndExpect(session_id, SUCCESS); |
| 484 } | 524 } |
| 485 | 525 |
| 486 TEST_F(MojoCdmTest, CloseSession_Failure) { | 526 TEST_F(MojoCdmTest, CloseSession_Failure) { |
| 487 const std::string session_id = "close2"; | 527 const std::string session_id = "close2"; |
| 488 Initialize(SUCCESS); | 528 Initialize(SUCCESS); |
| 489 CloseSessionAndExpect(session_id, FAILURE); | 529 CloseSessionAndExpect(session_id, FAILURE); |
| 490 } | 530 } |
| 491 | 531 |
| 532 TEST_F(MojoCdmTest, CloseSession_Pending) { |
| 533 const std::string session_id = "close2"; |
| 534 Initialize(SUCCESS); |
| 535 CloseSessionAndExpect(session_id, PENDING); |
| 536 } |
| 537 |
| 492 TEST_F(MojoCdmTest, CloseSession_ConnectionErrorBefore) { | 538 TEST_F(MojoCdmTest, CloseSession_ConnectionErrorBefore) { |
| 493 const std::string session_id = "close3"; | 539 const std::string session_id = "close3"; |
| 494 Initialize(SUCCESS); | 540 Initialize(SUCCESS); |
| 495 CloseSessionAndExpect(session_id, CONNECTION_ERROR_BEFORE); | 541 CloseSessionAndExpect(session_id, CONNECTION_ERROR_BEFORE); |
| 496 } | 542 } |
| 497 | 543 |
| 498 TEST_F(MojoCdmTest, CloseSession_ConnectionErrorDuring) { | 544 TEST_F(MojoCdmTest, CloseSession_ConnectionErrorDuring) { |
| 499 const std::string session_id = "close4"; | 545 const std::string session_id = "close4"; |
| 500 Initialize(SUCCESS); | 546 Initialize(SUCCESS); |
| 501 CloseSessionAndExpect(session_id, CONNECTION_ERROR_DURING); | 547 CloseSessionAndExpect(session_id, CONNECTION_ERROR_DURING); |
| 502 } | 548 } |
| 503 | 549 |
| 504 TEST_F(MojoCdmTest, RemoveSession_Success) { | 550 TEST_F(MojoCdmTest, RemoveSession_Success) { |
| 505 const std::string session_id = "remove1"; | 551 const std::string session_id = "remove1"; |
| 506 Initialize(SUCCESS); | 552 Initialize(SUCCESS); |
| 507 RemoveSessionAndExpect(session_id, SUCCESS); | 553 RemoveSessionAndExpect(session_id, SUCCESS); |
| 508 } | 554 } |
| 509 | 555 |
| 510 TEST_F(MojoCdmTest, RemoveSession_Failure) { | 556 TEST_F(MojoCdmTest, RemoveSession_Failure) { |
| 511 const std::string session_id = "remove2"; | 557 const std::string session_id = "remove2"; |
| 512 Initialize(SUCCESS); | 558 Initialize(SUCCESS); |
| 513 RemoveSessionAndExpect(session_id, FAILURE); | 559 RemoveSessionAndExpect(session_id, FAILURE); |
| 514 } | 560 } |
| 515 | 561 |
| 562 TEST_F(MojoCdmTest, RemoveSession_Pending) { |
| 563 const std::string session_id = "remove2"; |
| 564 Initialize(SUCCESS); |
| 565 RemoveSessionAndExpect(session_id, PENDING); |
| 566 } |
| 567 |
| 516 TEST_F(MojoCdmTest, RemoveSession_ConnectionErrorBefore) { | 568 TEST_F(MojoCdmTest, RemoveSession_ConnectionErrorBefore) { |
| 517 const std::string session_id = "remove3"; | 569 const std::string session_id = "remove3"; |
| 518 Initialize(SUCCESS); | 570 Initialize(SUCCESS); |
| 519 RemoveSessionAndExpect(session_id, CONNECTION_ERROR_BEFORE); | 571 RemoveSessionAndExpect(session_id, CONNECTION_ERROR_BEFORE); |
| 520 } | 572 } |
| 521 | 573 |
| 522 TEST_F(MojoCdmTest, RemoveSession_ConnectionErrorDuring) { | 574 TEST_F(MojoCdmTest, RemoveSession_ConnectionErrorDuring) { |
| 523 const std::string session_id = "remove4"; | 575 const std::string session_id = "remove4"; |
| 524 Initialize(SUCCESS); | 576 Initialize(SUCCESS); |
| 525 RemoveSessionAndExpect(session_id, CONNECTION_ERROR_DURING); | 577 RemoveSessionAndExpect(session_id, CONNECTION_ERROR_DURING); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 554 CdmKeysInfo keys_info; | 606 CdmKeysInfo keys_info; |
| 555 Initialize(SUCCESS); | 607 Initialize(SUCCESS); |
| 556 EXPECT_CALL(cdm_client_, | 608 EXPECT_CALL(cdm_client_, |
| 557 OnSessionKeysChangeCalled(session_id, has_additional_usable_key)); | 609 OnSessionKeysChangeCalled(session_id, has_additional_usable_key)); |
| 558 remote_cdm_->CallSessionKeysChangeCB(session_id, has_additional_usable_key, | 610 remote_cdm_->CallSessionKeysChangeCB(session_id, has_additional_usable_key, |
| 559 std::move(keys_info)); | 611 std::move(keys_info)); |
| 560 base::RunLoop().RunUntilIdle(); | 612 base::RunLoop().RunUntilIdle(); |
| 561 } | 613 } |
| 562 | 614 |
| 563 } // namespace media | 615 } // namespace media |
| OLD | NEW |