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 <math.h> | 5 #include <math.h> |
6 #include <cstdlib> | 6 #include <cstdlib> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2197 EXPECT_EQ(0, int_value); | 2197 EXPECT_EQ(0, int_value); |
2198 | 2198 |
2199 dict = FindNamePhase("event15", "X"); | 2199 dict = FindNamePhase("event15", "X"); |
2200 ASSERT_TRUE(dict); | 2200 ASSERT_TRUE(dict); |
2201 dict->GetDictionary("args", &args_dict); | 2201 dict->GetDictionary("args", &args_dict); |
2202 ASSERT_TRUE(args_dict); | 2202 ASSERT_TRUE(args_dict); |
2203 EXPECT_TRUE(args_dict->GetInteger("timeticks_one", &int_value)); | 2203 EXPECT_TRUE(args_dict->GetInteger("timeticks_one", &int_value)); |
2204 EXPECT_EQ(1, int_value); | 2204 EXPECT_EQ(1, int_value); |
2205 } | 2205 } |
2206 | 2206 |
| 2207 TEST_F(TraceEventTestFixture, ArgsWhitelisting) { |
| 2208 TraceOptions trace_options; |
| 2209 trace_options.enable_args_whitelist = true; |
| 2210 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), |
| 2211 TraceLog::RECORDING_MODE, trace_options); |
| 2212 |
| 2213 TRACE_EVENT1("toplevel", "event1", "int_one", 1); |
| 2214 TRACE_EVENT1("whitewashed", "event2", "int_two", 1); |
| 2215 EndTraceAndFlush(); |
| 2216 |
| 2217 const DictionaryValue* args_dict = NULL; |
| 2218 DictionaryValue* dict = NULL; |
| 2219 int int_value; |
| 2220 |
| 2221 dict = FindNamePhase("event1", "X"); |
| 2222 ASSERT_TRUE(dict); |
| 2223 dict->GetDictionary("args", &args_dict); |
| 2224 ASSERT_TRUE(args_dict); |
| 2225 EXPECT_TRUE(args_dict->GetInteger("int_one", &int_value)); |
| 2226 EXPECT_EQ(1, int_value); |
| 2227 |
| 2228 dict = FindNamePhase("event2", "X"); |
| 2229 ASSERT_TRUE(dict); |
| 2230 dict->GetDictionary("args", &args_dict); |
| 2231 ASSERT_TRUE(args_dict); |
| 2232 EXPECT_FALSE(args_dict->GetInteger("int_two", &int_value)); |
| 2233 EXPECT_TRUE(args_dict->GetInteger("stripped", &int_value)); |
| 2234 } |
| 2235 |
2207 class TraceEventCallbackTest : public TraceEventTestFixture { | 2236 class TraceEventCallbackTest : public TraceEventTestFixture { |
2208 public: | 2237 public: |
2209 void SetUp() override { | 2238 void SetUp() override { |
2210 TraceEventTestFixture::SetUp(); | 2239 TraceEventTestFixture::SetUp(); |
2211 ASSERT_EQ(NULL, s_instance); | 2240 ASSERT_EQ(NULL, s_instance); |
2212 s_instance = this; | 2241 s_instance = this; |
2213 } | 2242 } |
2214 void TearDown() override { | 2243 void TearDown() override { |
2215 TraceLog::GetInstance()->SetDisabled(); | 2244 TraceLog::GetInstance()->SetDisabled(); |
2216 ASSERT_TRUE(!!s_instance); | 2245 ASSERT_TRUE(!!s_instance); |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3074 EXPECT_EQ(original_option.record_mode, new_options.record_mode); | 3103 EXPECT_EQ(original_option.record_mode, new_options.record_mode); |
3075 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); | 3104 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); |
3076 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); | 3105 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); |
3077 } | 3106 } |
3078 } | 3107 } |
3079 } | 3108 } |
3080 } | 3109 } |
3081 | 3110 |
3082 } // namespace trace_event | 3111 } // namespace trace_event |
3083 } // namespace base | 3112 } // namespace base |
OLD | NEW |