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

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

Issue 734063004: Update from https://crrev.com/304418 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/debug/trace_event_impl.cc ('k') | base/metrics/histogram.h » ('j') | 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/debug/trace_event_unittest.h" 5 #include "base/debug/trace_event_unittest.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <cstdlib> 8 #include <cstdlib>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 ASSERT_TRUE(value->GetAsString(&async_end_id_str)); 1359 ASSERT_TRUE(value->GetAsString(&async_end_id_str));
1360 1360
1361 EXPECT_STREQ(async_begin_id_str.c_str(), async_begin2_id_str.c_str()); 1361 EXPECT_STREQ(async_begin_id_str.c_str(), async_begin2_id_str.c_str());
1362 EXPECT_STRNE(async_begin_id_str.c_str(), async_end_id_str.c_str()); 1362 EXPECT_STRNE(async_begin_id_str.c_str(), async_end_id_str.c_str());
1363 } 1363 }
1364 1364
1365 // Test that static strings are not copied. 1365 // Test that static strings are not copied.
1366 TEST_F(TraceEventTestFixture, StaticStringVsString) { 1366 TEST_F(TraceEventTestFixture, StaticStringVsString) {
1367 TraceLog* tracer = TraceLog::GetInstance(); 1367 TraceLog* tracer = TraceLog::GetInstance();
1368 // Make sure old events are flushed: 1368 // Make sure old events are flushed:
1369 EndTraceAndFlush(); 1369 EXPECT_EQ(0u, tracer->GetStatus().event_count);
1370 EXPECT_EQ(0u, tracer->GetEventsSize());
1371 const unsigned char* category_group_enabled = 1370 const unsigned char* category_group_enabled =
1372 TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED("cat"); 1371 TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED("cat");
1373 1372
1374 { 1373 {
1375 BeginTrace(); 1374 BeginTrace();
1376 // Test that string arguments are copied. 1375 // Test that string arguments are copied.
1377 TraceEventHandle handle1 = 1376 TraceEventHandle handle1 =
1378 trace_event_internal::AddTraceEvent( 1377 trace_event_internal::AddTraceEvent(
1379 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name1", 0, 0, 1378 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name1", 0, 0,
1380 "arg1", std::string("argval"), "arg2", std::string("argval")); 1379 "arg1", std::string("argval"), "arg2", std::string("argval"));
1381 // Test that static TRACE_STR_COPY string arguments are copied. 1380 // Test that static TRACE_STR_COPY string arguments are copied.
1382 TraceEventHandle handle2 = 1381 TraceEventHandle handle2 =
1383 trace_event_internal::AddTraceEvent( 1382 trace_event_internal::AddTraceEvent(
1384 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name2", 0, 0, 1383 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name2", 0, 0,
1385 "arg1", TRACE_STR_COPY("argval"), 1384 "arg1", TRACE_STR_COPY("argval"),
1386 "arg2", TRACE_STR_COPY("argval")); 1385 "arg2", TRACE_STR_COPY("argval"));
1387 size_t num_events = tracer->GetEventsSize(); 1386 EXPECT_GT(tracer->GetStatus().event_count, 1u);
1388 EXPECT_GT(num_events, 1u);
1389 const TraceEvent* event1 = tracer->GetEventByHandle(handle1); 1387 const TraceEvent* event1 = tracer->GetEventByHandle(handle1);
1390 const TraceEvent* event2 = tracer->GetEventByHandle(handle2); 1388 const TraceEvent* event2 = tracer->GetEventByHandle(handle2);
1391 ASSERT_TRUE(event1); 1389 ASSERT_TRUE(event1);
1392 ASSERT_TRUE(event2); 1390 ASSERT_TRUE(event2);
1393 EXPECT_STREQ("name1", event1->name()); 1391 EXPECT_STREQ("name1", event1->name());
1394 EXPECT_STREQ("name2", event2->name()); 1392 EXPECT_STREQ("name2", event2->name());
1395 EXPECT_TRUE(event1->parameter_copy_storage() != NULL); 1393 EXPECT_TRUE(event1->parameter_copy_storage() != NULL);
1396 EXPECT_TRUE(event2->parameter_copy_storage() != NULL); 1394 EXPECT_TRUE(event2->parameter_copy_storage() != NULL);
1397 EXPECT_GT(event1->parameter_copy_storage()->size(), 0u); 1395 EXPECT_GT(event1->parameter_copy_storage()->size(), 0u);
1398 EXPECT_GT(event2->parameter_copy_storage()->size(), 0u); 1396 EXPECT_GT(event2->parameter_copy_storage()->size(), 0u);
1399 EndTraceAndFlush(); 1397 EndTraceAndFlush();
1400 } 1398 }
1401 1399
1402 { 1400 {
1403 BeginTrace(); 1401 BeginTrace();
1404 // Test that static literal string arguments are not copied. 1402 // Test that static literal string arguments are not copied.
1405 TraceEventHandle handle1 = 1403 TraceEventHandle handle1 =
1406 trace_event_internal::AddTraceEvent( 1404 trace_event_internal::AddTraceEvent(
1407 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name1", 0, 0, 1405 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name1", 0, 0,
1408 "arg1", "argval", "arg2", "argval"); 1406 "arg1", "argval", "arg2", "argval");
1409 // Test that static TRACE_STR_COPY NULL string arguments are not copied. 1407 // Test that static TRACE_STR_COPY NULL string arguments are not copied.
1410 const char* str1 = NULL; 1408 const char* str1 = NULL;
1411 const char* str2 = NULL; 1409 const char* str2 = NULL;
1412 TraceEventHandle handle2 = 1410 TraceEventHandle handle2 =
1413 trace_event_internal::AddTraceEvent( 1411 trace_event_internal::AddTraceEvent(
1414 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name2", 0, 0, 1412 TRACE_EVENT_PHASE_INSTANT, category_group_enabled, "name2", 0, 0,
1415 "arg1", TRACE_STR_COPY(str1), 1413 "arg1", TRACE_STR_COPY(str1),
1416 "arg2", TRACE_STR_COPY(str2)); 1414 "arg2", TRACE_STR_COPY(str2));
1417 size_t num_events = tracer->GetEventsSize(); 1415 EXPECT_GT(tracer->GetStatus().event_count, 1u);
1418 EXPECT_GT(num_events, 1u);
1419 const TraceEvent* event1 = tracer->GetEventByHandle(handle1); 1416 const TraceEvent* event1 = tracer->GetEventByHandle(handle1);
1420 const TraceEvent* event2 = tracer->GetEventByHandle(handle2); 1417 const TraceEvent* event2 = tracer->GetEventByHandle(handle2);
1421 ASSERT_TRUE(event1); 1418 ASSERT_TRUE(event1);
1422 ASSERT_TRUE(event2); 1419 ASSERT_TRUE(event2);
1423 EXPECT_STREQ("name1", event1->name()); 1420 EXPECT_STREQ("name1", event1->name());
1424 EXPECT_STREQ("name2", event2->name()); 1421 EXPECT_STREQ("name2", event2->name());
1425 EXPECT_TRUE(event1->parameter_copy_storage() == NULL); 1422 EXPECT_TRUE(event1->parameter_copy_storage() == NULL);
1426 EXPECT_TRUE(event2->parameter_copy_storage() == NULL); 1423 EXPECT_TRUE(event2->parameter_copy_storage() == NULL);
1427 EndTraceAndFlush(); 1424 EndTraceAndFlush();
1428 } 1425 }
(...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after
3071 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); 3068 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling);
3072 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); 3069 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace);
3073 } 3070 }
3074 } 3071 }
3075 } 3072 }
3076 } 3073 }
3077 3074
3078 3075
3079 } // namespace debug 3076 } // namespace debug
3080 } // namespace base 3077 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | base/metrics/histogram.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698