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

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

Powered by Google App Engine
This is Rietveld 408576698