Chromium Code Reviews| Index: base/metrics/stats_table_unittest.cc |
| diff --git a/base/metrics/stats_table_unittest.cc b/base/metrics/stats_table_unittest.cc |
| index 32484a61b67f96566b19ef965737c31c2bb380c1..0d6a35361f9545635e9eefb670235fffb9033441 100644 |
| --- a/base/metrics/stats_table_unittest.cc |
| +++ b/base/metrics/stats_table_unittest.cc |
| @@ -101,7 +101,7 @@ void StatsTableThread::Run() { |
| mixed_counter.Decrement(); |
| else |
| mixed_counter.Increment(); |
| - PlatformThread::Sleep(index % 10); // short wait |
| + PlatformThread::Sleep(TimeDelta::FromMilliseconds(index % 10)); |
| } |
| } |
| @@ -180,7 +180,7 @@ MULTIPROCESS_TEST_MAIN(StatsTableMultipleProcessMain) { |
| lucky13_counter.Set(1313); |
| increment_counter.Increment(); |
| decrement_counter.Decrement(); |
| - PlatformThread::Sleep(index % 10); // short wait |
| + PlatformThread::Sleep(TimeDelta::FromMilliseconds(index % 10)); |
| } |
| return 0; |
| } |
| @@ -315,21 +315,21 @@ TEST_F(StatsTableTest, StatsCounterTimer) { |
| EXPECT_TRUE(bar.start_time().is_null()); |
| EXPECT_TRUE(bar.stop_time().is_null()); |
| - const int kRunMs = 100; |
| + const TimeDelta kRun = TimeDelta::FromMilliseconds(100); |
|
jar (doing other things)
2011/12/31 08:08:16
nit: please change the variable name kRun to kDura
|
| // Do some timing. |
| bar.Start(); |
| - PlatformThread::Sleep(kRunMs); |
| + PlatformThread::Sleep(kRun); |
| bar.Stop(); |
| EXPECT_GT(table.GetCounterValue("t:bar"), 0); |
| - EXPECT_LE(kRunMs, table.GetCounterValue("t:bar")); |
| + EXPECT_LE(kRun.InMilliseconds(), table.GetCounterValue("t:bar")); |
| // Verify that timing again is additive. |
| bar.Start(); |
| - PlatformThread::Sleep(kRunMs); |
| + PlatformThread::Sleep(kRun); |
| bar.Stop(); |
| EXPECT_GT(table.GetCounterValue("t:bar"), 0); |
| - EXPECT_LE(kRunMs * 2, table.GetCounterValue("t:bar")); |
| + EXPECT_LE(kRun.InMilliseconds() * 2, table.GetCounterValue("t:bar")); |
| } |
| // Test some basic StatsRate operations |
| @@ -348,21 +348,21 @@ TEST_F(StatsTableTest, StatsRate) { |
| EXPECT_EQ(0, table.GetCounterValue("c:baz")); |
| EXPECT_EQ(0, table.GetCounterValue("t:baz")); |
| - const int kRunMs = 100; |
| + const TimeDelta kRun = TimeDelta::FromMilliseconds(100); |
| // Do some timing. |
| baz.Start(); |
| - PlatformThread::Sleep(kRunMs); |
| + PlatformThread::Sleep(kRun); |
| baz.Stop(); |
| EXPECT_EQ(1, table.GetCounterValue("c:baz")); |
| - EXPECT_LE(kRunMs, table.GetCounterValue("t:baz")); |
| + EXPECT_LE(kRun.InMilliseconds(), table.GetCounterValue("t:baz")); |
| // Verify that timing again is additive. |
| baz.Start(); |
| - PlatformThread::Sleep(kRunMs); |
| + PlatformThread::Sleep(kRun); |
| baz.Stop(); |
| EXPECT_EQ(2, table.GetCounterValue("c:baz")); |
| - EXPECT_LE(kRunMs * 2, table.GetCounterValue("t:baz")); |
| + EXPECT_LE(kRun.InMilliseconds() * 2, table.GetCounterValue("t:baz")); |
| } |
| // Test some basic StatsScope operations |
| @@ -383,26 +383,26 @@ TEST_F(StatsTableTest, StatsScope) { |
| EXPECT_EQ(0, table.GetCounterValue("t:bar")); |
| EXPECT_EQ(0, table.GetCounterValue("c:bar")); |
| - const int kRunMs = 100; |
| + const TimeDelta kRun = TimeDelta::FromMilliseconds(100); |
| // Try a scope. |
| { |
| StatsScope<StatsCounterTimer> timer(foo); |
| StatsScope<StatsRate> timer2(bar); |
| - PlatformThread::Sleep(kRunMs); |
| + PlatformThread::Sleep(kRun); |
| } |
| - EXPECT_LE(kRunMs, table.GetCounterValue("t:foo")); |
| - EXPECT_LE(kRunMs, table.GetCounterValue("t:bar")); |
| + EXPECT_LE(kRun.InMilliseconds(), table.GetCounterValue("t:foo")); |
| + EXPECT_LE(kRun.InMilliseconds(), table.GetCounterValue("t:bar")); |
| EXPECT_EQ(1, table.GetCounterValue("c:bar")); |
| // Try a second scope. |
| { |
| StatsScope<StatsCounterTimer> timer(foo); |
| StatsScope<StatsRate> timer2(bar); |
| - PlatformThread::Sleep(kRunMs); |
| + PlatformThread::Sleep(kRun); |
| } |
| - EXPECT_LE(kRunMs * 2, table.GetCounterValue("t:foo")); |
| - EXPECT_LE(kRunMs * 2, table.GetCounterValue("t:bar")); |
| + EXPECT_LE(kRun.InMilliseconds() * 2, table.GetCounterValue("t:foo")); |
| + EXPECT_LE(kRun.InMilliseconds() * 2, table.GetCounterValue("t:bar")); |
| EXPECT_EQ(2, table.GetCounterValue("c:bar")); |
| DeleteShmem(kTableName); |