| OLD | NEW |
| 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/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/process/process.h" | 9 #include "base/process/process.h" |
| 10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 // Provides a public constructor allowing the test to create instances of | 38 // Provides a public constructor allowing the test to create instances of |
| 39 // DesktopSession directly. | 39 // DesktopSession directly. |
| 40 class FakeDesktopSession : public DesktopSession { | 40 class FakeDesktopSession : public DesktopSession { |
| 41 public: | 41 public: |
| 42 FakeDesktopSession(DaemonProcess* daemon_process, int id); | 42 FakeDesktopSession(DaemonProcess* daemon_process, int id); |
| 43 virtual ~FakeDesktopSession(); | 43 virtual ~FakeDesktopSession(); |
| 44 | 44 |
| 45 virtual void SetScreenResolution( | 45 virtual void SetScreenResolution( |
| 46 const ScreenResolution& resolution) OVERRIDE {} | 46 const ScreenResolution& resolution) override {} |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 DISALLOW_COPY_AND_ASSIGN(FakeDesktopSession); | 49 DISALLOW_COPY_AND_ASSIGN(FakeDesktopSession); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class MockDaemonProcess : public DaemonProcess { | 52 class MockDaemonProcess : public DaemonProcess { |
| 53 public: | 53 public: |
| 54 MockDaemonProcess( | 54 MockDaemonProcess( |
| 55 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 55 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 56 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 56 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
| 57 const base::Closure& stopped_callback); | 57 const base::Closure& stopped_callback); |
| 58 virtual ~MockDaemonProcess(); | 58 virtual ~MockDaemonProcess(); |
| 59 | 59 |
| 60 virtual scoped_ptr<DesktopSession> DoCreateDesktopSession( | 60 virtual scoped_ptr<DesktopSession> DoCreateDesktopSession( |
| 61 int terminal_id, | 61 int terminal_id, |
| 62 const ScreenResolution& resolution, | 62 const ScreenResolution& resolution, |
| 63 bool virtual_terminal) OVERRIDE; | 63 bool virtual_terminal) override; |
| 64 | 64 |
| 65 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 65 virtual bool OnMessageReceived(const IPC::Message& message) override; |
| 66 virtual void SendToNetwork(IPC::Message* message) OVERRIDE; | 66 virtual void SendToNetwork(IPC::Message* message) override; |
| 67 | 67 |
| 68 MOCK_METHOD1(Received, void(const IPC::Message&)); | 68 MOCK_METHOD1(Received, void(const IPC::Message&)); |
| 69 MOCK_METHOD1(Sent, void(const IPC::Message&)); | 69 MOCK_METHOD1(Sent, void(const IPC::Message&)); |
| 70 | 70 |
| 71 MOCK_METHOD3(OnDesktopSessionAgentAttached, | 71 MOCK_METHOD3(OnDesktopSessionAgentAttached, |
| 72 bool(int, base::ProcessHandle, IPC::PlatformFileForTransit)); | 72 bool(int, base::ProcessHandle, IPC::PlatformFileForTransit)); |
| 73 | 73 |
| 74 MOCK_METHOD1(DoCreateDesktopSessionPtr, DesktopSession*(int)); | 74 MOCK_METHOD1(DoCreateDesktopSessionPtr, DesktopSession*(int)); |
| 75 MOCK_METHOD1(DoCrashNetworkProcess, void(const tracked_objects::Location&)); | 75 MOCK_METHOD1(DoCrashNetworkProcess, void(const tracked_objects::Location&)); |
| 76 MOCK_METHOD0(LaunchNetworkProcess, void()); | 76 MOCK_METHOD0(LaunchNetworkProcess, void()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 delete message; | 117 delete message; |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace | 120 } // namespace |
| 121 | 121 |
| 122 class DaemonProcessTest : public testing::Test { | 122 class DaemonProcessTest : public testing::Test { |
| 123 public: | 123 public: |
| 124 DaemonProcessTest(); | 124 DaemonProcessTest(); |
| 125 virtual ~DaemonProcessTest(); | 125 virtual ~DaemonProcessTest(); |
| 126 | 126 |
| 127 virtual void SetUp() OVERRIDE; | 127 virtual void SetUp() override; |
| 128 virtual void TearDown() OVERRIDE; | 128 virtual void TearDown() override; |
| 129 | 129 |
| 130 // DaemonProcess mocks | 130 // DaemonProcess mocks |
| 131 DesktopSession* DoCreateDesktopSession(int terminal_id); | 131 DesktopSession* DoCreateDesktopSession(int terminal_id); |
| 132 void DoCrashNetworkProcess(const tracked_objects::Location& location); | 132 void DoCrashNetworkProcess(const tracked_objects::Location& location); |
| 133 void LaunchNetworkProcess(); | 133 void LaunchNetworkProcess(); |
| 134 | 134 |
| 135 // Deletes |daemon_process_|. | 135 // Deletes |daemon_process_|. |
| 136 void DeleteDaemonProcess(); | 136 void DeleteDaemonProcess(); |
| 137 | 137 |
| 138 // Quits |message_loop_|. | 138 // Quits |message_loop_|. |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 EXPECT_EQ(1u, desktop_sessions().size()); | 333 EXPECT_EQ(1u, desktop_sessions().size()); |
| 334 EXPECT_EQ(id, desktop_sessions().front()->id()); | 334 EXPECT_EQ(id, desktop_sessions().front()->id()); |
| 335 | 335 |
| 336 EXPECT_TRUE(daemon_process_->OnMessageReceived( | 336 EXPECT_TRUE(daemon_process_->OnMessageReceived( |
| 337 ChromotingNetworkHostMsg_ConnectTerminal(id, resolution, false))); | 337 ChromotingNetworkHostMsg_ConnectTerminal(id, resolution, false))); |
| 338 EXPECT_TRUE(desktop_sessions().empty()); | 338 EXPECT_TRUE(desktop_sessions().empty()); |
| 339 EXPECT_EQ(0, terminal_id_); | 339 EXPECT_EQ(0, terminal_id_); |
| 340 } | 340 } |
| 341 | 341 |
| 342 } // namespace remoting | 342 } // namespace remoting |
| OLD | NEW |