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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
8 #include "remoting/base/base_mock_objects.h" | 8 #include "remoting/base/base_mock_objects.h" |
9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
10 #include "remoting/protocol/fake_session.h" | 10 #include "remoting/protocol/fake_session.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 viewer_->set_input_stub(&input_stub_); | 36 viewer_->set_input_stub(&input_stub_); |
37 viewer_->SetEventHandler(&handler_); | 37 viewer_->SetEventHandler(&handler_); |
38 EXPECT_CALL(handler_, OnConnectionOpened(viewer_.get())); | 38 EXPECT_CALL(handler_, OnConnectionOpened(viewer_.get())); |
39 session_->state_change_callback().Run( | 39 session_->state_change_callback().Run( |
40 protocol::Session::CONNECTED); | 40 protocol::Session::CONNECTED); |
41 session_->state_change_callback().Run( | 41 session_->state_change_callback().Run( |
42 protocol::Session::CONNECTED_CHANNELS); | 42 protocol::Session::CONNECTED_CHANNELS); |
43 message_loop_.RunAllPending(); | 43 message_loop_.RunAllPending(); |
44 } | 44 } |
45 | 45 |
| 46 virtual void TearDown() OVERRIDE { |
| 47 viewer_ = NULL; |
| 48 message_loop_.RunAllPending(); |
| 49 } |
| 50 |
46 MessageLoop message_loop_; | 51 MessageLoop message_loop_; |
47 MockConnectionToClientEventHandler handler_; | 52 MockConnectionToClientEventHandler handler_; |
48 MockHostStub host_stub_; | 53 MockHostStub host_stub_; |
49 MockInputStub input_stub_; | 54 MockInputStub input_stub_; |
50 scoped_refptr<ConnectionToClient> viewer_; | 55 scoped_refptr<ConnectionToClient> viewer_; |
51 | 56 |
52 // Owned by |viewer_|. | 57 // Owned by |viewer_|. |
53 protocol::FakeSession* session_; | 58 protocol::FakeSession* session_; |
54 | 59 |
55 private: | 60 private: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 TEST_F(ConnectionToClientTest, StateChange) { | 99 TEST_F(ConnectionToClientTest, StateChange) { |
95 EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get())); | 100 EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get())); |
96 session_->state_change_callback().Run(protocol::Session::CLOSED); | 101 session_->state_change_callback().Run(protocol::Session::CLOSED); |
97 message_loop_.RunAllPending(); | 102 message_loop_.RunAllPending(); |
98 | 103 |
99 EXPECT_CALL(handler_, OnConnectionFailed(viewer_.get())); | 104 EXPECT_CALL(handler_, OnConnectionFailed(viewer_.get())); |
100 session_->state_change_callback().Run(protocol::Session::FAILED); | 105 session_->state_change_callback().Run(protocol::Session::FAILED); |
101 message_loop_.RunAllPending(); | 106 message_loop_.RunAllPending(); |
102 } | 107 } |
103 | 108 |
104 // Test that we can close client connection more than once. | |
105 TEST_F(ConnectionToClientTest, Close) { | |
106 viewer_->Disconnect(); | |
107 message_loop_.RunAllPending(); | |
108 viewer_->Disconnect(); | |
109 message_loop_.RunAllPending(); | |
110 } | |
111 | |
112 } // namespace protocol | 109 } // namespace protocol |
113 } // namespace remoting | 110 } // namespace remoting |
OLD | NEW |