Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: remoting/host/local_input_monitor_unittest.cc

Issue 2412733002: Add FileDescriptorWatcher in LocalInputMonitorTest (Closed)
Patch Set: inc Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/local_input_monitor.h" 5 #include "remoting/host/local_input_monitor.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "remoting/base/auto_thread_task_runner.h" 13 #include "remoting/base/auto_thread_task_runner.h"
14 #include "remoting/host/client_session_control.h" 14 #include "remoting/host/client_session_control.h"
15 #include "remoting/host/host_mock_objects.h" 15 #include "remoting/host/host_mock_objects.h"
16 #include "remoting/protocol/protocol_mock_objects.h" 16 #include "remoting/protocol/protocol_mock_objects.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 #if defined(OS_POSIX)
21 #include "base/files/file_descriptor_watcher_posix.h"
22 #endif
23
20 namespace remoting { 24 namespace remoting {
21 25
22 using testing::_; 26 using testing::_;
23 using testing::AnyNumber; 27 using testing::AnyNumber;
24 using testing::ReturnRef; 28 using testing::ReturnRef;
25 29
26 namespace { 30 namespace {
27 31
28 #if defined(OS_WIN) 32 #if defined(OS_WIN)
29 const base::MessageLoop::Type kDesiredMessageLoopType = 33 const base::MessageLoop::Type kDesiredMessageLoopType =
30 base::MessageLoop::TYPE_UI; 34 base::MessageLoop::TYPE_UI;
31 #else // !defined(OS_WIN) 35 #else // !defined(OS_WIN)
32 const base::MessageLoop::Type kDesiredMessageLoopType = 36 const base::MessageLoop::Type kDesiredMessageLoopType =
33 base::MessageLoop::TYPE_IO; 37 base::MessageLoop::TYPE_IO;
34 #endif // !defined(OS_WIN) 38 #endif // !defined(OS_WIN)
35 39
36 } // namespace 40 } // namespace
37 41
38 class LocalInputMonitorTest : public testing::Test { 42 class LocalInputMonitorTest : public testing::Test {
39 public: 43 public:
40 LocalInputMonitorTest(); 44 LocalInputMonitorTest();
41 45
42 void SetUp() override; 46 void SetUp() override;
43 47
44 base::MessageLoop message_loop_; 48 base::MessageLoop message_loop_;
49 #if defined(OS_POSIX)
50 // Required to watch a file descriptor from NativeMessageProcessHost.
51 base::FileDescriptorWatcher file_descriptor_watcher_;
52 #endif
45 base::RunLoop run_loop_; 53 base::RunLoop run_loop_;
46 scoped_refptr<AutoThreadTaskRunner> task_runner_; 54 scoped_refptr<AutoThreadTaskRunner> task_runner_;
47 55
48 std::string client_jid_; 56 std::string client_jid_;
49 MockClientSessionControl client_session_control_; 57 MockClientSessionControl client_session_control_;
50 base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_; 58 base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_;
51 }; 59 };
52 60
53 LocalInputMonitorTest::LocalInputMonitorTest() 61 LocalInputMonitorTest::LocalInputMonitorTest()
54 : message_loop_(kDesiredMessageLoopType), 62 : message_loop_(kDesiredMessageLoopType),
63 #if defined(OS_POSIX)
64 file_descriptor_watcher_(base::MessageLoopForIO::current()),
65 #endif
55 client_jid_("user@domain/rest-of-jid"), 66 client_jid_("user@domain/rest-of-jid"),
56 client_session_control_factory_(&client_session_control_) { 67 client_session_control_factory_(&client_session_control_) {
57 } 68 }
58 69
59 void LocalInputMonitorTest::SetUp() { 70 void LocalInputMonitorTest::SetUp() {
60 // Arrange to run |message_loop_| until no components depend on it. 71 // Arrange to run |message_loop_| until no components depend on it.
61 task_runner_ = new AutoThreadTaskRunner( 72 task_runner_ = new AutoThreadTaskRunner(
62 message_loop_.task_runner(), run_loop_.QuitClosure()); 73 message_loop_.task_runner(), run_loop_.QuitClosure());
63 } 74 }
64 75
(...skipping 16 matching lines...) Expand all
81 std::unique_ptr<LocalInputMonitor> local_input_monitor = 92 std::unique_ptr<LocalInputMonitor> local_input_monitor =
82 LocalInputMonitor::Create(task_runner_, task_runner_, task_runner_, 93 LocalInputMonitor::Create(task_runner_, task_runner_, task_runner_,
83 client_session_control_factory_.GetWeakPtr()); 94 client_session_control_factory_.GetWeakPtr());
84 task_runner_ = nullptr; 95 task_runner_ = nullptr;
85 } 96 }
86 97
87 run_loop_.Run(); 98 run_loop_.Run();
88 } 99 }
89 100
90 } // namespace remoting 101 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698