OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_loop_proxy.h" |
6 #include "remoting/base/base_mock_objects.h" | 7 #include "remoting/base/base_mock_objects.h" |
7 #include "remoting/base/constants.h" | 8 #include "remoting/base/constants.h" |
8 #include "remoting/protocol/fake_session.h" | 9 #include "remoting/protocol/fake_session.h" |
9 #include "remoting/protocol/connection_to_client.h" | 10 #include "remoting/protocol/connection_to_client.h" |
10 #include "remoting/protocol/protocol_mock_objects.h" | 11 #include "remoting/protocol/protocol_mock_objects.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
12 | 13 |
13 using ::testing::_; | 14 using ::testing::_; |
14 using ::testing::NotNull; | 15 using ::testing::NotNull; |
15 using ::testing::StrictMock; | 16 using ::testing::StrictMock; |
16 | 17 |
17 namespace remoting { | 18 namespace remoting { |
18 namespace protocol { | 19 namespace protocol { |
19 | 20 |
20 class ConnectionToClientTest : public testing::Test { | 21 class ConnectionToClientTest : public testing::Test { |
21 public: | 22 public: |
22 ConnectionToClientTest() { | 23 ConnectionToClientTest() { |
23 } | 24 } |
24 | 25 |
25 protected: | 26 protected: |
26 virtual void SetUp() { | 27 virtual void SetUp() { |
27 session_ = new protocol::FakeSession(); | 28 session_ = new protocol::FakeSession(); |
28 session_->set_message_loop(&message_loop_); | 29 session_->set_message_loop(&message_loop_); |
29 | 30 |
30 // Allocate a ClientConnection object with the mock objects. | 31 // Allocate a ClientConnection object with the mock objects. |
31 viewer_ = new ConnectionToClient(&message_loop_, &handler_); | 32 viewer_ = new ConnectionToClient( |
| 33 base::MessageLoopProxy::CreateForCurrentThread(), &handler_); |
32 viewer_->set_host_stub(&host_stub_); | 34 viewer_->set_host_stub(&host_stub_); |
33 viewer_->set_input_stub(&input_stub_); | 35 viewer_->set_input_stub(&input_stub_); |
34 viewer_->Init(session_); | 36 viewer_->Init(session_); |
35 EXPECT_CALL(handler_, OnConnectionOpened(viewer_.get())); | 37 EXPECT_CALL(handler_, OnConnectionOpened(viewer_.get())); |
36 session_->state_change_callback()->Run( | 38 session_->state_change_callback()->Run( |
37 protocol::Session::CONNECTED); | 39 protocol::Session::CONNECTED); |
38 session_->state_change_callback()->Run( | 40 session_->state_change_callback()->Run( |
39 protocol::Session::CONNECTED_CHANNELS); | 41 protocol::Session::CONNECTED_CHANNELS); |
40 message_loop_.RunAllPending(); | 42 message_loop_.RunAllPending(); |
41 } | 43 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // Test that we can close client connection more than once. | 103 // Test that we can close client connection more than once. |
102 TEST_F(ConnectionToClientTest, Close) { | 104 TEST_F(ConnectionToClientTest, Close) { |
103 viewer_->Disconnect(); | 105 viewer_->Disconnect(); |
104 message_loop_.RunAllPending(); | 106 message_loop_.RunAllPending(); |
105 viewer_->Disconnect(); | 107 viewer_->Disconnect(); |
106 message_loop_.RunAllPending(); | 108 message_loop_.RunAllPending(); |
107 } | 109 } |
108 | 110 |
109 } // namespace protocol | 111 } // namespace protocol |
110 } // namespace remoting | 112 } // namespace remoting |
OLD | NEW |