OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_host.h" | 5 #include "remoting/host/it2me/it2me_host.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
19 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
20 #include "components/policy/policy_constants.h" | 20 #include "components/policy/policy_constants.h" |
21 #include "remoting/base/auto_thread_task_runner.h" | 21 #include "remoting/base/auto_thread_task_runner.h" |
22 #include "remoting/host/chromoting_host_context.h" | 22 #include "remoting/host/chromoting_host_context.h" |
23 #include "remoting/host/it2me/it2me_confirmation_dialog.h" | 23 #include "remoting/host/it2me/it2me_confirmation_dialog.h" |
24 #include "remoting/host/policy_watcher.h" | 24 #include "remoting/host/policy_watcher.h" |
| 25 #include "remoting/signaling/fake_signal_strategy.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
26 | 27 |
27 namespace remoting { | 28 namespace remoting { |
28 | 29 |
29 namespace { | 30 namespace { |
30 | 31 |
31 // Shortening some type names for readability. | 32 // Shortening some type names for readability. |
32 typedef protocol::ValidatingAuthenticator::Result ValidationResult; | 33 typedef protocol::ValidatingAuthenticator::Result ValidationResult; |
33 typedef It2MeConfirmationDialog::Result DialogResult; | 34 typedef It2MeConfirmationDialog::Result DialogResult; |
34 | 35 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 104 |
104 private: | 105 private: |
105 std::unique_ptr<base::MessageLoop> message_loop_; | 106 std::unique_ptr<base::MessageLoop> message_loop_; |
106 std::unique_ptr<base::RunLoop> run_loop_; | 107 std::unique_ptr<base::RunLoop> run_loop_; |
107 | 108 |
108 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; | 109 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; |
109 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; | 110 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; |
110 | 111 |
111 scoped_refptr<It2MeHost> it2me_host_; | 112 scoped_refptr<It2MeHost> it2me_host_; |
112 | 113 |
113 std::string directory_bot_jid_; | |
114 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; | |
115 | |
116 DISALLOW_COPY_AND_ASSIGN(It2MeHostTest); | 114 DISALLOW_COPY_AND_ASSIGN(It2MeHostTest); |
117 }; | 115 }; |
118 | 116 |
119 void It2MeHostTest::SetUp() { | 117 void It2MeHostTest::SetUp() { |
120 message_loop_.reset(new base::MessageLoop()); | 118 message_loop_.reset(new base::MessageLoop()); |
121 run_loop_.reset(new base::RunLoop()); | 119 run_loop_.reset(new base::RunLoop()); |
122 | 120 |
123 std::unique_ptr<ChromotingHostContext> host_context( | 121 std::unique_ptr<ChromotingHostContext> host_context( |
124 ChromotingHostContext::Create(new AutoThreadTaskRunner( | 122 ChromotingHostContext::Create(new AutoThreadTaskRunner( |
125 base::ThreadTaskRunnerHandle::Get(), run_loop_->QuitClosure()))); | 123 base::ThreadTaskRunnerHandle::Get(), run_loop_->QuitClosure()))); |
126 network_task_runner_ = host_context->network_task_runner(); | 124 network_task_runner_ = host_context->network_task_runner(); |
127 ui_task_runner_ = host_context->ui_task_runner(); | 125 ui_task_runner_ = host_context->ui_task_runner(); |
128 | 126 |
129 dialog_ = new FakeIt2MeConfirmationDialog(); | 127 dialog_ = new FakeIt2MeConfirmationDialog(); |
130 | |
131 it2me_host_ = | 128 it2me_host_ = |
132 new It2MeHost(std::move(host_context), /*policy_watcher=*/nullptr, | 129 new It2MeHost(std::move(host_context), |
133 base::WrapUnique(dialog_), /*observer=*/nullptr, | 130 /*policy_watcher=*/nullptr, base::WrapUnique(dialog_), |
134 xmpp_server_config_, directory_bot_jid_); | 131 /*observer=*/nullptr, |
| 132 base::WrapUnique(new FakeSignalStrategy("fake_local_jid")), |
| 133 "fake_user_name", "fake_bot_jid"); |
135 } | 134 } |
136 | 135 |
137 void It2MeHostTest::TearDown() { | 136 void It2MeHostTest::TearDown() { |
138 network_task_runner_ = nullptr; | 137 network_task_runner_ = nullptr; |
139 ui_task_runner_ = nullptr; | 138 ui_task_runner_ = nullptr; |
140 it2me_host_ = nullptr; | 139 it2me_host_ = nullptr; |
141 run_loop_->Run(); | 140 run_loop_->Run(); |
142 } | 141 } |
143 | 142 |
144 void It2MeHostTest::OnValidationComplete(const base::Closure& resume_callback, | 143 void It2MeHostTest::OnValidationComplete(const base::Closure& resume_callback, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } | 239 } |
241 | 240 |
242 TEST_F(It2MeHostTest, ConnectionValidation_ConfirmationDialog_Reject) { | 241 TEST_F(It2MeHostTest, ConnectionValidation_ConfirmationDialog_Reject) { |
243 dialog_->set_dialog_result(DialogResult::CANCEL); | 242 dialog_->set_dialog_result(DialogResult::CANCEL); |
244 RunValidationCallback(kTestClientJid); | 243 RunValidationCallback(kTestClientJid); |
245 ASSERT_EQ(ValidationResult::ERROR_REJECTED_BY_USER, validation_result_); | 244 ASSERT_EQ(ValidationResult::ERROR_REJECTED_BY_USER, validation_result_); |
246 ASSERT_STREQ(kTestClientUserName, remote_user_email_.c_str()); | 245 ASSERT_STREQ(kTestClientUserName, remote_user_email_.c_str()); |
247 } | 246 } |
248 | 247 |
249 } // namespace remoting | 248 } // namespace remoting |
OLD | NEW |