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

Side by Side 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, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/debug/trace_event_unittest.h" 5 #include "base/debug/trace_event_unittest.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 898
899 EXPECT_CALL(observer, OnTraceLogWillDisable()) 899 EXPECT_CALL(observer, OnTraceLogWillDisable())
900 .Times(1); 900 .Times(1);
901 TraceLog::GetInstance()->SetDisabled(); 901 TraceLog::GetInstance()->SetDisabled();
902 testing::Mock::VerifyAndClear(&observer); 902 testing::Mock::VerifyAndClear(&observer);
903 903
904 // Cleanup. 904 // Cleanup.
905 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer); 905 TraceLog::GetInstance()->RemoveEnabledStateObserver(&observer);
906 } 906 }
907 907
908 bool IsNewTrace() {
909 bool is_new_trace;
910 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace);
911 return is_new_trace;
912 }
913
914 TEST_F(TraceEventTestFixture, NewTraceRecording) {
915 ManualTestSetUp();
916 ASSERT_FALSE(IsNewTrace());
917 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"),
918 TraceLog::RECORD_UNTIL_FULL);
919 // First call to IsNewTrace() should succeed. But, the second shouldn't.
920 ASSERT_TRUE(IsNewTrace());
921 ASSERT_FALSE(IsNewTrace());
922 EndTraceAndFlush();
923
924 // IsNewTrace() should definitely be false now.
925 ASSERT_FALSE(IsNewTrace());
926
927 // Start another trace. IsNewTrace() should become true again, briefly, as
928 // before.
929 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"),
930 TraceLog::RECORD_UNTIL_FULL);
931 ASSERT_TRUE(IsNewTrace());
932 ASSERT_FALSE(IsNewTrace());
933
934 // Cleanup.
935 EndTraceAndFlush();
936 }
937
938
908 // Test that categories work. 939 // Test that categories work.
909 TEST_F(TraceEventTestFixture, Categories) { 940 TEST_F(TraceEventTestFixture, Categories) {
910 ManualTestSetUp(); 941 ManualTestSetUp();
911 942
912 // Test that categories that are used can be retrieved whether trace was 943 // Test that categories that are used can be retrieved whether trace was
913 // enabled or disabled when the trace event was encountered. 944 // enabled or disabled when the trace event was encountered.
914 TRACE_EVENT_INSTANT0("c1", "name", TRACE_EVENT_SCOPE_THREAD); 945 TRACE_EVENT_INSTANT0("c1", "name", TRACE_EVENT_SCOPE_THREAD);
915 TRACE_EVENT_INSTANT0("c2", "name", TRACE_EVENT_SCOPE_THREAD); 946 TRACE_EVENT_INSTANT0("c2", "name", TRACE_EVENT_SCOPE_THREAD);
916 BeginTrace(); 947 BeginTrace();
917 TRACE_EVENT_INSTANT0("c3", "name", TRACE_EVENT_SCOPE_THREAD); 948 TRACE_EVENT_INSTANT0("c3", "name", TRACE_EVENT_SCOPE_THREAD);
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 2027 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1997 " bad_category ")); 2028 " bad_category "));
1998 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 2029 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1999 "")); 2030 ""));
2000 EXPECT_FALSE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 2031 EXPECT_FALSE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
2001 "good_category")); 2032 "good_category"));
2002 } 2033 }
2003 2034
2004 } // namespace debug 2035 } // namespace debug
2005 } // namespace base 2036 } // namespace base
OLDNEW
« 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