OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 13 matching lines...) Expand all Loading... |
24 ConnectionToClientTest() { | 24 ConnectionToClientTest() { |
25 } | 25 } |
26 | 26 |
27 protected: | 27 protected: |
28 virtual void SetUp() OVERRIDE { | 28 virtual void SetUp() OVERRIDE { |
29 session_ = new protocol::FakeSession(); | 29 session_ = new protocol::FakeSession(); |
30 session_->set_message_loop(&message_loop_); | 30 session_->set_message_loop(&message_loop_); |
31 | 31 |
32 // Allocate a ClientConnection object with the mock objects. | 32 // Allocate a ClientConnection object with the mock objects. |
33 viewer_.reset(new ConnectionToClient(session_)); | 33 viewer_.reset(new ConnectionToClient(session_)); |
| 34 viewer_->set_clipboard_stub(&clipboard_stub_); |
34 viewer_->set_host_stub(&host_stub_); | 35 viewer_->set_host_stub(&host_stub_); |
35 viewer_->set_input_stub(&input_stub_); | 36 viewer_->set_input_stub(&input_stub_); |
36 viewer_->SetEventHandler(&handler_); | 37 viewer_->SetEventHandler(&handler_); |
37 EXPECT_CALL(handler_, OnConnectionOpened(viewer_.get())); | 38 EXPECT_CALL(handler_, OnConnectionOpened(viewer_.get())); |
38 session_->state_change_callback().Run( | 39 session_->state_change_callback().Run( |
39 protocol::Session::CONNECTED); | 40 protocol::Session::CONNECTED); |
40 session_->state_change_callback().Run( | 41 session_->state_change_callback().Run( |
41 protocol::Session::AUTHENTICATED); | 42 protocol::Session::AUTHENTICATED); |
42 message_loop_.RunAllPending(); | 43 message_loop_.RunAllPending(); |
43 } | 44 } |
44 | 45 |
45 virtual void TearDown() OVERRIDE { | 46 virtual void TearDown() OVERRIDE { |
46 viewer_.reset(); | 47 viewer_.reset(); |
47 message_loop_.RunAllPending(); | 48 message_loop_.RunAllPending(); |
48 } | 49 } |
49 | 50 |
50 MessageLoop message_loop_; | 51 MessageLoop message_loop_; |
51 MockConnectionToClientEventHandler handler_; | 52 MockConnectionToClientEventHandler handler_; |
| 53 MockClipboardStub clipboard_stub_; |
52 MockHostStub host_stub_; | 54 MockHostStub host_stub_; |
53 MockInputStub input_stub_; | 55 MockInputStub input_stub_; |
54 scoped_ptr<ConnectionToClient> viewer_; | 56 scoped_ptr<ConnectionToClient> viewer_; |
55 | 57 |
56 // Owned by |viewer_|. | 58 // Owned by |viewer_|. |
57 protocol::FakeSession* session_; | 59 protocol::FakeSession* session_; |
58 | 60 |
59 private: | 61 private: |
60 DISALLOW_COPY_AND_ASSIGN(ConnectionToClientTest); | 62 DISALLOW_COPY_AND_ASSIGN(ConnectionToClientTest); |
61 }; | 63 }; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 message_loop_.RunAllPending(); | 103 message_loop_.RunAllPending(); |
102 | 104 |
103 EXPECT_CALL(handler_, OnConnectionFailed(viewer_.get(), SESSION_REJECTED)); | 105 EXPECT_CALL(handler_, OnConnectionFailed(viewer_.get(), SESSION_REJECTED)); |
104 session_->set_error(SESSION_REJECTED); | 106 session_->set_error(SESSION_REJECTED); |
105 session_->state_change_callback().Run(protocol::Session::FAILED); | 107 session_->state_change_callback().Run(protocol::Session::FAILED); |
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 |