Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1148)

Unified Diff: remoting/protocol/connection_unittest.cc

Issue 1580823003: Implement client-side video stream support for WebRTC-based protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@packet_options_rem
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/protocol/fake_video_renderer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/connection_unittest.cc
diff --git a/remoting/protocol/connection_unittest.cc b/remoting/protocol/connection_unittest.cc
index 1262435695bf60d661a78f9ef7eb623814054769..9f35abdf746c50c7cc9794eaef5b67b04ad801d1 100644
--- a/remoting/protocol/connection_unittest.cc
+++ b/remoting/protocol/connection_unittest.cc
@@ -15,10 +15,13 @@
#include "remoting/protocol/ice_connection_to_host.h"
#include "remoting/protocol/protocol_mock_objects.h"
#include "remoting/protocol/transport_context.h"
+#include "remoting/protocol/video_stream.h"
#include "remoting/protocol/webrtc_connection_to_client.h"
#include "remoting/protocol/webrtc_connection_to_host.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
+#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
using ::testing::_;
using ::testing::InvokeWithoutArgs;
@@ -57,6 +60,29 @@ class MockConnectionToHostEventCallback
const TransportRoute& route));
};
+class TestScreenCapturer : public webrtc::DesktopCapturer {
+ public:
+ TestScreenCapturer() {}
+ ~TestScreenCapturer() override {}
+
+ // webrtc::DesktopCapturer interface.
+ void Start(Callback* callback) override {
+ callback_ = callback;
+ }
+ void Capture(const webrtc::DesktopRegion& region) override {
+ // Return black 10x10 frame.
+ scoped_ptr<webrtc::DesktopFrame> frame(
+ new webrtc::BasicDesktopFrame(webrtc::DesktopSize(100, 100)));
+ memset(frame->data(), 0, frame->stride() * frame->size().height());
+ frame->mutable_updated_region()->SetRect(
+ webrtc::DesktopRect::MakeSize(frame->size()));
+ callback_->OnCaptureCompleted(frame.release());
+ }
+
+ private:
+ Callback* callback_ = nullptr;
+};
+
} // namespace
class ConnectionTest : public testing::Test,
@@ -65,14 +91,16 @@ class ConnectionTest : public testing::Test,
ConnectionTest() {}
protected:
+ bool is_using_webrtc() { return GetParam(); }
+
void SetUp() override {
// Create fake sessions.
host_session_ = new FakeSession();
owned_client_session_.reset(new FakeSession());
client_session_ = owned_client_session_.get();
- // Create Connection objects
- if (GetParam()) {
+ // Create Connection objects.
+ if (is_using_webrtc()) {
host_connection_.reset(new WebrtcConnectionToClient(
make_scoped_ptr(host_session_),
TransportContext::ForTests(protocol::TransportRole::SERVER)));
@@ -248,5 +276,41 @@ TEST_P(ConnectionTest, Events) {
run_loop.Run();
}
+TEST_P(ConnectionTest, Video) {
+ Connect();
+
+ scoped_ptr<VideoStream> video_stream = host_connection_->StartVideoStream(
+ make_scoped_ptr(new TestScreenCapturer()));
+
+ base::RunLoop run_loop;
+
+ // Expect frames to be passed to FrameConsumer when WebRTC is used, or to
+ // VideoStub otherwise.
+ if (is_using_webrtc()) {
+ client_video_renderer_.GetFrameConsumer()->set_on_frame_callback(
+ base::Bind(&base::RunLoop::Quit, base::Unretained(&run_loop)));
+ } else {
+ client_video_renderer_.GetVideoStub()->set_on_frame_callback(
+ base::Bind(&base::RunLoop::Quit, base::Unretained(&run_loop)));
+ }
+
+ run_loop.Run();
+
+ if (is_using_webrtc()) {
+ EXPECT_EQ(
+ client_video_renderer_.GetFrameConsumer()->received_frames().size(),
+ 1U);
+ EXPECT_EQ(client_video_renderer_.GetVideoStub()->received_packets().size(),
+ 0U);
+ } else {
+ EXPECT_EQ(
+ client_video_renderer_.GetFrameConsumer()->received_frames().size(),
+ 0U);
+ EXPECT_EQ(client_video_renderer_.GetVideoStub()->received_packets().size(),
+ 1U);
+ }
+
+}
+
} // namespace protocol
} // namespace remoting
« no previous file with comments | « no previous file | remoting/protocol/fake_video_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698