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

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

Issue 2544853003: Store log messages in global activity tracker. (Closed)
Patch Set: added comment about NUL terminator Created 4 years 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
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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // Now there should be only one again. Calling GetFirstAnalyzer invalidates 169 // Now there should be only one again. Calling GetFirstAnalyzer invalidates
170 // any previously returned analyzer pointers. 170 // any previously returned analyzer pointers.
171 ThreadActivityAnalyzer* ta2 = analyzer.GetFirstAnalyzer(); 171 ThreadActivityAnalyzer* ta2 = analyzer.GetFirstAnalyzer();
172 ASSERT_TRUE(ta2); 172 ASSERT_TRUE(ta2);
173 EXPECT_FALSE(analyzer.GetNextAnalyzer()); 173 EXPECT_FALSE(analyzer.GetNextAnalyzer());
174 ThreadActivityAnalyzer::ThreadKey tk2 = ta2->GetThreadKey(); 174 ThreadActivityAnalyzer::ThreadKey tk2 = ta2->GetThreadKey();
175 EXPECT_EQ(ta2, analyzer.GetAnalyzerForThread(tk2)); 175 EXPECT_EQ(ta2, analyzer.GetAnalyzerForThread(tk2));
176 EXPECT_EQ(tk1, tk2); 176 EXPECT_EQ(tk1, tk2);
177 } 177 }
178 178
179 TEST_F(ActivityAnalyzerTest, GlobalLogMessages) {
180 GlobalActivityTracker::CreateWithLocalMemory(kMemorySize, 0, "", 3);
181
182 PersistentMemoryAllocator* allocator =
183 GlobalActivityTracker::Get()->allocator();
184 GlobalActivityAnalyzer analyzer(MakeUnique<PersistentMemoryAllocator>(
185 const_cast<void*>(allocator->data()), allocator->size(), 0, 0, "", true));
186
187 GlobalActivityTracker::Get()->RecordLogMessage("hello world");
188 GlobalActivityTracker::Get()->RecordLogMessage("foo bar");
189
190 std::vector<std::string> messages = analyzer.GetLogMessages();
191 ASSERT_EQ(2U, messages.size());
192 EXPECT_EQ("hello world", messages[0]);
193 EXPECT_EQ("foo bar", messages[1]);
194 }
195
179 } // namespace debug 196 } // namespace debug
180 } // namespace base 197 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698