| OLD | NEW |
| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(MockRendererClient); | 54 DISALLOW_COPY_AND_ASSIGN(MockRendererClient); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 class MediaShellTest : public shell::test::ShellTest { | 57 class MediaShellTest : public shell::test::ShellTest { |
| 58 public: | 58 public: |
| 59 MediaShellTest() | 59 MediaShellTest() |
| 60 : ShellTest("exe:media_mojo_unittests"), | 60 : ShellTest("exe:media_mojo_unittests"), |
| 61 renderer_client_binding_(&renderer_client_), | 61 renderer_client_binding_(&renderer_client_), |
| 62 video_demuxer_stream_(DemuxerStream::VIDEO) {} | 62 video_stream_(DemuxerStream::VIDEO) {} |
| 63 ~MediaShellTest() override {} | 63 ~MediaShellTest() override {} |
| 64 | 64 |
| 65 void SetUp() override { | 65 void SetUp() override { |
| 66 ShellTest::SetUp(); | 66 ShellTest::SetUp(); |
| 67 | 67 |
| 68 connection_ = connector()->Connect("mojo:media"); | 68 connection_ = connector()->Connect("mojo:media"); |
| 69 connection_->SetConnectionLostClosure( | 69 connection_->SetConnectionLostClosure( |
| 70 base::Bind(&MediaShellTest::ConnectionClosed, base::Unretained(this))); | 70 base::Bind(&MediaShellTest::ConnectionClosed, base::Unretained(this))); |
| 71 | 71 |
| 72 connection_->GetInterface(&service_factory_); | 72 connection_->GetInterface(&service_factory_); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 95 key_system, kSecurityOrigin, mojom::CdmConfig::From(CdmConfig()), | 95 key_system, kSecurityOrigin, mojom::CdmConfig::From(CdmConfig()), |
| 96 base::Bind(&MediaShellTest::OnCdmInitialized, base::Unretained(this))); | 96 base::Bind(&MediaShellTest::OnCdmInitialized, base::Unretained(this))); |
| 97 } | 97 } |
| 98 | 98 |
| 99 MOCK_METHOD1(OnRendererInitialized, void(bool)); | 99 MOCK_METHOD1(OnRendererInitialized, void(bool)); |
| 100 | 100 |
| 101 void InitializeRenderer(const VideoDecoderConfig& video_config, | 101 void InitializeRenderer(const VideoDecoderConfig& video_config, |
| 102 bool expected_result) { | 102 bool expected_result) { |
| 103 service_factory_->CreateRenderer(mojo::GetProxy(&renderer_)); | 103 service_factory_->CreateRenderer(mojo::GetProxy(&renderer_)); |
| 104 | 104 |
| 105 video_demuxer_stream_.set_video_decoder_config(video_config); | 105 video_stream_.set_video_decoder_config(video_config); |
| 106 | 106 |
| 107 mojom::DemuxerStreamPtr video_stream; | 107 mojom::DemuxerStreamPtr video_stream_proxy; |
| 108 new MojoDemuxerStreamImpl(&video_demuxer_stream_, GetProxy(&video_stream)); | 108 mojo_video_stream_.reset(new MojoDemuxerStreamImpl( |
| 109 &video_stream_, GetProxy(&video_stream_proxy))); |
| 109 | 110 |
| 110 EXPECT_CALL(*this, OnRendererInitialized(expected_result)) | 111 EXPECT_CALL(*this, OnRendererInitialized(expected_result)) |
| 111 .Times(Exactly(1)) | 112 .Times(Exactly(1)) |
| 112 .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit)); | 113 .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit)); |
| 113 renderer_->Initialize(renderer_client_binding_.CreateInterfacePtrAndBind(), | 114 renderer_->Initialize(renderer_client_binding_.CreateInterfacePtrAndBind(), |
| 114 nullptr, std::move(video_stream), | 115 nullptr, std::move(video_stream_proxy), |
| 115 base::Bind(&MediaShellTest::OnRendererInitialized, | 116 base::Bind(&MediaShellTest::OnRendererInitialized, |
| 116 base::Unretained(this))); | 117 base::Unretained(this))); |
| 117 } | 118 } |
| 118 | 119 |
| 119 MOCK_METHOD0(ConnectionClosed, void()); | 120 MOCK_METHOD0(ConnectionClosed, void()); |
| 120 | 121 |
| 121 protected: | 122 protected: |
| 122 std::unique_ptr<base::RunLoop> run_loop_; | 123 std::unique_ptr<base::RunLoop> run_loop_; |
| 123 | 124 |
| 124 mojom::ServiceFactoryPtr service_factory_; | 125 mojom::ServiceFactoryPtr service_factory_; |
| 125 mojom::ContentDecryptionModulePtr cdm_; | 126 mojom::ContentDecryptionModulePtr cdm_; |
| 126 mojom::RendererPtr renderer_; | 127 mojom::RendererPtr renderer_; |
| 127 | 128 |
| 128 StrictMock<MockRendererClient> renderer_client_; | 129 StrictMock<MockRendererClient> renderer_client_; |
| 129 mojo::Binding<mojom::RendererClient> renderer_client_binding_; | 130 mojo::Binding<mojom::RendererClient> renderer_client_binding_; |
| 130 | 131 |
| 131 StrictMock<MockDemuxerStream> video_demuxer_stream_; | 132 StrictMock<MockDemuxerStream> video_stream_; |
| 133 std::unique_ptr<MojoDemuxerStreamImpl> mojo_video_stream_; |
| 132 | 134 |
| 133 private: | 135 private: |
| 134 std::unique_ptr<shell::Connection> connection_; | 136 std::unique_ptr<shell::Connection> connection_; |
| 135 | 137 |
| 136 DISALLOW_COPY_AND_ASSIGN(MediaShellTest); | 138 DISALLOW_COPY_AND_ASSIGN(MediaShellTest); |
| 137 }; | 139 }; |
| 138 | 140 |
| 139 } // namespace | 141 } // namespace |
| 140 | 142 |
| 141 // Note: base::RunLoop::RunUntilIdle() does not work well in these tests because | 143 // Note: base::RunLoop::RunUntilIdle() does not work well in these tests because |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // close the connection. | 183 // close the connection. |
| 182 EXPECT_CALL(*this, ConnectionClosed()) | 184 EXPECT_CALL(*this, ConnectionClosed()) |
| 183 .Times(Exactly(1)) | 185 .Times(Exactly(1)) |
| 184 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit)); | 186 .WillOnce(Invoke(run_loop_.get(), &base::RunLoop::Quit)); |
| 185 service_factory_.reset(); | 187 service_factory_.reset(); |
| 186 | 188 |
| 187 run_loop_->Run(); | 189 run_loop_->Run(); |
| 188 } | 190 } |
| 189 | 191 |
| 190 } // namespace media | 192 } // namespace media |
| OLD | NEW |