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

Side by Side Diff: media/mojo/clients/mojo_renderer_unittest.cc

Issue 2539703002: media: Add |bad_message_cb_| to MojoRendererService (Closed)
Patch Set: add TODO and ref to bug Created 4 years 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 | « no previous file | media/mojo/services/mojo_renderer_service.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 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/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/test_message_loop.h" 10 #include "base/test/test_message_loop.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 void Destroy() { 86 void Destroy() {
87 mojo_renderer_.reset(); 87 mojo_renderer_.reset();
88 base::RunLoop().RunUntilIdle(); 88 base::RunLoop().RunUntilIdle();
89 } 89 }
90 90
91 // Completion callbacks. 91 // Completion callbacks.
92 MOCK_METHOD1(OnInitialized, void(PipelineStatus)); 92 MOCK_METHOD1(OnInitialized, void(PipelineStatus));
93 MOCK_METHOD0(OnFlushed, void()); 93 MOCK_METHOD0(OnFlushed, void());
94 MOCK_METHOD1(OnCdmAttached, void(bool)); 94 MOCK_METHOD1(OnCdmAttached, void(bool));
95 MOCK_METHOD1(OnSurfaceRequestToken, void(const base::UnguessableToken&));
95 96
96 std::unique_ptr<StrictMock<MockDemuxerStream>> CreateStream( 97 std::unique_ptr<StrictMock<MockDemuxerStream>> CreateStream(
97 DemuxerStream::Type type) { 98 DemuxerStream::Type type) {
98 std::unique_ptr<StrictMock<MockDemuxerStream>> stream( 99 std::unique_ptr<StrictMock<MockDemuxerStream>> stream(
99 new StrictMock<MockDemuxerStream>(type)); 100 new StrictMock<MockDemuxerStream>(type));
100 return stream; 101 return stream;
101 } 102 }
102 103
103 void CreateAudioStream() { 104 void CreateAudioStream() {
104 audio_stream_ = CreateStream(DemuxerStream::AUDIO); 105 audio_stream_ = CreateStream(DemuxerStream::AUDIO);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // Flushing should pause media-time updates. 366 // Flushing should pause media-time updates.
366 EXPECT_CALL(*mock_renderer_, Flush(_)).WillOnce(RunClosure<0>()); 367 EXPECT_CALL(*mock_renderer_, Flush(_)).WillOnce(RunClosure<0>());
367 Flush(); 368 Flush();
368 base::TimeDelta pause_time = mojo_renderer_->GetMediaTime(); 369 base::TimeDelta pause_time = mojo_renderer_->GetMediaTime();
369 EXPECT_GT(pause_time, kStartTime); 370 EXPECT_GT(pause_time, kStartTime);
370 WaitFor(kSleepTime); 371 WaitFor(kSleepTime);
371 EXPECT_EQ(pause_time, mojo_renderer_->GetMediaTime()); 372 EXPECT_EQ(pause_time, mojo_renderer_->GetMediaTime());
372 Destroy(); 373 Destroy();
373 } 374 }
374 375
376 // When |initiate_surface_request_cb_| is not set, the client should not call
377 // InitiateScopedSurfaceRequest(). Otherwise, it will cause the pipe to be
378 // closed and MojoRendererService destroyed.
379 TEST_F(MojoRendererTest, InitiateScopedSurfaceRequest) {
380 Initialize();
381 DCHECK(renderer_binding_);
382
383 EXPECT_CALL(renderer_client_, OnError(PIPELINE_ERROR_DECODE)).Times(1);
384
385 mojo_renderer_->InitiateScopedSurfaceRequest(base::Bind(
386 &MojoRendererTest::OnSurfaceRequestToken, base::Unretained(this)));
387 base::RunLoop().RunUntilIdle();
388
389 DCHECK(!renderer_binding_);
390 }
391
375 TEST_F(MojoRendererTest, OnBufferingStateChange) { 392 TEST_F(MojoRendererTest, OnBufferingStateChange) {
376 Initialize(); 393 Initialize();
377 Play(); 394 Play();
378 395
379 EXPECT_CALL(renderer_client_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) 396 EXPECT_CALL(renderer_client_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
380 .Times(1); 397 .Times(1);
381 remote_renderer_client_->OnBufferingStateChange(BUFFERING_HAVE_ENOUGH); 398 remote_renderer_client_->OnBufferingStateChange(BUFFERING_HAVE_ENOUGH);
382 399
383 EXPECT_CALL(renderer_client_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) 400 EXPECT_CALL(renderer_client_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING))
384 .Times(1); 401 .Times(1);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 Play(); 457 Play();
441 remote_renderer_client_->OnError(PIPELINE_ERROR_DECODE); 458 remote_renderer_client_->OnError(PIPELINE_ERROR_DECODE);
442 base::RunLoop().RunUntilIdle(); 459 base::RunLoop().RunUntilIdle();
443 460
444 EXPECT_CALL(*mock_renderer_, SetPlaybackRate(0.0)).Times(1); 461 EXPECT_CALL(*mock_renderer_, SetPlaybackRate(0.0)).Times(1);
445 mojo_renderer_->SetPlaybackRate(0.0); 462 mojo_renderer_->SetPlaybackRate(0.0);
446 Flush(); 463 Flush();
447 } 464 }
448 465
449 } // namespace media 466 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/mojo/services/mojo_renderer_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698