Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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( |
| 77 const protocol::AggregatedProcessResourceUsage& usage, | 77 const protocol::AggregatedProcessResourceUsage& usage, |
| 78 size_t index) { | 78 size_t index) { |
| 79 ASSERT_EQ(usage.processor_usage(), index); | 79 ASSERT_EQ(usage.usages_size(), 1); |
| 80 ASSERT_EQ(usage.working_set_size(), index); | 80 ASSERT_EQ(usage.usages().Get(0).processor_usage(), index); |
|
joedow
2017/06/30 15:13:43
Do you want to ASSERT on processor_name as well?
Hzj_jie
2017/06/30 22:39:29
Done.
| |
| 81 ASSERT_EQ(usage.pagefile_size(), index); | 81 ASSERT_EQ(usage.usages().Get(0).working_set_size(), index); |
| 82 ASSERT_EQ(usage.usages().Get(0).pagefile_size(), index); | |
| 82 } | 83 } |
| 83 | 84 |
| 84 static void AssertExpected(const protocol::ProcessResourceUsage& usage, | 85 static void AssertExpected(const protocol::ProcessResourceUsage& usage, |
| 85 size_t index) { | 86 size_t index) { |
| 86 ASSERT_EQ(usage.processor_usage(), index); | 87 ASSERT_EQ(usage.processor_usage(), index); |
| 87 ASSERT_EQ(usage.working_set_size(), index); | 88 ASSERT_EQ(usage.working_set_size(), index); |
| 88 ASSERT_EQ(usage.pagefile_size(), index); | 89 ASSERT_EQ(usage.pagefile_size(), index); |
| 89 } | 90 } |
| 90 | 91 |
| 91 size_t issued_times() const { return index_; } | 92 size_t issued_times() const { return index_; } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 stats->reset(new ProcessStatsSender( | 163 stats->reset(new ProcessStatsSender( |
| 163 stub, base::TimeDelta::FromMilliseconds(1), | 164 stub, base::TimeDelta::FromMilliseconds(1), |
| 164 { agent1, agent2 } )); | 165 { agent1, agent2 } )); |
| 165 }, | 166 }, |
| 166 base::Unretained(&stats), base::Unretained(&stub), | 167 base::Unretained(&stats), base::Unretained(&stub), |
| 167 base::Unretained(&agent1), base::Unretained(&agent2))); | 168 base::Unretained(&agent1), base::Unretained(&agent2))); |
| 168 run_loop.Run(); | 169 run_loop.Run(); |
| 169 | 170 |
| 170 ASSERT_EQ(stub.received().size(), 10U); | 171 ASSERT_EQ(stub.received().size(), 10U); |
| 171 for (size_t i = 0; i < stub.received().size(); i++) { | 172 for (size_t i = 0; i < stub.received().size(); i++) { |
| 172 FakeProcessStatsAgent::AssertExpected(stub.received()[i], i * 2); | 173 ASSERT_EQ(stub.received()[i].usages_size(), 2); |
| 173 for (int j = 0; j < stub.received()[i].usages_size(); j++) { | 174 for (int j = 0; j < stub.received()[i].usages_size(); j++) { |
| 174 FakeProcessStatsAgent::AssertExpected( | 175 FakeProcessStatsAgent::AssertExpected( |
| 175 stub.received()[i].usages().Get(j), i); | 176 stub.received()[i].usages().Get(j), i); |
| 176 } | 177 } |
| 177 } | 178 } |
| 178 } | 179 } |
| 179 | 180 |
| 180 } // namespace remoting | 181 } // namespace remoting |
| OLD | NEW |