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

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

Issue 1888603002: Add CdmFileIOProvider interface for use by cdm_adapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "media/base/cdm_callback_promise.h" 12 #include "media/base/cdm_callback_promise.h"
13 #include "media/base/cdm_key_information.h" 13 #include "media/base/cdm_key_information.h"
14 #include "media/base/media_keys.h" 14 #include "media/base/media_keys.h"
15 #include "media/cdm/cdm_adapter.h" 15 #include "media/cdm/cdm_adapter.h"
16 #include "media/cdm/external_clear_key_test_helper.h" 16 #include "media/cdm/external_clear_key_test_helper.h"
17 #include "media/cdm/simple_cdm_allocator.h" 17 #include "media/cdm/simple_cdm_allocator.h"
18 #include "media/cdm/simple_cdm_file_io_provider.h"
18 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 using ::testing::_; 22 using ::testing::_;
22 using ::testing::SaveArg; 23 using ::testing::SaveArg;
23 MATCHER(IsNotEmpty, "") { 24 MATCHER(IsNotEmpty, "") {
24 return !arg.empty(); 25 return !arg.empty();
25 } 26 }
26 27
27 // TODO(jrummell): These tests are a subset of those in aes_decryptor_unittest. 28 // TODO(jrummell): These tests are a subset of those in aes_decryptor_unittest.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 CdmAdapterTest() {} 76 CdmAdapterTest() {}
76 ~CdmAdapterTest() override {} 77 ~CdmAdapterTest() override {}
77 78
78 protected: 79 protected:
79 // Initializes the adapter. |expected_result| tests that the call succeeds 80 // Initializes the adapter. |expected_result| tests that the call succeeds
80 // or generates an error. 81 // or generates an error.
81 void InitializeAndExpect(base::FilePath library_path, 82 void InitializeAndExpect(base::FilePath library_path,
82 ExpectedResult expected_result) { 83 ExpectedResult expected_result) {
83 CdmConfig cdm_config; // default settings of false are sufficient. 84 CdmConfig cdm_config; // default settings of false are sufficient.
84 scoped_ptr<CdmAllocator> allocator(new SimpleCdmAllocator()); 85 scoped_ptr<CdmAllocator> allocator(new SimpleCdmAllocator());
85 86 scoped_ptr<CdmFileIOProvider> provider(new SimpleCdmFileIOProvider());
86 CdmAdapter::Create( 87 CdmAdapter::Create(
87 helper_.KeySystemName(), library_path, cdm_config, std::move(allocator), 88 helper_.KeySystemName(), library_path, cdm_config, std::move(allocator),
89 std::move(provider),
88 base::Bind(&CdmAdapterTest::OnSessionMessage, base::Unretained(this)), 90 base::Bind(&CdmAdapterTest::OnSessionMessage, base::Unretained(this)),
89 base::Bind(&CdmAdapterTest::OnSessionClosed, base::Unretained(this)), 91 base::Bind(&CdmAdapterTest::OnSessionClosed, base::Unretained(this)),
90 base::Bind(&CdmAdapterTest::OnLegacySessionError, 92 base::Bind(&CdmAdapterTest::OnLegacySessionError,
91 base::Unretained(this)), 93 base::Unretained(this)),
92 base::Bind(&CdmAdapterTest::OnSessionKeysChange, 94 base::Bind(&CdmAdapterTest::OnSessionKeysChange,
93 base::Unretained(this)), 95 base::Unretained(this)),
94 base::Bind(&CdmAdapterTest::OnSessionExpirationUpdate, 96 base::Bind(&CdmAdapterTest::OnSessionExpirationUpdate,
95 base::Unretained(this)), 97 base::Unretained(this)),
96 base::Bind(&CdmAdapterTest::OnCdmCreated, base::Unretained(this), 98 base::Bind(&CdmAdapterTest::OnCdmCreated, base::Unretained(this),
97 expected_result)); 99 expected_result));
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) { 317 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) {
316 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); 318 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS);
317 319
318 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId)); 320 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId));
319 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS); 321 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS);
320 322
321 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true); 323 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true);
322 } 324 }
323 325
324 } // namespace media 326 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698