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

Side by Side Diff: base/trace_event/trace_event_memory_unittest.cc

Issue 1100773004: base: Remove most uses of MessageLoopProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added some missing includes. Created 5 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/trace_event/trace_event_memory.h" 5 #include "base/trace_event/trace_event_memory.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 9
10 #include "base/message_loop/message_loop.h"
11 #include "base/trace_event/trace_event_impl.h" 10 #include "base/trace_event/trace_event_impl.h"
12 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
13 12
14 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) 13 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED)
15 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" 14 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
16 #endif 15 #endif
17 16
18 namespace base { 17 namespace base {
19 namespace trace_event { 18 namespace trace_event {
20 19
(...skipping 12 matching lines...) Expand all
33 32
34 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) 33 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED)
35 34
36 TEST_F(TraceMemoryTest, TraceMemoryController) { 35 TEST_F(TraceMemoryTest, TraceMemoryController) {
37 MessageLoop message_loop; 36 MessageLoop message_loop;
38 37
39 // Start with no observers of the TraceLog. 38 // Start with no observers of the TraceLog.
40 EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest()); 39 EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest());
41 40
42 // Creating a controller adds it to the TraceLog observer list. 41 // Creating a controller adds it to the TraceLog observer list.
43 scoped_ptr<TraceMemoryController> controller( 42 scoped_ptr<TraceMemoryController> controller(new TraceMemoryController(
44 new TraceMemoryController( 43 message_loop.task_runner(), ::HeapProfilerWithPseudoStackStart,
45 message_loop.message_loop_proxy(), 44 ::HeapProfilerStop, ::GetHeapProfile));
46 ::HeapProfilerWithPseudoStackStart,
47 ::HeapProfilerStop,
48 ::GetHeapProfile));
49 EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest()); 45 EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest());
50 EXPECT_TRUE( 46 EXPECT_TRUE(
51 TraceLog::GetInstance()->HasEnabledStateObserver(controller.get())); 47 TraceLog::GetInstance()->HasEnabledStateObserver(controller.get()));
52 48
53 // By default the observer isn't dumping memory profiles. 49 // By default the observer isn't dumping memory profiles.
54 EXPECT_FALSE(controller->IsTimerRunningForTest()); 50 EXPECT_FALSE(controller->IsTimerRunningForTest());
55 51
56 // Simulate enabling tracing. 52 // Simulate enabling tracing.
57 controller->StartProfiling(); 53 controller->StartProfiling();
58 message_loop.RunUntilIdle(); 54 message_loop.RunUntilIdle();
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 EXPECT_STREQ("null", StringFromHexAddress("0x0")); 227 EXPECT_STREQ("null", StringFromHexAddress("0x0"));
232 EXPECT_STREQ("error", StringFromHexAddress("not an address")); 228 EXPECT_STREQ("error", StringFromHexAddress("not an address"));
233 const char kHello[] = "hello"; 229 const char kHello[] = "hello";
234 std::ostringstream hex_address; 230 std::ostringstream hex_address;
235 hex_address << &kHello; 231 hex_address << &kHello;
236 EXPECT_STREQ(kHello, StringFromHexAddress(hex_address.str())); 232 EXPECT_STREQ(kHello, StringFromHexAddress(hex_address.str()));
237 } 233 }
238 234
239 } // namespace trace_event 235 } // namespace trace_event
240 } // namespace base 236 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_memory.cc ('k') | base/trace_event/trace_event_system_stats_monitor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698