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 bfd0673081bf98b8b9fa5fcc6e437be27711ca12..a1ae5d2f0758fb196abc4cb6278ee1e37f3fc4f3 100644 |
--- a/base/trace_event/trace_event_unittest.cc |
+++ b/base/trace_event/trace_event_unittest.cc |
@@ -2661,105 +2661,6 @@ TEST_F(TraceEventTestFixture, TraceRecordAsMuchAsPossibleMode) { |
TraceLog::GetInstance()->SetDisabled(); |
} |
-// Test the category filter. |
-TEST_F(TraceEventTestFixture, CategoryFilter) { |
- // Using the default filter. |
- CategoryFilter default_cf = CategoryFilter( |
- CategoryFilter::kDefaultCategoryFilterString); |
- std::string category_filter_str = default_cf.ToString(); |
- EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); |
- EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); |
- EXPECT_FALSE( |
- default_cf.IsCategoryGroupEnabled("disabled-by-default-category")); |
- EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); |
- EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); |
- EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2")); |
- |
- // Make sure that upon an empty string, we fall back to the default filter. |
- default_cf = CategoryFilter(); |
- category_filter_str = default_cf.ToString(); |
- EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); |
- EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); |
- EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); |
- EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); |
- EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2")); |
- |
- // Using an arbitrary non-empty filter. |
- CategoryFilter cf("included,-excluded,inc_pattern*,-exc_pattern*"); |
- category_filter_str = cf.ToString(); |
- EXPECT_STREQ("included,inc_pattern*,-excluded,-exc_pattern*", |
- category_filter_str.c_str()); |
- EXPECT_TRUE(cf.IsCategoryGroupEnabled("included")); |
- EXPECT_TRUE(cf.IsCategoryGroupEnabled("inc_pattern_category")); |
- EXPECT_FALSE(cf.IsCategoryGroupEnabled("exc_pattern_category")); |
- EXPECT_FALSE(cf.IsCategoryGroupEnabled("excluded")); |
- EXPECT_FALSE(cf.IsCategoryGroupEnabled("not-excluded-nor-included")); |
- EXPECT_FALSE(cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); |
- EXPECT_FALSE(cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); |
- EXPECT_FALSE(cf.IsCategoryGroupEnabled("CategoryTest,Category2")); |
- |
- cf.Merge(default_cf); |
- category_filter_str = cf.ToString(); |
- EXPECT_STREQ("-excluded,-exc_pattern*,-*Debug,-*Test", |
- category_filter_str.c_str()); |
- cf.Clear(); |
- |
- CategoryFilter reconstructed_cf(category_filter_str); |
- category_filter_str = reconstructed_cf.ToString(); |
- EXPECT_STREQ("-excluded,-exc_pattern*,-*Debug,-*Test", |
- category_filter_str.c_str()); |
- |
- // One included category. |
- CategoryFilter one_inc_cf("only_inc_cat"); |
- category_filter_str = one_inc_cf.ToString(); |
- EXPECT_STREQ("only_inc_cat", category_filter_str.c_str()); |
- |
- // One excluded category. |
- CategoryFilter one_exc_cf("-only_exc_cat"); |
- category_filter_str = one_exc_cf.ToString(); |
- EXPECT_STREQ("-only_exc_cat", category_filter_str.c_str()); |
- |
- // Enabling a disabled- category does not require all categories to be traced |
- // to be included. |
- CategoryFilter disabled_cat("disabled-by-default-cc,-excluded"); |
- EXPECT_STREQ("disabled-by-default-cc,-excluded", |
- disabled_cat.ToString().c_str()); |
- EXPECT_TRUE(disabled_cat.IsCategoryGroupEnabled("disabled-by-default-cc")); |
- EXPECT_TRUE(disabled_cat.IsCategoryGroupEnabled("some_other_group")); |
- EXPECT_FALSE(disabled_cat.IsCategoryGroupEnabled("excluded")); |
- |
- // Enabled a disabled- category and also including makes all categories to |
- // be traced require including. |
- CategoryFilter disabled_inc_cat("disabled-by-default-cc,included"); |
- EXPECT_STREQ("included,disabled-by-default-cc", |
- disabled_inc_cat.ToString().c_str()); |
- EXPECT_TRUE( |
- disabled_inc_cat.IsCategoryGroupEnabled("disabled-by-default-cc")); |
- EXPECT_TRUE(disabled_inc_cat.IsCategoryGroupEnabled("included")); |
- EXPECT_FALSE(disabled_inc_cat.IsCategoryGroupEnabled("other_included")); |
- |
- // Test that IsEmptyOrContainsLeadingOrTrailingWhitespace actually catches |
- // categories that are explicitly forbiden. |
- // This method is called in a DCHECK to assert that we don't have these types |
- // of strings as categories. |
- EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
- " bad_category ")); |
- EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
- " bad_category")); |
- EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
- "bad_category ")); |
- EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
- " bad_category")); |
- EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
- "bad_category ")); |
- EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
- " bad_category ")); |
- EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
- "")); |
- EXPECT_FALSE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
- "good_category")); |
-} |
- |
void BlockUntilStopped(WaitableEvent* task_start_event, |
WaitableEvent* task_stop_event) { |
task_start_event->Signal(); |
@@ -3048,83 +2949,5 @@ TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { |
EXPECT_EQ(config, filter.ToString()); |
} |
-TEST(TraceOptionsTest, TraceOptionsFromString) { |
- TraceOptions options; |
- EXPECT_TRUE(options.SetFromString("record-until-full")); |
- EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); |
- EXPECT_FALSE(options.enable_sampling); |
- EXPECT_FALSE(options.enable_systrace); |
- |
- EXPECT_TRUE(options.SetFromString("record-continuously")); |
- EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode); |
- EXPECT_FALSE(options.enable_sampling); |
- EXPECT_FALSE(options.enable_systrace); |
- |
- EXPECT_TRUE(options.SetFromString("trace-to-console")); |
- EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode); |
- EXPECT_FALSE(options.enable_sampling); |
- EXPECT_FALSE(options.enable_systrace); |
- |
- EXPECT_TRUE(options.SetFromString("record-as-much-as-possible")); |
- EXPECT_EQ(RECORD_AS_MUCH_AS_POSSIBLE, options.record_mode); |
- EXPECT_FALSE(options.enable_sampling); |
- EXPECT_FALSE(options.enable_systrace); |
- |
- EXPECT_TRUE(options.SetFromString("record-until-full, enable-sampling")); |
- EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); |
- EXPECT_TRUE(options.enable_sampling); |
- EXPECT_FALSE(options.enable_systrace); |
- |
- EXPECT_TRUE(options.SetFromString("enable-systrace,record-continuously")); |
- EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode); |
- EXPECT_FALSE(options.enable_sampling); |
- EXPECT_TRUE(options.enable_systrace); |
- |
- EXPECT_TRUE(options.SetFromString( |
- "enable-systrace, trace-to-console,enable-sampling")); |
- EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode); |
- EXPECT_TRUE(options.enable_sampling); |
- EXPECT_TRUE(options.enable_systrace); |
- |
- EXPECT_TRUE(options.SetFromString( |
- "record-continuously,record-until-full,trace-to-console")); |
- EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode); |
- EXPECT_FALSE(options.enable_systrace); |
- EXPECT_FALSE(options.enable_sampling); |
- |
- EXPECT_TRUE(options.SetFromString("")); |
- EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); |
- EXPECT_FALSE(options.enable_systrace); |
- EXPECT_FALSE(options.enable_sampling); |
- |
- EXPECT_FALSE(options.SetFromString("foo-bar-baz")); |
-} |
- |
-TEST(TraceOptionsTest, TraceOptionsToString) { |
- // Test that we can intialize TraceOptions from a string got from |
- // TraceOptions.ToString() method to get a same TraceOptions. |
- TraceRecordMode modes[] = {RECORD_UNTIL_FULL, |
- RECORD_CONTINUOUSLY, |
- ECHO_TO_CONSOLE, |
- RECORD_AS_MUCH_AS_POSSIBLE}; |
- bool enable_sampling_options[] = {true, false}; |
- bool enable_systrace_options[] = {true, false}; |
- |
- for (int i = 0; i < 4; ++i) { |
- for (int j = 0; j < 2; ++j) { |
- for (int k = 0; k < 2; ++k) { |
- TraceOptions original_option = TraceOptions(modes[i]); |
- original_option.enable_sampling = enable_sampling_options[j]; |
- original_option.enable_systrace = enable_systrace_options[k]; |
- TraceOptions new_options; |
- EXPECT_TRUE(new_options.SetFromString(original_option.ToString())); |
- EXPECT_EQ(original_option.record_mode, new_options.record_mode); |
- EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); |
- EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); |
- } |
- } |
- } |
-} |
- |
} // namespace trace_event |
} // namespace base |