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

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

Issue 98953002: Configure synthetic delays through TraceLog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed test failure on ios_dbg_simulator Created 6 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 | Annotate | Revision Log
« no previous file with comments | « base/debug/trace_event_synthetic_delay.cc ('k') | base/debug/trace_event_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_synthetic_delay.h" 5 #include "base/debug/trace_event_synthetic_delay.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace base { 9 namespace base {
10 namespace debug { 10 namespace debug {
11 namespace { 11 namespace {
12 12
13 const int kTargetDurationMs = 100; 13 const int kTargetDurationMs = 100;
14 // Allow some leeway in timings to make it possible to run these tests with a 14 // Allow some leeway in timings to make it possible to run these tests with a
15 // wall clock time source too. 15 // wall clock time source too.
16 const int kShortDurationMs = 10; 16 const int kShortDurationMs = 10;
17 17
18 } // namespace 18 } // namespace
19 19
20 class TraceEventSyntheticDelayTest : public testing::Test, 20 class TraceEventSyntheticDelayTest : public testing::Test,
21 public TraceEventSyntheticDelayClock { 21 public TraceEventSyntheticDelayClock {
22 public: 22 public:
23 TraceEventSyntheticDelayTest() {} 23 TraceEventSyntheticDelayTest() {}
24 virtual ~TraceEventSyntheticDelayTest() {
25 ResetTraceEventSyntheticDelays();
26 }
24 27
25 // TraceEventSyntheticDelayClock implementation. 28 // TraceEventSyntheticDelayClock implementation.
26 virtual base::TimeTicks Now() OVERRIDE { 29 virtual base::TimeTicks Now() OVERRIDE {
27 AdvanceTime(base::TimeDelta::FromMilliseconds(kShortDurationMs / 10)); 30 AdvanceTime(base::TimeDelta::FromMilliseconds(kShortDurationMs / 10));
28 return now_; 31 return now_;
29 } 32 }
30 33
31 TraceEventSyntheticDelay* ConfigureDelay(const char* name) { 34 TraceEventSyntheticDelay* ConfigureDelay(const char* name) {
32 TraceEventSyntheticDelay* delay = TraceEventSyntheticDelay::Lookup(name); 35 TraceEventSyntheticDelay* delay = TraceEventSyntheticDelay::Lookup(name);
33 delay->SetClock(this); 36 delay->SetClock(this);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 delay->EndParallel(end_times[0]); 147 delay->EndParallel(end_times[0]);
145 EXPECT_GE((Now() - start_time).InMilliseconds(), kTargetDurationMs); 148 EXPECT_GE((Now() - start_time).InMilliseconds(), kTargetDurationMs);
146 149
147 start_time = Now(); 150 start_time = Now();
148 delay->EndParallel(end_times[1]); 151 delay->EndParallel(end_times[1]);
149 EXPECT_LT((Now() - start_time).InMilliseconds(), kShortDurationMs); 152 EXPECT_LT((Now() - start_time).InMilliseconds(), kShortDurationMs);
150 } 153 }
151 154
152 } // namespace debug 155 } // namespace debug
153 } // namespace base 156 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/trace_event_synthetic_delay.cc ('k') | base/debug/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698