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

Unified Diff: base/debug/trace_event_unittest.cc

Issue 15774010: Add TRACE_EVENT_IS_NEW_TRACE as a way to snapshot objects at start of recording (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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') | cc/layers/layer_impl.h » ('j') | 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 26e79c076ca73c176d4d9479582a894d9f08ad55..02bb899d2a227d4258a3b565c4aec00908b14b4e 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -905,6 +905,37 @@ TEST_F(TraceEventTestFixture, EnabledObserverFiresOnDisable) {
TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer);
}
+bool IsNewTrace() {
+ bool is_new_trace;
+ TRACE_EVENT_IS_NEW_TRACE(&is_new_trace);
+ return is_new_trace;
+}
+
+TEST_F(TraceEventTestFixture, NewTraceRecording) {
+ ManualTestSetUp();
+ ASSERT_FALSE(IsNewTrace());
+ TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"),
+ TraceLog::RECORD_UNTIL_FULL);
+ // First call to IsNewTrace() should succeed. But, the second shouldn't.
+ ASSERT_TRUE(IsNewTrace());
+ ASSERT_FALSE(IsNewTrace());
+ EndTraceAndFlush();
+
+ // IsNewTrace() should definitely be false now.
+ ASSERT_FALSE(IsNewTrace());
+
+ // Start another trace. IsNewTrace() should become true again, briefly, as
+ // before.
+ TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"),
+ TraceLog::RECORD_UNTIL_FULL);
+ ASSERT_TRUE(IsNewTrace());
+ ASSERT_FALSE(IsNewTrace());
+
+ // Cleanup.
+ EndTraceAndFlush();
+}
+
+
// Test that categories work.
TEST_F(TraceEventTestFixture, Categories) {
ManualTestSetUp();
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698