| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "remoting/codec/video_encoder.h" | 5 #include "remoting/codec/video_encoder.h" |
| 6 #include "remoting/host/fake_host_extension.h" | 6 #include "remoting/host/fake_host_extension.h" |
| 7 #include "remoting/host/host_extension_session_manager.h" | 7 #include "remoting/host/host_extension_session_manager.h" |
| 8 #include "remoting/host/host_mock_objects.h" | 8 #include "remoting/host/host_mock_objects.h" |
| 9 #include "remoting/proto/control.pb.h" | 9 #include "remoting/proto/control.pb.h" |
| 10 #include "remoting/protocol/protocol_mock_objects.h" | 10 #include "remoting/protocol/protocol_mock_objects.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 12 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" |
| 13 | 13 |
| 14 namespace remoting { | 14 namespace remoting { |
| 15 | 15 |
| 16 class HostExtensionSessionManagerTest : public testing::Test { | 16 class HostExtensionSessionManagerTest : public testing::Test { |
| 17 public: | 17 public: |
| 18 HostExtensionSessionManagerTest() | 18 HostExtensionSessionManagerTest() |
| 19 : extension1_("ext1", "cap1"), | 19 : extension1_("ext1", "cap1"), |
| 20 extension2_("ext2", ""), | 20 extension2_("ext2", ""), |
| 21 extension3_("ext3", "cap3") { | 21 extension3_("ext3", "cap3") { |
| 22 extensions_.push_back(&extension1_); | 22 extensions_.push_back(&extension1_); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 TEST_F(HostExtensionSessionManagerTest, CanWrapVideoCapturer) { | 100 TEST_F(HostExtensionSessionManagerTest, CanWrapVideoCapturer) { |
| 101 HostExtensionSessionManager extension_manager(extensions_, | 101 HostExtensionSessionManager extension_manager(extensions_, |
| 102 &client_session_control_); | 102 &client_session_control_); |
| 103 | 103 |
| 104 // Set up all the extensions to request to modify the video pipeline. | 104 // Set up all the extensions to request to modify the video pipeline. |
| 105 extension1_.set_steal_video_capturer(true); | 105 extension1_.set_steal_video_capturer(true); |
| 106 extension2_.set_steal_video_capturer(true); | 106 extension2_.set_steal_video_capturer(true); |
| 107 extension3_.set_steal_video_capturer(true); | 107 extension3_.set_steal_video_capturer(true); |
| 108 extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1"); | 108 extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1"); |
| 109 | 109 |
| 110 extension_manager.OnCreateVideoCapturer(scoped_ptr<webrtc::ScreenCapturer>()); | 110 extension_manager.OnCreateVideoCapturer( |
| 111 scoped_ptr<webrtc::DesktopCapturer>()); |
| 111 | 112 |
| 112 EXPECT_FALSE(extension1_.has_wrapped_video_encoder()); | 113 EXPECT_FALSE(extension1_.has_wrapped_video_encoder()); |
| 113 EXPECT_TRUE(extension1_.has_wrapped_video_capturer()); | 114 EXPECT_TRUE(extension1_.has_wrapped_video_capturer()); |
| 114 EXPECT_FALSE(extension2_.has_wrapped_video_encoder()); | 115 EXPECT_FALSE(extension2_.has_wrapped_video_encoder()); |
| 115 EXPECT_TRUE(extension2_.has_wrapped_video_capturer()); | 116 EXPECT_TRUE(extension2_.has_wrapped_video_capturer()); |
| 116 EXPECT_FALSE(extension3_.was_instantiated()); | 117 EXPECT_FALSE(extension3_.was_instantiated()); |
| 117 } | 118 } |
| 118 | 119 |
| 119 // Verifies that matching extensions are given the opportunity to wrap or | 120 // Verifies that matching extensions are given the opportunity to wrap or |
| 120 // replace the video encoders. | 121 // replace the video encoders. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 140 // Verifies that only extensions which report that they modify the video | 141 // Verifies that only extensions which report that they modify the video |
| 141 // pipeline actually get called to modify it. | 142 // pipeline actually get called to modify it. |
| 142 TEST_F(HostExtensionSessionManagerTest, RespectModifiesVideoPipeline) { | 143 TEST_F(HostExtensionSessionManagerTest, RespectModifiesVideoPipeline) { |
| 143 HostExtensionSessionManager extension_manager(extensions_, | 144 HostExtensionSessionManager extension_manager(extensions_, |
| 144 &client_session_control_); | 145 &client_session_control_); |
| 145 | 146 |
| 146 // Set up the second extension to request to modify the video pipeline. | 147 // Set up the second extension to request to modify the video pipeline. |
| 147 extension2_.set_steal_video_capturer(true); | 148 extension2_.set_steal_video_capturer(true); |
| 148 extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1"); | 149 extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1"); |
| 149 | 150 |
| 150 extension_manager.OnCreateVideoCapturer(scoped_ptr<webrtc::ScreenCapturer>()); | 151 extension_manager.OnCreateVideoCapturer( |
| 152 scoped_ptr<webrtc::DesktopCapturer>()); |
| 151 extension_manager.OnCreateVideoEncoder(scoped_ptr<VideoEncoder>()); | 153 extension_manager.OnCreateVideoEncoder(scoped_ptr<VideoEncoder>()); |
| 152 | 154 |
| 153 EXPECT_FALSE(extension1_.has_wrapped_video_encoder()); | 155 EXPECT_FALSE(extension1_.has_wrapped_video_encoder()); |
| 154 EXPECT_FALSE(extension1_.has_wrapped_video_capturer()); | 156 EXPECT_FALSE(extension1_.has_wrapped_video_capturer()); |
| 155 EXPECT_TRUE(extension2_.has_wrapped_video_encoder()); | 157 EXPECT_TRUE(extension2_.has_wrapped_video_encoder()); |
| 156 EXPECT_TRUE(extension2_.has_wrapped_video_capturer()); | 158 EXPECT_TRUE(extension2_.has_wrapped_video_capturer()); |
| 157 EXPECT_FALSE(extension3_.was_instantiated()); | 159 EXPECT_FALSE(extension3_.was_instantiated()); |
| 158 } | 160 } |
| 159 | 161 |
| 160 // Verifies that if an extension reports that they modify the video pipeline | 162 // Verifies that if an extension reports that they modify the video pipeline |
| 161 // then ResetVideoPipeline() is called on the ClientSessionControl interface. | 163 // then ResetVideoPipeline() is called on the ClientSessionControl interface. |
| 162 TEST_F(HostExtensionSessionManagerTest, CallsResetVideoPipeline) { | 164 TEST_F(HostExtensionSessionManagerTest, CallsResetVideoPipeline) { |
| 163 HostExtensionSessionManager extension_manager(extensions_, | 165 HostExtensionSessionManager extension_manager(extensions_, |
| 164 &client_session_control_); | 166 &client_session_control_); |
| 165 | 167 |
| 166 EXPECT_CALL(client_session_control_, ResetVideoPipeline()); | 168 EXPECT_CALL(client_session_control_, ResetVideoPipeline()); |
| 167 | 169 |
| 168 // Set up only the first extension to request to modify the video pipeline. | 170 // Set up only the first extension to request to modify the video pipeline. |
| 169 extension1_.set_steal_video_capturer(true); | 171 extension1_.set_steal_video_capturer(true); |
| 170 | 172 |
| 171 extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1"); | 173 extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1"); |
| 172 } | 174 } |
| 173 | 175 |
| 174 | 176 |
| 175 } // namespace remoting | 177 } // namespace remoting |
| OLD | NEW |