| OLD | NEW |
| 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_connection.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 scoped_refptr<ClientConnection> viewer_; | 39 scoped_refptr<ClientConnection> viewer_; |
| 40 | 40 |
| 41 scoped_refptr<FakeChromotocolConnection> connection_; | 41 scoped_refptr<FakeChromotocolConnection> connection_; |
| 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 ChromotingHostMessage message; |
| 50 viewer_->SendVideoPacket(packet); | 50 viewer_->SendUpdateStreamPacketMessage(message); |
| 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(connection_->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 connection_->state_change_callback()->Run(ChromotocolConnection::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 connection_->state_change_callback()->Run(ChromotocolConnection::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(connection_->is_closed()); |
| 78 | 78 |
| 79 VideoPacket packet; | 79 ChromotingHostMessage message; |
| 80 viewer_->SendVideoPacket(packet); | 80 viewer_->SendUpdateStreamPacketMessage(message); |
| 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(connection_->video_channel()->written_data().size(), 0u); |
| 86 } | 86 } |
| 87 | 87 |
| 88 } // namespace remoting | 88 } // namespace remoting |
| OLD | NEW |