| Index: base/debug/trace_event_unittest.cc
|
| diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
|
| index b5909845f27c1053b29b68278db598b1e7a14530..1ad53f4c78231f01a75823421a5df4f4f7709147 100644
|
| --- a/base/debug/trace_event_unittest.cc
|
| +++ b/base/debug/trace_event_unittest.cc
|
| @@ -90,6 +90,12 @@ class TraceEventTestFixture : public testing::Test {
|
| base::Unretained(this)));
|
| }
|
|
|
| + void FlushContinuousSampling() {
|
| + TraceLog::GetInstance()->FlushContinuousSamplingTracing(
|
| + base::Bind(&TraceEventTestFixture::OnTraceDataCollected,
|
| + base::Unretained(this)));
|
| + }
|
| +
|
| virtual void SetUp() OVERRIDE {
|
| const char* name = PlatformThread::GetName();
|
| old_thread_name_ = name ? strdup(name) : NULL;
|
| @@ -1737,6 +1743,56 @@ TEST_F(TraceEventTestFixture, TraceSamplingScope) {
|
| EndTraceAndFlush();
|
| }
|
|
|
| +TEST_F(TraceEventTestFixture, TraceContinuousSampling) {
|
| + event_watch_notification_ = 0;
|
| + TraceLog::GetInstance()->SetContinuousSamplingEnabled();
|
| +
|
| + WaitableEvent* sampled = new WaitableEvent(false, false);
|
| + TraceLog::GetInstance()->InstallWaitableEventForContinuousSamplingTesting(
|
| + sampled);
|
| +
|
| + TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "AAA");
|
| + sampled->Wait();
|
| + TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "BBB");
|
| + sampled->Wait();
|
| +
|
| + FlushContinuousSampling();
|
| +
|
| + // Make sure we can get the profiled data.
|
| + EXPECT_TRUE(FindNamePhase("AAA", "P"));
|
| + EXPECT_TRUE(FindNamePhase("BBB", "P"));
|
| +
|
| + Clear();
|
| +
|
| + TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "CCC");
|
| + sampled->Wait();
|
| + TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "DDD");
|
| + sampled->Wait();
|
| +
|
| + FlushContinuousSampling();
|
| +
|
| + // Make sure the profiled data is accumulated.
|
| + EXPECT_TRUE(FindNamePhase("AAA", "P"));
|
| + EXPECT_TRUE(FindNamePhase("BBB", "P"));
|
| + EXPECT_TRUE(FindNamePhase("CCC", "P"));
|
| + EXPECT_TRUE(FindNamePhase("DDD", "P"));
|
| +
|
| + Clear();
|
| +
|
| + TraceLog::GetInstance()->SetContinuousSamplingDisabled();
|
| +
|
| + FlushContinuousSampling();
|
| +
|
| + // Make sure disabling the continuous sampling thread clears
|
| + // the profiled data.
|
| + EXPECT_FALSE(FindNamePhase("AAA", "P"));
|
| + EXPECT_FALSE(FindNamePhase("BBB", "P"));
|
| + EXPECT_FALSE(FindNamePhase("CCC", "P"));
|
| + EXPECT_FALSE(FindNamePhase("DDD", "P"));
|
| +
|
| + Clear();
|
| +}
|
| +
|
| class MyData : public base::debug::ConvertableToTraceFormat {
|
| public:
|
| MyData() {}
|
|
|