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

Side by Side Diff: base/stats_table_unittest.cc

Issue 3026055: Cleanup in base. This moves the implementation (and a bunch of header file... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <process.h> 6 #include <process.h>
7 #include <windows.h> 7 #include <windows.h>
8 #endif 8 #endif
9 9
10 #include "base/multiprocess_test.h"
11 #include "base/platform_thread.h" 10 #include "base/platform_thread.h"
12 #include "base/simple_thread.h" 11 #include "base/simple_thread.h"
13 #include "base/shared_memory.h" 12 #include "base/shared_memory.h"
14 #include "base/stats_table.h" 13 #include "base/stats_table.h"
15 #include "base/stats_counters.h" 14 #include "base/stats_counters.h"
15 #include "base/string_piece.h"
16 #include "base/string_util.h"
17 #include "base/test/multiprocess_test.h"
16 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
17 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/multiprocess_func_list.h" 20 #include "testing/multiprocess_func_list.h"
19 21
20 namespace base { 22 namespace base {
21 23
22 class StatsTableTest : public MultiProcessTest { 24 class StatsTableTest : public MultiProcessTest {
23 public: 25 public:
24 void DeleteShmem(std::string name) { 26 void DeleteShmem(std::string name) {
25 base::SharedMemory mem; 27 base::SharedMemory mem;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 StatsTable::set_current(&table); 199 StatsTable::set_current(&table);
198 EXPECT_EQ(0, table.CountThreadsRegistered()); 200 EXPECT_EQ(0, table.CountThreadsRegistered());
199 201
200 // Spin up a set of processes to go bang on the various counters. 202 // Spin up a set of processes to go bang on the various counters.
201 // After we join the processes, we'll make sure the counters 203 // After we join the processes, we'll make sure the counters
202 // contain the values we expected. 204 // contain the values we expected.
203 ProcessHandle procs[kMaxProcs]; 205 ProcessHandle procs[kMaxProcs];
204 206
205 // Spawn the processes. 207 // Spawn the processes.
206 for (int16 index = 0; index < kMaxProcs; index++) { 208 for (int16 index = 0; index < kMaxProcs; index++) {
207 procs[index] = this->SpawnChild("StatsTableMultipleProcessMain"); 209 procs[index] = this->SpawnChild("StatsTableMultipleProcessMain", false);
208 EXPECT_NE(base::kNullProcessHandle, procs[index]); 210 EXPECT_NE(base::kNullProcessHandle, procs[index]);
209 } 211 }
210 212
211 // Wait for the processes to finish. 213 // Wait for the processes to finish.
212 for (int index = 0; index < kMaxProcs; index++) { 214 for (int index = 0; index < kMaxProcs; index++) {
213 EXPECT_TRUE(WaitForSingleProcess(procs[index], 60 * 1000)); 215 EXPECT_TRUE(WaitForSingleProcess(procs[index], 60 * 1000));
214 base::CloseProcessHandle(procs[index]); 216 base::CloseProcessHandle(procs[index]);
215 } 217 }
216 218
217 StatsCounter zero_counter(kCounterZero); 219 StatsCounter zero_counter(kCounterZero);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 PlatformThread::Sleep(500); 397 PlatformThread::Sleep(500);
396 } 398 }
397 EXPECT_LE(1000, table.GetCounterValue("t:foo")); 399 EXPECT_LE(1000, table.GetCounterValue("t:foo"));
398 EXPECT_LE(1000, table.GetCounterValue("t:bar")); 400 EXPECT_LE(1000, table.GetCounterValue("t:bar"));
399 EXPECT_EQ(2, table.GetCounterValue("c:bar")); 401 EXPECT_EQ(2, table.GetCounterValue("c:bar"));
400 402
401 DeleteShmem(kTableName); 403 DeleteShmem(kTableName);
402 } 404 }
403 405
404 } // namespace base 406 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698