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

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

Issue 2964613002: [Chromoting] Deprecate AggregatedProcessResourceUsage.* (Closed)
Patch Set: Use latest ipc_message_protobuf_utils to serialize and deserialize AggregatedProcessResourceUsage Created 3 years, 5 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 | « remoting/host/chromoting_param_traits.cc ('k') | remoting/host/process_stats_sender.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/desktop_session_agent.h" 5 #include "remoting/host/desktop_session_agent.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/threading/thread_task_runner_handle.h"
17 #include "ipc/ipc_channel_proxy.h" 18 #include "ipc/ipc_channel_proxy.h"
18 #include "ipc/ipc_listener.h" 19 #include "ipc/ipc_listener.h"
19 #include "remoting/base/auto_thread_task_runner.h" 20 #include "remoting/base/auto_thread_task_runner.h"
20 #include "remoting/host/chromoting_messages.h" 21 #include "remoting/host/chromoting_messages.h"
21 #include "remoting/host/desktop_environment_options.h" 22 #include "remoting/host/desktop_environment_options.h"
22 #include "remoting/host/fake_desktop_environment.h" 23 #include "remoting/host/fake_desktop_environment.h"
23 #include "remoting/host/screen_resolution.h" 24 #include "remoting/host/screen_resolution.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 26
26 namespace remoting { 27 namespace remoting {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 delegate->reset(); 190 delegate->reset();
190 proxy->reset(); 191 proxy->reset();
191 }, 192 },
192 base::Unretained(this), 193 base::Unretained(this),
193 base::Unretained(&delegate), 194 base::Unretained(&delegate),
194 base::Unretained(&proxy)), 195 base::Unretained(&proxy)),
195 base::TimeDelta::FromMilliseconds(1)); 196 base::TimeDelta::FromMilliseconds(1));
196 run_loop_.Run(); 197 run_loop_.Run();
197 } 198 }
198 199
200 TEST_F(DesktopSessionAgentTest, SendAggregatedProcessResourceUsage) {
201 std::unique_ptr<IPC::Channel> receiver;
202 std::unique_ptr<IPC::Channel> sender;
203 ProcessStatsListener listener(base::Bind([](
204 DesktopSessionAgentTest* test,
205 std::unique_ptr<IPC::Channel>* receiver,
206 std::unique_ptr<IPC::Channel>* sender) {
207 test->Shutdown();
208 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
209 FROM_HERE, receiver->release());
210 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
211 FROM_HERE, sender->release());
212 },
213 base::Unretained(this),
214 base::Unretained(&receiver),
215 base::Unretained(&sender)));
216 mojo::MessagePipe pipe;
217 receiver = IPC::Channel::CreateServer(
218 pipe.handle1.release(),
219 &listener,
220 task_runner_);
221 ASSERT_TRUE(receiver->Connect());
222 sender = IPC::Channel::CreateClient(
223 pipe.handle0.release(),
224 &listener,
225 task_runner_);
226 ASSERT_TRUE(sender->Connect());
227 protocol::AggregatedProcessResourceUsage aggregated;
228 for (int i = 0; i < 2; i++) {
229 *aggregated.add_usages() = protocol::ProcessResourceUsage();
230 }
231 ASSERT_TRUE(sender->Send(
232 new ChromotingAnyToNetworkMsg_ReportProcessStats(aggregated)));
233 run_loop_.Run();
234 }
235
236 TEST_F(DesktopSessionAgentTest, SendEmptyAggregatedProcessResourceUsage) {
237 std::unique_ptr<IPC::Channel> receiver;
238 std::unique_ptr<IPC::Channel> sender;
239 ProcessStatsListener listener(base::Bind([](
240 DesktopSessionAgentTest* test,
241 std::unique_ptr<IPC::Channel>* receiver,
242 std::unique_ptr<IPC::Channel>* sender) {
243 test->Shutdown();
244 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
245 FROM_HERE, receiver->release());
246 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
247 FROM_HERE, sender->release());
248 },
249 base::Unretained(this),
250 base::Unretained(&receiver),
251 base::Unretained(&sender)));
252 mojo::MessagePipe pipe;
253 receiver = IPC::Channel::CreateServer(
254 pipe.handle1.release(),
255 &listener,
256 task_runner_);
257 ASSERT_TRUE(receiver->Connect());
258 sender = IPC::Channel::CreateClient(
259 pipe.handle0.release(),
260 &listener,
261 task_runner_);
262 ASSERT_TRUE(sender->Connect());
263 ASSERT_TRUE(sender->Send(new ChromotingAnyToNetworkMsg_ReportProcessStats(
264 protocol::AggregatedProcessResourceUsage())));
265 run_loop_.Run();
266 }
267
199 } // namespace remoting 268 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_param_traits.cc ('k') | remoting/host/process_stats_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698