Commit 3fdfd76a authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

Add basic perf tests for chromoting protocol.

This CL doesn't yet include any emulation of network
characteristics (latency, bandwidth, etc.). I'm going to
implement it in a separate CL.

BUG=394067
R=rmsousa@chromium.org, ttuttle@chromium.org
TBR=ttuttle@chromium.org (DEPS on net in remoting/test)

Review URL: https://codereview.chromium.org/394883008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285429 0039d316-1c4b-4281-b951-d872f2087c98
parent a1d5e035
......@@ -41,7 +41,11 @@ ChromotingClient::ChromotingClient(
}
}
ChromotingClient::~ChromotingClient() {
ChromotingClient::~ChromotingClient() {}
void ChromotingClient::SetProtocolConfigForTests(
scoped_ptr<protocol::CandidateSessionConfig> config) {
connection_.set_candidate_config(config.Pass());
}
void ChromotingClient::Start(
......
......@@ -25,6 +25,7 @@ class SingleThreadTaskRunner;
namespace remoting {
namespace protocol {
class CandidateSessionConfig;
class TransportFactory;
} // namespace protocol
......@@ -48,6 +49,9 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback,
virtual ~ChromotingClient();
void SetProtocolConfigForTests(
scoped_ptr<protocol::CandidateSessionConfig> config);
// Start the client. Must be called on the main thread. |signal_strategy|
// must outlive the client.
void Start(SignalStrategy* signal_strategy,
......
......@@ -489,6 +489,8 @@ scoped_ptr<VideoEncoder> ClientSession::CreateVideoEncoder(
return remoting::VideoEncoderVpx::CreateForVP8().PassAs<VideoEncoder>();
} else if (video_config.codec == protocol::ChannelConfig::CODEC_VP9) {
return remoting::VideoEncoderVpx::CreateForVP9().PassAs<VideoEncoder>();
} else if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) {
return scoped_ptr<VideoEncoder>(new remoting::VideoEncoderVerbatim());
}
NOTREACHED();
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/fake_desktop_environment.h"
#include "remoting/host/audio_capturer.h"
#include "remoting/host/fake_screen_capturer.h"
#include "remoting/host/gnubby_auth_handler.h"
#include "remoting/host/input_injector.h"
namespace remoting {
FakeInputInjector::FakeInputInjector() {}
FakeInputInjector::~FakeInputInjector() {}
void FakeInputInjector::Start(
scoped_ptr<protocol::ClipboardStub> client_clipboard) {
}
void FakeInputInjector::InjectKeyEvent(const protocol::KeyEvent& event) {
}
void FakeInputInjector::InjectTextEvent(const protocol::TextEvent& event) {
}
void FakeInputInjector::InjectMouseEvent(const protocol::MouseEvent& event) {
}
void FakeInputInjector::InjectClipboardEvent(
const protocol::ClipboardEvent& event) {
}
FakeScreenControls::FakeScreenControls() {}
FakeScreenControls::~FakeScreenControls() {}
void FakeScreenControls::SetScreenResolution(
const ScreenResolution& resolution) {
}
FakeDesktopEnvironment::FakeDesktopEnvironment() {}
FakeDesktopEnvironment::~FakeDesktopEnvironment() {}
// DesktopEnvironment implementation.
scoped_ptr<AudioCapturer> FakeDesktopEnvironment::CreateAudioCapturer() {
return scoped_ptr<AudioCapturer>();
}
scoped_ptr<InputInjector> FakeDesktopEnvironment::CreateInputInjector() {
return scoped_ptr<InputInjector>(new FakeInputInjector());
}
scoped_ptr<ScreenControls> FakeDesktopEnvironment::CreateScreenControls() {
return scoped_ptr<ScreenControls>(new FakeScreenControls());
}
scoped_ptr<webrtc::ScreenCapturer>
FakeDesktopEnvironment::CreateVideoCapturer() {
scoped_ptr<FakeScreenCapturer> result(new FakeScreenCapturer());
if (!frame_generator_.is_null())
result->set_frame_generator(frame_generator_);
return result.PassAs<webrtc::ScreenCapturer>();
}
std::string FakeDesktopEnvironment::GetCapabilities() const {
return std::string();
}
void FakeDesktopEnvironment::SetCapabilities(const std::string& capabilities) {}
scoped_ptr<GnubbyAuthHandler> FakeDesktopEnvironment::CreateGnubbyAuthHandler(
protocol::ClientStub* client_stub) {
return scoped_ptr<GnubbyAuthHandler>();
}
FakeDesktopEnvironmentFactory::FakeDesktopEnvironmentFactory() {}
FakeDesktopEnvironmentFactory::~FakeDesktopEnvironmentFactory() {}
// DesktopEnvironmentFactory implementation.
scoped_ptr<DesktopEnvironment> FakeDesktopEnvironmentFactory::Create(
base::WeakPtr<ClientSessionControl> client_session_control) {
scoped_ptr<FakeDesktopEnvironment> result(new FakeDesktopEnvironment());
result->set_frame_generator(frame_generator_);
return result.PassAs<DesktopEnvironment>();
}
void FakeDesktopEnvironmentFactory::SetEnableCurtaining(bool enable) {}
bool FakeDesktopEnvironmentFactory::SupportsAudioCapture() const {
return false;
}
void FakeDesktopEnvironmentFactory::SetEnableGnubbyAuth(bool enable) {}
} // namespace remoting
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_FAKE_DESKTOP_ENVIRONMENT_H_
#define REMOTING_HOST_FAKE_DESKTOP_ENVIRONMENT_H_
#include "remoting/host/desktop_environment.h"
#include "remoting/host/fake_screen_capturer.h"
#include "remoting/host/input_injector.h"
#include "remoting/host/screen_controls.h"
namespace remoting {
class FakeInputInjector : public InputInjector {
public:
FakeInputInjector();
virtual ~FakeInputInjector();
virtual void Start(
scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE;
virtual void InjectKeyEvent(const protocol::KeyEvent& event) OVERRIDE;
virtual void InjectTextEvent(const protocol::TextEvent& event) OVERRIDE;
virtual void InjectMouseEvent(const protocol::MouseEvent& event) OVERRIDE;
virtual void InjectClipboardEvent(
const protocol::ClipboardEvent& event) OVERRIDE;
};
class FakeScreenControls : public ScreenControls {
public:
FakeScreenControls();
virtual ~FakeScreenControls();
// ScreenControls implementation.
virtual void SetScreenResolution(const ScreenResolution& resolution) OVERRIDE;
};
class FakeDesktopEnvironment : public DesktopEnvironment {
public:
FakeDesktopEnvironment();
virtual ~FakeDesktopEnvironment();
// Sets frame generator to be used for FakeScreenCapturer created by
// FakeDesktopEnvironment.
void set_frame_generator(FakeScreenCapturer::FrameGenerator frame_generator) {
frame_generator_ = frame_generator;
}
// DesktopEnvironment implementation.
virtual scoped_ptr<AudioCapturer> CreateAudioCapturer() OVERRIDE;
virtual scoped_ptr<InputInjector> CreateInputInjector() OVERRIDE;
virtual scoped_ptr<ScreenControls> CreateScreenControls() OVERRIDE;
virtual scoped_ptr<webrtc::ScreenCapturer> CreateVideoCapturer() OVERRIDE;
virtual std::string GetCapabilities() const OVERRIDE;
virtual void SetCapabilities(const std::string& capabilities) OVERRIDE;
virtual scoped_ptr<GnubbyAuthHandler> CreateGnubbyAuthHandler(
protocol::ClientStub* client_stub) OVERRIDE;
private:
FakeScreenCapturer::FrameGenerator frame_generator_;
DISALLOW_COPY_AND_ASSIGN(FakeDesktopEnvironment);
};
class FakeDesktopEnvironmentFactory : public DesktopEnvironmentFactory {
public:
FakeDesktopEnvironmentFactory();
virtual ~FakeDesktopEnvironmentFactory();
// Sets frame generator to be used for FakeScreenCapturer created by
// FakeDesktopEnvironment.
void set_frame_generator(FakeScreenCapturer::FrameGenerator frame_generator) {
frame_generator_ = frame_generator;
}
// DesktopEnvironmentFactory implementation.
virtual scoped_ptr<DesktopEnvironment> Create(
base::WeakPtr<ClientSessionControl> client_session_control) OVERRIDE;
virtual void SetEnableCurtaining(bool enable) OVERRIDE;
virtual bool SupportsAudioCapture() const OVERRIDE;
virtual void SetEnableGnubbyAuth(bool enable) OVERRIDE;
private:
FakeScreenCapturer::FrameGenerator frame_generator_;
DISALLOW_COPY_AND_ASSIGN(FakeDesktopEnvironmentFactory);
};
} // namespace remoting
#endif // REMOTING_HOST_FAKE_DESKTOP_ENVIRONMENT_H_
......@@ -4,7 +4,9 @@
#include "remoting/host/fake_screen_capturer.h"
#include "base/bind.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/time/time.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
......@@ -24,18 +26,113 @@ COMPILE_ASSERT((kBoxWidth % kSpeed == 0) && (kWidth % kSpeed == 0) &&
(kBoxHeight % kSpeed == 0) && (kHeight % kSpeed == 0),
sizes_must_be_multiple_of_kSpeed);
namespace {
class DefaultFrameGenerator
: public base::RefCountedThreadSafe<DefaultFrameGenerator> {
public:
DefaultFrameGenerator()
: bytes_per_row_(0),
box_pos_x_(0),
box_pos_y_(0),
box_speed_x_(kSpeed),
box_speed_y_(kSpeed),
first_frame_(true) {}
scoped_ptr<webrtc::DesktopFrame> GenerateFrame(
webrtc::ScreenCapturer::Callback* callback);
private:
friend class base::RefCountedThreadSafe<DefaultFrameGenerator>;
~DefaultFrameGenerator() {}
webrtc::DesktopSize size_;
int bytes_per_row_;
int box_pos_x_;
int box_pos_y_;
int box_speed_x_;
int box_speed_y_;
bool first_frame_;
DISALLOW_COPY_AND_ASSIGN(DefaultFrameGenerator);
};
scoped_ptr<webrtc::DesktopFrame> DefaultFrameGenerator::GenerateFrame(
webrtc::ScreenCapturer::Callback* callback) {
const int kBytesPerPixel = webrtc::DesktopFrame::kBytesPerPixel;
int buffer_size = kWidth * kHeight * kBytesPerPixel;
webrtc::SharedMemory* shared_memory =
callback->CreateSharedMemory(buffer_size);
scoped_ptr<webrtc::DesktopFrame> frame;
if (shared_memory) {
frame.reset(new webrtc::SharedMemoryDesktopFrame(
webrtc::DesktopSize(kWidth, kHeight), bytes_per_row_, shared_memory));
} else {
frame.reset(
new webrtc::BasicDesktopFrame(webrtc::DesktopSize(kWidth, kHeight)));
}
// Move the box.
bool old_box_pos_x = box_pos_x_;
box_pos_x_ += box_speed_x_;
if (box_pos_x_ + kBoxWidth >= kWidth || box_pos_x_ == 0)
box_speed_x_ = -box_speed_x_;
bool old_box_pos_y = box_pos_y_;
box_pos_y_ += box_speed_y_;
if (box_pos_y_ + kBoxHeight >= kHeight || box_pos_y_ == 0)
box_speed_y_ = -box_speed_y_;
memset(frame->data(), 0xff, kHeight * frame->stride());
// Draw rectangle with the following colors in its corners:
// cyan....yellow
// ..............
// blue.......red
uint8* row = frame->data() +
(box_pos_y_ * size_.width() + box_pos_x_) * kBytesPerPixel;
for (int y = 0; y < kBoxHeight; ++y) {
for (int x = 0; x < kBoxWidth; ++x) {
int r = x * 255 / kBoxWidth;
int g = y * 255 / kBoxHeight;
int b = 255 - (x * 255 / kBoxWidth);
row[x * kBytesPerPixel] = r;
row[x * kBytesPerPixel + 1] = g;
row[x * kBytesPerPixel + 2] = b;
row[x * kBytesPerPixel + 3] = 0xff;
}
row += frame->stride();
}
if (first_frame_) {
frame->mutable_updated_region()->SetRect(
webrtc::DesktopRect::MakeXYWH(0, 0, kWidth, kHeight));
first_frame_ = false;
} else {
frame->mutable_updated_region()->SetRect(webrtc::DesktopRect::MakeXYWH(
old_box_pos_x, old_box_pos_y, kBoxWidth, kBoxHeight));
frame->mutable_updated_region()->AddRect(webrtc::DesktopRect::MakeXYWH(
box_pos_x_, box_pos_y_, kBoxWidth, kBoxHeight));
}
return frame.Pass();
}
} // namespace
FakeScreenCapturer::FakeScreenCapturer()
: callback_(NULL),
mouse_shape_observer_(NULL),
bytes_per_row_(0),
box_pos_x_(0),
box_pos_y_(0),
box_speed_x_(kSpeed),
box_speed_y_(kSpeed) {
ScreenConfigurationChanged();
mouse_shape_observer_(NULL) {
frame_generator_ = base::Bind(&DefaultFrameGenerator::GenerateFrame,
new DefaultFrameGenerator());
}
FakeScreenCapturer::~FakeScreenCapturer() {
FakeScreenCapturer::~FakeScreenCapturer() {}
void FakeScreenCapturer::set_frame_generator(
const FrameGenerator& frame_generator) {
DCHECK(!callback_);
frame_generator_ = frame_generator;
}
void FakeScreenCapturer::Start(Callback* callback) {
......@@ -46,33 +143,10 @@ void FakeScreenCapturer::Start(Callback* callback) {
void FakeScreenCapturer::Capture(const webrtc::DesktopRegion& region) {
base::Time capture_start_time = base::Time::Now();
queue_.MoveToNextFrame();
if (!queue_.current_frame()) {
int buffer_size = size_.height() * bytes_per_row_;
webrtc::SharedMemory* shared_memory =
callback_->CreateSharedMemory(buffer_size);
scoped_ptr<webrtc::DesktopFrame> frame;
webrtc::DesktopSize frame_size(size_.width(), size_.height());
if (shared_memory) {
frame.reset(new webrtc::SharedMemoryDesktopFrame(
frame_size, bytes_per_row_, shared_memory));
} else {
frame.reset(new webrtc::BasicDesktopFrame(frame_size));
}
queue_.ReplaceCurrentFrame(frame.release());
}
DCHECK(queue_.current_frame());
GenerateImage();
queue_.current_frame()->mutable_updated_region()->SetRect(
webrtc::DesktopRect::MakeSize(size_));
queue_.current_frame()->set_capture_time_ms(
scoped_ptr<webrtc::DesktopFrame> frame = frame_generator_.Run(callback_);
frame->set_capture_time_ms(
(base::Time::Now() - capture_start_time).InMillisecondsRoundedUp());
callback_->OnCaptureCompleted(queue_.current_frame()->Share());
callback_->OnCaptureCompleted(frame.release());
}
void FakeScreenCapturer::SetMouseShapeObserver(
......@@ -92,47 +166,4 @@ bool FakeScreenCapturer::SelectScreen(webrtc::ScreenId id) {
return false;
}
void FakeScreenCapturer::GenerateImage() {
webrtc::DesktopFrame* frame = queue_.current_frame();
const int kBytesPerPixel = webrtc::DesktopFrame::kBytesPerPixel;
memset(frame->data(), 0xff,
size_.width() * size_.height() * kBytesPerPixel);
uint8* row = frame->data() +
(box_pos_y_ * size_.width() + box_pos_x_) * kBytesPerPixel;
box_pos_x_ += box_speed_x_;
if (box_pos_x_ + kBoxWidth >= size_.width() || box_pos_x_ == 0)
box_speed_x_ = -box_speed_x_;
box_pos_y_ += box_speed_y_;
if (box_pos_y_ + kBoxHeight >= size_.height() || box_pos_y_ == 0)
box_speed_y_ = -box_speed_y_;
// Draw rectangle with the following colors in its corners:
// cyan....yellow
// ..............
// blue.......red
for (int y = 0; y < kBoxHeight; ++y) {
for (int x = 0; x < kBoxWidth; ++x) {
int r = x * 255 / kBoxWidth;
int g = y * 255 / kBoxHeight;
int b = 255 - (x * 255 / kBoxWidth);
row[x * kBytesPerPixel] = r;
row[x * kBytesPerPixel + 1] = g;
row[x * kBytesPerPixel + 2] = b;
row[x * kBytesPerPixel + 3] = 0xff;
}
row += bytes_per_row_;
}
}
void FakeScreenCapturer::ScreenConfigurationChanged() {
size_.set(kWidth, kHeight);
queue_.Reset();
bytes_per_row_ = size_.width() * webrtc::DesktopFrame::kBytesPerPixel;
}
} // namespace remoting
......@@ -5,6 +5,7 @@
#ifndef REMOTING_HOST_FAKE_SCREEN_CAPTURER_H_
#define REMOTING_HOST_FAKE_SCREEN_CAPTURER_H_
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "media/base/media_export.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
......@@ -18,42 +19,36 @@ namespace remoting {
// FakeScreenCapturer is double-buffered as required by ScreenCapturer.
class FakeScreenCapturer : public webrtc::ScreenCapturer {
public:
// FakeScreenCapturer generates a picture of size kWidth x kHeight.
// By default FakeScreenCapturer generates frames of size kWidth x kHeight,
// but custom frame generator set using set_frame_generator() may generate
// frames of different size.
static const int kWidth = 800;
static const int kHeight = 600;
typedef base::Callback<scoped_ptr<webrtc::DesktopFrame>(
webrtc::ScreenCapturer::Callback* callback)> FrameGenerator;
FakeScreenCapturer();
virtual ~FakeScreenCapturer();
void set_frame_generator(const FrameGenerator& frame_generator);
// webrtc::DesktopCapturer interface.
virtual void Start(Callback* callback) OVERRIDE;
virtual void Capture(const webrtc::DesktopRegion& rect) OVERRIDE;
// ScreenCapturer interface.
// webrtc::ScreenCapturer interface.
virtual void SetMouseShapeObserver(
MouseShapeObserver* mouse_shape_observer) OVERRIDE;
virtual bool GetScreenList(ScreenList* screens) OVERRIDE;
virtual bool SelectScreen(webrtc::ScreenId id) OVERRIDE;
private:
// Generates an image in the front buffer.
void GenerateImage();
// Called when the screen configuration is changed.
void ScreenConfigurationChanged();
FrameGenerator frame_generator_;
Callback* callback_;
MouseShapeObserver* mouse_shape_observer_;
webrtc::DesktopSize size_;
int bytes_per_row_;
int box_pos_x_;
int box_pos_y_;
int box_speed_x_;
int box_speed_y_;
webrtc::ScreenCaptureFrameQueue queue_;
DISALLOW_COPY_AND_ASSIGN(FakeScreenCapturer);
};
......
......@@ -36,6 +36,13 @@ static const int kMaxPendingFrames = 2;
// RTO used in PseudoTCP, which is 250ms.
static const int kKeepAlivePacketIntervalMs = 200;
static bool g_enable_timestamps = false;
// static
void VideoScheduler::EnableTimestampsForTests() {
g_enable_timestamps = true;
}
VideoScheduler::VideoScheduler(
scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
......@@ -86,7 +93,8 @@ void VideoScheduler::OnCaptureCompleted(webrtc::DesktopFrame* frame) {
// that we don't start capturing frame n+2 before frame n is freed.
encode_task_runner_->PostTask(
FROM_HERE, base::Bind(&VideoScheduler::EncodeFrame, this,
base::Passed(&owned_frame), sequence_number_));
base::Passed(&owned_frame), sequence_number_,
base::TimeTicks::Now()));
// If a frame was skipped, try to capture it again.
if (did_skip_frame_) {
......@@ -337,7 +345,8 @@ void VideoScheduler::SendCursorShape(
void VideoScheduler::EncodeFrame(
scoped_ptr<webrtc::DesktopFrame> frame,
int64 sequence_number) {
int64 sequence_number,
base::TimeTicks timestamp) {
DCHECK(encode_task_runner_->BelongsToCurrentThread());
// Drop the frame if there were no changes.
......@@ -351,6 +360,10 @@ void VideoScheduler::EncodeFrame(
scoped_ptr<VideoPacket> packet = encoder_->Encode(*frame);
packet->set_client_sequence_number(sequence_number);
if (g_enable_timestamps) {
packet->set_timestamp(timestamp.ToInternalValue());
}
// Destroy the frame before sending |packet| because SendVideoPacket() may
// trigger another frame to be captured, and the screen capturer expects the
// old frame to be freed by then.
......
......@@ -76,6 +76,9 @@ class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>,
public webrtc::DesktopCapturer::Callback,
public webrtc::ScreenCapturer::MouseShapeObserver {
public:
// Enables timestamps for generated frames. Used for testing.
static void EnableTimestampsForTests();
// Creates a VideoScheduler running capture, encode and network tasks on the
// supplied TaskRunners. Video and cursor shape updates will be pumped to
// |video_stub| and |client_stub|, which must remain valid until Stop() is
......@@ -160,7 +163,8 @@ class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>,
// Encode a frame, passing generated VideoPackets to SendVideoPacket().
void EncodeFrame(scoped_ptr<webrtc::DesktopFrame> frame,
int64 sequence_number);
int64 sequence_number,
base::TimeTicks timestamp);
void EncodedDataAvailableCallback(int64 sequence_number,
scoped_ptr<VideoPacket> packet);
......
......@@ -63,4 +63,7 @@ message VideoPacket {
// True when |desktop_shape_rects| should be used.
optional bool use_desktop_shape = 11;
// Optional frame timestamp. Used in tests to estimate frame latency.
optional int64 timestamp = 12;
}
......@@ -482,6 +482,7 @@ void ChannelMultiplexer::NotifyWriteFailed(const std::string& name) {
void ChannelMultiplexer::OnIncomingPacket(scoped_ptr<MultiplexPacket> packet,
const base::Closure& done_task) {
DCHECK(packet->has_channel_id());
if (!packet->has_channel_id()) {
LOG(ERROR) << "Received packet without channel_id.";
done_task.Run();
......
......@@ -57,6 +57,16 @@ void ConnectionToHost::Connect(SignalStrategy* signal_strategy,
DCHECK(clipboard_stub_);
DCHECK(monitored_video_stub_);
// Initialize default |candidate_config_| if set_candidate_config() wasn't
// called.
if (!candidate_config_) {
candidate_config_ = CandidateSessionConfig::CreateDefault();
if (!audio_stub_) {
candidate_config_->DisableAudioChannel();
}
candidate_config_->EnableVideoCodec(ChannelConfig::CODEC_VP9);
}
signal_strategy_ = signal_strategy;
event_callback_ = event_callback;
authenticator_ = authenticator.Pass();
......@@ -74,6 +84,14 @@ void ConnectionToHost::Connect(SignalStrategy* signal_strategy,
SetState(CONNECTING, OK);
}
void ConnectionToHost::set_candidate_config(
scoped_ptr<CandidateSessionConfig> config) {
DCHECK_EQ(state_, INITIALIZING);
candidate_config_ = config.Pass();
}
const SessionConfig& ConnectionToHost::config() {
return session_->config();
}
......@@ -135,15 +153,8 @@ void ConnectionToHost::OnSessionManagerReady() {
DCHECK(CalledOnValidThread());
// After SessionManager is initialized we can try to connect to the host.
scoped_ptr<CandidateSessionConfig> candidate_config =
CandidateSessionConfig::CreateDefault();
if (!audio_stub_) {
candidate_config->DisableAudioChannel();
}
candidate_config->EnableVideoCodec(ChannelConfig::CODEC_VP9);
session_ = session_manager_->Connect(
host_jid_, authenticator_.Pass(), candidate_config.Pass());
host_jid_, authenticator_.Pass(), candidate_config_.Pass());
session_->SetEventHandler(this);
}
......
......@@ -20,6 +20,7 @@
#include "remoting/protocol/message_reader.h"
#include "remoting/protocol/monitored_video_stub.h"
#include "remoting/protocol/session.h"
#include "remoting/protocol/session_config.h"
#include "remoting/protocol/session_manager.h"
#include "remoting/signaling/signal_strategy.h"
......@@ -83,6 +84,10 @@ class ConnectionToHost : public SignalStrategy::Listener,
ConnectionToHost();
virtual ~ConnectionToHost();
// Allows to set a custom protocol configuration (e.g. for tests). Cannot be
// called after Connect().
void set_candidate_config(scoped_ptr<CandidateSessionConfig> config);
// Set the stubs which will handle messages from the host.
// The caller must ensure that stubs out-live the connection.
// Unless otherwise specified, all stubs must be set before Connect()
......@@ -156,6 +161,8 @@ class ConnectionToHost : public SignalStrategy::Listener,
HostEventCallback* event_callback_;
scoped_ptr<CandidateSessionConfig> candidate_config_;
// Stub for incoming messages.
ClientStub* client_stub_;
ClipboardStub* clipboard_stub_;
......
......@@ -4,6 +4,53 @@
{
'targets': [
{
'target_name': 'remoting_test_common',
'type': 'static_library',
'dependencies': [
'../base/base.gyp:base',
'../net/net.gyp:net_test_support',
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
'remoting_base',
'remoting_client',
'remoting_host',
'remoting_protocol',
'remoting_resources',
],
'sources': [
'host/fake_desktop_environment.cc',
'host/fake_desktop_environment.h',
'host/fake_host_status_monitor.h',
'host/fake_screen_capturer.cc',
'host/fake_screen_capturer.h',
'host/policy_hack/fake_policy_watcher.cc',
'host/policy_hack/fake_policy_watcher.h',
'host/policy_hack/mock_policy_callback.cc',
'host/policy_hack/mock_policy_callback.h',
'protocol/fake_authenticator.cc',
'protocol/fake_authenticator.h',
'protocol/fake_session.cc',
'protocol/fake_session.h',
'protocol/protocol_mock_objects.cc',
'protocol/protocol_mock_objects.h',
'signaling/fake_signal_strategy.cc',
'signaling/fake_signal_strategy.h',
'signaling/mock_signal_strategy.cc',
'signaling/mock_signal_strategy.h',
],
'conditions': [
['enable_remoting_host == 0', {
'dependencies!': [
'remoting_host',
],
'sources/': [
['exclude', '^host/'],
]
}],