| 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/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
| 22 #include "components/policy/policy_constants.h" | 22 #include "components/policy/policy_constants.h" |
| 23 #include "remoting/base/auto_thread_task_runner.h" | 23 #include "remoting/base/auto_thread_task_runner.h" |
| 24 #include "remoting/host/chromoting_host_context.h" | 24 #include "remoting/host/chromoting_host_context.h" |
| 25 #include "remoting/host/it2me/it2me_confirmation_dialog.h" | 25 #include "remoting/host/it2me/it2me_confirmation_dialog.h" |
| 26 #include "remoting/host/policy_watcher.h" | 26 #include "remoting/host/policy_watcher.h" |
| 27 #include "remoting/signaling/fake_signal_strategy.h" | 27 #include "remoting/signaling/fake_signal_strategy.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 29 |
| 30 #if defined(OS_LINUX) |
| 31 #include "base/linux_util.h" |
| 32 #endif // defined(OS_LINUX) |
| 33 |
| 30 namespace remoting { | 34 namespace remoting { |
| 31 | 35 |
| 32 namespace { | 36 namespace { |
| 33 | 37 |
| 34 // Shortening some type names for readability. | 38 // Shortening some type names for readability. |
| 35 typedef protocol::ValidatingAuthenticator::Result ValidationResult; | 39 typedef protocol::ValidatingAuthenticator::Result ValidationResult; |
| 36 typedef It2MeConfirmationDialog::Result DialogResult; | 40 typedef It2MeConfirmationDialog::Result DialogResult; |
| 37 | 41 |
| 38 const char kTestUserName[] = "ficticious_user@gmail.com"; | 42 const char kTestUserName[] = "ficticious_user@gmail.com"; |
| 39 const char kTestClientJid[] = "ficticious_user@gmail.com/jid_resource"; | 43 const char kTestClientJid[] = "ficticious_user@gmail.com/jid_resource"; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 base::WeakPtrFactory<It2MeHostTest> weak_factory_; | 179 base::WeakPtrFactory<It2MeHostTest> weak_factory_; |
| 176 | 180 |
| 177 DISALLOW_COPY_AND_ASSIGN(It2MeHostTest); | 181 DISALLOW_COPY_AND_ASSIGN(It2MeHostTest); |
| 178 }; | 182 }; |
| 179 | 183 |
| 180 It2MeHostTest::It2MeHostTest() : weak_factory_(this) {} | 184 It2MeHostTest::It2MeHostTest() : weak_factory_(this) {} |
| 181 | 185 |
| 182 It2MeHostTest::~It2MeHostTest() {} | 186 It2MeHostTest::~It2MeHostTest() {} |
| 183 | 187 |
| 184 void It2MeHostTest::SetUp() { | 188 void It2MeHostTest::SetUp() { |
| 189 #if defined(OS_LINUX) |
| 190 // Need to prime the host OS version value for linux to prevent IO on the |
| 191 // network thread. base::GetLinuxDistro() caches the result. |
| 192 base::GetLinuxDistro(); |
| 193 #endif |
| 185 message_loop_.reset(new base::MessageLoop()); | 194 message_loop_.reset(new base::MessageLoop()); |
| 186 run_loop_.reset(new base::RunLoop()); | 195 run_loop_.reset(new base::RunLoop()); |
| 187 | 196 |
| 188 std::unique_ptr<ChromotingHostContext> host_context( | 197 std::unique_ptr<ChromotingHostContext> host_context( |
| 189 ChromotingHostContext::Create(new AutoThreadTaskRunner( | 198 ChromotingHostContext::Create(new AutoThreadTaskRunner( |
| 190 base::ThreadTaskRunnerHandle::Get(), run_loop_->QuitClosure()))); | 199 base::ThreadTaskRunnerHandle::Get(), run_loop_->QuitClosure()))); |
| 191 network_task_runner_ = host_context->network_task_runner(); | 200 network_task_runner_ = host_context->network_task_runner(); |
| 192 ui_task_runner_ = host_context->ui_task_runner(); | 201 ui_task_runner_ = host_context->ui_task_runner(); |
| 193 | 202 |
| 194 std::unique_ptr<FakeIt2MeDialogFactory> dialog_factory( | 203 std::unique_ptr<FakeIt2MeDialogFactory> dialog_factory( |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 ASSERT_EQ(ValidationResult::SUCCESS, validation_result_); | 530 ASSERT_EQ(ValidationResult::SUCCESS, validation_result_); |
| 522 ASSERT_EQ(It2MeHostState::kConnecting, last_host_state_); | 531 ASSERT_EQ(It2MeHostState::kConnecting, last_host_state_); |
| 523 | 532 |
| 524 RunValidationCallback(kTestClientJid2); | 533 RunValidationCallback(kTestClientJid2); |
| 525 ASSERT_EQ(ValidationResult::ERROR_TOO_MANY_CONNECTIONS, validation_result_); | 534 ASSERT_EQ(ValidationResult::ERROR_TOO_MANY_CONNECTIONS, validation_result_); |
| 526 RunUntilStateChanged(It2MeHostState::kDisconnected); | 535 RunUntilStateChanged(It2MeHostState::kDisconnected); |
| 527 ASSERT_EQ(It2MeHostState::kDisconnected, last_host_state_); | 536 ASSERT_EQ(It2MeHostState::kDisconnected, last_host_state_); |
| 528 } | 537 } |
| 529 | 538 |
| 530 } // namespace remoting | 539 } // namespace remoting |
| OLD | NEW |