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 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3092 config1.Merge(config2); | 3092 config1.Merge(config2); |
3093 EXPECT_EQ(2u, config1.GetSyntheticDelayValues().size()); | 3093 EXPECT_EQ(2u, config1.GetSyntheticDelayValues().size()); |
3094 } | 3094 } |
3095 | 3095 |
3096 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { | 3096 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { |
3097 const char filter[] = "DELAY(test.Delay;16;oneshot)"; | 3097 const char filter[] = "DELAY(test.Delay;16;oneshot)"; |
3098 TraceConfig config(filter, ""); | 3098 TraceConfig config(filter, ""); |
3099 EXPECT_EQ(filter, config.ToCategoryFilterString()); | 3099 EXPECT_EQ(filter, config.ToCategoryFilterString()); |
3100 } | 3100 } |
3101 | 3101 |
| 3102 TEST_F(TraceEventTestFixture, EventFiltering) { |
| 3103 const char config_json[] = |
| 3104 "{" |
| 3105 " \"included_categories\": [" |
| 3106 " \"filtered_cat\"," |
| 3107 " \"unfiltered_cat\"]," |
| 3108 " \"event_filters\": [" |
| 3109 " {" |
| 3110 " \"filter_predicate\": \"event_whitelist_predicate\", " |
| 3111 " \"included_categories\": [\"*\"], " |
| 3112 " \"excluded_categories\": [\"unfiltered_cat\"], " |
| 3113 " \"filter_args\": {" |
| 3114 " \"event_name_whitelist\": [\"a snake\", \"a dog\"]" |
| 3115 " }" |
| 3116 " }" |
| 3117 " " |
| 3118 " ]" |
| 3119 "}"; |
| 3120 |
| 3121 TraceConfig trace_config(config_json); |
| 3122 TraceLog::GetInstance()->SetEnabled(trace_config, TraceLog::RECORDING_MODE); |
| 3123 EXPECT_TRUE(TraceLog::GetInstance()->IsEnabled()); |
| 3124 |
| 3125 TRACE_EVENT0("filtered_cat", "a snake"); |
| 3126 TRACE_EVENT0("filtered_cat", "a mushroom"); |
| 3127 TRACE_EVENT0("unfiltered_cat", "a cat"); |
| 3128 |
| 3129 EndTraceAndFlush(); |
| 3130 |
| 3131 EXPECT_TRUE(FindMatchingValue("name", "a snake")); |
| 3132 EXPECT_FALSE(FindMatchingValue("name", "a mushroom")); |
| 3133 EXPECT_TRUE(FindMatchingValue("name", "a cat")); |
| 3134 } |
| 3135 |
3102 } // namespace trace_event | 3136 } // namespace trace_event |
3103 } // namespace base | 3137 } // namespace base |
OLD | NEW |