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

Side by Side Diff: sandbox/win/src/threadpool_unittest.cc

Issue 1539423002: Revert of Switch to standard integer types in sandbox/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « sandbox/win/src/target_services.cc ('k') | sandbox/win/src/top_level_dispatcher.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 (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 <stdint.h>
6
7 #include "sandbox/win/src/win2k_threadpool.h" 5 #include "sandbox/win/src/win2k_threadpool.h"
8 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
9 7
10 void __stdcall EmptyCallBack(void*, unsigned char) { 8 void __stdcall EmptyCallBack(void*, unsigned char) {
11 } 9 }
12 10
13 void __stdcall TestCallBack(void* context, unsigned char) { 11 void __stdcall TestCallBack(void* context, unsigned char) {
14 HANDLE event = reinterpret_cast<HANDLE>(context); 12 HANDLE event = reinterpret_cast<HANDLE>(context);
15 ::SetEvent(event); 13 ::SetEvent(event);
16 } 14 }
17 15
18 namespace sandbox { 16 namespace sandbox {
19 17
20 // Test that register and unregister work, part 1. 18 // Test that register and unregister work, part 1.
21 TEST(IPCTest, ThreadPoolRegisterTest1) { 19 TEST(IPCTest, ThreadPoolRegisterTest1) {
22 Win2kThreadPool thread_pool; 20 Win2kThreadPool thread_pool;
23 21
24 EXPECT_EQ(0u, thread_pool.OutstandingWaits()); 22 EXPECT_EQ(0u, thread_pool.OutstandingWaits());
25 23
26 HANDLE event1 = ::CreateEventW(NULL, FALSE, FALSE, NULL); 24 HANDLE event1 = ::CreateEventW(NULL, FALSE, FALSE, NULL);
27 HANDLE event2 = ::CreateEventW(NULL, FALSE, FALSE, NULL); 25 HANDLE event2 = ::CreateEventW(NULL, FALSE, FALSE, NULL);
28 26
29 uint32_t context = 0; 27 uint32 context = 0;
30 EXPECT_FALSE(thread_pool.RegisterWait(0, event1, EmptyCallBack, &context)); 28 EXPECT_FALSE(thread_pool.RegisterWait(0, event1, EmptyCallBack, &context));
31 EXPECT_EQ(0u, thread_pool.OutstandingWaits()); 29 EXPECT_EQ(0u, thread_pool.OutstandingWaits());
32 30
33 EXPECT_TRUE(thread_pool.RegisterWait(this, event1, EmptyCallBack, &context)); 31 EXPECT_TRUE(thread_pool.RegisterWait(this, event1, EmptyCallBack, &context));
34 EXPECT_EQ(1u, thread_pool.OutstandingWaits()); 32 EXPECT_EQ(1u, thread_pool.OutstandingWaits());
35 EXPECT_TRUE(thread_pool.RegisterWait(this, event2, EmptyCallBack, &context)); 33 EXPECT_TRUE(thread_pool.RegisterWait(this, event2, EmptyCallBack, &context));
36 EXPECT_EQ(2u, thread_pool.OutstandingWaits()); 34 EXPECT_EQ(2u, thread_pool.OutstandingWaits());
37 35
38 EXPECT_TRUE(thread_pool.UnRegisterWaits(this)); 36 EXPECT_TRUE(thread_pool.UnRegisterWaits(this));
39 EXPECT_EQ(0u, thread_pool.OutstandingWaits()); 37 EXPECT_EQ(0u, thread_pool.OutstandingWaits());
40 38
41 EXPECT_EQ(TRUE, ::CloseHandle(event1)); 39 EXPECT_EQ(TRUE, ::CloseHandle(event1));
42 EXPECT_EQ(TRUE, ::CloseHandle(event2)); 40 EXPECT_EQ(TRUE, ::CloseHandle(event2));
43 } 41 }
44 42
45 // Test that register and unregister work, part 2. 43 // Test that register and unregister work, part 2.
46 TEST(IPCTest, ThreadPoolRegisterTest2) { 44 TEST(IPCTest, ThreadPoolRegisterTest2) {
47 Win2kThreadPool thread_pool; 45 Win2kThreadPool thread_pool;
48 46
49 HANDLE event1 = ::CreateEventW(NULL, FALSE, FALSE, NULL); 47 HANDLE event1 = ::CreateEventW(NULL, FALSE, FALSE, NULL);
50 HANDLE event2 = ::CreateEventW(NULL, FALSE, FALSE, NULL); 48 HANDLE event2 = ::CreateEventW(NULL, FALSE, FALSE, NULL);
51 49
52 uint32_t context = 0; 50 uint32 context = 0;
53 uint32_t c1 = 0; 51 uint32 c1 = 0;
54 uint32_t c2 = 0; 52 uint32 c2 = 0;
55 53
56 EXPECT_TRUE(thread_pool.RegisterWait(&c1, event1, EmptyCallBack, &context)); 54 EXPECT_TRUE(thread_pool.RegisterWait(&c1, event1, EmptyCallBack, &context));
57 EXPECT_EQ(1u, thread_pool.OutstandingWaits()); 55 EXPECT_EQ(1u, thread_pool.OutstandingWaits());
58 EXPECT_TRUE(thread_pool.RegisterWait(&c2, event2, EmptyCallBack, &context)); 56 EXPECT_TRUE(thread_pool.RegisterWait(&c2, event2, EmptyCallBack, &context));
59 EXPECT_EQ(2u, thread_pool.OutstandingWaits()); 57 EXPECT_EQ(2u, thread_pool.OutstandingWaits());
60 58
61 EXPECT_TRUE(thread_pool.UnRegisterWaits(&c2)); 59 EXPECT_TRUE(thread_pool.UnRegisterWaits(&c2));
62 EXPECT_EQ(1u, thread_pool.OutstandingWaits()); 60 EXPECT_EQ(1u, thread_pool.OutstandingWaits());
63 EXPECT_TRUE(thread_pool.UnRegisterWaits(&c2)); 61 EXPECT_TRUE(thread_pool.UnRegisterWaits(&c2));
64 EXPECT_EQ(1u, thread_pool.OutstandingWaits()); 62 EXPECT_EQ(1u, thread_pool.OutstandingWaits());
(...skipping 23 matching lines...) Expand all
88 EXPECT_EQ(0u, thread_pool.OutstandingWaits()); 86 EXPECT_EQ(0u, thread_pool.OutstandingWaits());
89 87
90 EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), 88 EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT),
91 ::SignalObjectAndWait(event1, event2, 1000, FALSE)); 89 ::SignalObjectAndWait(event1, event2, 1000, FALSE));
92 90
93 EXPECT_EQ(TRUE, ::CloseHandle(event1)); 91 EXPECT_EQ(TRUE, ::CloseHandle(event1));
94 EXPECT_EQ(TRUE, ::CloseHandle(event2)); 92 EXPECT_EQ(TRUE, ::CloseHandle(event2));
95 } 93 }
96 94
97 } // namespace sandbox 95 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/target_services.cc ('k') | sandbox/win/src/top_level_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698