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/stats_table.h" | 7 #include "base/stats_table.h" |
8 #include "base/stats_counters.h" | 8 #include "base/stats_counters.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
13 #include <process.h> | 13 #include <process.h> |
14 #include <windows.h> | 14 #include <windows.h> |
15 #endif | 15 #endif |
16 | 16 |
17 namespace { | 17 namespace { |
18 class StatsTableTest : public MultiProcessTest { | 18 class StatsTableTest : public MultiProcessTest { |
19 }; | 19 }; |
20 } | |
21 | 20 |
22 // Open a StatsTable and verify that we can write to each of the | 21 // Open a StatsTable and verify that we can write to each of the |
23 // locations in the table. | 22 // locations in the table. |
24 TEST_F(StatsTableTest, VerifySlots) { | 23 TEST_F(StatsTableTest, VerifySlots) { |
25 const std::wstring kTableName = L"VerifySlotsStatTable"; | 24 const std::wstring kTableName = L"VerifySlotsStatTable"; |
26 const int kMaxThreads = 1; | 25 const int kMaxThreads = 1; |
27 const int kMaxCounter = 5; | 26 const int kMaxCounter = 5; |
28 StatsTable table(kTableName, kMaxThreads, kMaxCounter); | 27 StatsTable table(kTableName, kMaxThreads, kMaxCounter); |
29 | 28 |
30 // Register a single thread. | 29 // Register a single thread. |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 { | 369 { |
371 StatsScope<StatsCounterTimer> timer(foo); | 370 StatsScope<StatsCounterTimer> timer(foo); |
372 StatsScope<StatsRate> timer2(bar); | 371 StatsScope<StatsRate> timer2(bar); |
373 PlatformThread::Sleep(500); | 372 PlatformThread::Sleep(500); |
374 } | 373 } |
375 EXPECT_LE(1000, table.GetCounterValue(L"t:foo")); | 374 EXPECT_LE(1000, table.GetCounterValue(L"t:foo")); |
376 EXPECT_LE(1000, table.GetCounterValue(L"t:bar")); | 375 EXPECT_LE(1000, table.GetCounterValue(L"t:bar")); |
377 EXPECT_EQ(2, table.GetCounterValue(L"c:bar")); | 376 EXPECT_EQ(2, table.GetCounterValue(L"c:bar")); |
378 } | 377 } |
379 | 378 |
| 379 } // namespace |
OLD | NEW |