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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/debug/trace_event_unittest.h" | 6 #include "base/debug/trace_event_unittest.h" |
7 #include "base/test/trace_event_analyzer.h" | 7 #include "base/test/trace_event_analyzer.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 void TraceEventAnalyzerTest::OnTraceDataCollected( | 34 void TraceEventAnalyzerTest::OnTraceDataCollected( |
35 const scoped_refptr<base::RefCountedString>& json_events_str) { | 35 const scoped_refptr<base::RefCountedString>& json_events_str) { |
36 buffer_.AddFragment(json_events_str->data()); | 36 buffer_.AddFragment(json_events_str->data()); |
37 } | 37 } |
38 | 38 |
39 void TraceEventAnalyzerTest::BeginTracing() { | 39 void TraceEventAnalyzerTest::BeginTracing() { |
40 output_.json_output.clear(); | 40 output_.json_output.clear(); |
41 buffer_.Start(); | 41 buffer_.Start(); |
42 base::debug::TraceLog::GetInstance()->SetEnabled( | 42 base::debug::TraceLog::GetInstance()->SetEnabled( |
43 true, | 43 base::debug::CategoryFilter("*"), |
44 base::debug::TraceLog::RECORD_UNTIL_FULL); | 44 base::debug::TraceLog::RECORD_UNTIL_FULL); |
45 } | 45 } |
46 | 46 |
47 void TraceEventAnalyzerTest::EndTracing() { | 47 void TraceEventAnalyzerTest::EndTracing() { |
48 base::debug::TraceLog::GetInstance()->SetEnabled( | 48 base::debug::TraceLog::GetInstance()->SetDisabled(); |
49 false, | |
50 base::debug::TraceLog::RECORD_UNTIL_FULL); | |
51 base::debug::TraceLog::GetInstance()->Flush( | 49 base::debug::TraceLog::GetInstance()->Flush( |
52 base::Bind(&TraceEventAnalyzerTest::OnTraceDataCollected, | 50 base::Bind(&TraceEventAnalyzerTest::OnTraceDataCollected, |
53 base::Unretained(this))); | 51 base::Unretained(this))); |
54 buffer_.Finish(); | 52 buffer_.Finish(); |
55 } | 53 } |
56 | 54 |
57 } // namespace | 55 } // namespace |
58 | 56 |
59 TEST_F(TraceEventAnalyzerTest, NoEvents) { | 57 TEST_F(TraceEventAnalyzerTest, NoEvents) { |
60 ManualSetUp(); | 58 ManualSetUp(); |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); | 827 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); |
830 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), | 828 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), |
831 1, num_events)); | 829 1, num_events)); |
832 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); | 830 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); |
833 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); | 831 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); |
834 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); | 832 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); |
835 } | 833 } |
836 | 834 |
837 | 835 |
838 } // namespace trace_analyzer | 836 } // namespace trace_analyzer |
OLD | NEW |