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

Side by Side Diff: remoting/host/client_connection_unittest.cc

Issue 4313001: Rename classes for Chromoting: (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: Resolve merge conflicts Created 10 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/client_connection.cc ('k') | remoting/protocol/chromotocol_server.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "remoting/base/mock_objects.h" 6 #include "remoting/base/mock_objects.h"
7 #include "remoting/host/client_connection.h" 7 #include "remoting/host/client_connection.h"
8 #include "remoting/host/mock_objects.h" 8 #include "remoting/host/mock_objects.h"
9 #include "remoting/protocol/fake_connection.h" 9 #include "remoting/protocol/fake_session.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
11 11
12 using ::testing::_; 12 using ::testing::_;
13 using ::testing::NotNull; 13 using ::testing::NotNull;
14 using ::testing::StrictMock; 14 using ::testing::StrictMock;
15 15
16 namespace remoting { 16 namespace remoting {
17 17
18 class ClientConnectionTest : public testing::Test { 18 class ClientConnectionTest : public testing::Test {
19 public: 19 public:
20 ClientConnectionTest() { 20 ClientConnectionTest() {
21 } 21 }
22 22
23 protected: 23 protected:
24 virtual void SetUp() { 24 virtual void SetUp() {
25 connection_ = new FakeChromotocolConnection(); 25 session_ = new protocol::FakeSession();
26 connection_->set_message_loop(&message_loop_); 26 session_->set_message_loop(&message_loop_);
27 27
28 // Allocate a ClientConnection object with the mock objects. 28 // Allocate a ClientConnection object with the mock objects.
29 viewer_ = new ClientConnection(&message_loop_, &handler_); 29 viewer_ = new ClientConnection(&message_loop_, &handler_);
30 viewer_->Init(connection_); 30 viewer_->Init(session_);
31 EXPECT_CALL(handler_, OnConnectionOpened(viewer_.get())); 31 EXPECT_CALL(handler_, OnConnectionOpened(viewer_.get()));
32 connection_->state_change_callback()->Run( 32 session_->state_change_callback()->Run(
33 ChromotocolConnection::CONNECTED); 33 protocol::Session::CONNECTED);
34 message_loop_.RunAllPending(); 34 message_loop_.RunAllPending();
35 } 35 }
36 36
37 MessageLoop message_loop_; 37 MessageLoop message_loop_;
38 MockClientConnectionEventHandler handler_; 38 MockClientConnectionEventHandler handler_;
39 scoped_refptr<ClientConnection> viewer_; 39 scoped_refptr<ClientConnection> viewer_;
40 40
41 scoped_refptr<FakeChromotocolConnection> connection_; 41 scoped_refptr<protocol::FakeSession> session_;
42 42
43 private: 43 private:
44 DISALLOW_COPY_AND_ASSIGN(ClientConnectionTest); 44 DISALLOW_COPY_AND_ASSIGN(ClientConnectionTest);
45 }; 45 };
46 46
47 TEST_F(ClientConnectionTest, SendUpdateStream) { 47 TEST_F(ClientConnectionTest, SendUpdateStream) {
48 // Then send the actual data. 48 // Then send the actual data.
49 VideoPacket packet; 49 VideoPacket packet;
50 viewer_->SendVideoPacket(packet); 50 viewer_->SendVideoPacket(packet);
51 51
52 // And then close the connection to ClientConnection. 52 // And then close the connection to ClientConnection.
53 viewer_->Disconnect(); 53 viewer_->Disconnect();
54 54
55 message_loop_.RunAllPending(); 55 message_loop_.RunAllPending();
56 56
57 // Verify that something has been written. 57 // Verify that something has been written.
58 // TODO(sergeyu): Verify that the correct data has been written. 58 // TODO(sergeyu): Verify that the correct data has been written.
59 EXPECT_GT(connection_->video_channel()->written_data().size(), 0u); 59 EXPECT_GT(session_->video_channel()->written_data().size(), 0u);
60 } 60 }
61 61
62 TEST_F(ClientConnectionTest, StateChange) { 62 TEST_F(ClientConnectionTest, StateChange) {
63 EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get())); 63 EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get()));
64 connection_->state_change_callback()->Run(ChromotocolConnection::CLOSED); 64 session_->state_change_callback()->Run(protocol::Session::CLOSED);
65 message_loop_.RunAllPending(); 65 message_loop_.RunAllPending();
66 66
67 EXPECT_CALL(handler_, OnConnectionFailed(viewer_.get())); 67 EXPECT_CALL(handler_, OnConnectionFailed(viewer_.get()));
68 connection_->state_change_callback()->Run(ChromotocolConnection::FAILED); 68 session_->state_change_callback()->Run(protocol::Session::FAILED);
69 message_loop_.RunAllPending(); 69 message_loop_.RunAllPending();
70 } 70 }
71 71
72 // Test that we can close client connection more than once and operations 72 // Test that we can close client connection more than once and operations
73 // after the connection is closed has no effect. 73 // after the connection is closed has no effect.
74 TEST_F(ClientConnectionTest, Close) { 74 TEST_F(ClientConnectionTest, Close) {
75 viewer_->Disconnect(); 75 viewer_->Disconnect();
76 message_loop_.RunAllPending(); 76 message_loop_.RunAllPending();
77 EXPECT_TRUE(connection_->is_closed()); 77 EXPECT_TRUE(session_->is_closed());
78 78
79 VideoPacket packet; 79 VideoPacket packet;
80 viewer_->SendVideoPacket(packet); 80 viewer_->SendVideoPacket(packet);
81 viewer_->Disconnect(); 81 viewer_->Disconnect();
82 message_loop_.RunAllPending(); 82 message_loop_.RunAllPending();
83 83
84 // Verify that nothing has been written. 84 // Verify that nothing has been written.
85 EXPECT_EQ(connection_->video_channel()->written_data().size(), 0u); 85 EXPECT_EQ(session_->video_channel()->written_data().size(), 0u);
86 } 86 }
87 87
88 } // namespace remoting 88 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/client_connection.cc ('k') | remoting/protocol/chromotocol_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698