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

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: 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
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, NameAndCategoryEscapedIfNeeded) {
2334 TraceLog::GetInstance()->SetEnabled(TraceConfig(kRecordAllCategoryFilter, ""),
2335 TraceLog::RECORDING_MODE);
2336 TRACE_EVENT0("category", "name\\with\\backspaces");
2337 TRACE_EVENT0("category\\with\\backspaces", "name");
2338 EndTraceAndFlush();
2339
2340 EXPECT_TRUE(FindMatchingValue("cat", "category"));
2341 EXPECT_TRUE(FindMatchingValue("name", "name\\with\\backspaces"));
2342 EXPECT_TRUE(FindMatchingValue("cat", "category\\with\\backspaces"));
2343 EXPECT_TRUE(FindMatchingValue("name", "name"));
2344 }
2345
2333 namespace { 2346 namespace {
2334 2347
2335 bool IsArgNameWhitelisted(const char* arg_name) { 2348 bool IsArgNameWhitelisted(const char* arg_name) {
2336 return base::MatchPattern(arg_name, "granular_arg_whitelisted"); 2349 return base::MatchPattern(arg_name, "granular_arg_whitelisted");
2337 } 2350 }
2338 2351
2339 bool IsTraceEventArgsWhitelisted(const char* category_group_name, 2352 bool IsTraceEventArgsWhitelisted(const char* category_group_name,
2340 const char* event_name, 2353 const char* event_name,
2341 ArgumentNameFilterPredicate* arg_filter) { 2354 ArgumentNameFilterPredicate* arg_filter) {
2342 if (base::MatchPattern(category_group_name, "toplevel") && 2355 if (base::MatchPattern(category_group_name, "toplevel") &&
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
3084 } 3097 }
3085 3098
3086 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { 3099 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) {
3087 const char filter[] = "DELAY(test.Delay;16;oneshot)"; 3100 const char filter[] = "DELAY(test.Delay;16;oneshot)";
3088 TraceConfig config(filter, ""); 3101 TraceConfig config(filter, "");
3089 EXPECT_EQ(filter, config.ToCategoryFilterString()); 3102 EXPECT_EQ(filter, config.ToCategoryFilterString());
3090 } 3103 }
3091 3104
3092 } // namespace trace_event 3105 } // namespace trace_event
3093 } // namespace base 3106 } // namespace base
OLDNEW
« base/trace_event/trace_event_impl.cc ('K') | « 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