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

Side by Side Diff: remoting/host/process_stats_sender_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/process_stats_sender.cc ('k') | remoting/host/process_stats_util.h » ('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/process_stats_sender.h" 5 #include "remoting/host/process_stats_sender.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 protocol::ProcessResourceUsage usage; 66 protocol::ProcessResourceUsage usage;
67 usage.set_process_name("FakeProcessStatsAgent"); 67 usage.set_process_name("FakeProcessStatsAgent");
68 usage.set_processor_usage(index_); 68 usage.set_processor_usage(index_);
69 usage.set_working_set_size(index_); 69 usage.set_working_set_size(index_);
70 usage.set_pagefile_size(index_); 70 usage.set_pagefile_size(index_);
71 index_++; 71 index_++;
72 return usage; 72 return usage;
73 } 73 }
74 74
75 // Checks the expected usage based on index. 75 // Checks the expected usage based on index.
76 static void AssertExpected( 76 static void AssertExpected(const protocol::ProcessResourceUsage& usage,
77 const protocol::AggregatedProcessResourceUsage& usage, 77 size_t index) {
78 size_t index) { 78 ASSERT_EQ(usage.process_name(), "FakeProcessStatsAgent");
79 ASSERT_EQ(usage.processor_usage(), index); 79 ASSERT_EQ(usage.processor_usage(), index);
80 ASSERT_EQ(usage.working_set_size(), index); 80 ASSERT_EQ(usage.working_set_size(), index);
81 ASSERT_EQ(usage.pagefile_size(), index); 81 ASSERT_EQ(usage.pagefile_size(), index);
82 } 82 }
83 83
84 static void AssertExpected(const protocol::ProcessResourceUsage& usage, 84 static void AssertExpected(
85 size_t index) { 85 const protocol::AggregatedProcessResourceUsage& usage,
86 ASSERT_EQ(usage.processor_usage(), index); 86 size_t index) {
87 ASSERT_EQ(usage.working_set_size(), index); 87 ASSERT_EQ(usage.usages_size(), 1);
88 ASSERT_EQ(usage.pagefile_size(), index); 88 AssertExpected(usage.usages().Get(0), index);
89 } 89 }
90 90
91 size_t issued_times() const { return index_; } 91 size_t issued_times() const { return index_; }
92 92
93 private: 93 private:
94 size_t index_ = 0; 94 size_t index_ = 0;
95 }; 95 };
96 96
97 } // namespace 97 } // namespace
98 98
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 stats->reset(new ProcessStatsSender( 162 stats->reset(new ProcessStatsSender(
163 stub, base::TimeDelta::FromMilliseconds(1), 163 stub, base::TimeDelta::FromMilliseconds(1),
164 { agent1, agent2 } )); 164 { agent1, agent2 } ));
165 }, 165 },
166 base::Unretained(&stats), base::Unretained(&stub), 166 base::Unretained(&stats), base::Unretained(&stub),
167 base::Unretained(&agent1), base::Unretained(&agent2))); 167 base::Unretained(&agent1), base::Unretained(&agent2)));
168 run_loop.Run(); 168 run_loop.Run();
169 169
170 ASSERT_EQ(stub.received().size(), 10U); 170 ASSERT_EQ(stub.received().size(), 10U);
171 for (size_t i = 0; i < stub.received().size(); i++) { 171 for (size_t i = 0; i < stub.received().size(); i++) {
172 FakeProcessStatsAgent::AssertExpected(stub.received()[i], i * 2); 172 ASSERT_EQ(stub.received()[i].usages_size(), 2);
173 for (int j = 0; j < stub.received()[i].usages_size(); j++) { 173 for (int j = 0; j < stub.received()[i].usages_size(); j++) {
174 FakeProcessStatsAgent::AssertExpected( 174 FakeProcessStatsAgent::AssertExpected(
175 stub.received()[i].usages().Get(j), i); 175 stub.received()[i].usages().Get(j), i);
176 } 176 }
177 } 177 }
178 } 178 }
179 179
180 } // namespace remoting 180 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/process_stats_sender.cc ('k') | remoting/host/process_stats_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698