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

Side by Side Diff: base/trace_event/trace_event_unittest.cc

Issue 1870563002: Escape name and category of trace events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove escaping of trace event category Created 4 years, 8 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
« no previous file with comments | « base/trace_event/trace_event_impl.cc ('k') | no next file » | 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/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 2312 matching lines...) Expand 10 before | Expand all | Expand 10 after
2323 EXPECT_EQ(0, int_value); 2323 EXPECT_EQ(0, int_value);
2324 2324
2325 dict = FindNamePhase("event15", "X"); 2325 dict = FindNamePhase("event15", "X");
2326 ASSERT_TRUE(dict); 2326 ASSERT_TRUE(dict);
2327 dict->GetDictionary("args", &args_dict); 2327 dict->GetDictionary("args", &args_dict);
2328 ASSERT_TRUE(args_dict); 2328 ASSERT_TRUE(args_dict);
2329 EXPECT_TRUE(args_dict->GetInteger("timeticks_one", &int_value)); 2329 EXPECT_TRUE(args_dict->GetInteger("timeticks_one", &int_value));
2330 EXPECT_EQ(1, int_value); 2330 EXPECT_EQ(1, int_value);
2331 } 2331 }
2332 2332
2333 TEST_F(TraceEventTestFixture, NameIsEscaped) {
2334 TraceLog::GetInstance()->SetEnabled(TraceConfig(kRecordAllCategoryFilter, ""),
2335 TraceLog::RECORDING_MODE);
2336 TRACE_EVENT0("category", "name\\with\\backspaces");
2337 EndTraceAndFlush();
2338
2339 EXPECT_TRUE(FindMatchingValue("cat", "category"));
2340 EXPECT_TRUE(FindMatchingValue("name", "name\\with\\backspaces"));
2341 }
2342
2333 namespace { 2343 namespace {
2334 2344
2335 bool IsArgNameWhitelisted(const char* arg_name) { 2345 bool IsArgNameWhitelisted(const char* arg_name) {
2336 return base::MatchPattern(arg_name, "granular_arg_whitelisted"); 2346 return base::MatchPattern(arg_name, "granular_arg_whitelisted");
2337 } 2347 }
2338 2348
2339 bool IsTraceEventArgsWhitelisted(const char* category_group_name, 2349 bool IsTraceEventArgsWhitelisted(const char* category_group_name,
2340 const char* event_name, 2350 const char* event_name,
2341 ArgumentNameFilterPredicate* arg_filter) { 2351 ArgumentNameFilterPredicate* arg_filter) {
2342 if (base::MatchPattern(category_group_name, "toplevel") && 2352 if (base::MatchPattern(category_group_name, "toplevel") &&
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
3084 } 3094 }
3085 3095
3086 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { 3096 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) {
3087 const char filter[] = "DELAY(test.Delay;16;oneshot)"; 3097 const char filter[] = "DELAY(test.Delay;16;oneshot)";
3088 TraceConfig config(filter, ""); 3098 TraceConfig config(filter, "");
3089 EXPECT_EQ(filter, config.ToCategoryFilterString()); 3099 EXPECT_EQ(filter, config.ToCategoryFilterString());
3090 } 3100 }
3091 3101
3092 } // namespace trace_event 3102 } // namespace trace_event
3093 } // namespace base 3103 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698