| Index: base/debug/trace_event_unittest.cc
|
| diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
|
| index 7217b1dee839010667d3580ff752ad0ad99ff1e9..bc5470e2988c53868bb74b85dc18a4baee55e047 100644
|
| --- a/base/debug/trace_event_unittest.cc
|
| +++ b/base/debug/trace_event_unittest.cc
|
| @@ -8,6 +8,7 @@
|
| #include "base/command_line.h"
|
| #include "base/json/json_reader.h"
|
| #include "base/json/json_writer.h"
|
| +#include "base/memory/ref_counted_memory.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/process_util.h"
|
| #include "base/stringprintf.h"
|
| @@ -462,6 +463,42 @@ TEST_F(TraceEventTestFixture, DataCapturedThreshold) {
|
| EXPECT_NOT_FIND_BE_("4thresholdlong2");
|
| }
|
|
|
| +// Test that static strings are not copied.
|
| +TEST_F(TraceEventTestFixture, StaticStringVsString) {
|
| + ManualTestSetUp();
|
| + TraceLog* tracer = TraceLog::GetInstance();
|
| + // Make sure old events are flushed:
|
| + tracer->SetEnabled(false);
|
| + EXPECT_EQ(0u, tracer->GetEventsSize());
|
| +
|
| + {
|
| + // Test that string arguments are copied.
|
| + tracer->SetEnabled(true);
|
| + TRACE_EVENT2("cat", "name1",
|
| + "arg1", std::string("argval"), "arg2", std::string("argval"));
|
| + size_t num_events = tracer->GetEventsSize();
|
| + EXPECT_GT(num_events, 0u);
|
| + const TraceEvent& event = tracer->GetEventAt(num_events - 1);
|
| + EXPECT_STREQ("name1", event.name());
|
| + EXPECT_TRUE(event.parameter_copy_storage() != NULL);
|
| + EXPECT_GT(event.parameter_copy_storage()->size(), 0u);
|
| + tracer->SetEnabled(false);
|
| + }
|
| +
|
| + {
|
| + // Test that static literal string arguments are not copied.
|
| + tracer->SetEnabled(true);
|
| + TRACE_EVENT2("cat", "name2",
|
| + "arg1", "argval", "arg2", "argval");
|
| + size_t num_events = tracer->GetEventsSize();
|
| + EXPECT_GT(num_events, 0u);
|
| + const TraceEvent& event = tracer->GetEventAt(num_events - 1);
|
| + EXPECT_STREQ("name2", event.name());
|
| + EXPECT_TRUE(event.parameter_copy_storage() == NULL);
|
| + tracer->SetEnabled(false);
|
| + }
|
| +}
|
| +
|
| // Test that data sent from other threads is gathered
|
| TEST_F(TraceEventTestFixture, DataCapturedOnThread) {
|
| ManualTestSetUp();
|
| @@ -684,8 +721,8 @@ TEST_F(TraceEventTestFixture, DeepCopy) {
|
| TRACE_EVENT_COPY_BEGIN1("category", name2.c_str(),
|
| arg1.c_str(), 5);
|
| TRACE_EVENT_COPY_END2("category", name3.c_str(),
|
| - arg1.c_str(), val1.c_str(),
|
| - arg2.c_str(), val2.c_str());
|
| + arg1.c_str(), val1,
|
| + arg2.c_str(), val2);
|
|
|
| // As per NormallyNoDeepCopy, modify the strings in place.
|
| name1[0] = name2[0] = name3[0] = arg1[0] = arg2[0] = val1[0] = val2[0] = '@';
|
|
|