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

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

Issue 9057001: Update Sleep() calls in base/test to use TimeDelta instead of int. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Make variable names style guide consistent. 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/test/test_file_util_win.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) 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/bind.h" 5 #include "base/bind.h"
6 #include "base/test/trace_event_analyzer.h" 6 #include "base/test/trace_event_analyzer.h"
7 #include "testing/gmock/include/gmock/gmock.h" 7 #include "testing/gmock/include/gmock/gmock.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace trace_analyzer { 10 namespace trace_analyzer {
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 analyzer->FindEvents(Query(EVENT_NAME) != Query::Pattern("name*"), &found); 382 analyzer->FindEvents(Query(EVENT_NAME) != Query::Pattern("name*"), &found);
383 ASSERT_EQ(1u, found.size()); 383 ASSERT_EQ(1u, found.size());
384 EXPECT_STREQ("no match", found[0]->name.c_str()); 384 EXPECT_STREQ("no match", found[0]->name.c_str());
385 } 385 }
386 386
387 // Test that duration queries work. 387 // Test that duration queries work.
388 TEST_F(TraceEventAnalyzerTest, Duration) { 388 TEST_F(TraceEventAnalyzerTest, Duration) {
389 using namespace trace_analyzer; 389 using namespace trace_analyzer;
390 ManualSetUp(); 390 ManualSetUp();
391 391
392 int sleep_time_us = 200000; 392 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(200);
393 // We will search for events that have a duration of greater than 90% of the 393 // We will search for events that have a duration of greater than 90% of the
394 // sleep time, so that there is no flakiness. 394 // sleep time, so that there is no flakiness.
395 int duration_cutoff_us = (sleep_time_us * 9) / 10; 395 int duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10;
396 396
397 BeginTracing(); 397 BeginTracing();
398 { 398 {
399 TRACE_EVENT0("cat1", "name1"); // found by duration query 399 TRACE_EVENT0("cat1", "name1"); // found by duration query
400 TRACE_EVENT0("noise", "name2"); // not searched for, just noise 400 TRACE_EVENT0("noise", "name2"); // not searched for, just noise
401 { 401 {
402 TRACE_EVENT0("cat2", "name3"); // found by duration query 402 TRACE_EVENT0("cat2", "name3"); // found by duration query
403 TRACE_EVENT_INSTANT0("noise", "name4"); // not searched for, just noise 403 TRACE_EVENT_INSTANT0("noise", "name4"); // not searched for, just noise
404 base::PlatformThread::Sleep(sleep_time_us / 1000); 404 base::PlatformThread::Sleep(kSleepTime);
405 TRACE_EVENT0("cat2", "name5"); // not found (duration too short) 405 TRACE_EVENT0("cat2", "name5"); // not found (duration too short)
406 } 406 }
407 } 407 }
408 EndTracing(); 408 EndTracing();
409 409
410 scoped_ptr<TraceAnalyzer> 410 scoped_ptr<TraceAnalyzer>
411 analyzer(TraceAnalyzer::Create(output_.json_output)); 411 analyzer(TraceAnalyzer::Create(output_.json_output));
412 ASSERT_TRUE(analyzer.get()); 412 ASSERT_TRUE(analyzer.get());
413 analyzer->AssociateBeginEndEvents(); 413 analyzer->AssociateBeginEndEvents();
414 414
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); 753 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true)));
754 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), 754 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true),
755 1, num_events)); 755 1, num_events));
756 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); 756 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one));
757 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); 757 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one));
758 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); 758 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named));
759 } 759 }
760 760
761 761
762 } // namespace trace_analyzer 762 } // namespace trace_analyzer
OLDNEW
« no previous file with comments | « base/test/test_file_util_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698