OLD | NEW |
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 <math.h> | 7 #include <math.h> |
8 #include <cstdlib> | 8 #include <cstdlib> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/debug/trace_event_synthetic_delay.h" | 13 #include "base/debug/trace_event_synthetic_delay.h" |
14 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
15 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
16 #include "base/memory/ref_counted_memory.h" | 16 #include "base/memory/ref_counted_memory.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/singleton.h" | 18 #include "base/memory/singleton.h" |
19 #include "base/process/process_handle.h" | 19 #include "base/process/process_handle.h" |
20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
21 #include "base/synchronization/waitable_event.h" | 21 #include "base/synchronization/waitable_event.h" |
22 #include "base/threading/platform_thread.h" | 22 #include "base/threading/platform_thread.h" |
23 #include "base/threading/thread.h" | 23 #include "base/threading/thread.h" |
24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
25 #include "base/values.h" | 25 #include "base/values.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 | 28 |
29 using base::debug::HighResSleepForTraceTest; | |
30 | |
31 namespace base { | 29 namespace base { |
32 namespace debug { | 30 namespace debug { |
33 | 31 |
34 namespace { | 32 namespace { |
35 | 33 |
36 enum CompareOp { | 34 enum CompareOp { |
37 IS_EQUAL, | 35 IS_EQUAL, |
38 IS_NOT_EQUAL, | 36 IS_NOT_EQUAL, |
39 }; | 37 }; |
40 | 38 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 trace_parsed_.Clear(); | 72 trace_parsed_.Clear(); |
75 json_output_.json_output.clear(); | 73 json_output_.json_output.clear(); |
76 } | 74 } |
77 | 75 |
78 void BeginTrace() { | 76 void BeginTrace() { |
79 BeginSpecificTrace("*"); | 77 BeginSpecificTrace("*"); |
80 } | 78 } |
81 | 79 |
82 void BeginSpecificTrace(const std::string& filter) { | 80 void BeginSpecificTrace(const std::string& filter) { |
83 event_watch_notification_ = 0; | 81 event_watch_notification_ = 0; |
84 TraceLog::GetInstance()->SetEnabled(CategoryFilter(filter), | 82 TraceLog::GetInstance()->SetEnabled( |
85 base::debug::TraceLog::RECORDING_MODE, | 83 CategoryFilter(filter), |
86 TraceLog::RECORD_UNTIL_FULL); | 84 TraceLog::RECORDING_MODE, |
| 85 TraceOptions()); |
87 } | 86 } |
88 | 87 |
89 void EndTraceAndFlush() { | 88 void EndTraceAndFlush() { |
90 WaitableEvent flush_complete_event(false, false); | 89 WaitableEvent flush_complete_event(false, false); |
91 EndTraceAndFlushAsync(&flush_complete_event); | 90 EndTraceAndFlushAsync(&flush_complete_event); |
92 flush_complete_event.Wait(); | 91 flush_complete_event.Wait(); |
93 } | 92 } |
94 | 93 |
95 // Used when testing thread-local buffers which requires the thread initiating | 94 // Used when testing thread-local buffers which requires the thread initiating |
96 // flush to have a message loop. | 95 // flush to have a message loop. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); | 141 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); |
143 PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : ""); | 142 PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : ""); |
144 free(old_thread_name_); | 143 free(old_thread_name_); |
145 old_thread_name_ = NULL; | 144 old_thread_name_ = NULL; |
146 // We want our singleton torn down after each test. | 145 // We want our singleton torn down after each test. |
147 TraceLog::DeleteForTesting(); | 146 TraceLog::DeleteForTesting(); |
148 } | 147 } |
149 | 148 |
150 char* old_thread_name_; | 149 char* old_thread_name_; |
151 ListValue trace_parsed_; | 150 ListValue trace_parsed_; |
152 base::debug::TraceResultBuffer trace_buffer_; | 151 TraceResultBuffer trace_buffer_; |
153 base::debug::TraceResultBuffer::SimpleOutput json_output_; | 152 TraceResultBuffer::SimpleOutput json_output_; |
154 int event_watch_notification_; | 153 int event_watch_notification_; |
155 | 154 |
156 private: | 155 private: |
157 // We want our singleton torn down after each test. | 156 // We want our singleton torn down after each test. |
158 ShadowingAtExitManager at_exit_manager_; | 157 ShadowingAtExitManager at_exit_manager_; |
159 Lock lock_; | 158 Lock lock_; |
160 }; | 159 }; |
161 | 160 |
162 void TraceEventTestFixture::OnTraceDataCollected( | 161 void TraceEventTestFixture::OnTraceDataCollected( |
163 WaitableEvent* flush_complete_event, | 162 WaitableEvent* flush_complete_event, |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 | 874 |
876 void HighResSleepForTraceTest(base::TimeDelta elapsed) { | 875 void HighResSleepForTraceTest(base::TimeDelta elapsed) { |
877 base::TimeTicks end_time = base::TimeTicks::HighResNow() + elapsed; | 876 base::TimeTicks end_time = base::TimeTicks::HighResNow() + elapsed; |
878 do { | 877 do { |
879 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); | 878 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); |
880 } while (base::TimeTicks::HighResNow() < end_time); | 879 } while (base::TimeTicks::HighResNow() < end_time); |
881 } | 880 } |
882 | 881 |
883 // Simple Test for emitting data and validating it was received. | 882 // Simple Test for emitting data and validating it was received. |
884 TEST_F(TraceEventTestFixture, DataCaptured) { | 883 TEST_F(TraceEventTestFixture, DataCaptured) { |
885 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 884 TraceLog::GetInstance()->SetEnabled( |
886 base::debug::TraceLog::RECORDING_MODE, | 885 CategoryFilter("*"), |
887 TraceLog::RECORD_UNTIL_FULL); | 886 TraceLog::RECORDING_MODE, |
| 887 TraceOptions()); |
888 | 888 |
889 TraceWithAllMacroVariants(NULL); | 889 TraceWithAllMacroVariants(NULL); |
890 | 890 |
891 EndTraceAndFlush(); | 891 EndTraceAndFlush(); |
892 | 892 |
893 ValidateAllTraceMacrosCreatedData(trace_parsed_); | 893 ValidateAllTraceMacrosCreatedData(trace_parsed_); |
894 } | 894 } |
895 | 895 |
896 class MockEnabledStateChangedObserver : | 896 class MockEnabledStateChangedObserver : |
897 public base::debug::TraceLog::EnabledStateObserver { | 897 public TraceLog::EnabledStateObserver { |
898 public: | 898 public: |
899 MOCK_METHOD0(OnTraceLogEnabled, void()); | 899 MOCK_METHOD0(OnTraceLogEnabled, void()); |
900 MOCK_METHOD0(OnTraceLogDisabled, void()); | 900 MOCK_METHOD0(OnTraceLogDisabled, void()); |
901 }; | 901 }; |
902 | 902 |
903 TEST_F(TraceEventTestFixture, EnabledObserverFiresOnEnable) { | 903 TEST_F(TraceEventTestFixture, EnabledObserverFiresOnEnable) { |
904 MockEnabledStateChangedObserver observer; | 904 MockEnabledStateChangedObserver observer; |
905 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); | 905 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); |
906 | 906 |
907 EXPECT_CALL(observer, OnTraceLogEnabled()) | 907 EXPECT_CALL(observer, OnTraceLogEnabled()) |
908 .Times(1); | 908 .Times(1); |
909 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 909 TraceLog::GetInstance()->SetEnabled( |
910 base::debug::TraceLog::RECORDING_MODE, | 910 CategoryFilter("*"), |
911 TraceLog::RECORD_UNTIL_FULL); | 911 TraceLog::RECORDING_MODE, |
| 912 TraceOptions()); |
912 testing::Mock::VerifyAndClear(&observer); | 913 testing::Mock::VerifyAndClear(&observer); |
913 EXPECT_TRUE(TraceLog::GetInstance()->IsEnabled()); | 914 EXPECT_TRUE(TraceLog::GetInstance()->IsEnabled()); |
914 | 915 |
915 // Cleanup. | 916 // Cleanup. |
916 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); | 917 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); |
917 TraceLog::GetInstance()->SetDisabled(); | 918 TraceLog::GetInstance()->SetDisabled(); |
918 } | 919 } |
919 | 920 |
920 TEST_F(TraceEventTestFixture, EnabledObserverDoesntFireOnSecondEnable) { | 921 TEST_F(TraceEventTestFixture, EnabledObserverDoesntFireOnSecondEnable) { |
921 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 922 TraceLog::GetInstance()->SetEnabled( |
922 base::debug::TraceLog::RECORDING_MODE, | 923 CategoryFilter("*"), |
923 TraceLog::RECORD_UNTIL_FULL); | 924 TraceLog::RECORDING_MODE, |
| 925 TraceOptions()); |
924 | 926 |
925 testing::StrictMock<MockEnabledStateChangedObserver> observer; | 927 testing::StrictMock<MockEnabledStateChangedObserver> observer; |
926 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); | 928 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); |
927 | 929 |
928 EXPECT_CALL(observer, OnTraceLogEnabled()) | 930 EXPECT_CALL(observer, OnTraceLogEnabled()) |
929 .Times(0); | 931 .Times(0); |
930 EXPECT_CALL(observer, OnTraceLogDisabled()) | 932 EXPECT_CALL(observer, OnTraceLogDisabled()) |
931 .Times(0); | 933 .Times(0); |
932 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 934 TraceLog::GetInstance()->SetEnabled( |
933 base::debug::TraceLog::RECORDING_MODE, | 935 CategoryFilter("*"), |
934 TraceLog::RECORD_UNTIL_FULL); | 936 TraceLog::RECORDING_MODE, |
| 937 TraceOptions()); |
935 testing::Mock::VerifyAndClear(&observer); | 938 testing::Mock::VerifyAndClear(&observer); |
936 EXPECT_TRUE(TraceLog::GetInstance()->IsEnabled()); | 939 EXPECT_TRUE(TraceLog::GetInstance()->IsEnabled()); |
937 | 940 |
938 // Cleanup. | 941 // Cleanup. |
939 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); | 942 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); |
940 TraceLog::GetInstance()->SetDisabled(); | 943 TraceLog::GetInstance()->SetDisabled(); |
941 TraceLog::GetInstance()->SetDisabled(); | 944 TraceLog::GetInstance()->SetDisabled(); |
942 } | 945 } |
943 | 946 |
944 TEST_F(TraceEventTestFixture, EnabledObserverFiresOnFirstDisable) { | 947 TEST_F(TraceEventTestFixture, EnabledObserverFiresOnFirstDisable) { |
945 CategoryFilter cf_inc_all("*"); | 948 CategoryFilter cf_inc_all("*"); |
946 TraceLog::GetInstance()->SetEnabled(cf_inc_all, | 949 TraceLog::GetInstance()->SetEnabled( |
947 base::debug::TraceLog::RECORDING_MODE, | 950 cf_inc_all, |
948 TraceLog::RECORD_UNTIL_FULL); | 951 TraceLog::RECORDING_MODE, |
949 TraceLog::GetInstance()->SetEnabled(cf_inc_all, | 952 TraceOptions()); |
950 base::debug::TraceLog::RECORDING_MODE, | 953 TraceLog::GetInstance()->SetEnabled( |
951 TraceLog::RECORD_UNTIL_FULL); | 954 cf_inc_all, |
| 955 TraceLog::RECORDING_MODE, |
| 956 TraceOptions()); |
952 | 957 |
953 testing::StrictMock<MockEnabledStateChangedObserver> observer; | 958 testing::StrictMock<MockEnabledStateChangedObserver> observer; |
954 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); | 959 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); |
955 | 960 |
956 EXPECT_CALL(observer, OnTraceLogEnabled()) | 961 EXPECT_CALL(observer, OnTraceLogEnabled()) |
957 .Times(0); | 962 .Times(0); |
958 EXPECT_CALL(observer, OnTraceLogDisabled()) | 963 EXPECT_CALL(observer, OnTraceLogDisabled()) |
959 .Times(1); | 964 .Times(1); |
960 TraceLog::GetInstance()->SetDisabled(); | 965 TraceLog::GetInstance()->SetDisabled(); |
961 testing::Mock::VerifyAndClear(&observer); | 966 testing::Mock::VerifyAndClear(&observer); |
962 | 967 |
963 // Cleanup. | 968 // Cleanup. |
964 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); | 969 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); |
965 TraceLog::GetInstance()->SetDisabled(); | 970 TraceLog::GetInstance()->SetDisabled(); |
966 } | 971 } |
967 | 972 |
968 TEST_F(TraceEventTestFixture, EnabledObserverFiresOnDisable) { | 973 TEST_F(TraceEventTestFixture, EnabledObserverFiresOnDisable) { |
969 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 974 TraceLog::GetInstance()->SetEnabled( |
970 base::debug::TraceLog::RECORDING_MODE, | 975 CategoryFilter("*"), |
971 TraceLog::RECORD_UNTIL_FULL); | 976 TraceLog::RECORDING_MODE, |
| 977 TraceOptions()); |
972 | 978 |
973 MockEnabledStateChangedObserver observer; | 979 MockEnabledStateChangedObserver observer; |
974 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); | 980 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); |
975 | 981 |
976 EXPECT_CALL(observer, OnTraceLogDisabled()) | 982 EXPECT_CALL(observer, OnTraceLogDisabled()) |
977 .Times(1); | 983 .Times(1); |
978 TraceLog::GetInstance()->SetDisabled(); | 984 TraceLog::GetInstance()->SetDisabled(); |
979 testing::Mock::VerifyAndClear(&observer); | 985 testing::Mock::VerifyAndClear(&observer); |
980 | 986 |
981 // Cleanup. | 987 // Cleanup. |
982 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); | 988 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); |
983 } | 989 } |
984 | 990 |
985 // Tests the IsEnabled() state of TraceLog changes before callbacks. | 991 // Tests the IsEnabled() state of TraceLog changes before callbacks. |
986 class AfterStateChangeEnabledStateObserver | 992 class AfterStateChangeEnabledStateObserver |
987 : public base::debug::TraceLog::EnabledStateObserver { | 993 : public TraceLog::EnabledStateObserver { |
988 public: | 994 public: |
989 AfterStateChangeEnabledStateObserver() {} | 995 AfterStateChangeEnabledStateObserver() {} |
990 virtual ~AfterStateChangeEnabledStateObserver() {} | 996 virtual ~AfterStateChangeEnabledStateObserver() {} |
991 | 997 |
992 // base::debug::TraceLog::EnabledStateObserver overrides: | 998 // TraceLog::EnabledStateObserver overrides: |
993 virtual void OnTraceLogEnabled() OVERRIDE { | 999 virtual void OnTraceLogEnabled() OVERRIDE { |
994 EXPECT_TRUE(TraceLog::GetInstance()->IsEnabled()); | 1000 EXPECT_TRUE(TraceLog::GetInstance()->IsEnabled()); |
995 } | 1001 } |
996 | 1002 |
997 virtual void OnTraceLogDisabled() OVERRIDE { | 1003 virtual void OnTraceLogDisabled() OVERRIDE { |
998 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); | 1004 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); |
999 } | 1005 } |
1000 }; | 1006 }; |
1001 | 1007 |
1002 TEST_F(TraceEventTestFixture, ObserversFireAfterStateChange) { | 1008 TEST_F(TraceEventTestFixture, ObserversFireAfterStateChange) { |
1003 AfterStateChangeEnabledStateObserver observer; | 1009 AfterStateChangeEnabledStateObserver observer; |
1004 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); | 1010 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); |
1005 | 1011 |
1006 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 1012 TraceLog::GetInstance()->SetEnabled( |
1007 base::debug::TraceLog::RECORDING_MODE, | 1013 CategoryFilter("*"), |
1008 TraceLog::RECORD_UNTIL_FULL); | 1014 TraceLog::RECORDING_MODE, |
| 1015 TraceOptions()); |
1009 EXPECT_TRUE(TraceLog::GetInstance()->IsEnabled()); | 1016 EXPECT_TRUE(TraceLog::GetInstance()->IsEnabled()); |
1010 | 1017 |
1011 TraceLog::GetInstance()->SetDisabled(); | 1018 TraceLog::GetInstance()->SetDisabled(); |
1012 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); | 1019 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); |
1013 | 1020 |
1014 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); | 1021 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); |
1015 } | 1022 } |
1016 | 1023 |
1017 // Tests that a state observer can remove itself during a callback. | 1024 // Tests that a state observer can remove itself during a callback. |
1018 class SelfRemovingEnabledStateObserver | 1025 class SelfRemovingEnabledStateObserver |
1019 : public base::debug::TraceLog::EnabledStateObserver { | 1026 : public TraceLog::EnabledStateObserver { |
1020 public: | 1027 public: |
1021 SelfRemovingEnabledStateObserver() {} | 1028 SelfRemovingEnabledStateObserver() {} |
1022 virtual ~SelfRemovingEnabledStateObserver() {} | 1029 virtual ~SelfRemovingEnabledStateObserver() {} |
1023 | 1030 |
1024 // base::debug::TraceLog::EnabledStateObserver overrides: | 1031 // TraceLog::EnabledStateObserver overrides: |
1025 virtual void OnTraceLogEnabled() OVERRIDE {} | 1032 virtual void OnTraceLogEnabled() OVERRIDE {} |
1026 | 1033 |
1027 virtual void OnTraceLogDisabled() OVERRIDE { | 1034 virtual void OnTraceLogDisabled() OVERRIDE { |
1028 TraceLog::GetInstance()->RemoveEnabledStateObserver(this); | 1035 TraceLog::GetInstance()->RemoveEnabledStateObserver(this); |
1029 } | 1036 } |
1030 }; | 1037 }; |
1031 | 1038 |
1032 TEST_F(TraceEventTestFixture, SelfRemovingObserver) { | 1039 TEST_F(TraceEventTestFixture, SelfRemovingObserver) { |
1033 ASSERT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest()); | 1040 ASSERT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest()); |
1034 | 1041 |
1035 SelfRemovingEnabledStateObserver observer; | 1042 SelfRemovingEnabledStateObserver observer; |
1036 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); | 1043 TraceLog::GetInstance()->AddEnabledStateObserver(&observer); |
1037 EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest()); | 1044 EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest()); |
1038 | 1045 |
1039 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 1046 TraceLog::GetInstance()->SetEnabled( |
1040 base::debug::TraceLog::RECORDING_MODE, | 1047 CategoryFilter("*"), |
1041 TraceLog::RECORD_UNTIL_FULL); | 1048 TraceLog::RECORDING_MODE, |
| 1049 TraceOptions()); |
1042 TraceLog::GetInstance()->SetDisabled(); | 1050 TraceLog::GetInstance()->SetDisabled(); |
1043 // The observer removed itself on disable. | 1051 // The observer removed itself on disable. |
1044 EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest()); | 1052 EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest()); |
1045 } | 1053 } |
1046 | 1054 |
1047 bool IsNewTrace() { | 1055 bool IsNewTrace() { |
1048 bool is_new_trace; | 1056 bool is_new_trace; |
1049 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); | 1057 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); |
1050 return is_new_trace; | 1058 return is_new_trace; |
1051 } | 1059 } |
1052 | 1060 |
1053 TEST_F(TraceEventTestFixture, NewTraceRecording) { | 1061 TEST_F(TraceEventTestFixture, NewTraceRecording) { |
1054 ASSERT_FALSE(IsNewTrace()); | 1062 ASSERT_FALSE(IsNewTrace()); |
1055 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 1063 TraceLog::GetInstance()->SetEnabled( |
1056 base::debug::TraceLog::RECORDING_MODE, | 1064 CategoryFilter("*"), |
1057 TraceLog::RECORD_UNTIL_FULL); | 1065 TraceLog::RECORDING_MODE, |
| 1066 TraceOptions()); |
1058 // First call to IsNewTrace() should succeed. But, the second shouldn't. | 1067 // First call to IsNewTrace() should succeed. But, the second shouldn't. |
1059 ASSERT_TRUE(IsNewTrace()); | 1068 ASSERT_TRUE(IsNewTrace()); |
1060 ASSERT_FALSE(IsNewTrace()); | 1069 ASSERT_FALSE(IsNewTrace()); |
1061 EndTraceAndFlush(); | 1070 EndTraceAndFlush(); |
1062 | 1071 |
1063 // IsNewTrace() should definitely be false now. | 1072 // IsNewTrace() should definitely be false now. |
1064 ASSERT_FALSE(IsNewTrace()); | 1073 ASSERT_FALSE(IsNewTrace()); |
1065 | 1074 |
1066 // Start another trace. IsNewTrace() should become true again, briefly, as | 1075 // Start another trace. IsNewTrace() should become true again, briefly, as |
1067 // before. | 1076 // before. |
1068 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 1077 TraceLog::GetInstance()->SetEnabled( |
1069 base::debug::TraceLog::RECORDING_MODE, | 1078 CategoryFilter("*"), |
1070 TraceLog::RECORD_UNTIL_FULL); | 1079 TraceLog::RECORDING_MODE, |
| 1080 TraceOptions()); |
1071 ASSERT_TRUE(IsNewTrace()); | 1081 ASSERT_TRUE(IsNewTrace()); |
1072 ASSERT_FALSE(IsNewTrace()); | 1082 ASSERT_FALSE(IsNewTrace()); |
1073 | 1083 |
1074 // Cleanup. | 1084 // Cleanup. |
1075 EndTraceAndFlush(); | 1085 EndTraceAndFlush(); |
1076 } | 1086 } |
1077 | 1087 |
1078 | 1088 |
1079 // Test that categories work. | 1089 // Test that categories work. |
1080 TEST_F(TraceEventTestFixture, Categories) { | 1090 TEST_F(TraceEventTestFixture, Categories) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 | 1125 |
1116 const std::vector<std::string> empty_categories; | 1126 const std::vector<std::string> empty_categories; |
1117 std::vector<std::string> included_categories; | 1127 std::vector<std::string> included_categories; |
1118 std::vector<std::string> excluded_categories; | 1128 std::vector<std::string> excluded_categories; |
1119 | 1129 |
1120 // Test that category filtering works. | 1130 // Test that category filtering works. |
1121 | 1131 |
1122 // Include nonexistent category -> no events | 1132 // Include nonexistent category -> no events |
1123 Clear(); | 1133 Clear(); |
1124 included_categories.clear(); | 1134 included_categories.clear(); |
1125 TraceLog::GetInstance()->SetEnabled(CategoryFilter("not_found823564786"), | 1135 TraceLog::GetInstance()->SetEnabled( |
1126 base::debug::TraceLog::RECORDING_MODE, | 1136 CategoryFilter("not_found823564786"), |
1127 TraceLog::RECORD_UNTIL_FULL); | 1137 TraceLog::RECORDING_MODE, |
| 1138 TraceOptions()); |
1128 TRACE_EVENT_INSTANT0("cat1", "name", TRACE_EVENT_SCOPE_THREAD); | 1139 TRACE_EVENT_INSTANT0("cat1", "name", TRACE_EVENT_SCOPE_THREAD); |
1129 TRACE_EVENT_INSTANT0("cat2", "name", TRACE_EVENT_SCOPE_THREAD); | 1140 TRACE_EVENT_INSTANT0("cat2", "name", TRACE_EVENT_SCOPE_THREAD); |
1130 EndTraceAndFlush(); | 1141 EndTraceAndFlush(); |
1131 DropTracedMetadataRecords(); | 1142 DropTracedMetadataRecords(); |
1132 EXPECT_TRUE(trace_parsed_.empty()); | 1143 EXPECT_TRUE(trace_parsed_.empty()); |
1133 | 1144 |
1134 // Include existent category -> only events of that category | 1145 // Include existent category -> only events of that category |
1135 Clear(); | 1146 Clear(); |
1136 included_categories.clear(); | 1147 included_categories.clear(); |
1137 TraceLog::GetInstance()->SetEnabled(CategoryFilter("inc"), | 1148 TraceLog::GetInstance()->SetEnabled( |
1138 base::debug::TraceLog::RECORDING_MODE, | 1149 CategoryFilter("inc"), |
1139 TraceLog::RECORD_UNTIL_FULL); | 1150 TraceLog::RECORDING_MODE, |
| 1151 TraceOptions()); |
1140 TRACE_EVENT_INSTANT0("inc", "name", TRACE_EVENT_SCOPE_THREAD); | 1152 TRACE_EVENT_INSTANT0("inc", "name", TRACE_EVENT_SCOPE_THREAD); |
1141 TRACE_EVENT_INSTANT0("inc2", "name", TRACE_EVENT_SCOPE_THREAD); | 1153 TRACE_EVENT_INSTANT0("inc2", "name", TRACE_EVENT_SCOPE_THREAD); |
1142 EndTraceAndFlush(); | 1154 EndTraceAndFlush(); |
1143 DropTracedMetadataRecords(); | 1155 DropTracedMetadataRecords(); |
1144 EXPECT_TRUE(FindMatchingValue("cat", "inc")); | 1156 EXPECT_TRUE(FindMatchingValue("cat", "inc")); |
1145 EXPECT_FALSE(FindNonMatchingValue("cat", "inc")); | 1157 EXPECT_FALSE(FindNonMatchingValue("cat", "inc")); |
1146 | 1158 |
1147 // Include existent wildcard -> all categories matching wildcard | 1159 // Include existent wildcard -> all categories matching wildcard |
1148 Clear(); | 1160 Clear(); |
1149 included_categories.clear(); | 1161 included_categories.clear(); |
1150 TraceLog::GetInstance()->SetEnabled( | 1162 TraceLog::GetInstance()->SetEnabled( |
1151 CategoryFilter("inc_wildcard_*,inc_wildchar_?_end"), | 1163 CategoryFilter("inc_wildcard_*,inc_wildchar_?_end"), |
1152 base::debug::TraceLog::RECORDING_MODE, | 1164 TraceLog::RECORDING_MODE, |
1153 TraceLog::RECORD_UNTIL_FULL); | 1165 TraceOptions()); |
1154 TRACE_EVENT_INSTANT0("inc_wildcard_abc", "included", | 1166 TRACE_EVENT_INSTANT0("inc_wildcard_abc", "included", |
1155 TRACE_EVENT_SCOPE_THREAD); | 1167 TRACE_EVENT_SCOPE_THREAD); |
1156 TRACE_EVENT_INSTANT0("inc_wildcard_", "included", TRACE_EVENT_SCOPE_THREAD); | 1168 TRACE_EVENT_INSTANT0("inc_wildcard_", "included", TRACE_EVENT_SCOPE_THREAD); |
1157 TRACE_EVENT_INSTANT0("inc_wildchar_x_end", "included", | 1169 TRACE_EVENT_INSTANT0("inc_wildchar_x_end", "included", |
1158 TRACE_EVENT_SCOPE_THREAD); | 1170 TRACE_EVENT_SCOPE_THREAD); |
1159 TRACE_EVENT_INSTANT0("inc_wildchar_bla_end", "not_inc", | 1171 TRACE_EVENT_INSTANT0("inc_wildchar_bla_end", "not_inc", |
1160 TRACE_EVENT_SCOPE_THREAD); | 1172 TRACE_EVENT_SCOPE_THREAD); |
1161 TRACE_EVENT_INSTANT0("cat1", "not_inc", TRACE_EVENT_SCOPE_THREAD); | 1173 TRACE_EVENT_INSTANT0("cat1", "not_inc", TRACE_EVENT_SCOPE_THREAD); |
1162 TRACE_EVENT_INSTANT0("cat2", "not_inc", TRACE_EVENT_SCOPE_THREAD); | 1174 TRACE_EVENT_INSTANT0("cat2", "not_inc", TRACE_EVENT_SCOPE_THREAD); |
1163 TRACE_EVENT_INSTANT0("inc_wildcard_category,other_category", "included", | 1175 TRACE_EVENT_INSTANT0("inc_wildcard_category,other_category", "included", |
1164 TRACE_EVENT_SCOPE_THREAD); | 1176 TRACE_EVENT_SCOPE_THREAD); |
1165 TRACE_EVENT_INSTANT0( | 1177 TRACE_EVENT_INSTANT0( |
1166 "non_included_category,inc_wildcard_category", "included", | 1178 "non_included_category,inc_wildcard_category", "included", |
1167 TRACE_EVENT_SCOPE_THREAD); | 1179 TRACE_EVENT_SCOPE_THREAD); |
1168 EndTraceAndFlush(); | 1180 EndTraceAndFlush(); |
1169 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildcard_abc")); | 1181 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildcard_abc")); |
1170 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildcard_")); | 1182 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildcard_")); |
1171 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildchar_x_end")); | 1183 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildchar_x_end")); |
1172 EXPECT_FALSE(FindMatchingValue("name", "not_inc")); | 1184 EXPECT_FALSE(FindMatchingValue("name", "not_inc")); |
1173 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildcard_category,other_category")); | 1185 EXPECT_TRUE(FindMatchingValue("cat", "inc_wildcard_category,other_category")); |
1174 EXPECT_TRUE(FindMatchingValue("cat", | 1186 EXPECT_TRUE(FindMatchingValue("cat", |
1175 "non_included_category,inc_wildcard_category")); | 1187 "non_included_category,inc_wildcard_category")); |
1176 | 1188 |
1177 included_categories.clear(); | 1189 included_categories.clear(); |
1178 | 1190 |
1179 // Exclude nonexistent category -> all events | 1191 // Exclude nonexistent category -> all events |
1180 Clear(); | 1192 Clear(); |
1181 TraceLog::GetInstance()->SetEnabled(CategoryFilter("-not_found823564786"), | 1193 TraceLog::GetInstance()->SetEnabled( |
1182 base::debug::TraceLog::RECORDING_MODE, | 1194 CategoryFilter("-not_found823564786"), |
1183 TraceLog::RECORD_UNTIL_FULL); | 1195 TraceLog::RECORDING_MODE, |
| 1196 TraceOptions()); |
1184 TRACE_EVENT_INSTANT0("cat1", "name", TRACE_EVENT_SCOPE_THREAD); | 1197 TRACE_EVENT_INSTANT0("cat1", "name", TRACE_EVENT_SCOPE_THREAD); |
1185 TRACE_EVENT_INSTANT0("cat2", "name", TRACE_EVENT_SCOPE_THREAD); | 1198 TRACE_EVENT_INSTANT0("cat2", "name", TRACE_EVENT_SCOPE_THREAD); |
1186 TRACE_EVENT_INSTANT0("category1,category2", "name", TRACE_EVENT_SCOPE_THREAD); | 1199 TRACE_EVENT_INSTANT0("category1,category2", "name", TRACE_EVENT_SCOPE_THREAD); |
1187 EndTraceAndFlush(); | 1200 EndTraceAndFlush(); |
1188 EXPECT_TRUE(FindMatchingValue("cat", "cat1")); | 1201 EXPECT_TRUE(FindMatchingValue("cat", "cat1")); |
1189 EXPECT_TRUE(FindMatchingValue("cat", "cat2")); | 1202 EXPECT_TRUE(FindMatchingValue("cat", "cat2")); |
1190 EXPECT_TRUE(FindMatchingValue("cat", "category1,category2")); | 1203 EXPECT_TRUE(FindMatchingValue("cat", "category1,category2")); |
1191 | 1204 |
1192 // Exclude existent category -> only events of other categories | 1205 // Exclude existent category -> only events of other categories |
1193 Clear(); | 1206 Clear(); |
1194 TraceLog::GetInstance()->SetEnabled(CategoryFilter("-inc"), | 1207 TraceLog::GetInstance()->SetEnabled( |
1195 base::debug::TraceLog::RECORDING_MODE, | 1208 CategoryFilter("-inc"), |
1196 TraceLog::RECORD_UNTIL_FULL); | 1209 TraceLog::RECORDING_MODE, |
| 1210 TraceOptions()); |
1197 TRACE_EVENT_INSTANT0("inc", "name", TRACE_EVENT_SCOPE_THREAD); | 1211 TRACE_EVENT_INSTANT0("inc", "name", TRACE_EVENT_SCOPE_THREAD); |
1198 TRACE_EVENT_INSTANT0("inc2", "name", TRACE_EVENT_SCOPE_THREAD); | 1212 TRACE_EVENT_INSTANT0("inc2", "name", TRACE_EVENT_SCOPE_THREAD); |
1199 TRACE_EVENT_INSTANT0("inc2,inc", "name", TRACE_EVENT_SCOPE_THREAD); | 1213 TRACE_EVENT_INSTANT0("inc2,inc", "name", TRACE_EVENT_SCOPE_THREAD); |
1200 TRACE_EVENT_INSTANT0("inc,inc2", "name", TRACE_EVENT_SCOPE_THREAD); | 1214 TRACE_EVENT_INSTANT0("inc,inc2", "name", TRACE_EVENT_SCOPE_THREAD); |
1201 EndTraceAndFlush(); | 1215 EndTraceAndFlush(); |
1202 EXPECT_TRUE(FindMatchingValue("cat", "inc2")); | 1216 EXPECT_TRUE(FindMatchingValue("cat", "inc2")); |
1203 EXPECT_FALSE(FindMatchingValue("cat", "inc")); | 1217 EXPECT_FALSE(FindMatchingValue("cat", "inc")); |
1204 EXPECT_FALSE(FindMatchingValue("cat", "inc2,inc")); | 1218 EXPECT_FALSE(FindMatchingValue("cat", "inc2,inc")); |
1205 EXPECT_FALSE(FindMatchingValue("cat", "inc,inc2")); | 1219 EXPECT_FALSE(FindMatchingValue("cat", "inc,inc2")); |
1206 | 1220 |
1207 // Exclude existent wildcard -> all categories not matching wildcard | 1221 // Exclude existent wildcard -> all categories not matching wildcard |
1208 Clear(); | 1222 Clear(); |
1209 TraceLog::GetInstance()->SetEnabled( | 1223 TraceLog::GetInstance()->SetEnabled( |
1210 CategoryFilter("-inc_wildcard_*,-inc_wildchar_?_end"), | 1224 CategoryFilter("-inc_wildcard_*,-inc_wildchar_?_end"), |
1211 base::debug::TraceLog::RECORDING_MODE, | 1225 TraceLog::RECORDING_MODE, |
1212 TraceLog::RECORD_UNTIL_FULL); | 1226 TraceOptions()); |
1213 TRACE_EVENT_INSTANT0("inc_wildcard_abc", "not_inc", | 1227 TRACE_EVENT_INSTANT0("inc_wildcard_abc", "not_inc", |
1214 TRACE_EVENT_SCOPE_THREAD); | 1228 TRACE_EVENT_SCOPE_THREAD); |
1215 TRACE_EVENT_INSTANT0("inc_wildcard_", "not_inc", | 1229 TRACE_EVENT_INSTANT0("inc_wildcard_", "not_inc", |
1216 TRACE_EVENT_SCOPE_THREAD); | 1230 TRACE_EVENT_SCOPE_THREAD); |
1217 TRACE_EVENT_INSTANT0("inc_wildchar_x_end", "not_inc", | 1231 TRACE_EVENT_INSTANT0("inc_wildchar_x_end", "not_inc", |
1218 TRACE_EVENT_SCOPE_THREAD); | 1232 TRACE_EVENT_SCOPE_THREAD); |
1219 TRACE_EVENT_INSTANT0("inc_wildchar_bla_end", "included", | 1233 TRACE_EVENT_INSTANT0("inc_wildchar_bla_end", "included", |
1220 TRACE_EVENT_SCOPE_THREAD); | 1234 TRACE_EVENT_SCOPE_THREAD); |
1221 TRACE_EVENT_INSTANT0("cat1", "included", TRACE_EVENT_SCOPE_THREAD); | 1235 TRACE_EVENT_INSTANT0("cat1", "included", TRACE_EVENT_SCOPE_THREAD); |
1222 TRACE_EVENT_INSTANT0("cat2", "included", TRACE_EVENT_SCOPE_THREAD); | 1236 TRACE_EVENT_INSTANT0("cat2", "included", TRACE_EVENT_SCOPE_THREAD); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 TraceLog* tracer = TraceLog::GetInstance(); | 1368 TraceLog* tracer = TraceLog::GetInstance(); |
1355 // Make sure old events are flushed: | 1369 // Make sure old events are flushed: |
1356 EndTraceAndFlush(); | 1370 EndTraceAndFlush(); |
1357 EXPECT_EQ(0u, tracer->GetEventsSize()); | 1371 EXPECT_EQ(0u, tracer->GetEventsSize()); |
1358 const unsigned char* category_group_enabled = | 1372 const unsigned char* category_group_enabled = |
1359 TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED("cat"); | 1373 TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED("cat"); |
1360 | 1374 |
1361 { | 1375 { |
1362 BeginTrace(); | 1376 BeginTrace(); |
1363 // Test that string arguments are copied. | 1377 // Test that string arguments are copied. |
1364 base::debug::TraceEventHandle handle1 = | 1378 TraceEventHandle handle1 = |
1365 trace_event_internal::AddTraceEvent( | 1379 trace_event_internal::AddTraceEvent( |
1366 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name1", 0, 0, | 1380 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name1", 0, 0, |
1367 "arg1", std::string("argval"), "arg2", std::string("argval")); | 1381 "arg1", std::string("argval"), "arg2", std::string("argval")); |
1368 // Test that static TRACE_STR_COPY string arguments are copied. | 1382 // Test that static TRACE_STR_COPY string arguments are copied. |
1369 base::debug::TraceEventHandle handle2 = | 1383 TraceEventHandle handle2 = |
1370 trace_event_internal::AddTraceEvent( | 1384 trace_event_internal::AddTraceEvent( |
1371 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name2", 0, 0, | 1385 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name2", 0, 0, |
1372 "arg1", TRACE_STR_COPY("argval"), | 1386 "arg1", TRACE_STR_COPY("argval"), |
1373 "arg2", TRACE_STR_COPY("argval")); | 1387 "arg2", TRACE_STR_COPY("argval")); |
1374 size_t num_events = tracer->GetEventsSize(); | 1388 size_t num_events = tracer->GetEventsSize(); |
1375 EXPECT_GT(num_events, 1u); | 1389 EXPECT_GT(num_events, 1u); |
1376 const TraceEvent* event1 = tracer->GetEventByHandle(handle1); | 1390 const TraceEvent* event1 = tracer->GetEventByHandle(handle1); |
1377 const TraceEvent* event2 = tracer->GetEventByHandle(handle2); | 1391 const TraceEvent* event2 = tracer->GetEventByHandle(handle2); |
1378 ASSERT_TRUE(event1); | 1392 ASSERT_TRUE(event1); |
1379 ASSERT_TRUE(event2); | 1393 ASSERT_TRUE(event2); |
1380 EXPECT_STREQ("name1", event1->name()); | 1394 EXPECT_STREQ("name1", event1->name()); |
1381 EXPECT_STREQ("name2", event2->name()); | 1395 EXPECT_STREQ("name2", event2->name()); |
1382 EXPECT_TRUE(event1->parameter_copy_storage() != NULL); | 1396 EXPECT_TRUE(event1->parameter_copy_storage() != NULL); |
1383 EXPECT_TRUE(event2->parameter_copy_storage() != NULL); | 1397 EXPECT_TRUE(event2->parameter_copy_storage() != NULL); |
1384 EXPECT_GT(event1->parameter_copy_storage()->size(), 0u); | 1398 EXPECT_GT(event1->parameter_copy_storage()->size(), 0u); |
1385 EXPECT_GT(event2->parameter_copy_storage()->size(), 0u); | 1399 EXPECT_GT(event2->parameter_copy_storage()->size(), 0u); |
1386 EndTraceAndFlush(); | 1400 EndTraceAndFlush(); |
1387 } | 1401 } |
1388 | 1402 |
1389 { | 1403 { |
1390 BeginTrace(); | 1404 BeginTrace(); |
1391 // Test that static literal string arguments are not copied. | 1405 // Test that static literal string arguments are not copied. |
1392 base::debug::TraceEventHandle handle1 = | 1406 TraceEventHandle handle1 = |
1393 trace_event_internal::AddTraceEvent( | 1407 trace_event_internal::AddTraceEvent( |
1394 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name1", 0, 0, | 1408 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name1", 0, 0, |
1395 "arg1", "argval", "arg2", "argval"); | 1409 "arg1", "argval", "arg2", "argval"); |
1396 // Test that static TRACE_STR_COPY NULL string arguments are not copied. | 1410 // Test that static TRACE_STR_COPY NULL string arguments are not copied. |
1397 const char* str1 = NULL; | 1411 const char* str1 = NULL; |
1398 const char* str2 = NULL; | 1412 const char* str2 = NULL; |
1399 base::debug::TraceEventHandle handle2 = | 1413 TraceEventHandle handle2 = |
1400 trace_event_internal::AddTraceEvent( | 1414 trace_event_internal::AddTraceEvent( |
1401 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name2", 0, 0, | 1415 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name2", 0, 0, |
1402 "arg1", TRACE_STR_COPY(str1), | 1416 "arg1", TRACE_STR_COPY(str1), |
1403 "arg2", TRACE_STR_COPY(str2)); | 1417 "arg2", TRACE_STR_COPY(str2)); |
1404 size_t num_events = tracer->GetEventsSize(); | 1418 size_t num_events = tracer->GetEventsSize(); |
1405 EXPECT_GT(num_events, 1u); | 1419 EXPECT_GT(num_events, 1u); |
1406 const TraceEvent* event1 = tracer->GetEventByHandle(handle1); | 1420 const TraceEvent* event1 = tracer->GetEventByHandle(handle1); |
1407 const TraceEvent* event2 = tracer->GetEventByHandle(handle2); | 1421 const TraceEvent* event2 = tracer->GetEventByHandle(handle2); |
1408 ASSERT_TRUE(event1); | 1422 ASSERT_TRUE(event1); |
1409 ASSERT_TRUE(event2); | 1423 ASSERT_TRUE(event2); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 TRACE_EVENT_INSTANT1("category", "test", TRACE_EVENT_SCOPE_THREAD, "a", a++); | 1724 TRACE_EVENT_INSTANT1("category", "test", TRACE_EVENT_SCOPE_THREAD, "a", a++); |
1711 EXPECT_EQ(1, a); | 1725 EXPECT_EQ(1, a); |
1712 | 1726 |
1713 EndTraceAndFlush(); | 1727 EndTraceAndFlush(); |
1714 } | 1728 } |
1715 | 1729 |
1716 TEST_F(TraceEventTestFixture, TraceEnableDisable) { | 1730 TEST_F(TraceEventTestFixture, TraceEnableDisable) { |
1717 TraceLog* trace_log = TraceLog::GetInstance(); | 1731 TraceLog* trace_log = TraceLog::GetInstance(); |
1718 CategoryFilter cf_inc_all("*"); | 1732 CategoryFilter cf_inc_all("*"); |
1719 trace_log->SetEnabled(cf_inc_all, | 1733 trace_log->SetEnabled(cf_inc_all, |
1720 base::debug::TraceLog::RECORDING_MODE, | 1734 TraceLog::RECORDING_MODE, |
1721 TraceLog::RECORD_UNTIL_FULL); | 1735 TraceOptions()); |
1722 EXPECT_TRUE(trace_log->IsEnabled()); | 1736 EXPECT_TRUE(trace_log->IsEnabled()); |
1723 trace_log->SetDisabled(); | 1737 trace_log->SetDisabled(); |
1724 EXPECT_FALSE(trace_log->IsEnabled()); | 1738 EXPECT_FALSE(trace_log->IsEnabled()); |
1725 | 1739 |
1726 trace_log->SetEnabled(cf_inc_all, | 1740 trace_log->SetEnabled(cf_inc_all, |
1727 base::debug::TraceLog::RECORDING_MODE, | 1741 TraceLog::RECORDING_MODE, |
1728 TraceLog::RECORD_UNTIL_FULL); | 1742 TraceOptions()); |
1729 EXPECT_TRUE(trace_log->IsEnabled()); | 1743 EXPECT_TRUE(trace_log->IsEnabled()); |
1730 const std::vector<std::string> empty; | 1744 const std::vector<std::string> empty; |
1731 trace_log->SetEnabled(CategoryFilter(""), | 1745 trace_log->SetEnabled(CategoryFilter(), |
1732 base::debug::TraceLog::RECORDING_MODE, | 1746 TraceLog::RECORDING_MODE, |
1733 TraceLog::RECORD_UNTIL_FULL); | 1747 TraceOptions()); |
1734 EXPECT_TRUE(trace_log->IsEnabled()); | 1748 EXPECT_TRUE(trace_log->IsEnabled()); |
1735 trace_log->SetDisabled(); | 1749 trace_log->SetDisabled(); |
1736 EXPECT_FALSE(trace_log->IsEnabled()); | 1750 EXPECT_FALSE(trace_log->IsEnabled()); |
1737 trace_log->SetDisabled(); | 1751 trace_log->SetDisabled(); |
1738 EXPECT_FALSE(trace_log->IsEnabled()); | 1752 EXPECT_FALSE(trace_log->IsEnabled()); |
1739 } | 1753 } |
1740 | 1754 |
1741 TEST_F(TraceEventTestFixture, TraceCategoriesAfterNestedEnable) { | 1755 TEST_F(TraceEventTestFixture, TraceCategoriesAfterNestedEnable) { |
1742 TraceLog* trace_log = TraceLog::GetInstance(); | 1756 TraceLog* trace_log = TraceLog::GetInstance(); |
1743 trace_log->SetEnabled(CategoryFilter("foo,bar"), | 1757 trace_log->SetEnabled(CategoryFilter("foo,bar"), |
1744 base::debug::TraceLog::RECORDING_MODE, | 1758 TraceLog::RECORDING_MODE, |
1745 TraceLog::RECORD_UNTIL_FULL); | 1759 TraceOptions()); |
1746 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo")); | 1760 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo")); |
1747 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("bar")); | 1761 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("bar")); |
1748 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("baz")); | 1762 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("baz")); |
1749 trace_log->SetEnabled(CategoryFilter("foo2"), | 1763 trace_log->SetEnabled(CategoryFilter("foo2"), |
1750 base::debug::TraceLog::RECORDING_MODE, | 1764 TraceLog::RECORDING_MODE, |
1751 TraceLog::RECORD_UNTIL_FULL); | 1765 TraceOptions()); |
1752 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo2")); | 1766 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo2")); |
1753 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("baz")); | 1767 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("baz")); |
1754 // The "" becomes the default catergory set when applied. | 1768 // The "" becomes the default catergory set when applied. |
1755 trace_log->SetEnabled(CategoryFilter(""), | 1769 trace_log->SetEnabled(CategoryFilter(), |
1756 base::debug::TraceLog::RECORDING_MODE, | 1770 TraceLog::RECORDING_MODE, |
1757 TraceLog::RECORD_UNTIL_FULL); | 1771 TraceOptions()); |
1758 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo")); | 1772 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("foo")); |
1759 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz")); | 1773 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz")); |
1760 EXPECT_STREQ("-*Debug,-*Test", | 1774 EXPECT_STREQ("-*Debug,-*Test", |
1761 trace_log->GetCurrentCategoryFilter().ToString().c_str()); | 1775 trace_log->GetCurrentCategoryFilter().ToString().c_str()); |
1762 trace_log->SetDisabled(); | 1776 trace_log->SetDisabled(); |
1763 trace_log->SetDisabled(); | 1777 trace_log->SetDisabled(); |
1764 trace_log->SetDisabled(); | 1778 trace_log->SetDisabled(); |
1765 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("foo")); | 1779 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("foo")); |
1766 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("baz")); | 1780 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("baz")); |
1767 | 1781 |
1768 trace_log->SetEnabled(CategoryFilter("-foo,-bar"), | 1782 trace_log->SetEnabled(CategoryFilter("-foo,-bar"), |
1769 base::debug::TraceLog::RECORDING_MODE, | 1783 TraceLog::RECORDING_MODE, |
1770 TraceLog::RECORD_UNTIL_FULL); | 1784 TraceOptions()); |
1771 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("foo")); | 1785 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("foo")); |
1772 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz")); | 1786 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz")); |
1773 trace_log->SetEnabled(CategoryFilter("moo"), | 1787 trace_log->SetEnabled(CategoryFilter("moo"), |
1774 base::debug::TraceLog::RECORDING_MODE, | 1788 TraceLog::RECORDING_MODE, |
1775 TraceLog::RECORD_UNTIL_FULL); | 1789 TraceOptions()); |
1776 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz")); | 1790 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("baz")); |
1777 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("moo")); | 1791 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("moo")); |
1778 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("foo")); | 1792 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("foo")); |
1779 EXPECT_STREQ("-foo,-bar", | 1793 EXPECT_STREQ("-foo,-bar", |
1780 trace_log->GetCurrentCategoryFilter().ToString().c_str()); | 1794 trace_log->GetCurrentCategoryFilter().ToString().c_str()); |
1781 trace_log->SetDisabled(); | 1795 trace_log->SetDisabled(); |
1782 trace_log->SetDisabled(); | 1796 trace_log->SetDisabled(); |
1783 | 1797 |
1784 // Make sure disabled categories aren't cleared if we set in the second. | 1798 // Make sure disabled categories aren't cleared if we set in the second. |
1785 trace_log->SetEnabled(CategoryFilter("disabled-by-default-cc,foo"), | 1799 trace_log->SetEnabled(CategoryFilter("disabled-by-default-cc,foo"), |
1786 base::debug::TraceLog::RECORDING_MODE, | 1800 TraceLog::RECORDING_MODE, |
1787 TraceLog::RECORD_UNTIL_FULL); | 1801 TraceOptions()); |
1788 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("bar")); | 1802 EXPECT_FALSE(*trace_log->GetCategoryGroupEnabled("bar")); |
1789 trace_log->SetEnabled(CategoryFilter("disabled-by-default-gpu"), | 1803 trace_log->SetEnabled(CategoryFilter("disabled-by-default-gpu"), |
1790 base::debug::TraceLog::RECORDING_MODE, | 1804 TraceLog::RECORDING_MODE, |
1791 TraceLog::RECORD_UNTIL_FULL); | 1805 TraceOptions()); |
1792 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-cc")); | 1806 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-cc")); |
1793 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-gpu")); | 1807 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-gpu")); |
1794 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("bar")); | 1808 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("bar")); |
1795 EXPECT_STREQ("disabled-by-default-cc,disabled-by-default-gpu", | 1809 EXPECT_STREQ("disabled-by-default-cc,disabled-by-default-gpu", |
1796 trace_log->GetCurrentCategoryFilter().ToString().c_str()); | 1810 trace_log->GetCurrentCategoryFilter().ToString().c_str()); |
1797 trace_log->SetDisabled(); | 1811 trace_log->SetDisabled(); |
1798 trace_log->SetDisabled(); | 1812 trace_log->SetDisabled(); |
1799 } | 1813 } |
1800 | 1814 |
1801 TEST_F(TraceEventTestFixture, TraceSampling) { | 1815 TEST_F(TraceEventTestFixture, TraceSampling) { |
1802 TraceLog::GetInstance()->SetEnabled( | 1816 TraceOptions trace_options(RECORD_UNTIL_FULL); |
1803 CategoryFilter("*"), | 1817 trace_options.enable_sampling = true; |
1804 base::debug::TraceLog::RECORDING_MODE, | 1818 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), |
1805 TraceLog::Options(TraceLog::RECORD_UNTIL_FULL | | 1819 TraceLog::RECORDING_MODE, |
1806 TraceLog::ENABLE_SAMPLING)); | 1820 trace_options); |
1807 | 1821 |
1808 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "cc", "Stuff"); | 1822 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "cc", "Stuff"); |
1809 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1823 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
1810 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "cc", "Things"); | 1824 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "cc", "Things"); |
1811 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1825 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
1812 | 1826 |
1813 EndTraceAndFlush(); | 1827 EndTraceAndFlush(); |
1814 | 1828 |
1815 // Make sure we hit at least once. | 1829 // Make sure we hit at least once. |
1816 EXPECT_TRUE(FindNamePhase("Stuff", "P")); | 1830 EXPECT_TRUE(FindNamePhase("Stuff", "P")); |
1817 EXPECT_TRUE(FindNamePhase("Things", "P")); | 1831 EXPECT_TRUE(FindNamePhase("Things", "P")); |
1818 } | 1832 } |
1819 | 1833 |
1820 TEST_F(TraceEventTestFixture, TraceSamplingScope) { | 1834 TEST_F(TraceEventTestFixture, TraceSamplingScope) { |
1821 TraceLog::GetInstance()->SetEnabled( | 1835 TraceOptions trace_options(RECORD_UNTIL_FULL); |
1822 CategoryFilter("*"), | 1836 trace_options.enable_sampling = true; |
1823 base::debug::TraceLog::RECORDING_MODE, | 1837 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), |
1824 TraceLog::Options(TraceLog::RECORD_UNTIL_FULL | | 1838 TraceLog::RECORDING_MODE, |
1825 TraceLog::ENABLE_SAMPLING)); | 1839 trace_options); |
1826 | 1840 |
1827 TRACE_EVENT_SCOPED_SAMPLING_STATE("AAA", "name"); | 1841 TRACE_EVENT_SCOPED_SAMPLING_STATE("AAA", "name"); |
1828 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1842 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
1829 { | 1843 { |
1830 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "AAA"); | 1844 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "AAA"); |
1831 TRACE_EVENT_SCOPED_SAMPLING_STATE("BBB", "name"); | 1845 TRACE_EVENT_SCOPED_SAMPLING_STATE("BBB", "name"); |
1832 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1846 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
1833 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "BBB"); | 1847 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "BBB"); |
1834 } | 1848 } |
1835 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1849 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
(...skipping 10 matching lines...) Expand all Loading... |
1846 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1860 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
1847 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD"); | 1861 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD"); |
1848 } | 1862 } |
1849 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1863 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
1850 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD"); | 1864 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD"); |
1851 | 1865 |
1852 EndTraceAndFlush(); | 1866 EndTraceAndFlush(); |
1853 } | 1867 } |
1854 | 1868 |
1855 TEST_F(TraceEventTestFixture, TraceContinuousSampling) { | 1869 TEST_F(TraceEventTestFixture, TraceContinuousSampling) { |
1856 TraceLog::GetInstance()->SetEnabled( | 1870 TraceOptions trace_options(RECORD_UNTIL_FULL); |
1857 CategoryFilter("*"), | 1871 trace_options.enable_sampling = true; |
1858 base::debug::TraceLog::MONITORING_MODE, | 1872 |
1859 TraceLog::Options(TraceLog::ENABLE_SAMPLING)); | 1873 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), |
| 1874 TraceLog::MONITORING_MODE, |
| 1875 trace_options); |
1860 | 1876 |
1861 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "AAA"); | 1877 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "AAA"); |
1862 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1878 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
1863 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "BBB"); | 1879 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "BBB"); |
1864 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1880 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
1865 | 1881 |
1866 FlushMonitoring(); | 1882 FlushMonitoring(); |
1867 | 1883 |
1868 // Make sure we can get the profiled data. | 1884 // Make sure we can get the profiled data. |
1869 EXPECT_TRUE(FindNamePhase("AAA", "P")); | 1885 EXPECT_TRUE(FindNamePhase("AAA", "P")); |
(...skipping 22 matching lines...) Expand all Loading... |
1892 // Make sure disabling the continuous sampling thread clears | 1908 // Make sure disabling the continuous sampling thread clears |
1893 // the profiled data. | 1909 // the profiled data. |
1894 EXPECT_FALSE(FindNamePhase("AAA", "P")); | 1910 EXPECT_FALSE(FindNamePhase("AAA", "P")); |
1895 EXPECT_FALSE(FindNamePhase("BBB", "P")); | 1911 EXPECT_FALSE(FindNamePhase("BBB", "P")); |
1896 EXPECT_FALSE(FindNamePhase("CCC", "P")); | 1912 EXPECT_FALSE(FindNamePhase("CCC", "P")); |
1897 EXPECT_FALSE(FindNamePhase("DDD", "P")); | 1913 EXPECT_FALSE(FindNamePhase("DDD", "P")); |
1898 | 1914 |
1899 Clear(); | 1915 Clear(); |
1900 } | 1916 } |
1901 | 1917 |
1902 class MyData : public base::debug::ConvertableToTraceFormat { | 1918 class MyData : public ConvertableToTraceFormat { |
1903 public: | 1919 public: |
1904 MyData() {} | 1920 MyData() {} |
1905 | 1921 |
1906 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { | 1922 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { |
1907 out->append("{\"foo\":1}"); | 1923 out->append("{\"foo\":1}"); |
1908 } | 1924 } |
1909 | 1925 |
1910 private: | 1926 private: |
1911 virtual ~MyData() {} | 1927 virtual ~MyData() {} |
1912 DISALLOW_COPY_AND_ASSIGN(MyData); | 1928 DISALLOW_COPY_AND_ASSIGN(MyData); |
1913 }; | 1929 }; |
1914 | 1930 |
1915 TEST_F(TraceEventTestFixture, ConvertableTypes) { | 1931 TEST_F(TraceEventTestFixture, ConvertableTypes) { |
1916 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 1932 TraceLog::GetInstance()->SetEnabled( |
1917 base::debug::TraceLog::RECORDING_MODE, | 1933 CategoryFilter("*"), |
1918 TraceLog::RECORD_UNTIL_FULL); | 1934 TraceLog::RECORDING_MODE, |
| 1935 TraceOptions()); |
1919 | 1936 |
1920 scoped_refptr<ConvertableToTraceFormat> data(new MyData()); | 1937 scoped_refptr<ConvertableToTraceFormat> data(new MyData()); |
1921 scoped_refptr<ConvertableToTraceFormat> data1(new MyData()); | 1938 scoped_refptr<ConvertableToTraceFormat> data1(new MyData()); |
1922 scoped_refptr<ConvertableToTraceFormat> data2(new MyData()); | 1939 scoped_refptr<ConvertableToTraceFormat> data2(new MyData()); |
1923 TRACE_EVENT1("foo", "bar", "data", data); | 1940 TRACE_EVENT1("foo", "bar", "data", data); |
1924 TRACE_EVENT2("foo", "baz", | 1941 TRACE_EVENT2("foo", "baz", |
1925 "data1", data1, | 1942 "data1", data1, |
1926 "data2", data2); | 1943 "data2", data2); |
1927 | 1944 |
1928 | 1945 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2012 value = NULL; | 2029 value = NULL; |
2013 convertable_dict = NULL; | 2030 convertable_dict = NULL; |
2014 foo_val = 0; | 2031 foo_val = 0; |
2015 EXPECT_TRUE(args_dict->Get("convert", &value)); | 2032 EXPECT_TRUE(args_dict->Get("convert", &value)); |
2016 ASSERT_TRUE(value->GetAsDictionary(&convertable_dict)); | 2033 ASSERT_TRUE(value->GetAsDictionary(&convertable_dict)); |
2017 EXPECT_TRUE(convertable_dict->GetInteger("foo", &foo_val)); | 2034 EXPECT_TRUE(convertable_dict->GetInteger("foo", &foo_val)); |
2018 EXPECT_EQ(1, foo_val); | 2035 EXPECT_EQ(1, foo_val); |
2019 } | 2036 } |
2020 | 2037 |
2021 TEST_F(TraceEventTestFixture, PrimitiveArgs) { | 2038 TEST_F(TraceEventTestFixture, PrimitiveArgs) { |
2022 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 2039 TraceLog::GetInstance()->SetEnabled( |
2023 base::debug::TraceLog::RECORDING_MODE, | 2040 CategoryFilter("*"), |
2024 TraceLog::RECORD_UNTIL_FULL); | 2041 TraceLog::RECORDING_MODE, |
| 2042 TraceOptions()); |
2025 | 2043 |
2026 TRACE_EVENT1("foo", "event1", "int_one", 1); | 2044 TRACE_EVENT1("foo", "event1", "int_one", 1); |
2027 TRACE_EVENT1("foo", "event2", "int_neg_ten", -10); | 2045 TRACE_EVENT1("foo", "event2", "int_neg_ten", -10); |
2028 TRACE_EVENT1("foo", "event3", "float_one", 1.0f); | 2046 TRACE_EVENT1("foo", "event3", "float_one", 1.0f); |
2029 TRACE_EVENT1("foo", "event4", "float_half", .5f); | 2047 TRACE_EVENT1("foo", "event4", "float_half", .5f); |
2030 TRACE_EVENT1("foo", "event5", "float_neghalf", -.5f); | 2048 TRACE_EVENT1("foo", "event5", "float_neghalf", -.5f); |
2031 TRACE_EVENT1("foo", "event6", "float_infinity", | 2049 TRACE_EVENT1("foo", "event6", "float_infinity", |
2032 std::numeric_limits<float>::infinity()); | 2050 std::numeric_limits<float>::infinity()); |
2033 TRACE_EVENT1("foo", "event6b", "float_neg_infinity", | 2051 TRACE_EVENT1("foo", "event6b", "float_neg_infinity", |
2034 -std::numeric_limits<float>::infinity()); | 2052 -std::numeric_limits<float>::infinity()); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2275 EXPECT_EQ(TRACE_EVENT_PHASE_INSTANT, collected_events_phases_[3]); | 2293 EXPECT_EQ(TRACE_EVENT_PHASE_INSTANT, collected_events_phases_[3]); |
2276 EXPECT_EQ("duration", collected_events_names_[4]); | 2294 EXPECT_EQ("duration", collected_events_names_[4]); |
2277 EXPECT_EQ(TRACE_EVENT_PHASE_END, collected_events_phases_[4]); | 2295 EXPECT_EQ(TRACE_EVENT_PHASE_END, collected_events_phases_[4]); |
2278 for (size_t i = 1; i < collected_events_timestamps_.size(); i++) { | 2296 for (size_t i = 1; i < collected_events_timestamps_.size(); i++) { |
2279 EXPECT_LE(collected_events_timestamps_[i - 1], | 2297 EXPECT_LE(collected_events_timestamps_[i - 1], |
2280 collected_events_timestamps_[i]); | 2298 collected_events_timestamps_[i]); |
2281 } | 2299 } |
2282 } | 2300 } |
2283 | 2301 |
2284 TEST_F(TraceEventCallbackTest, TraceEventCallbackWhileFull) { | 2302 TEST_F(TraceEventCallbackTest, TraceEventCallbackWhileFull) { |
2285 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 2303 TraceLog::GetInstance()->SetEnabled( |
2286 base::debug::TraceLog::RECORDING_MODE, | 2304 CategoryFilter("*"), |
2287 TraceLog::RECORD_UNTIL_FULL); | 2305 TraceLog::RECORDING_MODE, |
| 2306 TraceOptions()); |
2288 do { | 2307 do { |
2289 TRACE_EVENT_INSTANT0("all", "badger badger", TRACE_EVENT_SCOPE_GLOBAL); | 2308 TRACE_EVENT_INSTANT0("all", "badger badger", TRACE_EVENT_SCOPE_GLOBAL); |
2290 } while (!TraceLog::GetInstance()->BufferIsFull()); | 2309 } while (!TraceLog::GetInstance()->BufferIsFull()); |
2291 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("*"), | 2310 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("*"), |
2292 Callback); | 2311 Callback); |
2293 TRACE_EVENT_INSTANT0("all", "a snake", TRACE_EVENT_SCOPE_GLOBAL); | 2312 TRACE_EVENT_INSTANT0("all", "a snake", TRACE_EVENT_SCOPE_GLOBAL); |
2294 TraceLog::GetInstance()->SetEventCallbackDisabled(); | 2313 TraceLog::GetInstance()->SetEventCallbackDisabled(); |
2295 ASSERT_EQ(1u, collected_events_names_.size()); | 2314 ASSERT_EQ(1u, collected_events_names_.size()); |
2296 EXPECT_EQ("a snake", collected_events_names_[0]); | 2315 EXPECT_EQ("a snake", collected_events_names_[0]); |
2297 } | 2316 } |
2298 | 2317 |
2299 // 1: Enable callback, enable recording, disable callback, disable recording. | 2318 // 1: Enable callback, enable recording, disable callback, disable recording. |
2300 TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording1) { | 2319 TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording1) { |
2301 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2320 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2302 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2321 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2303 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("callback"), | 2322 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("callback"), |
2304 Callback); | 2323 Callback); |
2305 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2324 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2306 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2325 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2307 TraceLog::GetInstance()->SetEnabled(CategoryFilter("recording"), | 2326 TraceLog::GetInstance()->SetEnabled( |
2308 base::debug::TraceLog::RECORDING_MODE, | 2327 CategoryFilter("recording"), |
2309 TraceLog::RECORD_UNTIL_FULL); | 2328 TraceLog::RECORDING_MODE, |
| 2329 TraceOptions()); |
2310 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2330 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2311 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2331 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2312 TraceLog::GetInstance()->SetEventCallbackDisabled(); | 2332 TraceLog::GetInstance()->SetEventCallbackDisabled(); |
2313 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2333 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2314 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2334 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2315 EndTraceAndFlush(); | 2335 EndTraceAndFlush(); |
2316 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2336 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2317 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2337 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2318 | 2338 |
2319 DropTracedMetadataRecords(); | 2339 DropTracedMetadataRecords(); |
2320 VerifyCallbackAndRecordedEvents(2, 2); | 2340 VerifyCallbackAndRecordedEvents(2, 2); |
2321 } | 2341 } |
2322 | 2342 |
2323 // 2: Enable callback, enable recording, disable recording, disable callback. | 2343 // 2: Enable callback, enable recording, disable recording, disable callback. |
2324 TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording2) { | 2344 TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording2) { |
2325 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2345 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2326 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2346 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2327 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("callback"), | 2347 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("callback"), |
2328 Callback); | 2348 Callback); |
2329 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2349 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2330 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2350 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2331 TraceLog::GetInstance()->SetEnabled(CategoryFilter("recording"), | 2351 TraceLog::GetInstance()->SetEnabled( |
2332 base::debug::TraceLog::RECORDING_MODE, | 2352 CategoryFilter("recording"), |
2333 TraceLog::RECORD_UNTIL_FULL); | 2353 TraceLog::RECORDING_MODE, |
| 2354 TraceOptions()); |
2334 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2355 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2335 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2356 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2336 EndTraceAndFlush(); | 2357 EndTraceAndFlush(); |
2337 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2358 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2338 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2359 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2339 TraceLog::GetInstance()->SetEventCallbackDisabled(); | 2360 TraceLog::GetInstance()->SetEventCallbackDisabled(); |
2340 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2361 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2341 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2362 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2342 | 2363 |
2343 DropTracedMetadataRecords(); | 2364 DropTracedMetadataRecords(); |
2344 VerifyCallbackAndRecordedEvents(3, 1); | 2365 VerifyCallbackAndRecordedEvents(3, 1); |
2345 } | 2366 } |
2346 | 2367 |
2347 // 3: Enable recording, enable callback, disable callback, disable recording. | 2368 // 3: Enable recording, enable callback, disable callback, disable recording. |
2348 TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording3) { | 2369 TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording3) { |
2349 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2370 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2350 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2371 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2351 TraceLog::GetInstance()->SetEnabled(CategoryFilter("recording"), | 2372 TraceLog::GetInstance()->SetEnabled( |
2352 base::debug::TraceLog::RECORDING_MODE, | 2373 CategoryFilter("recording"), |
2353 TraceLog::RECORD_UNTIL_FULL); | 2374 TraceLog::RECORDING_MODE, |
| 2375 TraceOptions()); |
2354 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2376 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2355 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2377 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2356 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("callback"), | 2378 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("callback"), |
2357 Callback); | 2379 Callback); |
2358 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2380 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2359 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2381 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2360 TraceLog::GetInstance()->SetEventCallbackDisabled(); | 2382 TraceLog::GetInstance()->SetEventCallbackDisabled(); |
2361 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2383 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2362 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2384 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2363 EndTraceAndFlush(); | 2385 EndTraceAndFlush(); |
2364 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2386 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2365 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2387 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2366 | 2388 |
2367 DropTracedMetadataRecords(); | 2389 DropTracedMetadataRecords(); |
2368 VerifyCallbackAndRecordedEvents(1, 3); | 2390 VerifyCallbackAndRecordedEvents(1, 3); |
2369 } | 2391 } |
2370 | 2392 |
2371 // 4: Enable recording, enable callback, disable recording, disable callback. | 2393 // 4: Enable recording, enable callback, disable recording, disable callback. |
2372 TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording4) { | 2394 TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording4) { |
2373 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2395 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2374 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2396 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2375 TraceLog::GetInstance()->SetEnabled(CategoryFilter("recording"), | 2397 TraceLog::GetInstance()->SetEnabled( |
2376 base::debug::TraceLog::RECORDING_MODE, | 2398 CategoryFilter("recording"), |
2377 TraceLog::RECORD_UNTIL_FULL); | 2399 TraceLog::RECORDING_MODE, |
| 2400 TraceOptions()); |
2378 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2401 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2379 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2402 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2380 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("callback"), | 2403 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("callback"), |
2381 Callback); | 2404 Callback); |
2382 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2405 TRACE_EVENT_INSTANT0("recording", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2383 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2406 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2384 EndTraceAndFlush(); | 2407 EndTraceAndFlush(); |
2385 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2408 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2386 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); | 2409 TRACE_EVENT_INSTANT0("callback", "yes", TRACE_EVENT_SCOPE_GLOBAL); |
2387 TraceLog::GetInstance()->SetEventCallbackDisabled(); | 2410 TraceLog::GetInstance()->SetEventCallbackDisabled(); |
2388 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2411 TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2389 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); | 2412 TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL); |
2390 | 2413 |
2391 DropTracedMetadataRecords(); | 2414 DropTracedMetadataRecords(); |
2392 VerifyCallbackAndRecordedEvents(2, 2); | 2415 VerifyCallbackAndRecordedEvents(2, 2); |
2393 } | 2416 } |
2394 | 2417 |
2395 TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecordingDuration) { | 2418 TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecordingDuration) { |
2396 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("*"), | 2419 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("*"), |
2397 Callback); | 2420 Callback); |
2398 { | 2421 { |
2399 TRACE_EVENT0("callback", "duration1"); | 2422 TRACE_EVENT0("callback", "duration1"); |
2400 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 2423 TraceLog::GetInstance()->SetEnabled( |
2401 base::debug::TraceLog::RECORDING_MODE, | 2424 CategoryFilter("*"), |
2402 TraceLog::RECORD_UNTIL_FULL); | 2425 TraceLog::RECORDING_MODE, |
| 2426 TraceOptions()); |
2403 TRACE_EVENT0("callback", "duration2"); | 2427 TRACE_EVENT0("callback", "duration2"); |
2404 EndTraceAndFlush(); | 2428 EndTraceAndFlush(); |
2405 TRACE_EVENT0("callback", "duration3"); | 2429 TRACE_EVENT0("callback", "duration3"); |
2406 } | 2430 } |
2407 TraceLog::GetInstance()->SetEventCallbackDisabled(); | 2431 TraceLog::GetInstance()->SetEventCallbackDisabled(); |
2408 | 2432 |
2409 ASSERT_EQ(6u, collected_events_names_.size()); | 2433 ASSERT_EQ(6u, collected_events_names_.size()); |
2410 VerifyCollectedEvent(0, TRACE_EVENT_PHASE_BEGIN, "callback", "duration1"); | 2434 VerifyCollectedEvent(0, TRACE_EVENT_PHASE_BEGIN, "callback", "duration1"); |
2411 VerifyCollectedEvent(1, TRACE_EVENT_PHASE_BEGIN, "callback", "duration2"); | 2435 VerifyCollectedEvent(1, TRACE_EVENT_PHASE_BEGIN, "callback", "duration2"); |
2412 VerifyCollectedEvent(2, TRACE_EVENT_PHASE_BEGIN, "callback", "duration3"); | 2436 VerifyCollectedEvent(2, TRACE_EVENT_PHASE_BEGIN, "callback", "duration3"); |
2413 VerifyCollectedEvent(3, TRACE_EVENT_PHASE_END, "callback", "duration3"); | 2437 VerifyCollectedEvent(3, TRACE_EVENT_PHASE_END, "callback", "duration3"); |
2414 VerifyCollectedEvent(4, TRACE_EVENT_PHASE_END, "callback", "duration2"); | 2438 VerifyCollectedEvent(4, TRACE_EVENT_PHASE_END, "callback", "duration2"); |
2415 VerifyCollectedEvent(5, TRACE_EVENT_PHASE_END, "callback", "duration1"); | 2439 VerifyCollectedEvent(5, TRACE_EVENT_PHASE_END, "callback", "duration1"); |
2416 } | 2440 } |
2417 | 2441 |
2418 #if defined(OS_WIN) | 2442 #if defined(OS_WIN) |
2419 // http://crbug.com/396403 | 2443 // http://crbug.com/396403 |
2420 #define MAYBE_TraceBufferVectorReportFull DISABLED_TraceBufferVectorReportFull | 2444 #define MAYBE_TraceBufferVectorReportFull DISABLED_TraceBufferVectorReportFull |
2421 #else | 2445 #else |
2422 #define MAYBE_TraceBufferVectorReportFull TraceBufferVectorReportFull | 2446 #define MAYBE_TraceBufferVectorReportFull TraceBufferVectorReportFull |
2423 #endif | 2447 #endif |
2424 TEST_F(TraceEventTestFixture, MAYBE_TraceBufferVectorReportFull) { | 2448 TEST_F(TraceEventTestFixture, MAYBE_TraceBufferVectorReportFull) { |
2425 TraceLog* trace_log = TraceLog::GetInstance(); | 2449 TraceLog* trace_log = TraceLog::GetInstance(); |
2426 trace_log->SetEnabled(CategoryFilter("*"), | 2450 trace_log->SetEnabled(CategoryFilter("*"), |
2427 base::debug::TraceLog::RECORDING_MODE, | 2451 TraceLog::RECORDING_MODE, |
2428 TraceLog::RECORD_UNTIL_FULL); | 2452 TraceOptions()); |
2429 trace_log->logged_events_.reset( | 2453 trace_log->logged_events_.reset( |
2430 trace_log->CreateTraceBufferVectorOfSize(100)); | 2454 trace_log->CreateTraceBufferVectorOfSize(100)); |
2431 do { | 2455 do { |
2432 TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( | 2456 TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( |
2433 "all", "with_timestamp", 0, 0, | 2457 "all", "with_timestamp", 0, 0, |
2434 TimeTicks::NowFromSystemTraceTime().ToInternalValue()); | 2458 TimeTicks::NowFromSystemTraceTime().ToInternalValue()); |
2435 TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0( | 2459 TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0( |
2436 "all", "with_timestamp", 0, 0, | 2460 "all", "with_timestamp", 0, 0, |
2437 TimeTicks::NowFromSystemTraceTime().ToInternalValue()); | 2461 TimeTicks::NowFromSystemTraceTime().ToInternalValue()); |
2438 } while (!trace_log->BufferIsFull()); | 2462 } while (!trace_log->BufferIsFull()); |
(...skipping 25 matching lines...) Expand all Loading... |
2464 EXPECT_TRUE(trace_parsed_.GetDictionary(trace_parsed_.GetSize() - 1, | 2488 EXPECT_TRUE(trace_parsed_.GetDictionary(trace_parsed_.GetSize() - 1, |
2465 &last_trace_event)); | 2489 &last_trace_event)); |
2466 EXPECT_TRUE(last_trace_event->GetDouble("ts", &last_trace_event_timestamp)); | 2490 EXPECT_TRUE(last_trace_event->GetDouble("ts", &last_trace_event_timestamp)); |
2467 EXPECT_LE(last_trace_event_timestamp, buffer_limit_reached_timestamp); | 2491 EXPECT_LE(last_trace_event_timestamp, buffer_limit_reached_timestamp); |
2468 EXPECT_LE(buffer_limit_reached_timestamp, | 2492 EXPECT_LE(buffer_limit_reached_timestamp, |
2469 trace_log->OffsetNow().ToInternalValue()); | 2493 trace_log->OffsetNow().ToInternalValue()); |
2470 } | 2494 } |
2471 | 2495 |
2472 TEST_F(TraceEventTestFixture, TraceBufferRingBufferGetReturnChunk) { | 2496 TEST_F(TraceEventTestFixture, TraceBufferRingBufferGetReturnChunk) { |
2473 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 2497 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), |
2474 base::debug::TraceLog::RECORDING_MODE, | 2498 TraceLog::RECORDING_MODE, |
2475 TraceLog::RECORD_CONTINUOUSLY); | 2499 TraceOptions(RECORD_CONTINUOUSLY)); |
2476 TraceBuffer* buffer = TraceLog::GetInstance()->trace_buffer(); | 2500 TraceBuffer* buffer = TraceLog::GetInstance()->trace_buffer(); |
2477 size_t capacity = buffer->Capacity(); | 2501 size_t capacity = buffer->Capacity(); |
2478 size_t num_chunks = capacity / TraceBufferChunk::kTraceBufferChunkSize; | 2502 size_t num_chunks = capacity / TraceBufferChunk::kTraceBufferChunkSize; |
2479 uint32 last_seq = 0; | 2503 uint32 last_seq = 0; |
2480 size_t chunk_index; | 2504 size_t chunk_index; |
2481 EXPECT_EQ(0u, buffer->Size()); | 2505 EXPECT_EQ(0u, buffer->Size()); |
2482 | 2506 |
2483 scoped_ptr<TraceBufferChunk*[]> chunks(new TraceBufferChunk*[num_chunks]); | 2507 scoped_ptr<TraceBufferChunk*[]> chunks(new TraceBufferChunk*[num_chunks]); |
2484 for (size_t i = 0; i < num_chunks; ++i) { | 2508 for (size_t i = 0; i < num_chunks; ++i) { |
2485 chunks[i] = buffer->GetChunk(&chunk_index).release(); | 2509 chunks[i] = buffer->GetChunk(&chunk_index).release(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2524 } | 2548 } |
2525 | 2549 |
2526 for (size_t i = 0; i < num_chunks; ++i) | 2550 for (size_t i = 0; i < num_chunks; ++i) |
2527 buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i])); | 2551 buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i])); |
2528 | 2552 |
2529 TraceLog::GetInstance()->SetDisabled(); | 2553 TraceLog::GetInstance()->SetDisabled(); |
2530 } | 2554 } |
2531 | 2555 |
2532 TEST_F(TraceEventTestFixture, TraceBufferRingBufferHalfIteration) { | 2556 TEST_F(TraceEventTestFixture, TraceBufferRingBufferHalfIteration) { |
2533 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 2557 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), |
2534 base::debug::TraceLog::RECORDING_MODE, | 2558 TraceLog::RECORDING_MODE, |
2535 TraceLog::RECORD_CONTINUOUSLY); | 2559 TraceOptions(RECORD_CONTINUOUSLY)); |
2536 TraceBuffer* buffer = TraceLog::GetInstance()->trace_buffer(); | 2560 TraceBuffer* buffer = TraceLog::GetInstance()->trace_buffer(); |
2537 size_t capacity = buffer->Capacity(); | 2561 size_t capacity = buffer->Capacity(); |
2538 size_t num_chunks = capacity / TraceBufferChunk::kTraceBufferChunkSize; | 2562 size_t num_chunks = capacity / TraceBufferChunk::kTraceBufferChunkSize; |
2539 size_t chunk_index; | 2563 size_t chunk_index; |
2540 EXPECT_EQ(0u, buffer->Size()); | 2564 EXPECT_EQ(0u, buffer->Size()); |
2541 EXPECT_FALSE(buffer->NextChunk()); | 2565 EXPECT_FALSE(buffer->NextChunk()); |
2542 | 2566 |
2543 size_t half_chunks = num_chunks / 2; | 2567 size_t half_chunks = num_chunks / 2; |
2544 scoped_ptr<TraceBufferChunk*[]> chunks(new TraceBufferChunk*[half_chunks]); | 2568 scoped_ptr<TraceBufferChunk*[]> chunks(new TraceBufferChunk*[half_chunks]); |
2545 | 2569 |
2546 for (size_t i = 0; i < half_chunks; ++i) { | 2570 for (size_t i = 0; i < half_chunks; ++i) { |
2547 chunks[i] = buffer->GetChunk(&chunk_index).release(); | 2571 chunks[i] = buffer->GetChunk(&chunk_index).release(); |
2548 EXPECT_TRUE(chunks[i]); | 2572 EXPECT_TRUE(chunks[i]); |
2549 EXPECT_EQ(i, chunk_index); | 2573 EXPECT_EQ(i, chunk_index); |
2550 } | 2574 } |
2551 for (size_t i = 0; i < half_chunks; ++i) | 2575 for (size_t i = 0; i < half_chunks; ++i) |
2552 buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i])); | 2576 buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i])); |
2553 | 2577 |
2554 for (size_t i = 0; i < half_chunks; ++i) | 2578 for (size_t i = 0; i < half_chunks; ++i) |
2555 EXPECT_EQ(chunks[i], buffer->NextChunk()); | 2579 EXPECT_EQ(chunks[i], buffer->NextChunk()); |
2556 EXPECT_FALSE(buffer->NextChunk()); | 2580 EXPECT_FALSE(buffer->NextChunk()); |
2557 TraceLog::GetInstance()->SetDisabled(); | 2581 TraceLog::GetInstance()->SetDisabled(); |
2558 } | 2582 } |
2559 | 2583 |
2560 TEST_F(TraceEventTestFixture, TraceBufferRingBufferFullIteration) { | 2584 TEST_F(TraceEventTestFixture, TraceBufferRingBufferFullIteration) { |
2561 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 2585 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), |
2562 base::debug::TraceLog::RECORDING_MODE, | 2586 TraceLog::RECORDING_MODE, |
2563 TraceLog::RECORD_CONTINUOUSLY); | 2587 TraceOptions(RECORD_CONTINUOUSLY)); |
2564 TraceBuffer* buffer = TraceLog::GetInstance()->trace_buffer(); | 2588 TraceBuffer* buffer = TraceLog::GetInstance()->trace_buffer(); |
2565 size_t capacity = buffer->Capacity(); | 2589 size_t capacity = buffer->Capacity(); |
2566 size_t num_chunks = capacity / TraceBufferChunk::kTraceBufferChunkSize; | 2590 size_t num_chunks = capacity / TraceBufferChunk::kTraceBufferChunkSize; |
2567 size_t chunk_index; | 2591 size_t chunk_index; |
2568 EXPECT_EQ(0u, buffer->Size()); | 2592 EXPECT_EQ(0u, buffer->Size()); |
2569 EXPECT_FALSE(buffer->NextChunk()); | 2593 EXPECT_FALSE(buffer->NextChunk()); |
2570 | 2594 |
2571 scoped_ptr<TraceBufferChunk*[]> chunks(new TraceBufferChunk*[num_chunks]); | 2595 scoped_ptr<TraceBufferChunk*[]> chunks(new TraceBufferChunk*[num_chunks]); |
2572 | 2596 |
2573 for (size_t i = 0; i < num_chunks; ++i) { | 2597 for (size_t i = 0; i < num_chunks; ++i) { |
(...skipping 18 matching lines...) Expand all Loading... |
2592 std::string category_filter_str = default_cf.ToString(); | 2616 std::string category_filter_str = default_cf.ToString(); |
2593 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); | 2617 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); |
2594 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); | 2618 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); |
2595 EXPECT_FALSE( | 2619 EXPECT_FALSE( |
2596 default_cf.IsCategoryGroupEnabled("disabled-by-default-category")); | 2620 default_cf.IsCategoryGroupEnabled("disabled-by-default-category")); |
2597 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); | 2621 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); |
2598 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); | 2622 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); |
2599 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2")); | 2623 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2")); |
2600 | 2624 |
2601 // Make sure that upon an empty string, we fall back to the default filter. | 2625 // Make sure that upon an empty string, we fall back to the default filter. |
2602 default_cf = CategoryFilter(""); | 2626 default_cf = CategoryFilter(); |
2603 category_filter_str = default_cf.ToString(); | 2627 category_filter_str = default_cf.ToString(); |
2604 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); | 2628 EXPECT_STREQ("-*Debug,-*Test", category_filter_str.c_str()); |
2605 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); | 2629 EXPECT_TRUE(default_cf.IsCategoryGroupEnabled("not-excluded-category")); |
2606 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); | 2630 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("Category1,CategoryDebug")); |
2607 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); | 2631 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryDebug,Category1")); |
2608 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2")); | 2632 EXPECT_FALSE(default_cf.IsCategoryGroupEnabled("CategoryTest,Category2")); |
2609 | 2633 |
2610 // Using an arbitrary non-empty filter. | 2634 // Using an arbitrary non-empty filter. |
2611 CategoryFilter cf("included,-excluded,inc_pattern*,-exc_pattern*"); | 2635 CategoryFilter cf("included,-excluded,inc_pattern*,-exc_pattern*"); |
2612 category_filter_str = cf.ToString(); | 2636 category_filter_str = cf.ToString(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2709 FROM_HERE, Bind(&BlockUntilStopped, &task_start_event, &task_stop_event)); | 2733 FROM_HERE, Bind(&BlockUntilStopped, &task_start_event, &task_stop_event)); |
2710 task_start_event.Wait(); | 2734 task_start_event.Wait(); |
2711 | 2735 |
2712 EndTraceAndFlush(); | 2736 EndTraceAndFlush(); |
2713 ValidateAllTraceMacrosCreatedData(trace_parsed_); | 2737 ValidateAllTraceMacrosCreatedData(trace_parsed_); |
2714 | 2738 |
2715 task_stop_event.Signal(); | 2739 task_stop_event.Signal(); |
2716 thread.Stop(); | 2740 thread.Stop(); |
2717 } | 2741 } |
2718 | 2742 |
| 2743 TEST_F(TraceEventTestFixture, ConvertTraceOptionsToInternalOptions) { |
| 2744 TraceLog* trace_log = TraceLog::GetInstance(); |
| 2745 TraceOptions options(RECORD_UNTIL_FULL); |
| 2746 EXPECT_EQ(TraceLog::kInternalRecordUntilFull, |
| 2747 trace_log->GetInternalOptionsFromTraceOptions(options)); |
| 2748 |
| 2749 options.record_mode = RECORD_CONTINUOUSLY; |
| 2750 EXPECT_EQ(TraceLog::kInternalRecordContinuously, |
| 2751 trace_log->GetInternalOptionsFromTraceOptions(options)); |
| 2752 |
| 2753 options.record_mode = ECHO_TO_CONSOLE; |
| 2754 EXPECT_EQ(TraceLog::kInternalEchoToConsole, |
| 2755 trace_log->GetInternalOptionsFromTraceOptions(options)); |
| 2756 |
| 2757 options.enable_sampling = true; |
| 2758 |
| 2759 options.record_mode = RECORD_UNTIL_FULL; |
| 2760 EXPECT_EQ( |
| 2761 TraceLog::kInternalRecordUntilFull | TraceLog::kInternalEnableSampling, |
| 2762 trace_log->GetInternalOptionsFromTraceOptions(options)); |
| 2763 |
| 2764 options.record_mode = RECORD_CONTINUOUSLY; |
| 2765 EXPECT_EQ( |
| 2766 TraceLog::kInternalRecordContinuously | TraceLog::kInternalEnableSampling, |
| 2767 trace_log->GetInternalOptionsFromTraceOptions(options)); |
| 2768 |
| 2769 options.record_mode = ECHO_TO_CONSOLE; |
| 2770 EXPECT_EQ( |
| 2771 TraceLog::kInternalEchoToConsole | TraceLog::kInternalEnableSampling, |
| 2772 trace_log->GetInternalOptionsFromTraceOptions(options)); |
| 2773 |
| 2774 options.enable_systrace = true; |
| 2775 EXPECT_EQ( |
| 2776 TraceLog::kInternalEchoToConsole | TraceLog::kInternalEnableSampling, |
| 2777 trace_log->GetInternalOptionsFromTraceOptions(options)); |
| 2778 } |
| 2779 |
2719 void SetBlockingFlagAndBlockUntilStopped(WaitableEvent* task_start_event, | 2780 void SetBlockingFlagAndBlockUntilStopped(WaitableEvent* task_start_event, |
2720 WaitableEvent* task_stop_event) { | 2781 WaitableEvent* task_stop_event) { |
2721 TraceLog::GetInstance()->SetCurrentThreadBlocksMessageLoop(); | 2782 TraceLog::GetInstance()->SetCurrentThreadBlocksMessageLoop(); |
2722 BlockUntilStopped(task_start_event, task_stop_event); | 2783 BlockUntilStopped(task_start_event, task_stop_event); |
2723 } | 2784 } |
2724 | 2785 |
2725 TEST_F(TraceEventTestFixture, SetCurrentThreadBlocksMessageLoopAfterTracing) { | 2786 TEST_F(TraceEventTestFixture, SetCurrentThreadBlocksMessageLoopAfterTracing) { |
2726 BeginTrace(); | 2787 BeginTrace(); |
2727 | 2788 |
2728 Thread thread("1"); | 2789 Thread thread("1"); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2800 g_log_buffer = new std::string(); | 2861 g_log_buffer = new std::string(); |
2801 g_log_buffer->append(str); | 2862 g_log_buffer->append(str); |
2802 return false; | 2863 return false; |
2803 } | 2864 } |
2804 | 2865 |
2805 TEST_F(TraceEventTestFixture, EchoToConsole) { | 2866 TEST_F(TraceEventTestFixture, EchoToConsole) { |
2806 logging::LogMessageHandlerFunction old_log_message_handler = | 2867 logging::LogMessageHandlerFunction old_log_message_handler = |
2807 logging::GetLogMessageHandler(); | 2868 logging::GetLogMessageHandler(); |
2808 logging::SetLogMessageHandler(MockLogMessageHandler); | 2869 logging::SetLogMessageHandler(MockLogMessageHandler); |
2809 | 2870 |
2810 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 2871 TraceLog::GetInstance()->SetEnabled( |
2811 base::debug::TraceLog::RECORDING_MODE, | 2872 CategoryFilter("*"), |
2812 TraceLog::ECHO_TO_CONSOLE); | 2873 TraceLog::RECORDING_MODE, |
| 2874 TraceOptions(ECHO_TO_CONSOLE)); |
2813 TRACE_EVENT_BEGIN0("a", "begin_end"); | 2875 TRACE_EVENT_BEGIN0("a", "begin_end"); |
2814 { | 2876 { |
2815 TRACE_EVENT0("b", "duration"); | 2877 TRACE_EVENT0("b", "duration"); |
2816 TRACE_EVENT0("b1", "duration1"); | 2878 TRACE_EVENT0("b1", "duration1"); |
2817 } | 2879 } |
2818 TRACE_EVENT_INSTANT0("c", "instant", TRACE_EVENT_SCOPE_GLOBAL); | 2880 TRACE_EVENT_INSTANT0("c", "instant", TRACE_EVENT_SCOPE_GLOBAL); |
2819 TRACE_EVENT_END0("a", "begin_end"); | 2881 TRACE_EVENT_END0("a", "begin_end"); |
2820 | 2882 |
2821 EXPECT_NE(std::string::npos, g_log_buffer->find("begin_end[a]\x1b")); | 2883 EXPECT_NE(std::string::npos, g_log_buffer->find("begin_end[a]\x1b")); |
2822 EXPECT_NE(std::string::npos, g_log_buffer->find("| duration[b]\x1b")); | 2884 EXPECT_NE(std::string::npos, g_log_buffer->find("| duration[b]\x1b")); |
(...skipping 13 matching lines...) Expand all Loading... |
2836 const std::string&) { | 2898 const std::string&) { |
2837 TRACE_EVENT0("log", "trace_event"); | 2899 TRACE_EVENT0("log", "trace_event"); |
2838 return false; | 2900 return false; |
2839 } | 2901 } |
2840 | 2902 |
2841 TEST_F(TraceEventTestFixture, EchoToConsoleTraceEventRecursion) { | 2903 TEST_F(TraceEventTestFixture, EchoToConsoleTraceEventRecursion) { |
2842 logging::LogMessageHandlerFunction old_log_message_handler = | 2904 logging::LogMessageHandlerFunction old_log_message_handler = |
2843 logging::GetLogMessageHandler(); | 2905 logging::GetLogMessageHandler(); |
2844 logging::SetLogMessageHandler(LogMessageHandlerWithTraceEvent); | 2906 logging::SetLogMessageHandler(LogMessageHandlerWithTraceEvent); |
2845 | 2907 |
2846 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 2908 TraceLog::GetInstance()->SetEnabled( |
2847 base::debug::TraceLog::RECORDING_MODE, | 2909 CategoryFilter("*"), |
2848 TraceLog::ECHO_TO_CONSOLE); | 2910 TraceLog::RECORDING_MODE, |
| 2911 TraceOptions(ECHO_TO_CONSOLE)); |
2849 { | 2912 { |
2850 // This should not cause deadlock or infinite recursion. | 2913 // This should not cause deadlock or infinite recursion. |
2851 TRACE_EVENT0("b", "duration"); | 2914 TRACE_EVENT0("b", "duration"); |
2852 } | 2915 } |
2853 | 2916 |
2854 EndTraceAndFlush(); | 2917 EndTraceAndFlush(); |
2855 logging::SetLogMessageHandler(old_log_message_handler); | 2918 logging::SetLogMessageHandler(old_log_message_handler); |
2856 } | 2919 } |
2857 | 2920 |
2858 TEST_F(TraceEventTestFixture, TimeOffset) { | 2921 TEST_F(TraceEventTestFixture, TimeOffset) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2925 filter1.Merge(filter2); | 2988 filter1.Merge(filter2); |
2926 EXPECT_EQ(2u, filter1.GetSyntheticDelayValues().size()); | 2989 EXPECT_EQ(2u, filter1.GetSyntheticDelayValues().size()); |
2927 } | 2990 } |
2928 | 2991 |
2929 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { | 2992 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { |
2930 const char config[] = "DELAY(test.Delay;16;oneshot)"; | 2993 const char config[] = "DELAY(test.Delay;16;oneshot)"; |
2931 CategoryFilter filter(config); | 2994 CategoryFilter filter(config); |
2932 EXPECT_EQ(config, filter.ToString()); | 2995 EXPECT_EQ(config, filter.ToString()); |
2933 } | 2996 } |
2934 | 2997 |
| 2998 TEST(TraceOptionsTest, TraceOptionsFromString) { |
| 2999 TraceOptions options = TraceOptions("record-until-full"); |
| 3000 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); |
| 3001 EXPECT_FALSE(options.enable_sampling); |
| 3002 EXPECT_FALSE(options.enable_systrace); |
| 3003 |
| 3004 options = TraceOptions(RECORD_CONTINUOUSLY); |
| 3005 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode); |
| 3006 EXPECT_FALSE(options.enable_sampling); |
| 3007 EXPECT_FALSE(options.enable_systrace); |
| 3008 |
| 3009 options = TraceOptions("trace-to-console"); |
| 3010 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode); |
| 3011 EXPECT_FALSE(options.enable_sampling); |
| 3012 EXPECT_FALSE(options.enable_systrace); |
| 3013 |
| 3014 options = TraceOptions("record-until-full, enable-sampling"); |
| 3015 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); |
| 3016 EXPECT_TRUE(options.enable_sampling); |
| 3017 EXPECT_FALSE(options.enable_systrace); |
| 3018 |
| 3019 options = TraceOptions("enable-systrace,record-continuously"); |
| 3020 EXPECT_EQ(RECORD_CONTINUOUSLY, options.record_mode); |
| 3021 EXPECT_FALSE(options.enable_sampling); |
| 3022 EXPECT_TRUE(options.enable_systrace); |
| 3023 |
| 3024 options = TraceOptions("enable-systrace, trace-to-console,enable-sampling"); |
| 3025 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode); |
| 3026 EXPECT_TRUE(options.enable_sampling); |
| 3027 EXPECT_TRUE(options.enable_systrace); |
| 3028 |
| 3029 options = |
| 3030 TraceOptions("record-continuously,record-until-full,trace-to-console"); |
| 3031 EXPECT_EQ(ECHO_TO_CONSOLE, options.record_mode); |
| 3032 EXPECT_FALSE(options.enable_systrace); |
| 3033 EXPECT_FALSE(options.enable_sampling); |
| 3034 |
| 3035 options = TraceOptions(""); |
| 3036 EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode); |
| 3037 EXPECT_FALSE(options.enable_systrace); |
| 3038 EXPECT_FALSE(options.enable_sampling); |
| 3039 |
| 3040 #if GTEST_HAS_EXCEPTIONS |
| 3041 EXPECT_THROW(TraceOptions("foo-bar-baz"), int); |
| 3042 #endif |
| 3043 } |
| 3044 |
| 3045 TEST(TraceOptionsTest, TraceOptionsToString) { |
| 3046 // Test that we can intialize TraceOptions from a string got from |
| 3047 // TraceOptions.ToString() method to get a same TraceOptions. |
| 3048 TraceRecordMode modes[] = { |
| 3049 RECORD_UNTIL_FULL, RECORD_CONTINUOUSLY, ECHO_TO_CONSOLE}; |
| 3050 bool enable_sampling_options[] = {true, false}; |
| 3051 bool enable_systrace_options[] = {true, false}; |
| 3052 |
| 3053 for (int i = 0; i < 3; ++i) { |
| 3054 for (int j = 0; j < 2; ++j) { |
| 3055 for (int k = 0; k < 2; ++k) { |
| 3056 TraceOptions original_option = TraceOptions(modes[i]); |
| 3057 original_option.enable_sampling = enable_sampling_options[j]; |
| 3058 original_option.enable_systrace = enable_systrace_options[k]; |
| 3059 TraceOptions new_options = TraceOptions(original_option.ToString()); |
| 3060 EXPECT_EQ(original_option.record_mode, new_options.record_mode); |
| 3061 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); |
| 3062 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); |
| 3063 } |
| 3064 } |
| 3065 } |
| 3066 } |
| 3067 |
| 3068 |
2935 } // namespace debug | 3069 } // namespace debug |
2936 } // namespace base | 3070 } // namespace base |
OLD | NEW |