From ea12516899b23b38bcd006b9b462eaead73f4cb5 Mon Sep 17 00:00:00 2001 From: wez Date: Thu, 28 Aug 2014 18:41:52 -0700 Subject: 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} --- .../host_extension_session_manager_unittest.cc | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'remoting/host/host_extension_session_manager_unittest.cc') 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 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 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()); + scoped_ptr 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()); + scoped_ptr 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()); - extension_manager.OnCreateVideoEncoder(scoped_ptr()); + scoped_ptr dummy_capturer; + extension_manager.OnCreateVideoCapturer(&dummy_capturer); + scoped_ptr 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_, -- cgit v1.1