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

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

Issue 11366109: Adding raw tracing to trace framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
« base/debug/trace_event.h ('K') | « base/debug/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/debug/trace_event_unittest.h" 5 #include "base/debug/trace_event_unittest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 TRACE_EVENT_INSTANT_ETW("TRACE_EVENT_INSTANT_ETW1 call", 5, "value"); 372 TRACE_EVENT_INSTANT_ETW("TRACE_EVENT_INSTANT_ETW1 call", 5, "value");
373 373
374 TRACE_COUNTER1("all", "TRACE_COUNTER1 call", 31415); 374 TRACE_COUNTER1("all", "TRACE_COUNTER1 call", 31415);
375 TRACE_COUNTER2("all", "TRACE_COUNTER2 call", 375 TRACE_COUNTER2("all", "TRACE_COUNTER2 call",
376 "a", 30000, 376 "a", 30000,
377 "b", 1415); 377 "b", 1415);
378 378
379 TRACE_COUNTER_ID1("all", "TRACE_COUNTER_ID1 call", 0x319009, 31415); 379 TRACE_COUNTER_ID1("all", "TRACE_COUNTER_ID1 call", 0x319009, 31415);
380 TRACE_COUNTER_ID2("all", "TRACE_COUNTER_ID2 call", 0x319009, 380 TRACE_COUNTER_ID2("all", "TRACE_COUNTER_ID2 call", 0x319009,
381 "a", 30000, "b", 1415); 381 "a", 30000, "b", 1415);
382
383 TRACE_EVENT_COPY_BEGIN_EXPLICIT0("all",
384 "TRACE_EVENT_COPY_BEGIN_EXPLICIT0 call",
385 1, 12345);
386 TRACE_EVENT_COPY_END_EXPLICIT0("all", "TRACE_EVENT_COPY_END_EXPLICIT0 call",
387 1, 23456);
382 } // Scope close causes TRACE_EVENT0 etc to send their END events. 388 } // Scope close causes TRACE_EVENT0 etc to send their END events.
383 389
384 if (task_complete_event) 390 if (task_complete_event)
385 task_complete_event->Signal(); 391 task_complete_event->Signal();
386 } 392 }
387 393
388 void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) { 394 void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) {
389 const DictionaryValue* item = NULL; 395 const DictionaryValue* item = NULL;
390 396
391 #define EXPECT_FIND_(string) \ 397 #define EXPECT_FIND_(string) \
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 EXPECT_TRUE((item && item->GetString("ph", &ph))); 597 EXPECT_TRUE((item && item->GetString("ph", &ph)));
592 EXPECT_EQ("C", ph); 598 EXPECT_EQ("C", ph);
593 599
594 int value; 600 int value;
595 EXPECT_TRUE((item && item->GetInteger("args.a", &value))); 601 EXPECT_TRUE((item && item->GetInteger("args.a", &value)));
596 EXPECT_EQ(30000, value); 602 EXPECT_EQ(30000, value);
597 603
598 EXPECT_TRUE((item && item->GetInteger("args.b", &value))); 604 EXPECT_TRUE((item && item->GetInteger("args.b", &value)));
599 EXPECT_EQ(1415, value); 605 EXPECT_EQ(1415, value);
600 } 606 }
607
608 EXPECT_FIND_("TRACE_EVENT_COPY_BEGIN_EXPLICIT0 call");
609 {
610 int val;
611 EXPECT_TRUE((item && item->GetInteger("ts", &val)));
612 EXPECT_EQ(12345, val);
613 std::string id;
614 EXPECT_TRUE((item && item->GetString("id", &id)));
615 EXPECT_EQ("1", id);
616 }
617
618 EXPECT_FIND_("TRACE_EVENT_COPY_END_EXPLICIT0 call");
619 {
620 int val;
621 EXPECT_TRUE((item && item->GetInteger("ts", &val)));
622 EXPECT_EQ(23456, val);
623 std::string id;
624 EXPECT_TRUE((item && item->GetString("id", &id)));
625 EXPECT_EQ("1", id);
626 }
601 } 627 }
602 628
603 void TraceManyInstantEvents(int thread_id, int num_events, 629 void TraceManyInstantEvents(int thread_id, int num_events,
604 WaitableEvent* task_complete_event) { 630 WaitableEvent* task_complete_event) {
605 for (int i = 0; i < num_events; i++) { 631 for (int i = 0; i < num_events; i++) {
606 TRACE_EVENT_INSTANT2("all", "multi thread event", 632 TRACE_EVENT_INSTANT2("all", "multi thread event",
607 "thread", thread_id, 633 "thread", thread_id,
608 "event", i); 634 "event", i);
609 } 635 }
610 636
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 Clear(); 1477 Clear();
1452 1478
1453 trace_buffer_.Start(); 1479 trace_buffer_.Start();
1454 trace_buffer_.AddFragment("bla1,bla2,bla3,bla4"); 1480 trace_buffer_.AddFragment("bla1,bla2,bla3,bla4");
1455 trace_buffer_.Finish(); 1481 trace_buffer_.Finish();
1456 EXPECT_STREQ(json_output_.json_output.c_str(), "[bla1,bla2,bla3,bla4]"); 1482 EXPECT_STREQ(json_output_.json_output.c_str(), "[bla1,bla2,bla3,bla4]");
1457 } 1483 }
1458 1484
1459 } // namespace debug 1485 } // namespace debug
1460 } // namespace base 1486 } // namespace base
OLDNEW
« base/debug/trace_event.h ('K') | « base/debug/trace_event_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698