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

Side by Side Diff: base/debug/activity_analyzer_unittest.cc

Issue 2258713003: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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 | « base/debug/activity_analyzer.cc ('k') | base/debug/activity_tracker.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/debug/activity_analyzer.h" 5 #include "base/debug/activity_analyzer.h"
6 6
7 #include <atomic> 7 #include <atomic>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ~ActivityAnalyzerTest() override { 54 ~ActivityAnalyzerTest() override {
55 GlobalActivityTracker* global_tracker = GlobalActivityTracker::Get(); 55 GlobalActivityTracker* global_tracker = GlobalActivityTracker::Get();
56 if (global_tracker) { 56 if (global_tracker) {
57 global_tracker->ReleaseTrackerForCurrentThreadForTesting(); 57 global_tracker->ReleaseTrackerForCurrentThreadForTesting();
58 delete global_tracker; 58 delete global_tracker;
59 } 59 }
60 } 60 }
61 61
62 std::unique_ptr<ThreadActivityTracker> CreateActivityTracker() { 62 std::unique_ptr<ThreadActivityTracker> CreateActivityTracker() {
63 std::unique_ptr<char[]> memory(new char[kStackSize]); 63 std::unique_ptr<char[]> memory(new char[kStackSize]);
64 return WrapUnique(new TestActivityTracker(std::move(memory), kStackSize)); 64 return MakeUnique<TestActivityTracker>(std::move(memory), kStackSize);
65 } 65 }
66 66
67 static void DoNothing() {} 67 static void DoNothing() {}
68 }; 68 };
69 69
70 TEST_F(ActivityAnalyzerTest, ThreadAnalyzerConstruction) { 70 TEST_F(ActivityAnalyzerTest, ThreadAnalyzerConstruction) {
71 std::unique_ptr<ThreadActivityTracker> tracker = CreateActivityTracker(); 71 std::unique_ptr<ThreadActivityTracker> tracker = CreateActivityTracker();
72 { 72 {
73 ThreadActivityAnalyzer analyzer(*tracker); 73 ThreadActivityAnalyzer analyzer(*tracker);
74 EXPECT_TRUE(analyzer.IsValid()); 74 EXPECT_TRUE(analyzer.IsValid());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 ConditionVariable exit_condition_; 135 ConditionVariable exit_condition_;
136 136
137 DISALLOW_COPY_AND_ASSIGN(SimpleActivityThread); 137 DISALLOW_COPY_AND_ASSIGN(SimpleActivityThread);
138 }; 138 };
139 139
140 TEST_F(ActivityAnalyzerTest, GlobalAnalyzerConstruction) { 140 TEST_F(ActivityAnalyzerTest, GlobalAnalyzerConstruction) {
141 GlobalActivityTracker::CreateWithLocalMemory(kMemorySize, 0, "", 3); 141 GlobalActivityTracker::CreateWithLocalMemory(kMemorySize, 0, "", 3);
142 142
143 PersistentMemoryAllocator* allocator = 143 PersistentMemoryAllocator* allocator =
144 GlobalActivityTracker::Get()->allocator(); 144 GlobalActivityTracker::Get()->allocator();
145 GlobalActivityAnalyzer analyzer(WrapUnique( 145 GlobalActivityAnalyzer analyzer(MakeUnique<PersistentMemoryAllocator>(
146 new PersistentMemoryAllocator(const_cast<void*>(allocator->data()), 146 const_cast<void*>(allocator->data()), allocator->size(), 0, 0, "", true));
147 allocator->size(), 0, 0, "", true)));
148 147
149 // The only thread at thois point is the test thread. 148 // The only thread at thois point is the test thread.
150 ThreadActivityAnalyzer* ta1 = analyzer.GetFirstAnalyzer(); 149 ThreadActivityAnalyzer* ta1 = analyzer.GetFirstAnalyzer();
151 ASSERT_TRUE(ta1); 150 ASSERT_TRUE(ta1);
152 EXPECT_FALSE(analyzer.GetNextAnalyzer()); 151 EXPECT_FALSE(analyzer.GetNextAnalyzer());
153 ThreadActivityAnalyzer::ThreadKey tk1 = ta1->GetThreadKey(); 152 ThreadActivityAnalyzer::ThreadKey tk1 = ta1->GetThreadKey();
154 EXPECT_EQ(ta1, analyzer.GetAnalyzerForThread(tk1)); 153 EXPECT_EQ(ta1, analyzer.GetAnalyzerForThread(tk1));
155 154
156 // Create a second thread that will do something. 155 // Create a second thread that will do something.
157 SimpleActivityThread t2("t2", nullptr, Activity::ACT_TASK, 156 SimpleActivityThread t2("t2", nullptr, Activity::ACT_TASK,
(...skipping 15 matching lines...) Expand all
173 ThreadActivityAnalyzer* ta2 = analyzer.GetFirstAnalyzer(); 172 ThreadActivityAnalyzer* ta2 = analyzer.GetFirstAnalyzer();
174 ASSERT_TRUE(ta2); 173 ASSERT_TRUE(ta2);
175 EXPECT_FALSE(analyzer.GetNextAnalyzer()); 174 EXPECT_FALSE(analyzer.GetNextAnalyzer());
176 ThreadActivityAnalyzer::ThreadKey tk2 = ta2->GetThreadKey(); 175 ThreadActivityAnalyzer::ThreadKey tk2 = ta2->GetThreadKey();
177 EXPECT_EQ(ta2, analyzer.GetAnalyzerForThread(tk2)); 176 EXPECT_EQ(ta2, analyzer.GetAnalyzerForThread(tk2));
178 EXPECT_EQ(tk1, tk2); 177 EXPECT_EQ(tk1, tk2);
179 } 178 }
180 179
181 } // namespace debug 180 } // namespace debug
182 } // namespace base 181 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/activity_analyzer.cc ('k') | base/debug/activity_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698