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

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

Issue 11231060: [Chromoting] The desktop process now creates a pre-connected pipe and passes (with some help of the… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/daemon_process.cc ('k') | remoting/host/daemon_process_win.cc » ('j') | 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/process.h"
9 #include "ipc/ipc_message.h" 9 #include "ipc/ipc_message.h"
10 #include "ipc/ipc_message_macros.h" 10 #include "ipc/ipc_message_macros.h"
11 #include "ipc/ipc_platform_file.h"
11 #include "remoting/base/auto_thread_task_runner.h" 12 #include "remoting/base/auto_thread_task_runner.h"
12 #include "remoting/host/chromoting_messages.h" 13 #include "remoting/host/chromoting_messages.h"
13 #include "remoting/host/daemon_process.h" 14 #include "remoting/host/daemon_process.h"
14 #include "remoting/host/desktop_session.h" 15 #include "remoting/host/desktop_session.h"
15 #include "testing/gmock_mutant.h" 16 #include "testing/gmock_mutant.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 using testing::_; 20 using testing::_;
20 using testing::AnyNumber; 21 using testing::AnyNumber;
(...skipping 19 matching lines...) Expand all
40 FakeDesktopSession(DaemonProcess* daemon_process, int id); 41 FakeDesktopSession(DaemonProcess* daemon_process, int id);
41 virtual ~FakeDesktopSession(); 42 virtual ~FakeDesktopSession();
42 43
43 private: 44 private:
44 DISALLOW_COPY_AND_ASSIGN(FakeDesktopSession); 45 DISALLOW_COPY_AND_ASSIGN(FakeDesktopSession);
45 }; 46 };
46 47
47 class MockDaemonProcess : public DaemonProcess { 48 class MockDaemonProcess : public DaemonProcess {
48 public: 49 public:
49 MockDaemonProcess( 50 MockDaemonProcess(
50 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 51 scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
51 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, 52 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
52 const base::Closure& stopped_callback); 53 const base::Closure& stopped_callback);
53 virtual ~MockDaemonProcess(); 54 virtual ~MockDaemonProcess();
54 55
55 virtual scoped_ptr<DesktopSession> DoCreateDesktopSession( 56 virtual scoped_ptr<DesktopSession> DoCreateDesktopSession(
56 int terminal_id) OVERRIDE; 57 int terminal_id) OVERRIDE;
57 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
58 virtual void SendToNetwork(IPC::Message* message) OVERRIDE; 59 virtual void SendToNetwork(IPC::Message* message) OVERRIDE;
59 60
60 MOCK_METHOD1(Received, void(const IPC::Message&)); 61 MOCK_METHOD1(Received, void(const IPC::Message&));
61 MOCK_METHOD1(Sent, void(const IPC::Message&)); 62 MOCK_METHOD1(Sent, void(const IPC::Message&));
62 63
64 MOCK_METHOD3(OnDesktopSessionAgentAttached,
65 bool(int, base::ProcessHandle, IPC::PlatformFileForTransit));
66
63 MOCK_METHOD1(DoCreateDesktopSessionPtr, DesktopSession*(int)); 67 MOCK_METHOD1(DoCreateDesktopSessionPtr, DesktopSession*(int));
64 MOCK_METHOD0(LaunchNetworkProcess, void()); 68 MOCK_METHOD0(LaunchNetworkProcess, void());
65 69
66 private: 70 private:
67 DISALLOW_COPY_AND_ASSIGN(MockDaemonProcess); 71 DISALLOW_COPY_AND_ASSIGN(MockDaemonProcess);
68 }; 72 };
69 73
70 FakeDesktopSession::FakeDesktopSession(DaemonProcess* daemon_process, int id) 74 FakeDesktopSession::FakeDesktopSession(DaemonProcess* daemon_process, int id)
71 : DesktopSession(daemon_process, id) { 75 : DesktopSession(daemon_process, id) {
72 } 76 }
73 77
74 FakeDesktopSession::~FakeDesktopSession() { 78 FakeDesktopSession::~FakeDesktopSession() {
75 } 79 }
76 80
77 MockDaemonProcess::MockDaemonProcess( 81 MockDaemonProcess::MockDaemonProcess(
78 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 82 scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
79 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, 83 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
80 const base::Closure& stopped_callback) 84 const base::Closure& stopped_callback)
81 : DaemonProcess(caller_task_runner, io_task_runner, stopped_callback) { 85 : DaemonProcess(caller_task_runner, io_task_runner, stopped_callback) {
82 } 86 }
83 87
84 MockDaemonProcess::~MockDaemonProcess() { 88 MockDaemonProcess::~MockDaemonProcess() {
85 } 89 }
86 90
87 scoped_ptr<DesktopSession> MockDaemonProcess::DoCreateDesktopSession( 91 scoped_ptr<DesktopSession> MockDaemonProcess::DoCreateDesktopSession(
88 int terminal_id) { 92 int terminal_id) {
89 return scoped_ptr<DesktopSession>(DoCreateDesktopSessionPtr(terminal_id)); 93 return scoped_ptr<DesktopSession>(DoCreateDesktopSessionPtr(terminal_id));
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 EXPECT_EQ(1u, desktop_sessions().size()); 310 EXPECT_EQ(1u, desktop_sessions().size());
307 EXPECT_EQ(id, desktop_sessions().front()->id()); 311 EXPECT_EQ(id, desktop_sessions().front()->id());
308 312
309 EXPECT_TRUE(daemon_process_->OnMessageReceived( 313 EXPECT_TRUE(daemon_process_->OnMessageReceived(
310 ChromotingNetworkHostMsg_ConnectTerminal(id))); 314 ChromotingNetworkHostMsg_ConnectTerminal(id)));
311 EXPECT_TRUE(desktop_sessions().empty()); 315 EXPECT_TRUE(desktop_sessions().empty());
312 EXPECT_EQ(0, terminal_id_); 316 EXPECT_EQ(0, terminal_id_);
313 } 317 }
314 318
315 } // namespace remoting 319 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/daemon_process.cc ('k') | remoting/host/daemon_process_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698