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/trace_event/trace_event.h" | 5 #include "base/trace_event/trace_event.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 3295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3306 TRACE_EVENT0("filtered_cat", "a mushroom"); | 3306 TRACE_EVENT0("filtered_cat", "a mushroom"); |
3307 TRACE_EVENT0("unfiltered_cat", "a cat"); | 3307 TRACE_EVENT0("unfiltered_cat", "a cat"); |
3308 | 3308 |
3309 EndTraceAndFlush(); | 3309 EndTraceAndFlush(); |
3310 | 3310 |
3311 EXPECT_TRUE(FindMatchingValue("name", "a snake")); | 3311 EXPECT_TRUE(FindMatchingValue("name", "a snake")); |
3312 EXPECT_FALSE(FindMatchingValue("name", "a mushroom")); | 3312 EXPECT_FALSE(FindMatchingValue("name", "a mushroom")); |
3313 EXPECT_TRUE(FindMatchingValue("name", "a cat")); | 3313 EXPECT_TRUE(FindMatchingValue("name", "a cat")); |
3314 } | 3314 } |
3315 | 3315 |
| 3316 TEST_F(TraceEventTestFixture, HeapProfilerFiltering) { |
| 3317 const char config_json[] = |
| 3318 "{" |
| 3319 " \"included_categories\": [" |
| 3320 " \"filtered_cat\"," |
| 3321 " \"unfiltered_cat\"]," |
| 3322 " \"excluded_categories\": [\"excluded_cat\"]," |
| 3323 " \"event_filters\": [" |
| 3324 " {" |
| 3325 " \"filter_predicate\": \"heap_profiler_predicate\", " |
| 3326 " \"included_categories\": [\"*\"]" |
| 3327 " }" |
| 3328 " ]" |
| 3329 "}"; |
| 3330 |
| 3331 TraceConfig trace_config(config_json); |
| 3332 TraceLog::GetInstance()->SetEnabled(trace_config, TraceLog::RECORDING_MODE); |
| 3333 EXPECT_TRUE(TraceLog::GetInstance()->IsEnabled()); |
| 3334 |
| 3335 TRACE_EVENT0("filtered_cat", "a snake"); |
| 3336 TRACE_EVENT0("excluded_cat", "a mushroom"); |
| 3337 TRACE_EVENT0("unfiltered_cat", "a cat"); |
| 3338 |
| 3339 EndTraceAndFlush(); |
| 3340 |
| 3341 // The predicate should not change behavior of the trace events. |
| 3342 EXPECT_TRUE(FindMatchingValue("name", "a snake")); |
| 3343 EXPECT_FALSE(FindMatchingValue("name", "a mushroom")); |
| 3344 EXPECT_TRUE(FindMatchingValue("name", "a cat")); |
| 3345 } |
| 3346 |
3316 TEST_F(TraceEventTestFixture, ClockSyncEventsAreAlwaysAddedToTrace) { | 3347 TEST_F(TraceEventTestFixture, ClockSyncEventsAreAlwaysAddedToTrace) { |
3317 BeginSpecificTrace("-*"); | 3348 BeginSpecificTrace("-*"); |
3318 TRACE_EVENT_CLOCK_SYNC_RECEIVER(1); | 3349 TRACE_EVENT_CLOCK_SYNC_RECEIVER(1); |
3319 EndTraceAndFlush(); | 3350 EndTraceAndFlush(); |
3320 EXPECT_TRUE(FindNamePhase("clock_sync", "c")); | 3351 EXPECT_TRUE(FindNamePhase("clock_sync", "c")); |
3321 } | 3352 } |
3322 | 3353 |
3323 } // namespace trace_event | 3354 } // namespace trace_event |
3324 } // namespace base | 3355 } // namespace base |
OLD | NEW |