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

Unified Diff: services/resource_coordinator/memory/coordinator/coordinator_impl_unittest.cc

Issue 2694083005: memory-infra: Finish moving memory_infra from TracingController (Closed)
Patch Set: style: auto must not deduce to raw pointer Created 3 years, 10 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
Index: services/resource_coordinator/memory/coordinator/coordinator_impl_unittest.cc
diff --git a/services/resource_coordinator/memory/coordinator/coordinator_impl_unittest.cc b/services/resource_coordinator/memory/coordinator/coordinator_impl_unittest.cc
index 1bc8254b90282a01e301422f3c558b2c944cde85..4d63e98b63758b4efc93941fa8dbde7a574244cb 100644
--- a/services/resource_coordinator/memory/coordinator/coordinator_impl_unittest.cc
+++ b/services/resource_coordinator/memory/coordinator/coordinator_impl_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "services/resource_coordinator/memory/coordinator/coordinator_impl.h"
+#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback_forward.h"
#include "base/memory/ref_counted.h"
@@ -20,15 +21,20 @@ class CoordinatorImplTest : public testing::Test {
public:
CoordinatorImplTest() {}
void SetUp() override {
- dump_response_args_ = {static_cast<uint64_t>(-1), false};
+ dump_response_args_ = {0U, false};
+ coordinator_.reset(new CoordinatorImpl());
+ coordinator_->InitializeForTest(base::ThreadTaskRunnerHandle::Get());
}
+ void TearDown() override { coordinator_.reset(); }
+
void RegisterProcessLocalDumpManager(
mojom::ProcessLocalDumpManagerPtr process_manager) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&CoordinatorImpl::RegisterProcessLocalDumpManager,
- base::Unretained(&coordinator_),
- base::Passed(&process_manager)));
+ FROM_HERE,
+ base::Bind(&CoordinatorImpl::RegisterProcessLocalDumpManager,
+ base::Unretained(coordinator_.get()),
+ base::Passed(&process_manager)));
}
void RequestGlobalMemoryDump(base::trace_event::MemoryDumpRequestArgs args,
@@ -36,7 +42,7 @@ class CoordinatorImplTest : public testing::Test {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&CoordinatorImpl::RequestGlobalMemoryDump,
- base::Unretained(&coordinator_), args,
+ base::Unretained(coordinator_.get()), args,
base::Bind(&CoordinatorImplTest::OnGlobalMemoryDumpResponse,
base::Unretained(this), closure)));
}
@@ -57,11 +63,11 @@ class CoordinatorImplTest : public testing::Test {
DumpResponseArgs dump_response_args_;
private:
- CoordinatorImpl coordinator_;
+ std::unique_ptr<CoordinatorImpl> coordinator_;
base::MessageLoop message_loop_;
};
-class MockDumpManager : mojom::ProcessLocalDumpManager {
+class MockDumpManager : public mojom::ProcessLocalDumpManager {
public:
MockDumpManager(CoordinatorImplTest* test_coordinator, int expected_calls)
: binding_(this), expected_calls_(expected_calls) {
@@ -93,7 +99,7 @@ TEST_F(CoordinatorImplTest, NoProcessLocalManagers) {
base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
RequestGlobalMemoryDump(args, run_loop.QuitClosure());
run_loop.Run();
- EXPECT_EQ(static_cast<uint64_t>(1234), dump_response_args_.dump_guid);
+ EXPECT_EQ(1234U, dump_response_args_.dump_guid);
EXPECT_TRUE(dump_response_args_.success);
}
@@ -109,7 +115,7 @@ TEST_F(CoordinatorImplTest, SeveralProcessLocalManagers) {
run_loop.Run();
- EXPECT_EQ(static_cast<uint64_t>(2345), dump_response_args_.dump_guid);
+ EXPECT_EQ(2345U, dump_response_args_.dump_guid);
EXPECT_TRUE(dump_response_args_.success);
}
@@ -132,7 +138,7 @@ TEST_F(CoordinatorImplTest, FaultyProcessLocalManager) {
run_loop.Run();
- EXPECT_EQ(static_cast<uint64_t>(3456), dump_response_args_.dump_guid);
+ EXPECT_EQ(3456U, dump_response_args_.dump_guid);
EXPECT_FALSE(dump_response_args_.success);
}
} // namespace memory_instrumentation

Powered by Google App Engine
This is Rietveld 408576698