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

Side by Side Diff: base/test/trace_event_analyzer_unittest.cc

Issue 10828326: Fix TraceEventTestFixture flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sharing HighResSleepForTraceTest between tests Created 8 years, 4 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 | Annotate | Revision Log
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/bind.h" 5 #include "base/bind.h"
6 #include "base/debug/trace_event_unittest.h"
6 #include "base/test/trace_event_analyzer.h" 7 #include "base/test/trace_event_analyzer.h"
7 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 10
10 namespace trace_analyzer { 11 namespace trace_analyzer {
11 12
12 namespace { 13 namespace {
13 14
14 class TraceEventAnalyzerTest : public testing::Test { 15 class TraceEventAnalyzerTest : public testing::Test {
15 public: 16 public:
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // sleep time, so that there is no flakiness. 386 // sleep time, so that there is no flakiness.
386 int duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10; 387 int duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10;
387 388
388 BeginTracing(); 389 BeginTracing();
389 { 390 {
390 TRACE_EVENT0("cat1", "name1"); // found by duration query 391 TRACE_EVENT0("cat1", "name1"); // found by duration query
391 TRACE_EVENT0("noise", "name2"); // not searched for, just noise 392 TRACE_EVENT0("noise", "name2"); // not searched for, just noise
392 { 393 {
393 TRACE_EVENT0("cat2", "name3"); // found by duration query 394 TRACE_EVENT0("cat2", "name3"); // found by duration query
394 TRACE_EVENT_INSTANT0("noise", "name4"); // not searched for, just noise 395 TRACE_EVENT_INSTANT0("noise", "name4"); // not searched for, just noise
395 base::PlatformThread::Sleep(kSleepTime); 396 base::debug::HighResSleepForTraceTest(kSleepTime);
396 TRACE_EVENT0("cat2", "name5"); // not found (duration too short) 397 TRACE_EVENT0("cat2", "name5"); // not found (duration too short)
397 } 398 }
398 } 399 }
399 EndTracing(); 400 EndTracing();
400 401
401 scoped_ptr<TraceAnalyzer> 402 scoped_ptr<TraceAnalyzer>
402 analyzer(TraceAnalyzer::Create(output_.json_output)); 403 analyzer(TraceAnalyzer::Create(output_.json_output));
403 ASSERT_TRUE(analyzer.get()); 404 ASSERT_TRUE(analyzer.get());
404 analyzer->AssociateBeginEndEvents(); 405 analyzer->AssociateBeginEndEvents();
405 406
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); 819 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true)));
819 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), 820 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true),
820 1, num_events)); 821 1, num_events));
821 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); 822 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one));
822 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); 823 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one));
823 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); 824 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named));
824 } 825 }
825 826
826 827
827 } // namespace trace_analyzer 828 } // namespace trace_analyzer
OLDNEW
« base/debug/trace_event_unittest.cc ('K') | « base/debug/trace_event_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698