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

Side by Side Diff: base/trace_event/trace_event_system_stats_monitor_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_system_stats_monitor.h" 5 #include "base/trace_event/trace_event_system_stats_monitor.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 namespace base { 13 namespace base {
15 namespace trace_event { 14 namespace trace_event {
16 15
17 #if !defined(OS_IOS) 16 #if !defined(OS_IOS)
18 // Tests for the system stats monitor. 17 // Tests for the system stats monitor.
19 // Exists as a class so it can be a friend of TraceEventSystemStatsMonitor. 18 // Exists as a class so it can be a friend of TraceEventSystemStatsMonitor.
20 class TraceSystemStatsMonitorTest : public testing::Test { 19 class TraceSystemStatsMonitorTest : public testing::Test {
21 public: 20 public:
22 TraceSystemStatsMonitorTest() {} 21 TraceSystemStatsMonitorTest() {}
23 ~TraceSystemStatsMonitorTest() override {} 22 ~TraceSystemStatsMonitorTest() override {}
24 23
25 private: 24 private:
26 DISALLOW_COPY_AND_ASSIGN(TraceSystemStatsMonitorTest); 25 DISALLOW_COPY_AND_ASSIGN(TraceSystemStatsMonitorTest);
27 }; 26 };
28 27
29 ////////////////////////////////////////////////////////////////////////////// 28 //////////////////////////////////////////////////////////////////////////////
30 29
31 TEST_F(TraceSystemStatsMonitorTest, TraceEventSystemStatsMonitor) { 30 TEST_F(TraceSystemStatsMonitorTest, TraceEventSystemStatsMonitor) {
32 MessageLoop message_loop; 31 MessageLoop message_loop;
33 32
34 // Start with no observers of the TraceLog. 33 // Start with no observers of the TraceLog.
35 EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest()); 34 EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest());
36 35
37 // Creating a system stats monitor adds it to the TraceLog observer list. 36 // Creating a system stats monitor adds it to the TraceLog observer list.
38 scoped_ptr<TraceEventSystemStatsMonitor> system_stats_monitor( 37 scoped_ptr<TraceEventSystemStatsMonitor> system_stats_monitor(
39 new TraceEventSystemStatsMonitor( 38 new TraceEventSystemStatsMonitor(message_loop.task_runner()));
40 message_loop.message_loop_proxy()));
41 EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest()); 39 EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest());
42 EXPECT_TRUE( 40 EXPECT_TRUE(
43 TraceLog::GetInstance()->HasEnabledStateObserver( 41 TraceLog::GetInstance()->HasEnabledStateObserver(
44 system_stats_monitor.get())); 42 system_stats_monitor.get()));
45 43
46 // By default the observer isn't dumping memory profiles. 44 // By default the observer isn't dumping memory profiles.
47 EXPECT_FALSE(system_stats_monitor->IsTimerRunningForTest()); 45 EXPECT_FALSE(system_stats_monitor->IsTimerRunningForTest());
48 46
49 // Simulate enabling tracing. 47 // Simulate enabling tracing.
50 system_stats_monitor->StartProfiling(); 48 system_stats_monitor->StartProfiling();
51 message_loop.RunUntilIdle(); 49 message_loop.RunUntilIdle();
52 EXPECT_TRUE(system_stats_monitor->IsTimerRunningForTest()); 50 EXPECT_TRUE(system_stats_monitor->IsTimerRunningForTest());
53 51
54 // Simulate disabling tracing. 52 // Simulate disabling tracing.
55 system_stats_monitor->StopProfiling(); 53 system_stats_monitor->StopProfiling();
56 message_loop.RunUntilIdle(); 54 message_loop.RunUntilIdle();
57 EXPECT_FALSE(system_stats_monitor->IsTimerRunningForTest()); 55 EXPECT_FALSE(system_stats_monitor->IsTimerRunningForTest());
58 56
59 // Deleting the observer removes it from the TraceLog observer list. 57 // Deleting the observer removes it from the TraceLog observer list.
60 system_stats_monitor.reset(); 58 system_stats_monitor.reset();
61 EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest()); 59 EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest());
62 } 60 }
63 #endif // !defined(OS_IOS) 61 #endif // !defined(OS_IOS)
64 62
65 } // namespace trace_event 63 } // namespace trace_event
66 } // namespace base 64 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_memory_unittest.cc ('k') | base/trace_event/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698