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

Unified Diff: remoting/host/process_stats_sender_unittest.cc

Issue 2858813002: [Chromoting] Use ProcessStatsSender in host process
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/process_stats_sender.cc ('k') | remoting/protocol/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/process_stats_sender_unittest.cc
diff --git a/remoting/host/process_stats_sender_unittest.cc b/remoting/host/process_stats_sender_unittest.cc
index 6d08818c5343271c10557df58b0c051dd8bf6661..f0cfc0c52559a7f63be927fe701b987713ea01c6 100644
--- a/remoting/host/process_stats_sender_unittest.cc
+++ b/remoting/host/process_stats_sender_unittest.cc
@@ -16,47 +16,13 @@
#include "base/time/time.h"
#include "remoting/host/process_stats_agent.h"
#include "remoting/proto/process_stats.pb.h"
-#include "remoting/protocol/process_stats_stub.h"
+#include "remoting/protocol/fake_process_stats_stub.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace remoting {
namespace {
-class FakeProcessStatsStub : public protocol::ProcessStatsStub {
- public:
- FakeProcessStatsStub() = default;
- ~FakeProcessStatsStub() override = default;
-
- void OnProcessStats(
- const protocol::AggregatedProcessResourceUsage& usage) override {
- received_.push_back(usage);
- DCHECK_LE(received_.size(), expected_usage_count_);
- DCHECK(!quit_closure_.is_null());
- if (received_.size() == expected_usage_count_) {
- quit_closure_.Run();
- }
- }
-
- const std::vector<protocol::AggregatedProcessResourceUsage>& received()
- const {
- return received_;
- }
-
- void set_quit_closure(base::Closure quit_closure) {
- quit_closure_ = quit_closure;
- }
-
- void set_expected_usage_count(size_t expected_usage_count) {
- expected_usage_count_ = expected_usage_count;
- }
-
- private:
- std::vector<protocol::AggregatedProcessResourceUsage> received_;
- size_t expected_usage_count_ = 0;
- base::Closure quit_closure_;
-};
-
class FakeProcessStatsAgent : public ProcessStatsAgent {
public:
FakeProcessStatsAgent() = default;
@@ -99,14 +65,15 @@ class FakeProcessStatsAgent : public ProcessStatsAgent {
TEST(ProcessStatsSenderTest, ReportUsage) {
base::MessageLoop message_loop;
base::RunLoop run_loop;
- FakeProcessStatsStub stub;
+ protocol::FakeProcessStatsStub stub;
std::unique_ptr<ProcessStatsSender> stats;
FakeProcessStatsAgent agent;
stub.set_expected_usage_count(10);
stub.set_quit_closure(base::Bind(
[](std::unique_ptr<ProcessStatsSender>* stats,
- const FakeProcessStatsStub& stub, const FakeProcessStatsAgent& agent,
+ const protocol::FakeProcessStatsStub& stub,
+ const FakeProcessStatsAgent& agent,
base::RunLoop* run_loop) -> void {
ASSERT_EQ(stub.received().size(), agent.issued_times());
stats->reset();
@@ -118,9 +85,11 @@ TEST(ProcessStatsSenderTest, ReportUsage) {
FROM_HERE,
base::Bind(
[](std::unique_ptr<ProcessStatsSender>* stats,
- FakeProcessStatsStub* stub, FakeProcessStatsAgent* agent) -> void {
+ protocol::FakeProcessStatsStub* stub,
+ FakeProcessStatsAgent* agent) -> void {
stats->reset(new ProcessStatsSender(
- stub, base::TimeDelta::FromMilliseconds(1), { agent }));
+ stub, base::TimeDelta::FromMilliseconds(1),
+ { agent, nullptr }));
},
base::Unretained(&stats), base::Unretained(&stub),
base::Unretained(&agent)));
@@ -135,7 +104,7 @@ TEST(ProcessStatsSenderTest, ReportUsage) {
TEST(ProcessStatsSenderTest, MergeUsage) {
base::MessageLoop message_loop;
base::RunLoop run_loop;
- FakeProcessStatsStub stub;
+ protocol::FakeProcessStatsStub stub;
std::unique_ptr<ProcessStatsSender> stats;
// Owned by |stats|.
FakeProcessStatsAgent agent1;
@@ -144,8 +113,10 @@ TEST(ProcessStatsSenderTest, MergeUsage) {
stub.set_expected_usage_count(10);
stub.set_quit_closure(base::Bind(
[](std::unique_ptr<ProcessStatsSender>* stats,
- const FakeProcessStatsStub& stub, const FakeProcessStatsAgent& agent1,
- const FakeProcessStatsAgent& agent2, base::RunLoop* run_loop) -> void {
+ const protocol::FakeProcessStatsStub& stub,
+ const FakeProcessStatsAgent& agent1,
+ const FakeProcessStatsAgent& agent2,
+ base::RunLoop* run_loop) -> void {
ASSERT_EQ(stub.received().size(), agent1.issued_times());
ASSERT_EQ(stub.received().size(), agent2.issued_times());
stats->reset();
@@ -157,11 +128,12 @@ TEST(ProcessStatsSenderTest, MergeUsage) {
FROM_HERE,
base::Bind(
[](std::unique_ptr<ProcessStatsSender>* stats,
- FakeProcessStatsStub* stub, FakeProcessStatsAgent* agent1,
+ protocol::FakeProcessStatsStub* stub,
+ FakeProcessStatsAgent* agent1,
FakeProcessStatsAgent* agent2) -> void {
stats->reset(new ProcessStatsSender(
stub, base::TimeDelta::FromMilliseconds(1),
- { agent1, agent2 } ));
+ { agent1, nullptr, agent2, nullptr, nullptr } ));
},
base::Unretained(&stats), base::Unretained(&stub),
base::Unretained(&agent1), base::Unretained(&agent2)));
« no previous file with comments | « remoting/host/process_stats_sender.cc ('k') | remoting/protocol/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698