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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 100 |
100 // Used to set ConfirmationDialog behavior. | 101 // Used to set ConfirmationDialog behavior. |
101 FakeIt2MeConfirmationDialog* dialog_ = nullptr; | 102 FakeIt2MeConfirmationDialog* dialog_ = nullptr; |
102 | 103 |
103 private: | 104 private: |
104 std::unique_ptr<base::MessageLoop> message_loop_; | 105 std::unique_ptr<base::MessageLoop> message_loop_; |
105 std::unique_ptr<base::RunLoop> run_loop_; | 106 std::unique_ptr<base::RunLoop> run_loop_; |
106 | 107 |
107 scoped_refptr<It2MeHost> it2me_host_; | 108 scoped_refptr<It2MeHost> it2me_host_; |
108 | 109 |
109 std::string directory_bot_jid_; | |
110 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; | |
111 | |
112 DISALLOW_COPY_AND_ASSIGN(It2MeHostTest); | 110 DISALLOW_COPY_AND_ASSIGN(It2MeHostTest); |
113 }; | 111 }; |
114 | 112 |
115 void It2MeHostTest::SetUp() { | 113 void It2MeHostTest::SetUp() { |
116 message_loop_.reset(new base::MessageLoop()); | 114 message_loop_.reset(new base::MessageLoop()); |
117 run_loop_.reset(new base::RunLoop()); | 115 run_loop_.reset(new base::RunLoop()); |
118 | 116 |
119 scoped_refptr<AutoThreadTaskRunner> auto_thread_task_runner = | 117 scoped_refptr<AutoThreadTaskRunner> auto_thread_task_runner = |
120 new AutoThreadTaskRunner(base::ThreadTaskRunnerHandle::Get(), | 118 new AutoThreadTaskRunner(base::ThreadTaskRunnerHandle::Get(), |
121 run_loop_->QuitClosure()); | 119 run_loop_->QuitClosure()); |
122 dialog_ = new FakeIt2MeConfirmationDialog(); | 120 dialog_ = new FakeIt2MeConfirmationDialog(); |
123 it2me_host_ = new It2MeHost( | 121 it2me_host_ = |
124 ChromotingHostContext::Create(auto_thread_task_runner), | 122 new It2MeHost(ChromotingHostContext::Create(auto_thread_task_runner), |
125 /*policy_watcher=*/nullptr, base::WrapUnique(dialog_), | 123 /*policy_watcher=*/nullptr, base::WrapUnique(dialog_), |
126 /*observer=*/nullptr, xmpp_server_config_, directory_bot_jid_); | 124 /*observer=*/nullptr, |
| 125 base::WrapUnique(new FakeSignalStrategy("fake_local_jid")), |
| 126 "fake_user_name", "fake_bot_jid"); |
127 } | 127 } |
128 | 128 |
129 void It2MeHostTest::TearDown() { | 129 void It2MeHostTest::TearDown() { |
130 it2me_host_ = nullptr; | 130 it2me_host_ = nullptr; |
131 run_loop_->Run(); | 131 run_loop_->Run(); |
132 } | 132 } |
133 | 133 |
134 void It2MeHostTest::OnValidationComplete(const base::Closure& resume_callback, | 134 void It2MeHostTest::OnValidationComplete(const base::Closure& resume_callback, |
135 ValidationResult validation_result) { | 135 ValidationResult validation_result) { |
136 validation_result_ = validation_result; | 136 validation_result_ = validation_result; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 } | 220 } |
221 | 221 |
222 TEST_F(It2MeHostTest, ConnectionValidation_ConfirmationDialog_Reject) { | 222 TEST_F(It2MeHostTest, ConnectionValidation_ConfirmationDialog_Reject) { |
223 dialog_->set_dialog_result(DialogResult::CANCEL); | 223 dialog_->set_dialog_result(DialogResult::CANCEL); |
224 RunValidationCallback(kTestClientJid); | 224 RunValidationCallback(kTestClientJid); |
225 ASSERT_EQ(ValidationResult::ERROR_REJECTED_BY_USER, validation_result_); | 225 ASSERT_EQ(ValidationResult::ERROR_REJECTED_BY_USER, validation_result_); |
226 ASSERT_STREQ(kTestClientUserName, dialog_->get_remote_user_email().c_str()); | 226 ASSERT_STREQ(kTestClientUserName, dialog_->get_remote_user_email().c_str()); |
227 } | 227 } |
228 | 228 |
229 } // namespace remoting | 229 } // namespace remoting |
OLD | NEW |