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 "remoting/host/client_session.h" | 5 #include "remoting/host/client_session.h" |
6 #include "remoting/host/host_mock_objects.h" | 6 #include "remoting/host/host_mock_objects.h" |
7 #include "remoting/protocol/protocol_mock_objects.h" | 7 #include "remoting/protocol/protocol_mock_objects.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace remoting { | 10 namespace remoting { |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 // A task that does nothing. | 14 // A task that does nothing. |
15 class DummyTask : public Task { | 15 class DummyTask : public Task { |
16 public: | 16 public: |
17 void Run() {} | 17 void Run() {} |
18 }; | 18 }; |
19 | 19 |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 using protocol::MockConnectionToClient; | 22 using protocol::MockConnectionToClient; |
23 using protocol::MockConnectionToClientEventHandler; | 23 using protocol::MockConnectionToClientEventHandler; |
24 using protocol::MockHostStub; | 24 using protocol::MockHostStub; |
25 using protocol::MockInputStub; | 25 using protocol::MockInputStub; |
| 26 using protocol::MockSession; |
26 | 27 |
27 using testing::_; | 28 using testing::_; |
28 using testing::DeleteArg; | 29 using testing::DeleteArg; |
29 using testing::InSequence; | 30 using testing::InSequence; |
30 using testing::Return; | 31 using testing::Return; |
| 32 using testing::ReturnRef; |
31 | 33 |
32 class ClientSessionTest : public testing::Test { | 34 class ClientSessionTest : public testing::Test { |
33 public: | 35 public: |
34 ClientSessionTest() {} | 36 ClientSessionTest() {} |
35 | 37 |
36 virtual void SetUp() { | 38 virtual void SetUp() { |
| 39 client_jid_ = "user@domain/rest-of-jid"; |
| 40 EXPECT_CALL(session_, jid()).WillRepeatedly(ReturnRef(client_jid_)); |
| 41 |
37 connection_ = new MockConnectionToClient( | 42 connection_ = new MockConnectionToClient( |
38 &connection_event_handler_, &host_stub_, &input_stub_); | 43 &connection_event_handler_, &host_stub_, &input_stub_); |
| 44 |
| 45 EXPECT_CALL(*connection_, session()).WillRepeatedly(Return(&session_)); |
| 46 |
39 user_authenticator_ = new MockUserAuthenticator(); | 47 user_authenticator_ = new MockUserAuthenticator(); |
40 client_session_ = new ClientSession( | 48 client_session_ = new ClientSession( |
41 &session_event_handler_, | 49 &session_event_handler_, |
42 user_authenticator_, | 50 user_authenticator_, |
43 connection_, | 51 connection_, |
44 &input_stub_); | 52 &input_stub_); |
45 | 53 |
46 ON_CALL(input_stub_, InjectKeyEvent(_, _)).WillByDefault(DeleteArg<1>()); | 54 ON_CALL(input_stub_, InjectKeyEvent(_, _)).WillByDefault(DeleteArg<1>()); |
47 ON_CALL(input_stub_, InjectMouseEvent(_, _)).WillByDefault(DeleteArg<1>()); | 55 ON_CALL(input_stub_, InjectMouseEvent(_, _)).WillByDefault(DeleteArg<1>()); |
48 } | 56 } |
49 | 57 |
50 protected: | 58 protected: |
51 MessageLoop message_loop_; | 59 MessageLoop message_loop_; |
| 60 std::string client_jid_; |
| 61 MockSession session_; |
52 MockConnectionToClientEventHandler connection_event_handler_; | 62 MockConnectionToClientEventHandler connection_event_handler_; |
53 MockHostStub host_stub_; | 63 MockHostStub host_stub_; |
54 MockInputStub input_stub_; | 64 MockInputStub input_stub_; |
55 MockClientSessionEventHandler session_event_handler_; | 65 MockClientSessionEventHandler session_event_handler_; |
56 MockUserAuthenticator* user_authenticator_; | 66 MockUserAuthenticator* user_authenticator_; |
57 scoped_refptr<MockConnectionToClient> connection_; | 67 scoped_refptr<MockConnectionToClient> connection_; |
58 scoped_refptr<ClientSession> client_session_; | 68 scoped_refptr<ClientSession> client_session_; |
59 }; | 69 }; |
60 | 70 |
61 TEST_F(ClientSessionTest, InputStubFilter) { | 71 TEST_F(ClientSessionTest, InputStubFilter) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 client_session_->RecordKeyEvent(&key1); | 183 client_session_->RecordKeyEvent(&key1); |
174 client_session_->RecordKeyEvent(&key2); | 184 client_session_->RecordKeyEvent(&key2); |
175 | 185 |
176 EXPECT_CALL(input_stub_, InjectKeyEvent(IsMatchingKeyUp(&key1), _)); | 186 EXPECT_CALL(input_stub_, InjectKeyEvent(IsMatchingKeyUp(&key1), _)); |
177 EXPECT_CALL(input_stub_, InjectKeyEvent(IsMatchingKeyUp(&key2), _)); | 187 EXPECT_CALL(input_stub_, InjectKeyEvent(IsMatchingKeyUp(&key2), _)); |
178 | 188 |
179 client_session_->UnpressKeys(); | 189 client_session_->UnpressKeys(); |
180 } | 190 } |
181 | 191 |
182 } // namespace remoting | 192 } // namespace remoting |
OLD | NEW |