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

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: fix Win compile issue 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
« no previous file with comments | « media/cdm/cdm_adapter.cc ('k') | media/cdm/cdm_file_io.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 "media/cdm/cdm_adapter.h"
6
5 #include <stdint.h> 7 #include <stdint.h>
8 #include <memory>
6 9
7 #include "base/bind.h" 10 #include "base/bind.h"
8 #include "base/logging.h" 11 #include "base/logging.h"
9 #include "base/macros.h" 12 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
11 #include "base/run_loop.h" 14 #include "base/run_loop.h"
12 #include "media/base/cdm_callback_promise.h" 15 #include "media/base/cdm_callback_promise.h"
13 #include "media/base/cdm_key_information.h" 16 #include "media/base/cdm_key_information.h"
14 #include "media/base/media_keys.h" 17 #include "media/base/media_keys.h"
15 #include "media/cdm/cdm_adapter.h" 18 #include "media/cdm/cdm_file_io.h"
16 #include "media/cdm/external_clear_key_test_helper.h" 19 #include "media/cdm/external_clear_key_test_helper.h"
17 #include "media/cdm/simple_cdm_allocator.h" 20 #include "media/cdm/simple_cdm_allocator.h"
18 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
20 23
21 using ::testing::_; 24 using ::testing::_;
22 using ::testing::SaveArg; 25 using ::testing::SaveArg;
23 MATCHER(IsNotEmpty, "") { 26 MATCHER(IsNotEmpty, "") {
24 return !arg.empty(); 27 return !arg.empty();
25 } 28 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 CdmAdapterTest() {} 78 CdmAdapterTest() {}
76 ~CdmAdapterTest() override {} 79 ~CdmAdapterTest() override {}
77 80
78 protected: 81 protected:
79 // Initializes the adapter. |expected_result| tests that the call succeeds 82 // Initializes the adapter. |expected_result| tests that the call succeeds
80 // or generates an error. 83 // or generates an error.
81 void InitializeAndExpect(base::FilePath library_path, 84 void InitializeAndExpect(base::FilePath library_path,
82 ExpectedResult expected_result) { 85 ExpectedResult expected_result) {
83 CdmConfig cdm_config; // default settings of false are sufficient. 86 CdmConfig cdm_config; // default settings of false are sufficient.
84 scoped_ptr<CdmAllocator> allocator(new SimpleCdmAllocator()); 87 scoped_ptr<CdmAllocator> allocator(new SimpleCdmAllocator());
85
86 CdmAdapter::Create( 88 CdmAdapter::Create(
87 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)),
88 base::Bind(&CdmAdapterTest::OnSessionMessage, base::Unretained(this)), 91 base::Bind(&CdmAdapterTest::OnSessionMessage, base::Unretained(this)),
89 base::Bind(&CdmAdapterTest::OnSessionClosed, base::Unretained(this)), 92 base::Bind(&CdmAdapterTest::OnSessionClosed, base::Unretained(this)),
90 base::Bind(&CdmAdapterTest::OnLegacySessionError, 93 base::Bind(&CdmAdapterTest::OnLegacySessionError,
91 base::Unretained(this)), 94 base::Unretained(this)),
92 base::Bind(&CdmAdapterTest::OnSessionKeysChange, 95 base::Bind(&CdmAdapterTest::OnSessionKeysChange,
93 base::Unretained(this)), 96 base::Unretained(this)),
94 base::Bind(&CdmAdapterTest::OnSessionExpirationUpdate, 97 base::Bind(&CdmAdapterTest::OnSessionExpirationUpdate,
95 base::Unretained(this)), 98 base::Unretained(this)),
96 base::Bind(&CdmAdapterTest::OnCdmCreated, base::Unretained(this), 99 base::Bind(&CdmAdapterTest::OnCdmCreated, base::Unretained(this),
97 expected_result)); 100 expected_result));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 scoped_ptr<NewSessionCdmPromise> promise( 199 scoped_ptr<NewSessionCdmPromise> promise(
197 new CdmCallbackPromise<std::string>( 200 new CdmCallbackPromise<std::string>(
198 base::Bind(&CdmAdapterTest::OnResolveWithSession, 201 base::Bind(&CdmAdapterTest::OnResolveWithSession,
199 base::Unretained(this)), 202 base::Unretained(this)),
200 base::Bind(&CdmAdapterTest::OnReject, base::Unretained(this)))); 203 base::Bind(&CdmAdapterTest::OnReject, base::Unretained(this))));
201 return promise; 204 return promise;
202 } 205 }
203 206
204 void RunUntilIdle() { message_loop_.RunUntilIdle(); } 207 void RunUntilIdle() { message_loop_.RunUntilIdle(); }
205 208
209 std::unique_ptr<CdmFileIO> CreateCdmFileIO(cdm::FileIOClient* client) {
210 ADD_FAILURE() << "Should never be called";
211 return nullptr;
212 }
213
206 // Methods used for promise resolved/rejected. 214 // Methods used for promise resolved/rejected.
207 MOCK_METHOD0(OnResolve, void()); 215 MOCK_METHOD0(OnResolve, void());
208 MOCK_METHOD1(OnResolveWithSession, void(const std::string& session_id)); 216 MOCK_METHOD1(OnResolveWithSession, void(const std::string& session_id));
209 MOCK_METHOD3(OnReject, 217 MOCK_METHOD3(OnReject,
210 void(MediaKeys::Exception exception_code, 218 void(MediaKeys::Exception exception_code,
211 uint32_t system_code, 219 uint32_t system_code,
212 const std::string& error_message)); 220 const std::string& error_message));
213 221
214 // Methods used for the events possibly generated by CdmAdapater. 222 // Methods used for the events possibly generated by CdmAdapater.
215 MOCK_METHOD4(OnSessionMessage, 223 MOCK_METHOD4(OnSessionMessage,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) { 323 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) {
316 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); 324 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS);
317 325
318 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId)); 326 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId));
319 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS); 327 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS);
320 328
321 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true); 329 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true);
322 } 330 }
323 331
324 } // namespace media 332 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/cdm_adapter.cc ('k') | media/cdm/cdm_file_io.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698