| 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 <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 void FakePolicyService::RefreshPolicies(const base::Closure& callback) { | 121 void FakePolicyService::RefreshPolicies(const base::Closure& callback) { |
| 122 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); | 122 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); |
| 123 } | 123 } |
| 124 | 124 |
| 125 class MockIt2MeHost : public It2MeHost { | 125 class MockIt2MeHost : public It2MeHost { |
| 126 public: | 126 public: |
| 127 MockIt2MeHost(std::unique_ptr<ChromotingHostContext> context, | 127 MockIt2MeHost(std::unique_ptr<ChromotingHostContext> context, |
| 128 std::unique_ptr<PolicyWatcher> policy_watcher, | 128 std::unique_ptr<PolicyWatcher> policy_watcher, |
| 129 base::WeakPtr<It2MeHost::Observer> observer, | 129 base::WeakPtr<It2MeHost::Observer> observer, |
| 130 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 130 std::unique_ptr<SignalStrategy> signal_strategy, |
| 131 const std::string& username, |
| 131 const std::string& directory_bot_jid) | 132 const std::string& directory_bot_jid) |
| 132 : It2MeHost(std::move(context), | 133 : It2MeHost(std::move(context), |
| 133 std::move(policy_watcher), | 134 std::move(policy_watcher), |
| 134 /*confirmation_dialog_factory=*/nullptr, | 135 /*confirmation_dialog_factory=*/nullptr, |
| 135 observer, | 136 observer, |
| 136 xmpp_server_config, | 137 std::move(signal_strategy), |
| 138 username, |
| 137 directory_bot_jid) {} | 139 directory_bot_jid) {} |
| 138 | 140 |
| 139 // It2MeHost overrides | 141 // It2MeHost overrides |
| 140 void Connect() override; | 142 void Connect() override; |
| 141 void Disconnect() override; | 143 void Disconnect() override; |
| 142 void RequestNatPolicy() override; | 144 void RequestNatPolicy() override; |
| 143 | 145 |
| 144 private: | 146 private: |
| 145 ~MockIt2MeHost() override {} | 147 ~MockIt2MeHost() override {} |
| 146 | 148 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 202 |
| 201 class MockIt2MeHostFactory : public It2MeHostFactory { | 203 class MockIt2MeHostFactory : public It2MeHostFactory { |
| 202 public: | 204 public: |
| 203 MockIt2MeHostFactory(); | 205 MockIt2MeHostFactory(); |
| 204 ~MockIt2MeHostFactory() override; | 206 ~MockIt2MeHostFactory() override; |
| 205 | 207 |
| 206 scoped_refptr<It2MeHost> CreateIt2MeHost( | 208 scoped_refptr<It2MeHost> CreateIt2MeHost( |
| 207 std::unique_ptr<ChromotingHostContext> context, | 209 std::unique_ptr<ChromotingHostContext> context, |
| 208 policy::PolicyService* policy_service, | 210 policy::PolicyService* policy_service, |
| 209 base::WeakPtr<It2MeHost::Observer> observer, | 211 base::WeakPtr<It2MeHost::Observer> observer, |
| 210 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 212 std::unique_ptr<SignalStrategy> signal_strategy, |
| 213 const std::string& username, |
| 211 const std::string& directory_bot_jid) override; | 214 const std::string& directory_bot_jid) override; |
| 212 | 215 |
| 213 private: | 216 private: |
| 214 DISALLOW_COPY_AND_ASSIGN(MockIt2MeHostFactory); | 217 DISALLOW_COPY_AND_ASSIGN(MockIt2MeHostFactory); |
| 215 }; | 218 }; |
| 216 | 219 |
| 217 MockIt2MeHostFactory::MockIt2MeHostFactory() : It2MeHostFactory() {} | 220 MockIt2MeHostFactory::MockIt2MeHostFactory() : It2MeHostFactory() {} |
| 218 | 221 |
| 219 MockIt2MeHostFactory::~MockIt2MeHostFactory() {} | 222 MockIt2MeHostFactory::~MockIt2MeHostFactory() {} |
| 220 | 223 |
| 221 scoped_refptr<It2MeHost> MockIt2MeHostFactory::CreateIt2MeHost( | 224 scoped_refptr<It2MeHost> MockIt2MeHostFactory::CreateIt2MeHost( |
| 222 std::unique_ptr<ChromotingHostContext> context, | 225 std::unique_ptr<ChromotingHostContext> context, |
| 223 policy::PolicyService* policy_service, | 226 policy::PolicyService* policy_service, |
| 224 base::WeakPtr<It2MeHost::Observer> observer, | 227 base::WeakPtr<It2MeHost::Observer> observer, |
| 225 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 228 std::unique_ptr<SignalStrategy> signal_strategy, |
| 229 const std::string& username, |
| 226 const std::string& directory_bot_jid) { | 230 const std::string& directory_bot_jid) { |
| 227 return new MockIt2MeHost(std::move(context), | 231 return new MockIt2MeHost(std::move(context), |
| 228 /*policy_watcher=*/nullptr, observer, | 232 /*policy_watcher=*/nullptr, observer, |
| 229 xmpp_server_config, directory_bot_jid); | 233 std::move(signal_strategy), username, |
| 234 directory_bot_jid); |
| 230 } | 235 } |
| 231 | 236 |
| 232 } // namespace | 237 } // namespace |
| 233 | 238 |
| 234 class It2MeNativeMessagingHostTest : public testing::Test { | 239 class It2MeNativeMessagingHostTest : public testing::Test { |
| 235 public: | 240 public: |
| 236 It2MeNativeMessagingHostTest() {} | 241 It2MeNativeMessagingHostTest() {} |
| 237 ~It2MeNativeMessagingHostTest() override {} | 242 ~It2MeNativeMessagingHostTest() override {} |
| 238 | 243 |
| 239 void SetUp() override; | 244 void SetUp() override; |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 } | 624 } |
| 620 | 625 |
| 621 // Verify rejection if type is unrecognized. | 626 // Verify rejection if type is unrecognized. |
| 622 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { | 627 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { |
| 623 base::DictionaryValue message; | 628 base::DictionaryValue message; |
| 624 message.SetString("type", "xxx"); | 629 message.SetString("type", "xxx"); |
| 625 TestBadRequest(message, true); | 630 TestBadRequest(message, true); |
| 626 } | 631 } |
| 627 | 632 |
| 628 } // namespace remoting | 633 } // namespace remoting |
| OLD | NEW |