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

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

Issue 1673383002: Add allocator interface for use by cdm_adapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add MEDIA_CDM_EXPORT for Windows Created 4 years, 10 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/cdm/cdm_adapter.cc ('k') | media/cdm/cdm_allocator.h » ('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 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 "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 using ::testing::_; 21 using ::testing::_;
21 using ::testing::SaveArg; 22 using ::testing::SaveArg;
22 MATCHER(IsNotEmpty, "") { 23 MATCHER(IsNotEmpty, "") {
23 return !arg.empty(); 24 return !arg.empty();
24 } 25 }
25 26
26 // TODO(jrummell): These tests are a subset of those in aes_decryptor_unittest. 27 // TODO(jrummell): These tests are a subset of those in aes_decryptor_unittest.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 74
74 CdmAdapterTest() {} 75 CdmAdapterTest() {}
75 ~CdmAdapterTest() override {} 76 ~CdmAdapterTest() override {}
76 77
77 protected: 78 protected:
78 // Initializes the adapter. |expected_result| tests that the call succeeds 79 // Initializes the adapter. |expected_result| tests that the call succeeds
79 // or generates an error. 80 // or generates an error.
80 void InitializeAndExpect(base::FilePath library_path, 81 void InitializeAndExpect(base::FilePath library_path,
81 ExpectedResult expected_result) { 82 ExpectedResult expected_result) {
82 CdmConfig cdm_config; // default settings of false are sufficient. 83 CdmConfig cdm_config; // default settings of false are sufficient.
84 scoped_ptr<CdmAllocator> allocator(new SimpleCdmAllocator());
83 85
84 CdmAdapter::Create( 86 CdmAdapter::Create(
85 helper_.KeySystemName(), library_path, cdm_config, 87 helper_.KeySystemName(), library_path, cdm_config, std::move(allocator),
86 base::Bind(&CdmAdapterTest::OnSessionMessage, base::Unretained(this)), 88 base::Bind(&CdmAdapterTest::OnSessionMessage, base::Unretained(this)),
87 base::Bind(&CdmAdapterTest::OnSessionClosed, base::Unretained(this)), 89 base::Bind(&CdmAdapterTest::OnSessionClosed, base::Unretained(this)),
88 base::Bind(&CdmAdapterTest::OnLegacySessionError, 90 base::Bind(&CdmAdapterTest::OnLegacySessionError,
89 base::Unretained(this)), 91 base::Unretained(this)),
90 base::Bind(&CdmAdapterTest::OnSessionKeysChange, 92 base::Bind(&CdmAdapterTest::OnSessionKeysChange,
91 base::Unretained(this)), 93 base::Unretained(this)),
92 base::Bind(&CdmAdapterTest::OnSessionExpirationUpdate, 94 base::Bind(&CdmAdapterTest::OnSessionExpirationUpdate,
93 base::Unretained(this)), 95 base::Unretained(this)),
94 base::Bind(&CdmAdapterTest::OnCdmCreated, base::Unretained(this), 96 base::Bind(&CdmAdapterTest::OnCdmCreated, base::Unretained(this),
95 expected_result)); 97 expected_result));
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) { 315 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) {
314 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); 316 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS);
315 317
316 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId)); 318 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId));
317 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS); 319 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS);
318 320
319 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true); 321 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true);
320 } 322 }
321 323
322 } // namespace media 324 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/cdm_adapter.cc ('k') | media/cdm/cdm_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698