| 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 <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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 const char kAsyncIdStr[] = "0x5"; | 46 const char kAsyncIdStr[] = "0x5"; |
| 47 const int kAsyncId2 = 6; | 47 const int kAsyncId2 = 6; |
| 48 const char kAsyncId2Str[] = "0x6"; | 48 const char kAsyncId2Str[] = "0x6"; |
| 49 | 49 |
| 50 class TraceEventTestFixture : public testing::Test { | 50 class TraceEventTestFixture : public testing::Test { |
| 51 public: | 51 public: |
| 52 void OnTraceDataCollected( | 52 void OnTraceDataCollected( |
| 53 WaitableEvent* flush_complete_event, | 53 WaitableEvent* flush_complete_event, |
| 54 const scoped_refptr<base::RefCountedString>& events_str, | 54 const scoped_refptr<base::RefCountedString>& events_str, |
| 55 bool has_more_events); | 55 bool has_more_events); |
| 56 void OnTraceNotification(int notification) { | 56 void OnWatchEventMatched() { |
| 57 if (notification & TraceLog::EVENT_WATCH_NOTIFICATION) | 57 ++event_watch_notification_; |
| 58 ++event_watch_notification_; | |
| 59 notifications_received_ |= notification; | |
| 60 } | 58 } |
| 61 DictionaryValue* FindMatchingTraceEntry(const JsonKeyValue* key_values); | 59 DictionaryValue* FindMatchingTraceEntry(const JsonKeyValue* key_values); |
| 62 DictionaryValue* FindNamePhase(const char* name, const char* phase); | 60 DictionaryValue* FindNamePhase(const char* name, const char* phase); |
| 63 DictionaryValue* FindNamePhaseKeyValue(const char* name, | 61 DictionaryValue* FindNamePhaseKeyValue(const char* name, |
| 64 const char* phase, | 62 const char* phase, |
| 65 const char* key, | 63 const char* key, |
| 66 const char* value); | 64 const char* value); |
| 67 bool FindMatchingValue(const char* key, | 65 bool FindMatchingValue(const char* key, |
| 68 const char* value); | 66 const char* value); |
| 69 bool FindNonMatchingValue(const char* key, | 67 bool FindNonMatchingValue(const char* key, |
| 70 const char* value); | 68 const char* value); |
| 71 void Clear() { | 69 void Clear() { |
| 72 trace_parsed_.Clear(); | 70 trace_parsed_.Clear(); |
| 73 json_output_.json_output.clear(); | 71 json_output_.json_output.clear(); |
| 74 } | 72 } |
| 75 | 73 |
| 76 void BeginTrace() { | 74 void BeginTrace() { |
| 77 BeginSpecificTrace("*"); | 75 BeginSpecificTrace("*"); |
| 78 } | 76 } |
| 79 | 77 |
| 80 void BeginSpecificTrace(const std::string& filter) { | 78 void BeginSpecificTrace(const std::string& filter) { |
| 81 event_watch_notification_ = 0; | 79 event_watch_notification_ = 0; |
| 82 notifications_received_ = 0; | |
| 83 TraceLog::GetInstance()->SetEnabled(CategoryFilter(filter), | 80 TraceLog::GetInstance()->SetEnabled(CategoryFilter(filter), |
| 84 TraceLog::RECORD_UNTIL_FULL); | 81 TraceLog::RECORD_UNTIL_FULL); |
| 85 } | 82 } |
| 86 | 83 |
| 87 void EndTraceAndFlush() { | 84 void EndTraceAndFlush() { |
| 88 WaitableEvent flush_complete_event(false, false); | 85 WaitableEvent flush_complete_event(false, false); |
| 89 EndTraceAndFlushAsync(&flush_complete_event); | 86 EndTraceAndFlushAsync(&flush_complete_event); |
| 90 flush_complete_event.Wait(); | 87 flush_complete_event.Wait(); |
| 91 } | 88 } |
| 92 | 89 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 120 void FlushMonitoring(WaitableEvent* flush_complete_event) { | 117 void FlushMonitoring(WaitableEvent* flush_complete_event) { |
| 121 TraceLog::GetInstance()->FlushButLeaveBufferIntact( | 118 TraceLog::GetInstance()->FlushButLeaveBufferIntact( |
| 122 base::Bind(&TraceEventTestFixture::OnTraceDataCollected, | 119 base::Bind(&TraceEventTestFixture::OnTraceDataCollected, |
| 123 base::Unretained(static_cast<TraceEventTestFixture*>(this)), | 120 base::Unretained(static_cast<TraceEventTestFixture*>(this)), |
| 124 base::Unretained(flush_complete_event))); | 121 base::Unretained(flush_complete_event))); |
| 125 } | 122 } |
| 126 | 123 |
| 127 virtual void SetUp() OVERRIDE { | 124 virtual void SetUp() OVERRIDE { |
| 128 const char* name = PlatformThread::GetName(); | 125 const char* name = PlatformThread::GetName(); |
| 129 old_thread_name_ = name ? strdup(name) : NULL; | 126 old_thread_name_ = name ? strdup(name) : NULL; |
| 130 notifications_received_ = 0; | |
| 131 | 127 |
| 132 TraceLog::DeleteForTesting(); | 128 TraceLog::DeleteForTesting(); |
| 133 TraceLog* tracelog = TraceLog::GetInstance(); | 129 TraceLog* tracelog = TraceLog::GetInstance(); |
| 134 ASSERT_TRUE(tracelog); | 130 ASSERT_TRUE(tracelog); |
| 135 ASSERT_FALSE(tracelog->IsEnabled()); | 131 ASSERT_FALSE(tracelog->IsEnabled()); |
| 136 tracelog->SetNotificationCallback( | |
| 137 base::Bind(&TraceEventTestFixture::OnTraceNotification, | |
| 138 base::Unretained(this))); | |
| 139 trace_buffer_.SetOutputCallback(json_output_.GetCallback()); | 132 trace_buffer_.SetOutputCallback(json_output_.GetCallback()); |
| 133 event_watch_notification_ = 0; |
| 140 } | 134 } |
| 141 virtual void TearDown() OVERRIDE { | 135 virtual void TearDown() OVERRIDE { |
| 142 if (TraceLog::GetInstance()) | 136 if (TraceLog::GetInstance()) |
| 143 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); | 137 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); |
| 144 PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : ""); | 138 PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : ""); |
| 145 free(old_thread_name_); | 139 free(old_thread_name_); |
| 146 old_thread_name_ = NULL; | 140 old_thread_name_ = NULL; |
| 147 // We want our singleton torn down after each test. | 141 // We want our singleton torn down after each test. |
| 148 TraceLog::DeleteForTesting(); | 142 TraceLog::DeleteForTesting(); |
| 149 } | 143 } |
| 150 | 144 |
| 151 char* old_thread_name_; | 145 char* old_thread_name_; |
| 152 ListValue trace_parsed_; | 146 ListValue trace_parsed_; |
| 153 base::debug::TraceResultBuffer trace_buffer_; | 147 base::debug::TraceResultBuffer trace_buffer_; |
| 154 base::debug::TraceResultBuffer::SimpleOutput json_output_; | 148 base::debug::TraceResultBuffer::SimpleOutput json_output_; |
| 155 int event_watch_notification_; | 149 int event_watch_notification_; |
| 156 int notifications_received_; | |
| 157 | 150 |
| 158 private: | 151 private: |
| 159 // We want our singleton torn down after each test. | 152 // We want our singleton torn down after each test. |
| 160 ShadowingAtExitManager at_exit_manager_; | 153 ShadowingAtExitManager at_exit_manager_; |
| 161 Lock lock_; | 154 Lock lock_; |
| 162 }; | 155 }; |
| 163 | 156 |
| 164 void TraceEventTestFixture::OnTraceDataCollected( | 157 void TraceEventTestFixture::OnTraceDataCollected( |
| 165 WaitableEvent* flush_complete_event, | 158 WaitableEvent* flush_complete_event, |
| 166 const scoped_refptr<base::RefCountedString>& events_str, | 159 const scoped_refptr<base::RefCountedString>& events_str, |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 EXPECT_TRUE(FindMatchingValue("cat", "cat1")); | 1174 EXPECT_TRUE(FindMatchingValue("cat", "cat1")); |
| 1182 EXPECT_TRUE(FindMatchingValue("cat", "cat2")); | 1175 EXPECT_TRUE(FindMatchingValue("cat", "cat2")); |
| 1183 EXPECT_FALSE(FindMatchingValue("name", "not_inc")); | 1176 EXPECT_FALSE(FindMatchingValue("name", "not_inc")); |
| 1184 } | 1177 } |
| 1185 | 1178 |
| 1186 | 1179 |
| 1187 // Test EVENT_WATCH_NOTIFICATION | 1180 // Test EVENT_WATCH_NOTIFICATION |
| 1188 TEST_F(TraceEventTestFixture, EventWatchNotification) { | 1181 TEST_F(TraceEventTestFixture, EventWatchNotification) { |
| 1189 // Basic one occurrence. | 1182 // Basic one occurrence. |
| 1190 BeginTrace(); | 1183 BeginTrace(); |
| 1191 TraceLog::GetInstance()->SetWatchEvent("cat", "event"); | 1184 TraceLog::WatchEventCallback callback = |
| 1185 base::Bind(&TraceEventTestFixture::OnWatchEventMatched, |
| 1186 base::Unretained(this)); |
| 1187 TraceLog::GetInstance()->SetWatchEvent("cat", "event", callback); |
| 1192 TRACE_EVENT_INSTANT0("cat", "event", TRACE_EVENT_SCOPE_THREAD); | 1188 TRACE_EVENT_INSTANT0("cat", "event", TRACE_EVENT_SCOPE_THREAD); |
| 1193 EndTraceAndFlush(); | 1189 EndTraceAndFlush(); |
| 1194 EXPECT_EQ(event_watch_notification_, 1); | 1190 EXPECT_EQ(event_watch_notification_, 1); |
| 1195 | 1191 |
| 1196 // Auto-reset after end trace. | 1192 // Auto-reset after end trace. |
| 1197 BeginTrace(); | 1193 BeginTrace(); |
| 1198 TraceLog::GetInstance()->SetWatchEvent("cat", "event"); | 1194 TraceLog::GetInstance()->SetWatchEvent("cat", "event", callback); |
| 1199 EndTraceAndFlush(); | 1195 EndTraceAndFlush(); |
| 1200 BeginTrace(); | 1196 BeginTrace(); |
| 1201 TRACE_EVENT_INSTANT0("cat", "event", TRACE_EVENT_SCOPE_THREAD); | 1197 TRACE_EVENT_INSTANT0("cat", "event", TRACE_EVENT_SCOPE_THREAD); |
| 1202 EndTraceAndFlush(); | 1198 EndTraceAndFlush(); |
| 1203 EXPECT_EQ(event_watch_notification_, 0); | 1199 EXPECT_EQ(event_watch_notification_, 0); |
| 1204 | 1200 |
| 1205 // Multiple occurrence. | 1201 // Multiple occurrence. |
| 1206 BeginTrace(); | 1202 BeginTrace(); |
| 1207 int num_occurrences = 5; | 1203 int num_occurrences = 5; |
| 1208 TraceLog::GetInstance()->SetWatchEvent("cat", "event"); | 1204 TraceLog::GetInstance()->SetWatchEvent("cat", "event", callback); |
| 1209 for (int i = 0; i < num_occurrences; ++i) | 1205 for (int i = 0; i < num_occurrences; ++i) |
| 1210 TRACE_EVENT_INSTANT0("cat", "event", TRACE_EVENT_SCOPE_THREAD); | 1206 TRACE_EVENT_INSTANT0("cat", "event", TRACE_EVENT_SCOPE_THREAD); |
| 1211 EndTraceAndFlush(); | 1207 EndTraceAndFlush(); |
| 1212 EXPECT_EQ(event_watch_notification_, num_occurrences); | 1208 EXPECT_EQ(event_watch_notification_, num_occurrences); |
| 1213 | 1209 |
| 1214 // Wrong category. | 1210 // Wrong category. |
| 1215 BeginTrace(); | 1211 BeginTrace(); |
| 1216 TraceLog::GetInstance()->SetWatchEvent("cat", "event"); | 1212 TraceLog::GetInstance()->SetWatchEvent("cat", "event", callback); |
| 1217 TRACE_EVENT_INSTANT0("wrong_cat", "event", TRACE_EVENT_SCOPE_THREAD); | 1213 TRACE_EVENT_INSTANT0("wrong_cat", "event", TRACE_EVENT_SCOPE_THREAD); |
| 1218 EndTraceAndFlush(); | 1214 EndTraceAndFlush(); |
| 1219 EXPECT_EQ(event_watch_notification_, 0); | 1215 EXPECT_EQ(event_watch_notification_, 0); |
| 1220 | 1216 |
| 1221 // Wrong name. | 1217 // Wrong name. |
| 1222 BeginTrace(); | 1218 BeginTrace(); |
| 1223 TraceLog::GetInstance()->SetWatchEvent("cat", "event"); | 1219 TraceLog::GetInstance()->SetWatchEvent("cat", "event", callback); |
| 1224 TRACE_EVENT_INSTANT0("cat", "wrong_event", TRACE_EVENT_SCOPE_THREAD); | 1220 TRACE_EVENT_INSTANT0("cat", "wrong_event", TRACE_EVENT_SCOPE_THREAD); |
| 1225 EndTraceAndFlush(); | 1221 EndTraceAndFlush(); |
| 1226 EXPECT_EQ(event_watch_notification_, 0); | 1222 EXPECT_EQ(event_watch_notification_, 0); |
| 1227 | 1223 |
| 1228 // Canceled. | 1224 // Canceled. |
| 1229 BeginTrace(); | 1225 BeginTrace(); |
| 1230 TraceLog::GetInstance()->SetWatchEvent("cat", "event"); | 1226 TraceLog::GetInstance()->SetWatchEvent("cat", "event", callback); |
| 1231 TraceLog::GetInstance()->CancelWatchEvent(); | 1227 TraceLog::GetInstance()->CancelWatchEvent(); |
| 1232 TRACE_EVENT_INSTANT0("cat", "event", TRACE_EVENT_SCOPE_THREAD); | 1228 TRACE_EVENT_INSTANT0("cat", "event", TRACE_EVENT_SCOPE_THREAD); |
| 1233 EndTraceAndFlush(); | 1229 EndTraceAndFlush(); |
| 1234 EXPECT_EQ(event_watch_notification_, 0); | 1230 EXPECT_EQ(event_watch_notification_, 0); |
| 1235 } | 1231 } |
| 1236 | 1232 |
| 1237 // Test ASYNC_BEGIN/END events | 1233 // Test ASYNC_BEGIN/END events |
| 1238 TEST_F(TraceEventTestFixture, AsyncBeginEndEvents) { | 1234 TEST_F(TraceEventTestFixture, AsyncBeginEndEvents) { |
| 1239 BeginTrace(); | 1235 BeginTrace(); |
| 1240 | 1236 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 TraceLog::RECORD_UNTIL_FULL); | 1723 TraceLog::RECORD_UNTIL_FULL); |
| 1728 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-cc")); | 1724 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-cc")); |
| 1729 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-gpu")); | 1725 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("disabled-by-default-gpu")); |
| 1730 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("bar")); | 1726 EXPECT_TRUE(*trace_log->GetCategoryGroupEnabled("bar")); |
| 1731 EXPECT_STREQ("disabled-by-default-cc,disabled-by-default-gpu", | 1727 EXPECT_STREQ("disabled-by-default-cc,disabled-by-default-gpu", |
| 1732 trace_log->GetCurrentCategoryFilter().ToString().c_str()); | 1728 trace_log->GetCurrentCategoryFilter().ToString().c_str()); |
| 1733 trace_log->SetDisabled(); | 1729 trace_log->SetDisabled(); |
| 1734 trace_log->SetDisabled(); | 1730 trace_log->SetDisabled(); |
| 1735 } | 1731 } |
| 1736 | 1732 |
| 1737 TEST_F(TraceEventTestFixture, TraceOptionsParsing) { | |
| 1738 EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL, | |
| 1739 TraceLog::TraceOptionsFromString(std::string())); | |
| 1740 | |
| 1741 EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL, | |
| 1742 TraceLog::TraceOptionsFromString("record-until-full")); | |
| 1743 EXPECT_EQ(TraceLog::RECORD_CONTINUOUSLY, | |
| 1744 TraceLog::TraceOptionsFromString("record-continuously")); | |
| 1745 EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL | TraceLog::ENABLE_SAMPLING, | |
| 1746 TraceLog::TraceOptionsFromString("enable-sampling")); | |
| 1747 EXPECT_EQ(TraceLog::RECORD_CONTINUOUSLY | TraceLog::ENABLE_SAMPLING, | |
| 1748 TraceLog::TraceOptionsFromString( | |
| 1749 "record-continuously,enable-sampling")); | |
| 1750 } | |
| 1751 | |
| 1752 TEST_F(TraceEventTestFixture, TraceSampling) { | 1733 TEST_F(TraceEventTestFixture, TraceSampling) { |
| 1753 event_watch_notification_ = 0; | |
| 1754 TraceLog::GetInstance()->SetEnabled( | 1734 TraceLog::GetInstance()->SetEnabled( |
| 1755 CategoryFilter("*"), | 1735 CategoryFilter("*"), |
| 1756 TraceLog::Options(TraceLog::RECORD_UNTIL_FULL | | 1736 TraceLog::Options(TraceLog::RECORD_UNTIL_FULL | |
| 1757 TraceLog::ENABLE_SAMPLING)); | 1737 TraceLog::ENABLE_SAMPLING)); |
| 1758 | 1738 |
| 1759 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "cc", "Stuff"); | 1739 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "cc", "Stuff"); |
| 1760 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1740 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
| 1761 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "cc", "Things"); | 1741 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "cc", "Things"); |
| 1762 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1742 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
| 1763 | 1743 |
| 1764 EndTraceAndFlush(); | 1744 EndTraceAndFlush(); |
| 1765 | 1745 |
| 1766 // Make sure we hit at least once. | 1746 // Make sure we hit at least once. |
| 1767 EXPECT_TRUE(FindNamePhase("Stuff", "P")); | 1747 EXPECT_TRUE(FindNamePhase("Stuff", "P")); |
| 1768 EXPECT_TRUE(FindNamePhase("Things", "P")); | 1748 EXPECT_TRUE(FindNamePhase("Things", "P")); |
| 1769 } | 1749 } |
| 1770 | 1750 |
| 1771 TEST_F(TraceEventTestFixture, TraceSamplingScope) { | 1751 TEST_F(TraceEventTestFixture, TraceSamplingScope) { |
| 1772 event_watch_notification_ = 0; | |
| 1773 TraceLog::GetInstance()->SetEnabled( | 1752 TraceLog::GetInstance()->SetEnabled( |
| 1774 CategoryFilter("*"), | 1753 CategoryFilter("*"), |
| 1775 TraceLog::Options(TraceLog::RECORD_UNTIL_FULL | | 1754 TraceLog::Options(TraceLog::RECORD_UNTIL_FULL | |
| 1776 TraceLog::ENABLE_SAMPLING)); | 1755 TraceLog::ENABLE_SAMPLING)); |
| 1777 | 1756 |
| 1778 TRACE_EVENT_SCOPED_SAMPLING_STATE("AAA", "name"); | 1757 TRACE_EVENT_SCOPED_SAMPLING_STATE("AAA", "name"); |
| 1779 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1758 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
| 1780 { | 1759 { |
| 1781 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "AAA"); | 1760 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "AAA"); |
| 1782 TRACE_EVENT_SCOPED_SAMPLING_STATE("BBB", "name"); | 1761 TRACE_EVENT_SCOPED_SAMPLING_STATE("BBB", "name"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1797 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1776 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
| 1798 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD"); | 1777 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD"); |
| 1799 } | 1778 } |
| 1800 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1779 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
| 1801 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD"); | 1780 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD"); |
| 1802 | 1781 |
| 1803 EndTraceAndFlush(); | 1782 EndTraceAndFlush(); |
| 1804 } | 1783 } |
| 1805 | 1784 |
| 1806 TEST_F(TraceEventTestFixture, TraceContinuousSampling) { | 1785 TEST_F(TraceEventTestFixture, TraceContinuousSampling) { |
| 1807 event_watch_notification_ = 0; | |
| 1808 TraceLog::GetInstance()->SetEnabled( | 1786 TraceLog::GetInstance()->SetEnabled( |
| 1809 CategoryFilter("*"), | 1787 CategoryFilter("*"), |
| 1810 TraceLog::Options(TraceLog::MONITOR_SAMPLING)); | 1788 TraceLog::Options(TraceLog::MONITOR_SAMPLING)); |
| 1811 | 1789 |
| 1812 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "AAA"); | 1790 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "AAA"); |
| 1813 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1791 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
| 1814 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "BBB"); | 1792 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(1, "category", "BBB"); |
| 1815 TraceLog::GetInstance()->WaitSamplingEventForTesting(); | 1793 TraceLog::GetInstance()->WaitSamplingEventForTesting(); |
| 1816 | 1794 |
| 1817 FlushMonitoring(); | 1795 FlushMonitoring(); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 EXPECT_LE(collected_events_timestamps_[i - 1], | 2042 EXPECT_LE(collected_events_timestamps_[i - 1], |
| 2065 collected_events_timestamps_[i]); | 2043 collected_events_timestamps_[i]); |
| 2066 } | 2044 } |
| 2067 } | 2045 } |
| 2068 | 2046 |
| 2069 TEST_F(TraceEventCallbackTest, TraceEventCallbackWhileFull) { | 2047 TEST_F(TraceEventCallbackTest, TraceEventCallbackWhileFull) { |
| 2070 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), | 2048 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), |
| 2071 TraceLog::RECORD_UNTIL_FULL); | 2049 TraceLog::RECORD_UNTIL_FULL); |
| 2072 do { | 2050 do { |
| 2073 TRACE_EVENT_INSTANT0("all", "badger badger", TRACE_EVENT_SCOPE_GLOBAL); | 2051 TRACE_EVENT_INSTANT0("all", "badger badger", TRACE_EVENT_SCOPE_GLOBAL); |
| 2074 } while ((notifications_received_ & TraceLog::TRACE_BUFFER_FULL) == 0); | 2052 } while (!TraceLog::GetInstance()->BufferIsFull()); |
| 2075 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("*"), | 2053 TraceLog::GetInstance()->SetEventCallbackEnabled(CategoryFilter("*"), |
| 2076 Callback); | 2054 Callback); |
| 2077 TRACE_EVENT_INSTANT0("all", "a snake", TRACE_EVENT_SCOPE_GLOBAL); | 2055 TRACE_EVENT_INSTANT0("all", "a snake", TRACE_EVENT_SCOPE_GLOBAL); |
| 2078 TraceLog::GetInstance()->SetEventCallbackDisabled(); | 2056 TraceLog::GetInstance()->SetEventCallbackDisabled(); |
| 2079 ASSERT_EQ(1u, collected_events_names_.size()); | 2057 ASSERT_EQ(1u, collected_events_names_.size()); |
| 2080 EXPECT_EQ("a snake", collected_events_names_[0]); | 2058 EXPECT_EQ("a snake", collected_events_names_[0]); |
| 2081 } | 2059 } |
| 2082 | 2060 |
| 2083 // 1: Enable callback, enable recording, disable callback, disable recording. | 2061 // 1: Enable callback, enable recording, disable callback, disable recording. |
| 2084 TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording1) { | 2062 TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording1) { |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2577 double timestamp; | 2555 double timestamp; |
| 2578 EXPECT_TRUE(item->GetDouble("ts", ×tamp)); | 2556 EXPECT_TRUE(item->GetDouble("ts", ×tamp)); |
| 2579 EXPECT_GE(timestamp, last_timestamp); | 2557 EXPECT_GE(timestamp, last_timestamp); |
| 2580 EXPECT_LE(timestamp, end_time); | 2558 EXPECT_LE(timestamp, end_time); |
| 2581 last_timestamp = timestamp; | 2559 last_timestamp = timestamp; |
| 2582 } | 2560 } |
| 2583 } | 2561 } |
| 2584 | 2562 |
| 2585 } // namespace debug | 2563 } // namespace debug |
| 2586 } // namespace base | 2564 } // namespace base |
| OLD | NEW |