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

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

Issue 12302036: Add a mode flag to the tracing framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with master. Created 7 years, 10 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') | base/test/trace_event_analyzer_unittest.cc » ('j') | 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 const char* value); 66 const char* value);
67 bool FindNonMatchingValue(const char* key, 67 bool FindNonMatchingValue(const char* key,
68 const char* value); 68 const char* value);
69 void Clear() { 69 void Clear() {
70 trace_parsed_.Clear(); 70 trace_parsed_.Clear();
71 json_output_.json_output.clear(); 71 json_output_.json_output.clear();
72 } 72 }
73 73
74 void BeginTrace() { 74 void BeginTrace() {
75 event_watch_notification_ = 0; 75 event_watch_notification_ = 0;
76 TraceLog::GetInstance()->SetEnabled(std::string("*")); 76 TraceLog::GetInstance()->SetEnabled(std::string("*"),
77 TraceLog::RECORD_UNTIL_FULL);
77 } 78 }
78 79
79 void EndTraceAndFlush() { 80 void EndTraceAndFlush() {
80 while (TraceLog::GetInstance()->IsEnabled()) 81 while (TraceLog::GetInstance()->IsEnabled())
81 TraceLog::GetInstance()->SetDisabled(); 82 TraceLog::GetInstance()->SetDisabled();
82 TraceLog::GetInstance()->Flush( 83 TraceLog::GetInstance()->Flush(
83 base::Bind(&TraceEventTestFixture::OnTraceDataCollected, 84 base::Bind(&TraceEventTestFixture::OnTraceDataCollected,
84 base::Unretained(this))); 85 base::Unretained(this)));
85 } 86 }
86 87
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 void HighResSleepForTraceTest(base::TimeDelta elapsed) { 708 void HighResSleepForTraceTest(base::TimeDelta elapsed) {
708 base::TimeTicks end_time = base::TimeTicks::HighResNow() + elapsed; 709 base::TimeTicks end_time = base::TimeTicks::HighResNow() + elapsed;
709 do { 710 do {
710 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); 711 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
711 } while (base::TimeTicks::HighResNow() < end_time); 712 } while (base::TimeTicks::HighResNow() < end_time);
712 } 713 }
713 714
714 // Simple Test for emitting data and validating it was received. 715 // Simple Test for emitting data and validating it was received.
715 TEST_F(TraceEventTestFixture, DataCaptured) { 716 TEST_F(TraceEventTestFixture, DataCaptured) {
716 ManualTestSetUp(); 717 ManualTestSetUp();
717 TraceLog::GetInstance()->SetEnabled(true); 718 TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
718 719
719 TraceWithAllMacroVariants(NULL); 720 TraceWithAllMacroVariants(NULL);
720 721
721 EndTraceAndFlush(); 722 EndTraceAndFlush();
722 723
723 ValidateAllTraceMacrosCreatedData(trace_parsed_); 724 ValidateAllTraceMacrosCreatedData(trace_parsed_);
724 } 725 }
725 726
726 class MockEnabledStateChangedObserver : 727 class MockEnabledStateChangedObserver :
727 public base::debug::TraceLog::EnabledStateChangedObserver { 728 public base::debug::TraceLog::EnabledStateChangedObserver {
728 public: 729 public:
729 MOCK_METHOD0(OnTraceLogWillEnable, void()); 730 MOCK_METHOD0(OnTraceLogWillEnable, void());
730 MOCK_METHOD0(OnTraceLogWillDisable, void()); 731 MOCK_METHOD0(OnTraceLogWillDisable, void());
731 }; 732 };
732 733
733 TEST_F(TraceEventTestFixture, EnabledObserverFiresOnEnable) { 734 TEST_F(TraceEventTestFixture, EnabledObserverFiresOnEnable) {
734 ManualTestSetUp(); 735 ManualTestSetUp();
735 736
736 MockEnabledStateChangedObserver observer; 737 MockEnabledStateChangedObserver observer;
737 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); 738 TraceLog::GetInstance()->AddEnabledStateObserver(&observer);
738 739
739 EXPECT_CALL(observer, OnTraceLogWillEnable()) 740 EXPECT_CALL(observer, OnTraceLogWillEnable())
740 .Times(1); 741 .Times(1);
741 TraceLog::GetInstance()->SetEnabled(true); 742 TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
742 testing::Mock::VerifyAndClear(&observer); 743 testing::Mock::VerifyAndClear(&observer);
743 744
744 // Cleanup. 745 // Cleanup.
745 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); 746 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer);
746 TraceLog::GetInstance()->SetEnabled(false); 747 TraceLog::GetInstance()->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
747 } 748 }
748 749
749 TEST_F(TraceEventTestFixture, EnabledObserverDoesntFireOnSecondEnable) { 750 TEST_F(TraceEventTestFixture, EnabledObserverDoesntFireOnSecondEnable) {
750 ManualTestSetUp(); 751 ManualTestSetUp();
751 752
752 TraceLog::GetInstance()->SetEnabled(true); 753 TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
753 754
754 testing::StrictMock<MockEnabledStateChangedObserver> observer; 755 testing::StrictMock<MockEnabledStateChangedObserver> observer;
755 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); 756 TraceLog::GetInstance()->AddEnabledStateObserver(&observer);
756 757
757 EXPECT_CALL(observer, OnTraceLogWillEnable()) 758 EXPECT_CALL(observer, OnTraceLogWillEnable())
758 .Times(0); 759 .Times(0);
759 EXPECT_CALL(observer, OnTraceLogWillDisable()) 760 EXPECT_CALL(observer, OnTraceLogWillDisable())
760 .Times(0); 761 .Times(0);
761 TraceLog::GetInstance()->SetEnabled(true); 762 TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
762 testing::Mock::VerifyAndClear(&observer); 763 testing::Mock::VerifyAndClear(&observer);
763 764
764 // Cleanup. 765 // Cleanup.
765 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); 766 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer);
766 TraceLog::GetInstance()->SetEnabled(false); 767 TraceLog::GetInstance()->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
767 TraceLog::GetInstance()->SetEnabled(false); 768 TraceLog::GetInstance()->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
768 } 769 }
769 770
770 TEST_F(TraceEventTestFixture, EnabledObserverDoesntFireOnNestedDisable) { 771 TEST_F(TraceEventTestFixture, EnabledObserverDoesntFireOnNestedDisable) {
771 ManualTestSetUp(); 772 ManualTestSetUp();
772 773
773 TraceLog::GetInstance()->SetEnabled(true); 774 TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
774 TraceLog::GetInstance()->SetEnabled(true); 775 TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
775 776
776 testing::StrictMock<MockEnabledStateChangedObserver> observer; 777 testing::StrictMock<MockEnabledStateChangedObserver> observer;
777 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); 778 TraceLog::GetInstance()->AddEnabledStateObserver(&observer);
778 779
779 EXPECT_CALL(observer, OnTraceLogWillEnable()) 780 EXPECT_CALL(observer, OnTraceLogWillEnable())
780 .Times(0); 781 .Times(0);
781 EXPECT_CALL(observer, OnTraceLogWillDisable()) 782 EXPECT_CALL(observer, OnTraceLogWillDisable())
782 .Times(0); 783 .Times(0);
783 TraceLog::GetInstance()->SetEnabled(false); 784 TraceLog::GetInstance()->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
784 testing::Mock::VerifyAndClear(&observer); 785 testing::Mock::VerifyAndClear(&observer);
785 786
786 // Cleanup. 787 // Cleanup.
787 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); 788 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer);
788 TraceLog::GetInstance()->SetEnabled(false); 789 TraceLog::GetInstance()->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
789 } 790 }
790 791
791 TEST_F(TraceEventTestFixture, EnabledObserverFiresOnDisable) { 792 TEST_F(TraceEventTestFixture, EnabledObserverFiresOnDisable) {
792 ManualTestSetUp(); 793 ManualTestSetUp();
793 794
794 TraceLog::GetInstance()->SetEnabled(true); 795 TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
795 796
796 MockEnabledStateChangedObserver observer; 797 MockEnabledStateChangedObserver observer;
797 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); 798 TraceLog::GetInstance()->AddEnabledStateObserver(&observer);
798 799
799 EXPECT_CALL(observer, OnTraceLogWillDisable()) 800 EXPECT_CALL(observer, OnTraceLogWillDisable())
800 .Times(1); 801 .Times(1);
801 TraceLog::GetInstance()->SetEnabled(false); 802 TraceLog::GetInstance()->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
802 testing::Mock::VerifyAndClear(&observer); 803 testing::Mock::VerifyAndClear(&observer);
803 804
804 // Cleanup. 805 // Cleanup.
805 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); 806 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer);
806 } 807 }
807 808
808 // Test that categories work. 809 // Test that categories work.
809 TEST_F(TraceEventTestFixture, Categories) { 810 TEST_F(TraceEventTestFixture, Categories) {
810 ManualTestSetUp(); 811 ManualTestSetUp();
811 812
(...skipping 15 matching lines...) Expand all
827 const std::vector<std::string> empty_categories; 828 const std::vector<std::string> empty_categories;
828 std::vector<std::string> included_categories; 829 std::vector<std::string> included_categories;
829 std::vector<std::string> excluded_categories; 830 std::vector<std::string> excluded_categories;
830 831
831 // Test that category filtering works. 832 // Test that category filtering works.
832 833
833 // Include nonexistent category -> no events 834 // Include nonexistent category -> no events
834 Clear(); 835 Clear();
835 included_categories.clear(); 836 included_categories.clear();
836 included_categories.push_back("not_found823564786"); 837 included_categories.push_back("not_found823564786");
837 TraceLog::GetInstance()->SetEnabled(included_categories, empty_categories); 838 TraceLog::GetInstance()->SetEnabled(included_categories, empty_categories,
839 TraceLog::RECORD_UNTIL_FULL);
838 TRACE_EVENT_INSTANT0("cat1", "name"); 840 TRACE_EVENT_INSTANT0("cat1", "name");
839 TRACE_EVENT_INSTANT0("cat2", "name"); 841 TRACE_EVENT_INSTANT0("cat2", "name");
840 EndTraceAndFlush(); 842 EndTraceAndFlush();
841 EXPECT_TRUE(trace_parsed_.empty()); 843 EXPECT_TRUE(trace_parsed_.empty());
842 844
843 // Include existent category -> only events of that category 845 // Include existent category -> only events of that category
844 Clear(); 846 Clear();
845 included_categories.clear(); 847 included_categories.clear();
846 included_categories.push_back("inc"); 848 included_categories.push_back("inc");
847 TraceLog::GetInstance()->SetEnabled(included_categories, empty_categories); 849 TraceLog::GetInstance()->SetEnabled(included_categories, empty_categories,
850 TraceLog::RECORD_UNTIL_FULL);
848 TRACE_EVENT_INSTANT0("inc", "name"); 851 TRACE_EVENT_INSTANT0("inc", "name");
849 TRACE_EVENT_INSTANT0("inc2", "name"); 852 TRACE_EVENT_INSTANT0("inc2", "name");
850 EndTraceAndFlush(); 853 EndTraceAndFlush();
851 EXPECT_TRUE(FindMatchingValue("cat", "inc")); 854 EXPECT_TRUE(FindMatchingValue("cat", "inc"));
852 EXPECT_FALSE(FindNonMatchingValue("cat", "inc")); 855 EXPECT_FALSE(FindNonMatchingValue("cat", "inc"));
853 856
854 // Include existent wildcard -> all categories matching wildcard 857 // Include existent wildcard -> all categories matching wildcard
855 Clear(); 858 Clear();
856 included_categories.clear(); 859 included_categories.clear();
857 included_categories.push_back("inc_wildcard_*"); 860 included_categories.push_back("inc_wildcard_*");
858 included_categories.push_back("inc_wildchar_?_end"); 861 included_categories.push_back("inc_wildchar_?_end");
859 TraceLog::GetInstance()->SetEnabled(included_categories, empty_categories); 862 TraceLog::GetInstance()->SetEnabled(included_categories, empty_categories,
863 TraceLog::RECORD_UNTIL_FULL);
860 TRACE_EVENT_INSTANT0("inc_wildcard_abc", "included"); 864 TRACE_EVENT_INSTANT0("inc_wildcard_abc", "included");
861 TRACE_EVENT_INSTANT0("inc_wildcard_", "included"); 865 TRACE_EVENT_INSTANT0("inc_wildcard_", "included");
862 TRACE_EVENT_INSTANT0("inc_wildchar_x_end", "included"); 866 TRACE_EVENT_INSTANT0("inc_wildchar_x_end", "included");
863 TRACE_EVENT_INSTANT0("inc_wildchar_bla_end", "not_inc"); 867 TRACE_EVENT_INSTANT0("inc_wildchar_bla_end", "not_inc");
864 TRACE_EVENT_INSTANT0("cat1", "not_inc"); 868 TRACE_EVENT_INSTANT0("cat1", "not_inc");
865 TRACE_EVENT_INSTANT0("cat2", "not_inc"); 869 TRACE_EVENT_INSTANT0("cat2", "not_inc");
866 EndTraceAndFlush(); 870 EndTraceAndFlush();
867 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildcard_abc")); 871 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildcard_abc"));
868 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildcard_")); 872 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildcard_"));
869 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildchar_x_end")); 873 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildchar_x_end"));
870 EXPECT_FALSE(FindMatchingValue("name", "not_inc")); 874 EXPECT_FALSE(FindMatchingValue("name", "not_inc"));
871 875
872 included_categories.clear(); 876 included_categories.clear();
873 877
874 // Exclude nonexistent category -> all events 878 // Exclude nonexistent category -> all events
875 Clear(); 879 Clear();
876 excluded_categories.clear(); 880 excluded_categories.clear();
877 excluded_categories.push_back("not_found823564786"); 881 excluded_categories.push_back("not_found823564786");
878 TraceLog::GetInstance()->SetEnabled(empty_categories, excluded_categories); 882 TraceLog::GetInstance()->SetEnabled(empty_categories, excluded_categories,
883 TraceLog::RECORD_UNTIL_FULL);
879 TRACE_EVENT_INSTANT0("cat1", "name"); 884 TRACE_EVENT_INSTANT0("cat1", "name");
880 TRACE_EVENT_INSTANT0("cat2", "name"); 885 TRACE_EVENT_INSTANT0("cat2", "name");
881 EndTraceAndFlush(); 886 EndTraceAndFlush();
882 EXPECT_TRUE(FindMatchingValue("cat", "cat1")); 887 EXPECT_TRUE(FindMatchingValue("cat", "cat1"));
883 EXPECT_TRUE(FindMatchingValue("cat", "cat2")); 888 EXPECT_TRUE(FindMatchingValue("cat", "cat2"));
884 889
885 // Exclude existent category -> only events of other categories 890 // Exclude existent category -> only events of other categories
886 Clear(); 891 Clear();
887 excluded_categories.clear(); 892 excluded_categories.clear();
888 excluded_categories.push_back("inc"); 893 excluded_categories.push_back("inc");
889 TraceLog::GetInstance()->SetEnabled(empty_categories, excluded_categories); 894 TraceLog::GetInstance()->SetEnabled(empty_categories, excluded_categories,
895 TraceLog::RECORD_UNTIL_FULL);
890 TRACE_EVENT_INSTANT0("inc", "name"); 896 TRACE_EVENT_INSTANT0("inc", "name");
891 TRACE_EVENT_INSTANT0("inc2", "name"); 897 TRACE_EVENT_INSTANT0("inc2", "name");
892 EndTraceAndFlush(); 898 EndTraceAndFlush();
893 EXPECT_TRUE(FindMatchingValue("cat", "inc2")); 899 EXPECT_TRUE(FindMatchingValue("cat", "inc2"));
894 EXPECT_FALSE(FindMatchingValue("cat", "inc")); 900 EXPECT_FALSE(FindMatchingValue("cat", "inc"));
895 901
896 // Exclude existent wildcard -> all categories not matching wildcard 902 // Exclude existent wildcard -> all categories not matching wildcard
897 Clear(); 903 Clear();
898 excluded_categories.clear(); 904 excluded_categories.clear();
899 excluded_categories.push_back("inc_wildcard_*"); 905 excluded_categories.push_back("inc_wildcard_*");
900 excluded_categories.push_back("inc_wildchar_?_end"); 906 excluded_categories.push_back("inc_wildchar_?_end");
901 TraceLog::GetInstance()->SetEnabled(empty_categories, excluded_categories); 907 TraceLog::GetInstance()->SetEnabled(empty_categories, excluded_categories,
908 TraceLog::RECORD_UNTIL_FULL);
902 TRACE_EVENT_INSTANT0("inc_wildcard_abc", "not_inc"); 909 TRACE_EVENT_INSTANT0("inc_wildcard_abc", "not_inc");
903 TRACE_EVENT_INSTANT0("inc_wildcard_", "not_inc"); 910 TRACE_EVENT_INSTANT0("inc_wildcard_", "not_inc");
904 TRACE_EVENT_INSTANT0("inc_wildchar_x_end", "not_inc"); 911 TRACE_EVENT_INSTANT0("inc_wildchar_x_end", "not_inc");
905 TRACE_EVENT_INSTANT0("inc_wildchar_bla_end", "included"); 912 TRACE_EVENT_INSTANT0("inc_wildchar_bla_end", "included");
906 TRACE_EVENT_INSTANT0("cat1", "included"); 913 TRACE_EVENT_INSTANT0("cat1", "included");
907 TRACE_EVENT_INSTANT0("cat2", "included"); 914 TRACE_EVENT_INSTANT0("cat2", "included");
908 EndTraceAndFlush(); 915 EndTraceAndFlush();
909 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildchar_bla_end")); 916 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildchar_bla_end"));
910 EXPECT_TRUE(FindMatchingValue("cat", "cat1")); 917 EXPECT_TRUE(FindMatchingValue("cat", "cat1"));
911 EXPECT_TRUE(FindMatchingValue("cat", "cat2")); 918 EXPECT_TRUE(FindMatchingValue("cat", "cat2"));
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 TRACE_EVENT_INSTANT1("category", "test", "a", a++); 1431 TRACE_EVENT_INSTANT1("category", "test", "a", a++);
1425 EXPECT_EQ(1, a); 1432 EXPECT_EQ(1, a);
1426 1433
1427 EndTraceAndFlush(); 1434 EndTraceAndFlush();
1428 } 1435 }
1429 1436
1430 TEST_F(TraceEventTestFixture, TraceEnableDisable) { 1437 TEST_F(TraceEventTestFixture, TraceEnableDisable) {
1431 ManualTestSetUp(); 1438 ManualTestSetUp();
1432 1439
1433 TraceLog* trace_log = TraceLog::GetInstance(); 1440 TraceLog* trace_log = TraceLog::GetInstance();
1434 trace_log->SetEnabled(std::string()); 1441 trace_log->SetEnabled(std::string(), TraceLog::RECORD_UNTIL_FULL);
1435 EXPECT_TRUE(trace_log->IsEnabled()); 1442 EXPECT_TRUE(trace_log->IsEnabled());
1436 trace_log->SetDisabled(); 1443 trace_log->SetDisabled();
1437 EXPECT_FALSE(trace_log->IsEnabled()); 1444 EXPECT_FALSE(trace_log->IsEnabled());
1438 1445
1439 trace_log->SetEnabled(true); 1446 trace_log->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
1440 EXPECT_TRUE(trace_log->IsEnabled()); 1447 EXPECT_TRUE(trace_log->IsEnabled());
1441 const std::vector<std::string> empty; 1448 const std::vector<std::string> empty;
1442 trace_log->SetEnabled(empty, empty); 1449 trace_log->SetEnabled(empty, empty, TraceLog::RECORD_UNTIL_FULL);
1443 EXPECT_TRUE(trace_log->IsEnabled()); 1450 EXPECT_TRUE(trace_log->IsEnabled());
1444 trace_log->SetEnabled(false); 1451 trace_log->SetEnabled(false, TraceLog::RECORD_UNTIL_FULL);
1445 EXPECT_TRUE(trace_log->IsEnabled()); 1452 EXPECT_TRUE(trace_log->IsEnabled());
1446 trace_log->SetDisabled(); 1453 trace_log->SetDisabled();
1447 EXPECT_FALSE(trace_log->IsEnabled()); 1454 EXPECT_FALSE(trace_log->IsEnabled());
1448 } 1455 }
1449 1456
1450 TEST_F(TraceEventTestFixture, TraceCategoriesAfterNestedEnable) { 1457 TEST_F(TraceEventTestFixture, TraceCategoriesAfterNestedEnable) {
1451 ManualTestSetUp(); 1458 ManualTestSetUp();
1452 1459
1453 TraceLog* trace_log = TraceLog::GetInstance(); 1460 TraceLog* trace_log = TraceLog::GetInstance();
1454 trace_log->SetEnabled(std::string("foo,bar")); 1461 trace_log->SetEnabled(std::string("foo,bar"), TraceLog::RECORD_UNTIL_FULL);
1455 EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo")); 1462 EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo"));
1456 EXPECT_TRUE(*trace_log->GetCategoryEnabled("bar")); 1463 EXPECT_TRUE(*trace_log->GetCategoryEnabled("bar"));
1457 EXPECT_FALSE(*trace_log->GetCategoryEnabled("baz")); 1464 EXPECT_FALSE(*trace_log->GetCategoryEnabled("baz"));
1458 trace_log->SetEnabled(std::string("foo2")); 1465 trace_log->SetEnabled(std::string("foo2"), TraceLog::RECORD_UNTIL_FULL);
1459 EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo2")); 1466 EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo2"));
1460 EXPECT_FALSE(*trace_log->GetCategoryEnabled("baz")); 1467 EXPECT_FALSE(*trace_log->GetCategoryEnabled("baz"));
1461 trace_log->SetEnabled(std::string("")); 1468 trace_log->SetEnabled(std::string(""), TraceLog::RECORD_UNTIL_FULL);
1462 EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo")); 1469 EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo"));
1463 EXPECT_TRUE(*trace_log->GetCategoryEnabled("baz")); 1470 EXPECT_TRUE(*trace_log->GetCategoryEnabled("baz"));
1464 trace_log->SetDisabled(); 1471 trace_log->SetDisabled();
1465 trace_log->SetDisabled(); 1472 trace_log->SetDisabled();
1466 trace_log->SetDisabled(); 1473 trace_log->SetDisabled();
1467 EXPECT_FALSE(*trace_log->GetCategoryEnabled("foo")); 1474 EXPECT_FALSE(*trace_log->GetCategoryEnabled("foo"));
1468 EXPECT_FALSE(*trace_log->GetCategoryEnabled("baz")); 1475 EXPECT_FALSE(*trace_log->GetCategoryEnabled("baz"));
1469 1476
1470 trace_log->SetEnabled(std::string("-foo,-bar")); 1477 trace_log->SetEnabled(std::string("-foo,-bar"), TraceLog::RECORD_UNTIL_FULL);
1471 EXPECT_FALSE(*trace_log->GetCategoryEnabled("foo")); 1478 EXPECT_FALSE(*trace_log->GetCategoryEnabled("foo"));
1472 EXPECT_TRUE(*trace_log->GetCategoryEnabled("baz")); 1479 EXPECT_TRUE(*trace_log->GetCategoryEnabled("baz"));
1473 trace_log->SetEnabled(std::string("moo")); 1480 trace_log->SetEnabled(std::string("moo"), TraceLog::RECORD_UNTIL_FULL);
1474 EXPECT_TRUE(*trace_log->GetCategoryEnabled("baz")); 1481 EXPECT_TRUE(*trace_log->GetCategoryEnabled("baz"));
1475 EXPECT_TRUE(*trace_log->GetCategoryEnabled("moo")); 1482 EXPECT_TRUE(*trace_log->GetCategoryEnabled("moo"));
1476 EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo")); 1483 EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo"));
1477 trace_log->SetDisabled(); 1484 trace_log->SetDisabled();
1478 trace_log->SetDisabled(); 1485 trace_log->SetDisabled();
1479 } 1486 }
1480 1487
1488 TEST_F(TraceEventTestFixture, TraceOptionsParsing) {
1489 ManualTestSetUp();
1490
1491 EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL, TraceLog::TraceOptionsFromString(""));
1492
1493 EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL,
1494 TraceLog::TraceOptionsFromString("record-until-full"));
1495 }
1496
1481 } // namespace debug 1497 } // namespace debug
1482 } // namespace base 1498 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | base/test/trace_event_analyzer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698