diff options
author | wez <wez@chromium.org> | 2014-08-28 18:41:52 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-29 01:42:43 +0000 |
commit | ea12516899b23b38bcd006b9b462eaead73f4cb5 (patch) | |
tree | fc8d69a04c18121a280b7285bca3e7dfa3b17271 /remoting/host/host_extension_session_manager_unittest.cc | |
parent | 8d684e3f2775bd978fc003c6cd343b40caf13bbf (diff) | |
download | chromium_src-ea12516899b23b38bcd006b9b462eaead73f4cb5.zip chromium_src-ea12516899b23b38bcd006b9b462eaead73f4cb5.tar.gz chromium_src-ea12516899b23b38bcd006b9b462eaead73f4cb5.tar.bz2 |
Readability review.
These CLs implement a simple frame recording and fetch "extension" for the Chromoting protocol, to allow sample sessions to be captured for performance testing.
The three main classes introduced are:
- HostExtensionSessionManager
This pulls logic for handling Chromoting extensions out of
ClientSession instances into a dedicated manager class.
It also introduces hooks through which extensions can
wrap or replace the Chromoting video encoder or capturer.
- VideoFrameRecorder
This allows a VideoEncoder to be wrapped to return a new
encoder that will optionally copy & deliver frames to the
VideoFrameRecorder before supplying them to the real
encoder.
- VideoFrameRecorderHostExtension
This extension uses a VideoFrameRecorder to allow a
connected client to start/stop recording, and to retrieve
the resulting frame data.
Original CLs:
crrev.com/402233003
crrev.com/339073002
crrev.com/372943002
crrev.com/462503002
BUG=260879
Review URL: https://codereview.chromium.org/468613002
Cr-Commit-Position: refs/heads/master@{#292541}
Diffstat (limited to 'remoting/host/host_extension_session_manager_unittest.cc')
-rw-r--r-- | remoting/host/host_extension_session_manager_unittest.cc | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/remoting/host/host_extension_session_manager_unittest.cc b/remoting/host/host_extension_session_manager_unittest.cc index f2c875c..7a3592e 100644 --- a/remoting/host/host_extension_session_manager_unittest.cc +++ b/remoting/host/host_extension_session_manager_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/strings/string_util.h" #include "remoting/codec/video_encoder.h" #include "remoting/host/fake_host_extension.h" #include "remoting/host/host_extension_session_manager.h" @@ -17,7 +18,7 @@ class HostExtensionSessionManagerTest : public testing::Test { public: HostExtensionSessionManagerTest() : extension1_("ext1", "cap1"), - extension2_("ext2", ""), + extension2_("ext2", std::string()), extension3_("ext3", "cap3") { extensions_.push_back(&extension1_); extensions_.push_back(&extension2_); @@ -30,14 +31,16 @@ class HostExtensionSessionManagerTest : public testing::Test { FakeExtension extension1_; FakeExtension extension2_; FakeExtension extension3_; - std::vector<HostExtension*> extensions_; + HostExtensionSessionManager::HostExtensions extensions_; // Mocks of interfaces provided by ClientSession. MockClientSessionControl client_session_control_; protocol::MockClientStub client_stub_; + + DISALLOW_COPY_AND_ASSIGN(HostExtensionSessionManagerTest); }; -// Verifies that messages are passed to be handled by the correct extension. +// Verifies that messages are handled by the correct extension. TEST_F(HostExtensionSessionManagerTest, ExtensionMessages_MessageHandled) { HostExtensionSessionManager extension_manager(extensions_, &client_session_control_); @@ -76,7 +79,13 @@ TEST_F(HostExtensionSessionManagerTest, ExtensionCapabilities_AreReported) { HostExtensionSessionManager extension_manager(extensions_, &client_session_control_); - EXPECT_EQ(extension_manager.GetCapabilities(), "cap1 cap3"); + std::vector<std::string> reported_caps; + Tokenize(extension_manager.GetCapabilities(), " ", &reported_caps); + std::sort(reported_caps.begin(), reported_caps.end()); + + ASSERT_EQ(2U, reported_caps.size()); + EXPECT_EQ("cap1", reported_caps[0]); + EXPECT_EQ("cap3", reported_caps[1]); } // Verifies that an extension is not instantiated if the client does not @@ -107,8 +116,8 @@ TEST_F(HostExtensionSessionManagerTest, CanWrapVideoCapturer) { extension3_.set_steal_video_capturer(true); extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1"); - extension_manager.OnCreateVideoCapturer( - scoped_ptr<webrtc::DesktopCapturer>()); + scoped_ptr<webrtc::DesktopCapturer> dummy_capturer; + extension_manager.OnCreateVideoCapturer(&dummy_capturer); EXPECT_FALSE(extension1_.has_wrapped_video_encoder()); EXPECT_TRUE(extension1_.has_wrapped_video_capturer()); @@ -129,7 +138,8 @@ TEST_F(HostExtensionSessionManagerTest, CanWrapVideoEncoder) { extension3_.set_steal_video_capturer(true); extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1"); - extension_manager.OnCreateVideoEncoder(scoped_ptr<VideoEncoder>()); + scoped_ptr<VideoEncoder> dummy_encoder; + extension_manager.OnCreateVideoEncoder(&dummy_encoder); EXPECT_TRUE(extension1_.has_wrapped_video_encoder()); EXPECT_FALSE(extension1_.has_wrapped_video_capturer()); @@ -148,9 +158,10 @@ TEST_F(HostExtensionSessionManagerTest, RespectModifiesVideoPipeline) { extension2_.set_steal_video_capturer(true); extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1"); - extension_manager.OnCreateVideoCapturer( - scoped_ptr<webrtc::DesktopCapturer>()); - extension_manager.OnCreateVideoEncoder(scoped_ptr<VideoEncoder>()); + scoped_ptr<webrtc::DesktopCapturer> dummy_capturer; + extension_manager.OnCreateVideoCapturer(&dummy_capturer); + scoped_ptr<VideoEncoder> dummy_encoder; + extension_manager.OnCreateVideoEncoder(&dummy_encoder); EXPECT_FALSE(extension1_.has_wrapped_video_encoder()); EXPECT_FALSE(extension1_.has_wrapped_video_capturer()); @@ -159,7 +170,7 @@ TEST_F(HostExtensionSessionManagerTest, RespectModifiesVideoPipeline) { EXPECT_FALSE(extension3_.was_instantiated()); } -// Verifies that if an extension reports that they modify the video pipeline +// Verifies that if an extension reports that it modifies the video pipeline // then ResetVideoPipeline() is called on the ClientSessionControl interface. TEST_F(HostExtensionSessionManagerTest, CallsResetVideoPipeline) { HostExtensionSessionManager extension_manager(extensions_, |