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

Unified Diff: remoting/host/client_connection_unittest.cc

Issue 2690003: Copy the (early prototype of) remoting in Chrome into the public tree.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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 | « remoting/host/client_connection.cc ('k') | remoting/host/differ_block.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/client_connection_unittest.cc
===================================================================
--- remoting/host/client_connection_unittest.cc (revision 0)
+++ remoting/host/client_connection_unittest.cc (revision 0)
@@ -0,0 +1,99 @@
+// Copyright (c) 2010 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 "base/message_loop.h"
+#include "media/base/data_buffer.h"
+#include "remoting/base/mock_objects.h"
+#include "remoting/host/client_connection.h"
+#include "remoting/host/mock_objects.h"
+#include "remoting/jingle_glue/mock_objects.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+using ::testing::_;
+using ::testing::NotNull;
+
+namespace remoting {
+
+class ClientConnectionTest : public testing::Test {
+ public:
+ ClientConnectionTest() {
+ }
+
+ protected:
+ virtual void SetUp() {
+ decoder_ = new MockProtocolDecoder();
+ channel_ = new MockJingleChannel();
+
+ // Allocate a ClientConnection object with the mock objects. we give the
+ // ownership of decoder to the viewer.
+ viewer_ = new ClientConnection(&message_loop_,
+ decoder_,
+ &handler_);
+
+ viewer_->set_jingle_channel(channel_.get());
+ }
+
+ MessageLoop message_loop_;
+ MockProtocolDecoder* decoder_;
+ MockClientConnectionEventHandler handler_;
+ scoped_refptr<MockJingleChannel> channel_;
+ scoped_refptr<ClientConnection> viewer_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ClientConnectionTest);
+};
+
+TEST_F(ClientConnectionTest, SendUpdateStream) {
+ // Tell the viewer we are starting an update stream.
+ EXPECT_CALL(*channel_, Write(_));
+ viewer_->SendBeginUpdateStreamMessage();
+
+ // Then send the actual data.
+ EXPECT_CALL(*channel_, Write(_));
+ chromotocol_pb::UpdateStreamPacketHeader* header
+ = new chromotocol_pb::UpdateStreamPacketHeader();
+ header->set_x(0);
+ header->set_y(0);
+ header->set_width(640);
+ header->set_height(480);
+ scoped_refptr<media::DataBuffer> data = new media::DataBuffer(10);
+ viewer_->SendUpdateStreamPacketMessage(header, data);
+ delete header;
+
+ // Send the end of update message.
+ EXPECT_CALL(*channel_, Write(_));
+ viewer_->SendEndUpdateStreamMessage();
+
+ // And then close the connection to ClientConnection.
+ EXPECT_CALL(*channel_, Close());
+ viewer_->Disconnect();
+}
+
+TEST_F(ClientConnectionTest, StateChange) {
+ EXPECT_CALL(handler_, OnConnectionOpened(viewer_.get()));
+ viewer_->OnStateChange(channel_.get(), JingleChannel::OPEN);
+ message_loop_.RunAllPending();
+
+ EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get()));
+ viewer_->OnStateChange(channel_.get(), JingleChannel::CLOSED);
+ message_loop_.RunAllPending();
+
+ EXPECT_CALL(handler_, OnConnectionFailed(viewer_.get()));
+ viewer_->OnStateChange(channel_.get(), JingleChannel::FAILED);
+ message_loop_.RunAllPending();
+}
+
+TEST_F(ClientConnectionTest, ParseMessages) {
+ scoped_refptr<media::DataBuffer> data;
+
+ // Give the data to the ClientConnection, it will use ProtocolDecoder to
+ // decode the messages.
+ EXPECT_CALL(*decoder_, ParseClientMessages(data, NotNull()));
+ EXPECT_CALL(handler_, HandleMessages(viewer_.get(), NotNull()));
+
+ viewer_->OnPacketReceived(channel_.get(), data);
+ message_loop_.RunAllPending();
+}
+
+} // namespace remoting
Property changes on: remoting/host/client_connection_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « remoting/host/client_connection.cc ('k') | remoting/host/differ_block.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698