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

Unified Diff: base/debug/trace_event_unittest.cc

Issue 13912028: Invoke trace callback even when trace buffer is full (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_event_unittest.cc
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
index 64f992d50302110a2cc1bd2f8b0ceada92790987..a78b002066eb0ffb17b17a91d81ce00a037e9b34 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -55,6 +55,7 @@ class TraceEventTestFixture : public testing::Test {
void OnTraceNotification(int notification) {
if (notification & TraceLog::EVENT_WATCH_NOTIFICATION)
++event_watch_notification_;
+ notifications_received_ |= notification;
}
DictionaryValue* FindMatchingTraceEntry(const JsonKeyValue* key_values);
DictionaryValue* FindNamePhase(const char* name, const char* phase);
@@ -73,6 +74,7 @@ class TraceEventTestFixture : public testing::Test {
void BeginTrace() {
event_watch_notification_ = 0;
+ notifications_received_ = 0;
TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"),
TraceLog::RECORD_UNTIL_FULL);
}
@@ -102,6 +104,7 @@ class TraceEventTestFixture : public testing::Test {
base::debug::TraceResultBuffer trace_buffer_;
base::debug::TraceResultBuffer::SimpleOutput json_output_;
int event_watch_notification_;
+ int notifications_received_;
private:
// We want our singleton torn down after each test.
@@ -1666,11 +1669,24 @@ TEST_F(TraceEventCallbackTest, TraceEventCallback) {
TraceLog::GetInstance()->SetEventCallback(NULL);
TRACE_EVENT_INSTANT0("all", "after callback removed",
TRACE_EVENT_SCOPE_GLOBAL);
- EXPECT_EQ(2u, collected_events_.size());
+ ASSERT_EQ(2u, collected_events_.size());
jar (doing other things) 2013/04/26 16:43:31 nice catch/correction.
EXPECT_EQ("event1", collected_events_[0]);
EXPECT_EQ("event2", collected_events_[1]);
}
+TEST_F(TraceEventCallbackTest, TraceEventCallbackWhileFull) {
+ TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"),
+ TraceLog::RECORD_UNTIL_FULL);
+ do {
+ TRACE_EVENT_INSTANT0("all", "badger badger", TRACE_EVENT_SCOPE_GLOBAL);
+ } while ((notifications_received_ & TraceLog::TRACE_BUFFER_FULL) == 0);
+ TraceLog::GetInstance()->SetEventCallback(Callback);
+ TRACE_EVENT_INSTANT0("all", "a snake", TRACE_EVENT_SCOPE_GLOBAL);
+ TraceLog::GetInstance()->SetEventCallback(NULL);
+ ASSERT_EQ(1u, collected_events_.size());
+ EXPECT_EQ("a snake", collected_events_[0]);
+}
+
// TODO(dsinclair): Continuous Tracing unit test.
// Test the category filter.
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698