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

Side by Side Diff: media/test/pipeline_integration_test.cc

Issue 1544313002: Convert Pass()→std::move() in //media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <utility>
7 8
8 #include "base/bind.h" 9 #include "base/bind.h"
9 #include "base/command_line.h" 10 #include "base/command_line.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "build/build_config.h" 16 #include "build/build_config.h"
16 #include "media/base/cdm_callback_promise.h" 17 #include "media/base/cdm_callback_promise.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 230 }
230 231
231 void OnSessionClosed(const std::string& session_id) { 232 void OnSessionClosed(const std::string& session_id) {
232 app_->OnSessionClosed(session_id); 233 app_->OnSessionClosed(session_id);
233 } 234 }
234 235
235 void OnSessionKeysChange(const std::string& session_id, 236 void OnSessionKeysChange(const std::string& session_id,
236 bool has_additional_usable_key, 237 bool has_additional_usable_key,
237 CdmKeysInfo keys_info) { 238 CdmKeysInfo keys_info) {
238 app_->OnSessionKeysChange(session_id, has_additional_usable_key, 239 app_->OnSessionKeysChange(session_id, has_additional_usable_key,
239 keys_info.Pass()); 240 std::move(keys_info));
240 } 241 }
241 242
242 void OnLegacySessionError(const std::string& session_id, 243 void OnLegacySessionError(const std::string& session_id,
243 const std::string& error_name, 244 const std::string& error_name,
244 uint32_t system_code, 245 uint32_t system_code,
245 const std::string& error_message) { 246 const std::string& error_message) {
246 app_->OnLegacySessionError(session_id, error_name, system_code, 247 app_->OnLegacySessionError(session_id, error_name, system_code,
247 error_message); 248 error_message);
248 } 249 }
249 250
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 const std::string& error_message) { 294 const std::string& error_message) {
294 EXPECT_EQ(expected, REJECTED) << error_message; 295 EXPECT_EQ(expected, REJECTED) << error_message;
295 } 296 }
296 297
297 scoped_ptr<SimpleCdmPromise> CreatePromise(PromiseResult expected) { 298 scoped_ptr<SimpleCdmPromise> CreatePromise(PromiseResult expected) {
298 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>( 299 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>(
299 base::Bind( 300 base::Bind(
300 &KeyProvidingApp::OnResolve, base::Unretained(this), expected), 301 &KeyProvidingApp::OnResolve, base::Unretained(this), expected),
301 base::Bind( 302 base::Bind(
302 &KeyProvidingApp::OnReject, base::Unretained(this), expected))); 303 &KeyProvidingApp::OnReject, base::Unretained(this), expected)));
303 return promise.Pass(); 304 return promise;
304 } 305 }
305 306
306 scoped_ptr<NewSessionCdmPromise> CreateSessionPromise( 307 scoped_ptr<NewSessionCdmPromise> CreateSessionPromise(
307 PromiseResult expected) { 308 PromiseResult expected) {
308 scoped_ptr<media::NewSessionCdmPromise> promise( 309 scoped_ptr<media::NewSessionCdmPromise> promise(
309 new media::CdmCallbackPromise<std::string>( 310 new media::CdmCallbackPromise<std::string>(
310 base::Bind(&KeyProvidingApp::OnResolveWithSession, 311 base::Bind(&KeyProvidingApp::OnResolveWithSession,
311 base::Unretained(this), 312 base::Unretained(this),
312 expected), 313 expected),
313 base::Bind( 314 base::Bind(
314 &KeyProvidingApp::OnReject, base::Unretained(this), expected))); 315 &KeyProvidingApp::OnReject, base::Unretained(this), expected)));
315 return promise.Pass(); 316 return promise;
316 } 317 }
317 318
318 void OnSessionMessage(const std::string& session_id, 319 void OnSessionMessage(const std::string& session_id,
319 MediaKeys::MessageType message_type, 320 MediaKeys::MessageType message_type,
320 const std::vector<uint8_t>& message, 321 const std::vector<uint8_t>& message,
321 const GURL& legacy_destination_url, 322 const GURL& legacy_destination_url,
322 AesDecryptor* decryptor) override { 323 AesDecryptor* decryptor) override {
323 EXPECT_FALSE(session_id.empty()); 324 EXPECT_FALSE(session_id.empty());
324 EXPECT_FALSE(message.empty()); 325 EXPECT_FALSE(message.empty());
325 EXPECT_EQ(current_session_id_, session_id); 326 EXPECT_EQ(current_session_id_, session_id);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 486
486 if (initial_append_size_ == kAppendWholeFile) 487 if (initial_append_size_ == kAppendWholeFile)
487 initial_append_size_ = file_data_->data_size(); 488 initial_append_size_ = file_data_->data_size();
488 489
489 DCHECK_GT(initial_append_size_, 0); 490 DCHECK_GT(initial_append_size_, 0);
490 DCHECK_LE(initial_append_size_, file_data_->data_size()); 491 DCHECK_LE(initial_append_size_, file_data_->data_size());
491 } 492 }
492 493
493 virtual ~MockMediaSource() {} 494 virtual ~MockMediaSource() {}
494 495
495 scoped_ptr<Demuxer> GetDemuxer() { return owned_chunk_demuxer_.Pass(); } 496 scoped_ptr<Demuxer> GetDemuxer() { return std::move(owned_chunk_demuxer_); }
496 497
497 void set_encrypted_media_init_data_cb( 498 void set_encrypted_media_init_data_cb(
498 const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) { 499 const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) {
499 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; 500 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb;
500 } 501 }
501 502
502 void Seek(base::TimeDelta seek_time, int new_position, int seek_append_size) { 503 void Seek(base::TimeDelta seek_time, int new_position, int seek_append_size) {
503 chunk_demuxer_->StartWaitingForSeek(seek_time); 504 chunk_demuxer_->StartWaitingForSeek(seek_time);
504 505
505 chunk_demuxer_->ResetParserState( 506 chunk_demuxer_->ResetParserState(
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 } 647 }
647 648
648 protected: 649 protected:
649 scoped_ptr<Renderer> CreateRenderer() override { 650 scoped_ptr<Renderer> CreateRenderer() override {
650 application_impl()->ConnectToService("mojo:media", &media_service_factory_); 651 application_impl()->ConnectToService("mojo:media", &media_service_factory_);
651 652
652 interfaces::RendererPtr mojo_renderer; 653 interfaces::RendererPtr mojo_renderer;
653 media_service_factory_->CreateRenderer(mojo::GetProxy(&mojo_renderer)); 654 media_service_factory_->CreateRenderer(mojo::GetProxy(&mojo_renderer));
654 655
655 return make_scoped_ptr(new MojoRendererImpl(message_loop_.task_runner(), 656 return make_scoped_ptr(new MojoRendererImpl(message_loop_.task_runner(),
656 mojo_renderer.Pass())); 657 std::move(mojo_renderer)));
657 } 658 }
658 659
659 private: 660 private:
660 interfaces::ServiceFactoryPtr media_service_factory_; 661 interfaces::ServiceFactoryPtr media_service_factory_;
661 }; 662 };
662 #else 663 #else
663 class PipelineIntegrationTestHost : public testing::Test, 664 class PipelineIntegrationTestHost : public testing::Test,
664 public PipelineIntegrationTestBase {}; 665 public PipelineIntegrationTestBase {};
665 #endif 666 #endif
666 667
667 class PipelineIntegrationTest : public PipelineIntegrationTestHost { 668 class PipelineIntegrationTest : public PipelineIntegrationTestHost {
668 public: 669 public:
669 void StartPipelineWithMediaSource(MockMediaSource* source) { 670 void StartPipelineWithMediaSource(MockMediaSource* source) {
670 EXPECT_CALL(*source, InitSegmentReceived()).Times(AtLeast(1)); 671 EXPECT_CALL(*source, InitSegmentReceived()).Times(AtLeast(1));
671 EXPECT_CALL(*this, OnMetadata(_)) 672 EXPECT_CALL(*this, OnMetadata(_))
672 .Times(AtMost(1)) 673 .Times(AtMost(1))
673 .WillRepeatedly(SaveArg<0>(&metadata_)); 674 .WillRepeatedly(SaveArg<0>(&metadata_));
674 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) 675 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH))
675 .Times(AnyNumber()); 676 .Times(AnyNumber());
676 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) 677 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING))
677 .Times(AnyNumber()); 678 .Times(AnyNumber());
678 679
679 // Encrypted content not used, so this is never called. 680 // Encrypted content not used, so this is never called.
680 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); 681 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0);
681 682
682 demuxer_ = source->GetDemuxer().Pass(); 683 demuxer_ = source->GetDemuxer();
683 pipeline_->Start( 684 pipeline_->Start(
684 demuxer_.get(), CreateRenderer(), 685 demuxer_.get(), CreateRenderer(),
685 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), 686 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)),
686 base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), 687 base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)),
687 base::Bind(&PipelineIntegrationTest::OnStatusCallback, 688 base::Bind(&PipelineIntegrationTest::OnStatusCallback,
688 base::Unretained(this)), 689 base::Unretained(this)),
689 base::Bind(&PipelineIntegrationTest::OnMetadata, 690 base::Bind(&PipelineIntegrationTest::OnMetadata,
690 base::Unretained(this)), 691 base::Unretained(this)),
691 base::Bind(&PipelineIntegrationTest::OnBufferingStateChanged, 692 base::Bind(&PipelineIntegrationTest::OnBufferingStateChanged,
692 base::Unretained(this)), 693 base::Unretained(this)),
(...skipping 26 matching lines...) Expand all
719 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) 720 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH))
720 .Times(AnyNumber()); 721 .Times(AnyNumber());
721 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) 722 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING))
722 .Times(AnyNumber()); 723 .Times(AnyNumber());
723 EXPECT_CALL(*this, DecryptorAttached(true)); 724 EXPECT_CALL(*this, DecryptorAttached(true));
724 725
725 // Encrypted content used but keys provided in advance, so this is 726 // Encrypted content used but keys provided in advance, so this is
726 // never called. 727 // never called.
727 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); 728 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0);
728 729
729 demuxer_ = source->GetDemuxer().Pass(); 730 demuxer_ = source->GetDemuxer();
730 731
731 pipeline_->SetCdm(encrypted_media->GetCdmContext(), 732 pipeline_->SetCdm(encrypted_media->GetCdmContext(),
732 base::Bind(&PipelineIntegrationTest::DecryptorAttached, 733 base::Bind(&PipelineIntegrationTest::DecryptorAttached,
733 base::Unretained(this))); 734 base::Unretained(this)));
734 735
735 pipeline_->Start( 736 pipeline_->Start(
736 demuxer_.get(), CreateRenderer(), 737 demuxer_.get(), CreateRenderer(),
737 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), 738 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)),
738 base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), 739 base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)),
739 base::Bind(&PipelineIntegrationTest::OnStatusCallback, 740 base::Bind(&PipelineIntegrationTest::OnStatusCallback,
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 1936
1936 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 1937 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
1937 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 1938 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
1938 Play(); 1939 Play();
1939 ASSERT_TRUE(WaitUntilOnEnded()); 1940 ASSERT_TRUE(WaitUntilOnEnded());
1940 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 1941 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
1941 demuxer_->GetStartTime()); 1942 demuxer_->GetStartTime());
1942 } 1943 }
1943 1944
1944 } // namespace media 1945 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/video_renderer_impl_unittest.cc ('k') | media/test/pipeline_integration_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698