OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/it2me/it2me_native_messaging_host.h" | 5 #include "remoting/host/it2me/it2me_native_messaging_host.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <cstdint> |
8 | 8 #include <memory> |
| 9 #include <string> |
9 #include <utility> | 10 #include <utility> |
10 | 11 |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
13 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
16 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
17 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
18 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 75 |
75 class MockIt2MeHost : public It2MeHost { | 76 class MockIt2MeHost : public It2MeHost { |
76 public: | 77 public: |
77 MockIt2MeHost(std::unique_ptr<ChromotingHostContext> context, | 78 MockIt2MeHost(std::unique_ptr<ChromotingHostContext> context, |
78 std::unique_ptr<PolicyWatcher> policy_watcher, | 79 std::unique_ptr<PolicyWatcher> policy_watcher, |
79 base::WeakPtr<It2MeHost::Observer> observer, | 80 base::WeakPtr<It2MeHost::Observer> observer, |
80 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 81 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
81 const std::string& directory_bot_jid) | 82 const std::string& directory_bot_jid) |
82 : It2MeHost(std::move(context), | 83 : It2MeHost(std::move(context), |
83 std::move(policy_watcher), | 84 std::move(policy_watcher), |
84 nullptr, | 85 /*confirmation_dialog_factory=*/nullptr, |
85 observer, | 86 observer, |
86 xmpp_server_config, | 87 xmpp_server_config, |
87 directory_bot_jid) {} | 88 directory_bot_jid) {} |
88 | 89 |
89 // It2MeHost overrides | 90 // It2MeHost overrides |
90 void Connect() override; | 91 void Connect() override; |
91 void Disconnect() override; | 92 void Disconnect() override; |
92 void RequestNatPolicy() override; | 93 void RequestNatPolicy() override; |
93 | 94 |
94 private: | 95 private: |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 155 } |
155 | 156 |
156 class MockIt2MeHostFactory : public It2MeHostFactory { | 157 class MockIt2MeHostFactory : public It2MeHostFactory { |
157 public: | 158 public: |
158 MockIt2MeHostFactory() : It2MeHostFactory() {} | 159 MockIt2MeHostFactory() : It2MeHostFactory() {} |
159 scoped_refptr<It2MeHost> CreateIt2MeHost( | 160 scoped_refptr<It2MeHost> CreateIt2MeHost( |
160 std::unique_ptr<ChromotingHostContext> context, | 161 std::unique_ptr<ChromotingHostContext> context, |
161 base::WeakPtr<It2MeHost::Observer> observer, | 162 base::WeakPtr<It2MeHost::Observer> observer, |
162 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 163 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
163 const std::string& directory_bot_jid) override { | 164 const std::string& directory_bot_jid) override { |
164 return new MockIt2MeHost(std::move(context), nullptr, observer, | 165 return new MockIt2MeHost(std::move(context), |
| 166 /*confirmation_dialog_factory=*/nullptr, observer, |
165 xmpp_server_config, directory_bot_jid); | 167 xmpp_server_config, directory_bot_jid); |
166 } | 168 } |
167 | 169 |
168 private: | 170 private: |
169 DISALLOW_COPY_AND_ASSIGN(MockIt2MeHostFactory); | 171 DISALLOW_COPY_AND_ASSIGN(MockIt2MeHostFactory); |
170 }; // MockIt2MeHostFactory | 172 }; // MockIt2MeHostFactory |
171 | 173 |
172 class It2MeNativeMessagingHostTest : public testing::Test { | 174 class It2MeNativeMessagingHostTest : public testing::Test { |
173 public: | 175 public: |
174 It2MeNativeMessagingHostTest() {} | 176 It2MeNativeMessagingHostTest() {} |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 } | 551 } |
550 | 552 |
551 // Verify rejection if type is unrecognized. | 553 // Verify rejection if type is unrecognized. |
552 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { | 554 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { |
553 base::DictionaryValue message; | 555 base::DictionaryValue message; |
554 message.SetString("type", "xxx"); | 556 message.SetString("type", "xxx"); |
555 TestBadRequest(message, true); | 557 TestBadRequest(message, true); |
556 } | 558 } |
557 | 559 |
558 } // namespace remoting | 560 } // namespace remoting |
OLD | NEW |