| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/multiprocess_test.h" | 5 #include "base/multiprocess_test.h" |
| 6 #include "base/platform_thread.h" | 6 #include "base/platform_thread.h" |
| 7 #include "base/simple_thread.h" | 7 #include "base/simple_thread.h" |
| 8 #include "base/shared_memory.h" | 8 #include "base/shared_memory.h" |
| 9 #include "base/stats_table.h" | 9 #include "base/stats_table.h" |
| 10 #include "base/stats_counters.h" | 10 #include "base/stats_counters.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 foo.Set(0); | 273 foo.Set(0); |
| 274 EXPECT_EQ(0, table.GetCounterValue("c:foo")); | 274 EXPECT_EQ(0, table.GetCounterValue("c:foo")); |
| 275 foo.Set(100); | 275 foo.Set(100); |
| 276 EXPECT_EQ(100, table.GetCounterValue("c:foo")); | 276 EXPECT_EQ(100, table.GetCounterValue("c:foo")); |
| 277 foo.Set(-1); | 277 foo.Set(-1); |
| 278 EXPECT_EQ(-1, table.GetCounterValue("c:foo")); | 278 EXPECT_EQ(-1, table.GetCounterValue("c:foo")); |
| 279 foo.Set(0); | 279 foo.Set(0); |
| 280 EXPECT_EQ(0, table.GetCounterValue("c:foo")); | 280 EXPECT_EQ(0, table.GetCounterValue("c:foo")); |
| 281 | 281 |
| 282 // Test Decrement. | 282 // Test Decrement. |
| 283 foo.Decrement(1); | 283 foo.Subtract(1); |
| 284 EXPECT_EQ(-1, table.GetCounterValue("c:foo")); | 284 EXPECT_EQ(-1, table.GetCounterValue("c:foo")); |
| 285 foo.Decrement(0); | 285 foo.Subtract(0); |
| 286 EXPECT_EQ(-1, table.GetCounterValue("c:foo")); | 286 EXPECT_EQ(-1, table.GetCounterValue("c:foo")); |
| 287 foo.Decrement(-1); | 287 foo.Subtract(-1); |
| 288 EXPECT_EQ(0, table.GetCounterValue("c:foo")); | 288 EXPECT_EQ(0, table.GetCounterValue("c:foo")); |
| 289 | 289 |
| 290 DeleteShmem(kTableName); | 290 DeleteShmem(kTableName); |
| 291 } | 291 } |
| 292 | 292 |
| 293 class MockStatsCounterTimer : public StatsCounterTimer { | 293 class MockStatsCounterTimer : public StatsCounterTimer { |
| 294 public: | 294 public: |
| 295 MockStatsCounterTimer(const std::string& name) | 295 MockStatsCounterTimer(const std::string& name) |
| 296 : StatsCounterTimer(name) {} | 296 : StatsCounterTimer(name) {} |
| 297 | 297 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 PlatformThread::Sleep(500); | 394 PlatformThread::Sleep(500); |
| 395 } | 395 } |
| 396 EXPECT_LE(1000, table.GetCounterValue("t:foo")); | 396 EXPECT_LE(1000, table.GetCounterValue("t:foo")); |
| 397 EXPECT_LE(1000, table.GetCounterValue("t:bar")); | 397 EXPECT_LE(1000, table.GetCounterValue("t:bar")); |
| 398 EXPECT_EQ(2, table.GetCounterValue("c:bar")); | 398 EXPECT_EQ(2, table.GetCounterValue("c:bar")); |
| 399 | 399 |
| 400 DeleteShmem(kTableName); | 400 DeleteShmem(kTableName); |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace base | 403 } // namespace base |
| OLD | NEW |