OLD | NEW |
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/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/run_loop.h" |
11 #include "base/trace_event/trace_event_impl.h" | 12 #include "base/trace_event/trace_event_impl.h" |
12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 namespace trace_event { | 17 namespace trace_event { |
17 | 18 |
18 #if !defined(OS_IOS) | 19 #if !defined(OS_IOS) |
19 // Tests for the system stats monitor. | 20 // Tests for the system stats monitor. |
20 // Exists as a class so it can be a friend of TraceEventSystemStatsMonitor. | 21 // Exists as a class so it can be a friend of TraceEventSystemStatsMonitor. |
(...skipping 20 matching lines...) Expand all Loading... |
41 EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest()); | 42 EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest()); |
42 EXPECT_TRUE( | 43 EXPECT_TRUE( |
43 TraceLog::GetInstance()->HasEnabledStateObserver( | 44 TraceLog::GetInstance()->HasEnabledStateObserver( |
44 system_stats_monitor.get())); | 45 system_stats_monitor.get())); |
45 | 46 |
46 // By default the observer isn't dumping memory profiles. | 47 // By default the observer isn't dumping memory profiles. |
47 EXPECT_FALSE(system_stats_monitor->IsTimerRunningForTest()); | 48 EXPECT_FALSE(system_stats_monitor->IsTimerRunningForTest()); |
48 | 49 |
49 // Simulate enabling tracing. | 50 // Simulate enabling tracing. |
50 system_stats_monitor->StartProfiling(); | 51 system_stats_monitor->StartProfiling(); |
51 message_loop.RunUntilIdle(); | 52 RunLoop().RunUntilIdle(); |
52 EXPECT_TRUE(system_stats_monitor->IsTimerRunningForTest()); | 53 EXPECT_TRUE(system_stats_monitor->IsTimerRunningForTest()); |
53 | 54 |
54 // Simulate disabling tracing. | 55 // Simulate disabling tracing. |
55 system_stats_monitor->StopProfiling(); | 56 system_stats_monitor->StopProfiling(); |
56 message_loop.RunUntilIdle(); | 57 RunLoop().RunUntilIdle(); |
57 EXPECT_FALSE(system_stats_monitor->IsTimerRunningForTest()); | 58 EXPECT_FALSE(system_stats_monitor->IsTimerRunningForTest()); |
58 | 59 |
59 // Deleting the observer removes it from the TraceLog observer list. | 60 // Deleting the observer removes it from the TraceLog observer list. |
60 system_stats_monitor.reset(); | 61 system_stats_monitor.reset(); |
61 EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest()); | 62 EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest()); |
62 } | 63 } |
63 #endif // !defined(OS_IOS) | 64 #endif // !defined(OS_IOS) |
64 | 65 |
65 } // namespace trace_event | 66 } // namespace trace_event |
66 } // namespace base | 67 } // namespace base |
OLD | NEW |