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

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

Issue 2950993003: [Chromoting] Use ProcessStatsSender in DaemonProcess (daemon process) (Closed)
Patch Set: Stop process stats when network process crashes Created 3 years, 6 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
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/daemon_process.h" 5 #include "remoting/host/daemon_process.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 22 matching lines...) Expand all
33 namespace remoting { 33 namespace remoting {
34 34
35 namespace { 35 namespace {
36 36
37 enum Messages { 37 enum Messages {
38 kMessageCrash = ChromotingDaemonMsg_Crash::ID, 38 kMessageCrash = ChromotingDaemonMsg_Crash::ID,
39 kMessageConfiguration = ChromotingDaemonNetworkMsg_Configuration::ID, 39 kMessageConfiguration = ChromotingDaemonNetworkMsg_Configuration::ID,
40 kMessageConnectTerminal = ChromotingNetworkHostMsg_ConnectTerminal::ID, 40 kMessageConnectTerminal = ChromotingNetworkHostMsg_ConnectTerminal::ID,
41 kMessageDisconnectTerminal = ChromotingNetworkHostMsg_DisconnectTerminal::ID, 41 kMessageDisconnectTerminal = ChromotingNetworkHostMsg_DisconnectTerminal::ID,
42 kMessageTerminalDisconnected = 42 kMessageTerminalDisconnected =
43 ChromotingDaemonNetworkMsg_TerminalDisconnected::ID 43 ChromotingDaemonNetworkMsg_TerminalDisconnected::ID,
44 kMessageReportProcessStats = ChromotingAnyToNetworkMsg_ReportProcessStats::ID,
44 }; 45 };
45 46
46 // Provides a public constructor allowing the test to create instances of 47 // Provides a public constructor allowing the test to create instances of
47 // DesktopSession directly. 48 // DesktopSession directly.
48 class FakeDesktopSession : public DesktopSession { 49 class FakeDesktopSession : public DesktopSession {
49 public: 50 public:
50 FakeDesktopSession(DaemonProcess* daemon_process, int id); 51 FakeDesktopSession(DaemonProcess* daemon_process, int id);
51 ~FakeDesktopSession() override; 52 ~FakeDesktopSession() override;
52 53
53 void SetScreenResolution(const ScreenResolution& resolution) override {} 54 void SetScreenResolution(const ScreenResolution& resolution) override {}
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 ChromotingNetworkHostMsg_ConnectTerminal(id, resolution, false))); 341 ChromotingNetworkHostMsg_ConnectTerminal(id, resolution, false)));
341 EXPECT_EQ(1u, desktop_sessions().size()); 342 EXPECT_EQ(1u, desktop_sessions().size());
342 EXPECT_EQ(id, desktop_sessions().front()->id()); 343 EXPECT_EQ(id, desktop_sessions().front()->id());
343 344
344 EXPECT_TRUE(daemon_process_->OnMessageReceived( 345 EXPECT_TRUE(daemon_process_->OnMessageReceived(
345 ChromotingNetworkHostMsg_ConnectTerminal(id, resolution, false))); 346 ChromotingNetworkHostMsg_ConnectTerminal(id, resolution, false)));
346 EXPECT_TRUE(desktop_sessions().empty()); 347 EXPECT_TRUE(desktop_sessions().empty());
347 EXPECT_EQ(0, terminal_id_); 348 EXPECT_EQ(0, terminal_id_);
348 } 349 }
349 350
351 TEST_F(DaemonProcessTest, StartProcessStatsReport) {
352 EXPECT_CALL(*daemon_process_, Sent(Message(kMessageReportProcessStats)));
353 daemon_process_->OnMessageReceived(
354 ChromotingNetworkToAnyMsg_StartProcessStatsReport(
355 base::TimeDelta::FromMilliseconds(1)));
356 base::RunLoop run_loop;
357 ON_CALL(*daemon_process_, Sent(_))
358 .WillByDefault(testing::Invoke(
359 [&run_loop](const IPC::Message& message) {
360 run_loop.Quit();
361 }));
362 run_loop.Run();
363 }
joedow 2017/06/23 18:03:07 If you feel strongly about keeping the counter, th
Hzj_jie 2017/06/24 00:51:40 Done.
364
350 } // namespace remoting 365 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698