Index: base/trace_event/trace_event_unittest.cc |
diff --git a/base/trace_event/trace_event_unittest.cc b/base/trace_event/trace_event_unittest.cc |
index a1b1229e12813223e8b8de0266e571bf4d2f5389..ff8ec2de78880d93f521dce452c719965af25151 100644 |
--- a/base/trace_event/trace_event_unittest.cc |
+++ b/base/trace_event/trace_event_unittest.cc |
@@ -1004,6 +1004,17 @@ void ValidateInstantEventPresentOnEveryThread(const ListValue& trace_parsed, |
} |
} |
+void CheckTraceDefaultCategoryFilters(const TraceLog& trace_log) { |
+ // Default enables all category filters except the disabled-by-default-* ones. |
+ EXPECT_TRUE(*trace_log.GetCategoryGroupEnabled("foo")); |
+ EXPECT_TRUE(*trace_log.GetCategoryGroupEnabled("bar")); |
+ EXPECT_TRUE(*trace_log.GetCategoryGroupEnabled("foo,bar")); |
+ EXPECT_TRUE(*trace_log.GetCategoryGroupEnabled( |
+ "foo,disabled-by-default-foo")); |
+ EXPECT_FALSE(*trace_log.GetCategoryGroupEnabled( |
+ "disabled-by-default-foo,disabled-by-default-bar")); |
+} |
+ |
} // namespace |
// Simple Test for emitting data and validating it was received. |
@@ -1963,7 +1974,7 @@ TEST_F(TraceEventTestFixture, TraceCategoriesAfterNestedEnable) { |
EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo")); |
EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz")); |
EXPECT_STREQ( |
- "-*Debug,-*Test", |
+ "", |
trace_log->GetCurrentTraceConfig().ToCategoryFilterString().c_str()); |
trace_log->SetDisabled(); |
trace_log->SetDisabled(); |
@@ -2000,6 +2011,48 @@ TEST_F(TraceEventTestFixture, TraceCategoriesAfterNestedEnable) { |
trace_log->SetDisabled(); |
} |
+TEST_F(TraceEventTestFixture, TraceWithDefaultCategoryFilters) { |
+ TraceLog* trace_log = TraceLog::GetInstance(); |
+ |
+ trace_log->SetEnabled(TraceConfig(), TraceLog::RECORDING_MODE); |
+ CheckTraceDefaultCategoryFilters(*trace_log); |
+ trace_log->SetDisabled(); |
+ |
+ trace_log->SetEnabled(TraceConfig("", ""), TraceLog::RECORDING_MODE); |
+ CheckTraceDefaultCategoryFilters(*trace_log); |
+ trace_log->SetDisabled(); |
+ |
+ trace_log->SetEnabled(TraceConfig("*", ""), TraceLog::RECORDING_MODE); |
+ CheckTraceDefaultCategoryFilters(*trace_log); |
+ trace_log->SetDisabled(); |
+ |
+ trace_log->SetEnabled(TraceConfig(""), TraceLog::RECORDING_MODE); |
+ CheckTraceDefaultCategoryFilters(*trace_log); |
+ trace_log->SetDisabled(); |
+} |
+ |
+TEST_F(TraceEventTestFixture, TraceWithDisabledByDefaultCategoryFilters) { |
+ TraceLog* trace_log = TraceLog::GetInstance(); |
+ |
+ trace_log->SetEnabled(TraceConfig("foo,disabled-by-default-foo", ""), |
+ TraceLog::RECORDING_MODE); |
+ EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo")); |
+ EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-foo")); |
+ EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("bar")); |
+ EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-bar")); |
+ trace_log->SetDisabled(); |
+ |
+ // Enabling only the disabled-by-default-* category means the default ones |
+ // are also enabled. |
+ trace_log->SetEnabled(TraceConfig("disabled-by-default-foo", ""), |
+ TraceLog::RECORDING_MODE); |
+ EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-foo")); |
+ EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo")); |
+ EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("bar")); |
+ EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-bar")); |
+ trace_log->SetDisabled(); |
+} |
+ |
TEST_F(TraceEventTestFixture, TraceSampling) { |
TraceLog::GetInstance()->SetEnabled( |
TraceConfig(kRecordAllCategoryFilter, "record-until-full,enable-sampling"), |