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

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

Issue 9055001: Change code in base (primarily unit tests) to use Sleep(TimeDelta). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Qualify windows Sleep calls to go through PlatformThread. Created 8 years, 11 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/debug/debugger_posix.cc ('k') | base/file_util_unittest.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "base/debug/trace_event.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/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 TraceLog::GetInstance()->SetEnabled(true); 622 TraceLog::GetInstance()->SetEnabled(true);
623 623
624 // Test that events at the same level are properly filtered by threshold. 624 // Test that events at the same level are properly filtered by threshold.
625 { 625 {
626 TRACE_EVENT_IF_LONGER_THAN0(100, "time", "threshold 100"); 626 TRACE_EVENT_IF_LONGER_THAN0(100, "time", "threshold 100");
627 TRACE_EVENT_IF_LONGER_THAN0(1000, "time", "threshold 1000"); 627 TRACE_EVENT_IF_LONGER_THAN0(1000, "time", "threshold 1000");
628 TRACE_EVENT_IF_LONGER_THAN0(10000, "time", "threshold 10000"); 628 TRACE_EVENT_IF_LONGER_THAN0(10000, "time", "threshold 10000");
629 // 100+ seconds to avoid flakiness. 629 // 100+ seconds to avoid flakiness.
630 TRACE_EVENT_IF_LONGER_THAN0(100000000, "time", "threshold long1"); 630 TRACE_EVENT_IF_LONGER_THAN0(100000000, "time", "threshold long1");
631 TRACE_EVENT_IF_LONGER_THAN0(200000000, "time", "threshold long2"); 631 TRACE_EVENT_IF_LONGER_THAN0(200000000, "time", "threshold long2");
632 base::PlatformThread::Sleep(20); // 20000 us 632 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20));
633 } 633 }
634 634
635 // Test that a normal nested event remains after it's parent event is dropped. 635 // Test that a normal nested event remains after it's parent event is dropped.
636 { 636 {
637 TRACE_EVENT_IF_LONGER_THAN0(1000000, "time", "2threshold10000"); 637 TRACE_EVENT_IF_LONGER_THAN0(1000000, "time", "2threshold10000");
638 { 638 {
639 TRACE_EVENT0("time", "nonthreshold1"); 639 TRACE_EVENT0("time", "nonthreshold1");
640 } 640 }
641 } 641 }
642 642
643 // Test that parent thresholded events are dropped while some nested events 643 // Test that parent thresholded events are dropped while some nested events
644 // remain. 644 // remain.
645 { 645 {
646 TRACE_EVENT0("time", "nonthreshold3"); 646 TRACE_EVENT0("time", "nonthreshold3");
647 { 647 {
648 TRACE_EVENT_IF_LONGER_THAN0(200000000, "time", "3thresholdlong2"); 648 TRACE_EVENT_IF_LONGER_THAN0(200000000, "time", "3thresholdlong2");
649 { 649 {
650 TRACE_EVENT_IF_LONGER_THAN0(100000000, "time", "3thresholdlong1"); 650 TRACE_EVENT_IF_LONGER_THAN0(100000000, "time", "3thresholdlong1");
651 { 651 {
652 TRACE_EVENT_IF_LONGER_THAN0(10000, "time", "3threshold10000"); 652 TRACE_EVENT_IF_LONGER_THAN0(10000, "time", "3threshold10000");
653 { 653 {
654 TRACE_EVENT_IF_LONGER_THAN0(1000, "time", "3threshold1000"); 654 TRACE_EVENT_IF_LONGER_THAN0(1000, "time", "3threshold1000");
655 { 655 {
656 TRACE_EVENT_IF_LONGER_THAN0(100, "time", "3threshold100"); 656 TRACE_EVENT_IF_LONGER_THAN0(100, "time", "3threshold100");
657 base::PlatformThread::Sleep(20); 657 base::PlatformThread::Sleep(
658 base::TimeDelta::FromMilliseconds(20));
658 } 659 }
659 } 660 }
660 } 661 }
661 } 662 }
662 } 663 }
663 } 664 }
664 665
665 // Test that child thresholded events are dropped while some parent events 666 // Test that child thresholded events are dropped while some parent events
666 // remain. 667 // remain.
667 { 668 {
668 TRACE_EVENT0("time", "nonthreshold4"); 669 TRACE_EVENT0("time", "nonthreshold4");
669 { 670 {
670 TRACE_EVENT_IF_LONGER_THAN0(100, "time", "4threshold100"); 671 TRACE_EVENT_IF_LONGER_THAN0(100, "time", "4threshold100");
671 { 672 {
672 TRACE_EVENT_IF_LONGER_THAN0(1000, "time", "4threshold1000"); 673 TRACE_EVENT_IF_LONGER_THAN0(1000, "time", "4threshold1000");
673 { 674 {
674 TRACE_EVENT_IF_LONGER_THAN0(10000, "time", "4threshold10000"); 675 TRACE_EVENT_IF_LONGER_THAN0(10000, "time", "4threshold10000");
675 { 676 {
676 TRACE_EVENT_IF_LONGER_THAN0(100000000, "time", 677 TRACE_EVENT_IF_LONGER_THAN0(100000000, "time",
677 "4thresholdlong1"); 678 "4thresholdlong1");
678 { 679 {
679 TRACE_EVENT_IF_LONGER_THAN0(200000000, "time", 680 TRACE_EVENT_IF_LONGER_THAN0(200000000, "time",
680 "4thresholdlong2"); 681 "4thresholdlong2");
681 base::PlatformThread::Sleep(20); 682 base::PlatformThread::Sleep(
683 base::TimeDelta::FromMilliseconds(20));
682 } 684 }
683 } 685 }
684 } 686 }
685 } 687 }
686 } 688 }
687 } 689 }
688 690
689 TraceLog::GetInstance()->SetEnabled(false); 691 TraceLog::GetInstance()->SetEnabled(false);
690 692
691 #define EXPECT_FIND_BE_(str) \ 693 #define EXPECT_FIND_BE_(str) \
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 Clear(); 1148 Clear();
1147 1149
1148 trace_buffer_.Start(); 1150 trace_buffer_.Start();
1149 trace_buffer_.AddFragment("bla1,bla2,bla3,bla4"); 1151 trace_buffer_.AddFragment("bla1,bla2,bla3,bla4");
1150 trace_buffer_.Finish(); 1152 trace_buffer_.Finish();
1151 EXPECT_STREQ(json_output_.json_output.c_str(), "[bla1,bla2,bla3,bla4]"); 1153 EXPECT_STREQ(json_output_.json_output.c_str(), "[bla1,bla2,bla3,bla4]");
1152 } 1154 }
1153 1155
1154 } // namespace debug 1156 } // namespace debug
1155 } // namespace base 1157 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/debugger_posix.cc ('k') | base/file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698