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

Side by Side Diff: base/debug/trace_event_unittest.cc

Issue 14748003: Allow tracing categories to default to disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/debug/trace_event_unittest.h" 5 #include "base/debug/trace_event_unittest.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 bool FindMatchingValue(const char* key, 68 bool FindMatchingValue(const char* key,
69 const char* value); 69 const char* value);
70 bool FindNonMatchingValue(const char* key, 70 bool FindNonMatchingValue(const char* key,
71 const char* value); 71 const char* value);
72 void Clear() { 72 void Clear() {
73 trace_parsed_.Clear(); 73 trace_parsed_.Clear();
74 json_output_.json_output.clear(); 74 json_output_.json_output.clear();
75 } 75 }
76 76
77 void BeginTrace() { 77 void BeginTrace() {
78 BeginSpecificTrace("*");
79 }
80
81 void BeginSpecificTrace(const std::string& filter) {
78 event_watch_notification_ = 0; 82 event_watch_notification_ = 0;
79 notifications_received_ = 0; 83 notifications_received_ = 0;
80 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), 84 TraceLog::GetInstance()->SetEnabled(CategoryFilter(filter),
81 TraceLog::RECORD_UNTIL_FULL); 85 TraceLog::RECORD_UNTIL_FULL);
82 } 86 }
83 87
84 void EndTraceAndFlush() { 88 void EndTraceAndFlush() {
85 while (TraceLog::GetInstance()->IsEnabled()) 89 while (TraceLog::GetInstance()->IsEnabled())
86 TraceLog::GetInstance()->SetDisabled(); 90 TraceLog::GetInstance()->SetDisabled();
87 TraceLog::GetInstance()->Flush( 91 TraceLog::GetInstance()->Flush(
88 base::Bind(&TraceEventTestFixture::OnTraceDataCollected, 92 base::Bind(&TraceEventTestFixture::OnTraceDataCollected,
89 base::Unretained(this))); 93 base::Unretained(this)));
90 } 94 }
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 // Test that categories that are used can be retrieved whether trace was 912 // Test that categories that are used can be retrieved whether trace was
909 // enabled or disabled when the trace event was encountered. 913 // enabled or disabled when the trace event was encountered.
910 TRACE_EVENT_INSTANT0("c1", "name", TRACE_EVENT_SCOPE_THREAD); 914 TRACE_EVENT_INSTANT0("c1", "name", TRACE_EVENT_SCOPE_THREAD);
911 TRACE_EVENT_INSTANT0("c2", "name", TRACE_EVENT_SCOPE_THREAD); 915 TRACE_EVENT_INSTANT0("c2", "name", TRACE_EVENT_SCOPE_THREAD);
912 BeginTrace(); 916 BeginTrace();
913 TRACE_EVENT_INSTANT0("c3", "name", TRACE_EVENT_SCOPE_THREAD); 917 TRACE_EVENT_INSTANT0("c3", "name", TRACE_EVENT_SCOPE_THREAD);
914 TRACE_EVENT_INSTANT0("c4", "name", TRACE_EVENT_SCOPE_THREAD); 918 TRACE_EVENT_INSTANT0("c4", "name", TRACE_EVENT_SCOPE_THREAD);
915 // Category groups containing more than one category. 919 // Category groups containing more than one category.
916 TRACE_EVENT_INSTANT0("c5,c6", "name", TRACE_EVENT_SCOPE_THREAD); 920 TRACE_EVENT_INSTANT0("c5,c6", "name", TRACE_EVENT_SCOPE_THREAD);
917 TRACE_EVENT_INSTANT0("c7,c8", "name", TRACE_EVENT_SCOPE_THREAD); 921 TRACE_EVENT_INSTANT0("c7,c8", "name", TRACE_EVENT_SCOPE_THREAD);
922 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("c9"), "name",
923 TRACE_EVENT_SCOPE_THREAD);
918 924
919 EndTraceAndFlush(); 925 EndTraceAndFlush();
920 std::vector<std::string> cat_groups; 926 std::vector<std::string> cat_groups;
921 TraceLog::GetInstance()->GetKnownCategoryGroups(&cat_groups); 927 TraceLog::GetInstance()->GetKnownCategoryGroups(&cat_groups);
922 EXPECT_TRUE(std::find(cat_groups.begin(), 928 EXPECT_TRUE(std::find(cat_groups.begin(),
923 cat_groups.end(), "c1") != cat_groups.end()); 929 cat_groups.end(), "c1") != cat_groups.end());
924 EXPECT_TRUE(std::find(cat_groups.begin(), 930 EXPECT_TRUE(std::find(cat_groups.begin(),
925 cat_groups.end(), "c2") != cat_groups.end()); 931 cat_groups.end(), "c2") != cat_groups.end());
926 EXPECT_TRUE(std::find(cat_groups.begin(), 932 EXPECT_TRUE(std::find(cat_groups.begin(),
927 cat_groups.end(), "c3") != cat_groups.end()); 933 cat_groups.end(), "c3") != cat_groups.end());
928 EXPECT_TRUE(std::find(cat_groups.begin(), 934 EXPECT_TRUE(std::find(cat_groups.begin(),
929 cat_groups.end(), "c4") != cat_groups.end()); 935 cat_groups.end(), "c4") != cat_groups.end());
930 EXPECT_TRUE(std::find(cat_groups.begin(), 936 EXPECT_TRUE(std::find(cat_groups.begin(),
931 cat_groups.end(), "c5,c6") != cat_groups.end()); 937 cat_groups.end(), "c5,c6") != cat_groups.end());
932 EXPECT_TRUE(std::find(cat_groups.begin(), 938 EXPECT_TRUE(std::find(cat_groups.begin(),
933 cat_groups.end(), "c7,c8") != cat_groups.end()); 939 cat_groups.end(), "c7,c8") != cat_groups.end());
940 EXPECT_TRUE(std::find(cat_groups.begin(),
941 cat_groups.end(),
942 "disabled-by-default-c9") != cat_groups.end());
934 // Make sure metadata isn't returned. 943 // Make sure metadata isn't returned.
935 EXPECT_TRUE(std::find(cat_groups.begin(), 944 EXPECT_TRUE(std::find(cat_groups.begin(),
936 cat_groups.end(), "__metadata") == cat_groups.end()); 945 cat_groups.end(), "__metadata") == cat_groups.end());
937 946
938 const std::vector<std::string> empty_categories; 947 const std::vector<std::string> empty_categories;
939 std::vector<std::string> included_categories; 948 std::vector<std::string> included_categories;
940 std::vector<std::string> excluded_categories; 949 std::vector<std::string> excluded_categories;
941 950
942 // Test that category filtering works. 951 // Test that category filtering works.
943 952
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 int tid; 1386 int tid;
1378 EXPECT_TRUE(item->GetInteger("tid", &tid)); 1387 EXPECT_TRUE(item->GetInteger("tid", &tid));
1379 EXPECT_EQ(PlatformThread::CurrentId(), static_cast<PlatformThreadId>(tid)); 1388 EXPECT_EQ(PlatformThread::CurrentId(), static_cast<PlatformThreadId>(tid));
1380 1389
1381 std::string expected_name = "cafe,pub, bar"; 1390 std::string expected_name = "cafe,pub, bar";
1382 std::string tmp; 1391 std::string tmp;
1383 EXPECT_TRUE(item->GetString("args.name", &tmp)); 1392 EXPECT_TRUE(item->GetString("args.name", &tmp));
1384 EXPECT_EQ(expected_name, tmp); 1393 EXPECT_EQ(expected_name, tmp);
1385 } 1394 }
1386 1395
1396 // Test that the disabled trace categories are included/excluded from the
1397 // trace output correctly.
1398 TEST_F(TraceEventTestFixture, DisabledCategories) {
1399 ManualTestSetUp();
1400
1401 BeginTrace();
1402 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("cc"), "first",
1403 TRACE_EVENT_SCOPE_THREAD);
1404 TRACE_EVENT_INSTANT0("included", "first", TRACE_EVENT_SCOPE_THREAD);
1405 EndTraceAndFlush();
1406 {
1407 const DictionaryValue* item = NULL;
1408 ListValue& trace_parsed = trace_parsed_;
1409 EXPECT_NOT_FIND_("disabled-by-default-cc");
1410 EXPECT_FIND_("included");
1411 }
1412 Clear();
1413
1414 BeginSpecificTrace("disabled-by-default-cc");
1415 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("cc"), "second",
1416 TRACE_EVENT_SCOPE_THREAD);
1417 TRACE_EVENT_INSTANT0("other_included", "second", TRACE_EVENT_SCOPE_THREAD);
1418 EndTraceAndFlush();
1419
1420 {
1421 const DictionaryValue* item = NULL;
1422 ListValue& trace_parsed = trace_parsed_;
1423 EXPECT_FIND_("disabled-by-default-cc");
1424 EXPECT_FIND_("other_included");
1425 }
1426 }
1427
1387 // Test trace calls made after tracing singleton shut down. 1428 // Test trace calls made after tracing singleton shut down.
1388 // 1429 //
1389 // The singleton is destroyed by our base::AtExitManager, but there can be 1430 // The singleton is destroyed by our base::AtExitManager, but there can be
1390 // code still executing as the C++ static objects are destroyed. This test 1431 // code still executing as the C++ static objects are destroyed. This test
1391 // forces the singleton to destroy early, and intentinally makes trace calls 1432 // forces the singleton to destroy early, and intentinally makes trace calls
1392 // afterwards. 1433 // afterwards.
1393 TEST_F(TraceEventTestFixture, AtExit) { 1434 TEST_F(TraceEventTestFixture, AtExit) {
1394 // Repeat this test a few times. Besides just showing robustness, it also 1435 // Repeat this test a few times. Besides just showing robustness, it also
1395 // allows us to test that events at shutdown do not appear with valid events 1436 // allows us to test that events at shutdown do not appear with valid events
1396 // recorded after the system is started again. 1437 // recorded after the system is started again.
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 ManualTestSetUp(); 1628 ManualTestSetUp();
1588 1629
1589 TraceLog* trace_log = TraceLog::GetInstance(); 1630 TraceLog* trace_log = TraceLog::GetInstance();
1590 trace_log->SetEnabled(CategoryFilter("foo,bar"), TraceLog::RECORD_UNTIL_FULL); 1631 trace_log->SetEnabled(CategoryFilter("foo,bar"), TraceLog::RECORD_UNTIL_FULL);
1591 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo")); 1632 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo"));
1592 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("bar")); 1633 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("bar"));
1593 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("baz")); 1634 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("baz"));
1594 trace_log->SetEnabled(CategoryFilter("foo2"), TraceLog::RECORD_UNTIL_FULL); 1635 trace_log->SetEnabled(CategoryFilter("foo2"), TraceLog::RECORD_UNTIL_FULL);
1595 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo2")); 1636 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo2"));
1596 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("baz")); 1637 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("baz"));
1638 // The "" becomes the default catergory set when applied.
1597 trace_log->SetEnabled(CategoryFilter(""), TraceLog::RECORD_UNTIL_FULL); 1639 trace_log->SetEnabled(CategoryFilter(""), TraceLog::RECORD_UNTIL_FULL);
1598 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo")); 1640 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo"));
1599 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz")); 1641 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz"));
1642 EXPECT_STREQ("-*Debug,-*Test",
1643 trace_log->GetCurrentCategoryFilter().ToString().c_str());
1600 trace_log->SetDisabled(); 1644 trace_log->SetDisabled();
1601 trace_log->SetDisabled(); 1645 trace_log->SetDisabled();
1602 trace_log->SetDisabled(); 1646 trace_log->SetDisabled();
1603 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("foo")); 1647 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("foo"));
1604 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("baz")); 1648 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("baz"));
1605 1649
1606 trace_log->SetEnabled(CategoryFilter("-foo,-bar"), 1650 trace_log->SetEnabled(CategoryFilter("-foo,-bar"),
1607 TraceLog::RECORD_UNTIL_FULL); 1651 TraceLog::RECORD_UNTIL_FULL);
1608 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("foo")); 1652 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("foo"));
1609 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz")); 1653 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz"));
1610 trace_log->SetEnabled(CategoryFilter("moo"), TraceLog::RECORD_UNTIL_FULL); 1654 trace_log->SetEnabled(CategoryFilter("moo"), TraceLog::RECORD_UNTIL_FULL);
1611 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz")); 1655 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz"));
1612 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("moo")); 1656 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("moo"));
1613 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo")); 1657 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("foo"));
1658 EXPECT_STREQ("-foo,-bar",
1659 trace_log->GetCurrentCategoryFilter().ToString().c_str());
1660 trace_log->SetDisabled();
1661 trace_log->SetDisabled();
1662
1663 // Make sure disabled categories aren't cleared if we set in the second.
1664 trace_log->SetEnabled(CategoryFilter("disabled-by-default-cc,foo"),
1665 TraceLog::RECORD_UNTIL_FULL);
1666 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("bar"));
1667 trace_log->SetEnabled(CategoryFilter("disabled-by-default-gpu"),
1668 TraceLog::RECORD_UNTIL_FULL);
1669 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-cc"));
1670 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-gpu"));
1671 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("bar"));
1672 EXPECT_STREQ("disabled-by-default-cc,disabled-by-default-gpu",
1673 trace_log->GetCurrentCategoryFilter().ToString().c_str());
1614 trace_log->SetDisabled(); 1674 trace_log->SetDisabled();
1615 trace_log->SetDisabled(); 1675 trace_log->SetDisabled();
1616 } 1676 }
1617 1677
1618 TEST_F(TraceEventTestFixture, TraceOptionsParsing) { 1678 TEST_F(TraceEventTestFixture, TraceOptionsParsing) {
1619 ManualTestSetUp(); 1679 ManualTestSetUp();
1620 1680
1621 EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL, 1681 EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL,
1622 TraceLog::TraceOptionsFromString(std::string())); 1682 TraceLog::TraceOptionsFromString(std::string()));
1623 1683
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 // Test the category filter. 1843 // Test the category filter.
1784 TEST_F(TraceEventTestFixture, CategoryFilter) { 1844 TEST_F(TraceEventTestFixture, CategoryFilter) {
1785 ManualTestSetUp(); 1845 ManualTestSetUp();
1786 1846
1787 // Using the default filter. 1847 // Using the default filter.
1788 CategoryFilter default_cf = CategoryFilter( 1848 CategoryFilter default_cf = CategoryFilter(
1789 CategoryFilter::kDefaultCategoryFilterString); 1849 CategoryFilter::kDefaultCategoryFilterString);
1790 std::string category_filter_str = default_cf.ToString(); 1850 std::string category_filter_str = default_cf.ToString();
1791 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); 1851 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str());
1792 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); 1852 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category"));
1853 EXPECT_FALSE(
1854 default_cf.IsCategoryGroupEnabled("disabled-by-default-category"));
1793 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); 1855 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug"));
1794 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); 1856 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1"));
1795 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2")); 1857 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2"));
1796 1858
1797 // Make sure that upon an empty string, we fall back to the default filter. 1859 // Make sure that upon an empty string, we fall back to the default filter.
1798 default_cf = CategoryFilter(""); 1860 default_cf = CategoryFilter("");
1799 category_filter_str = default_cf.ToString(); 1861 category_filter_str = default_cf.ToString();
1800 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); 1862 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str());
1801 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); 1863 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category"));
1802 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); 1864 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug"));
1803 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); 1865 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1"));
1804 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2")); 1866 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2"));
1805 1867
1806 // Using an arbitrary non-empty filter. 1868 // Using an arbitrary non-empty filter.
1807 CategoryFilter cf("included,-excluded,inc_pattern*,-exc_pattern*"); 1869 CategoryFilter cf("included,-excluded,inc_pattern*,-exc_pattern*");
1808 category_filter_str = cf.ToString(); 1870 category_filter_str = cf.ToString();
1809 EXPECT_STREQ("included,inc_pattern*,-excluded,-exc_pattern*", 1871 EXPECT_STREQ("included,inc_pattern*,-excluded,-exc_pattern*",
1810 category_filter_str.c_str()); 1872 category_filter_str.c_str());
1811 EXPECT_TRUE(cf.IsCategoryGroupEnabled("included")); 1873 EXPECT_TRUE(cf.IsCategoryGroupEnabled("included"));
1812 EXPECT_TRUE(cf.IsCategoryGroupEnabled("inc_pattern_category")); 1874 EXPECT_TRUE(cf.IsCategoryGroupEnabled("inc_pattern_category"));
1813 EXPECT_FALSE(cf.IsCategoryGroupEnabled("exc_pattern_category")); 1875 EXPECT_FALSE(cf.IsCategoryGroupEnabled("exc_pattern_category"));
1814 EXPECT_FALSE(cf.IsCategoryGroupEnabled("excluded")); 1876 EXPECT_FALSE(cf.IsCategoryGroupEnabled("excluded"));
1815 EXPECT_FALSE(cf.IsCategoryGroupEnabled("not-excluded-nor-included")); 1877 EXPECT_FALSE(cf.IsCategoryGroupEnabled("not-excluded-nor-included"));
1816 EXPECT_FALSE(cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); 1878 EXPECT_FALSE(cf.IsCategoryGroupEnabled("Category1,CategoryDebug"));
1817 EXPECT_FALSE(cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); 1879 EXPECT_FALSE(cf.IsCategoryGroupEnabled("CategoryDebug,Category1"));
1818 EXPECT_FALSE(cf.IsCategoryGroupEnabled("CategoryTest,Category2")); 1880 EXPECT_FALSE(cf.IsCategoryGroupEnabled("CategoryTest,Category2"));
1819 1881
1820 cf.Merge(default_cf); 1882 cf.Merge(default_cf);
1821 category_filter_str = cf.ToString(); 1883 category_filter_str = cf.ToString();
1822 EXPECT_STREQ("included,inc_pattern*,-excluded,-exc_pattern*,-*Debug,-*Test", 1884 EXPECT_STREQ("-excluded,-exc_pattern*,-*Debug,-*Test",
1823 category_filter_str.c_str()); 1885 category_filter_str.c_str());
1824 cf.Clear(); 1886 cf.Clear();
1825 EXPECT_FALSE(cf.HasIncludedPatterns());
1826 1887
1827 CategoryFilter reconstructed_cf(category_filter_str); 1888 CategoryFilter reconstructed_cf(category_filter_str);
1828 category_filter_str = reconstructed_cf.ToString(); 1889 category_filter_str = reconstructed_cf.ToString();
1829 EXPECT_STREQ("included,inc_pattern*,-excluded,-exc_pattern*,-*Debug,-*Test", 1890 EXPECT_STREQ("-excluded,-exc_pattern*,-*Debug,-*Test",
1830 category_filter_str.c_str()); 1891 category_filter_str.c_str());
1831 1892
1832 // One included category. 1893 // One included category.
1833 CategoryFilter one_inc_cf("only_inc_cat"); 1894 CategoryFilter one_inc_cf("only_inc_cat");
1834 category_filter_str = one_inc_cf.ToString(); 1895 category_filter_str = one_inc_cf.ToString();
1835 EXPECT_STREQ("only_inc_cat", category_filter_str.c_str()); 1896 EXPECT_STREQ("only_inc_cat", category_filter_str.c_str());
1836 1897
1837 // One excluded category. 1898 // One excluded category.
1838 CategoryFilter one_exc_cf("-only_exc_cat"); 1899 CategoryFilter one_exc_cf("-only_exc_cat");
1839 category_filter_str = one_exc_cf.ToString(); 1900 category_filter_str = one_exc_cf.ToString();
1840 EXPECT_STREQ("-only_exc_cat", category_filter_str.c_str()); 1901 EXPECT_STREQ("-only_exc_cat", category_filter_str.c_str());
1841 1902
1903 // Enabling a disabled- category does not require all categories to be traced
1904 // to be included.
1905 CategoryFilter disabled_cat("disabled-by-default-cc,-excluded");
1906 EXPECT_STREQ("disabled-by-default-cc,-excluded",
1907 disabled_cat.ToString().c_str());
1908 EXPECT_TRUE(disabled_cat.IsCategoryGroupEnabled("disabled-by-default-cc"));
1909 EXPECT_TRUE(disabled_cat.IsCategoryGroupEnabled("some_other_group"));
1910 EXPECT_FALSE(disabled_cat.IsCategoryGroupEnabled("excluded"));
1911
1912 // Enabled a disabled- category and also including makes all categories to
1913 // be traced require including.
1914 CategoryFilter disabled_inc_cat("disabled-by-default-cc,included");
1915 EXPECT_STREQ("included,disabled-by-default-cc",
1916 disabled_inc_cat.ToString().c_str());
1917 EXPECT_TRUE(
1918 disabled_inc_cat.IsCategoryGroupEnabled("disabled-by-default-cc"));
1919 EXPECT_TRUE(disabled_inc_cat.IsCategoryGroupEnabled("included"));
1920 EXPECT_FALSE(disabled_inc_cat.IsCategoryGroupEnabled("other_included"));
1921
1842 // Test that IsEmptyOrContainsLeadingOrTrailingWhitespace actually catches 1922 // Test that IsEmptyOrContainsLeadingOrTrailingWhitespace actually catches
1843 // categories that are explicitly forbiden. 1923 // categories that are explicitly forbiden.
1844 // This method is called in a DCHECK to assert that we don't have these types 1924 // This method is called in a DCHECK to assert that we don't have these types
1845 // of strings as categories. 1925 // of strings as categories.
1846 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 1926 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1847 " bad_category ")); 1927 " bad_category "));
1848 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 1928 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1849 " bad_category")); 1929 " bad_category"));
1850 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 1930 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1851 "bad_category ")); 1931 "bad_category "));
1852 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 1932 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1853 " bad_category")); 1933 " bad_category"));
1854 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 1934 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1855 "bad_category ")); 1935 "bad_category "));
1856 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 1936 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1857 " bad_category ")); 1937 " bad_category "));
1858 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 1938 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1859 "")); 1939 ""));
1860 EXPECT_FALSE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 1940 EXPECT_FALSE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1861 "good_category")); 1941 "good_category"));
1862 } 1942 }
1863 1943
1864 } // namespace debug 1944 } // namespace debug
1865 } // namespace base 1945 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698