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

Side by Side Diff: ipc/attachment_broker_privileged_mac_unittest.cc

Issue 1414603003: ipc: Move AttachmentBrokerPrivileged singleton logic into ipc/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor formatting. Created 5 years, 2 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 | « ipc/attachment_broker_privileged_mac.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ipc/attachment_broker_privileged_mac.h" 5 #include "ipc/attachment_broker_privileged_mac.h"
6 6
7 #include <mach/mach.h> 7 #include <mach/mach.h>
8 #include <mach/mach_vm.h> 8 #include <mach/mach_vm.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 base::Process child_process_; 161 base::Process child_process_;
162 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerPrivilegedMacMultiProcessTest); 162 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerPrivilegedMacMultiProcessTest);
163 }; 163 };
164 164
165 // The attachment broker inserts a right for a memory object into the 165 // The attachment broker inserts a right for a memory object into the
166 // destination task. 166 // destination task.
167 TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertRight) { 167 TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertRight) {
168 SetUpChild("InsertRightClient"); 168 SetUpChild("InsertRightClient");
169 mach_msg_type_number_t original_name_count = GetActiveNameCount(); 169 mach_msg_type_number_t original_name_count = GetActiveNameCount();
170 IPC::AttachmentBrokerPrivilegedMac broker; 170 IPC::AttachmentBrokerPrivilegedMac broker(nullptr);
171 171
172 // Create some shared memory. 172 // Create some shared memory.
173 scoped_ptr<base::SharedMemory> shared_memory = 173 scoped_ptr<base::SharedMemory> shared_memory =
174 CreateAndPopulateSharedMemoryHandle(s_memory_size); 174 CreateAndPopulateSharedMemoryHandle(s_memory_size);
175 ASSERT_TRUE(shared_memory->handle().IsValid()); 175 ASSERT_TRUE(shared_memory->handle().IsValid());
176 176
177 // Insert the memory object into the destination task, via an intermediate 177 // Insert the memory object into the destination task, via an intermediate
178 // port. 178 // port.
179 IncrementMachRefCount(shared_memory->handle().GetMemoryObject(), 179 IncrementMachRefCount(shared_memory->handle().GetMemoryObject(),
180 MACH_PORT_RIGHT_SEND); 180 MACH_PORT_RIGHT_SEND);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 EXPECT_EQ(original_name_count, GetActiveNameCount()); 223 EXPECT_EQ(original_name_count, GetActiveNameCount());
224 224
225 return 0; 225 return 0;
226 } 226 }
227 227
228 // The attachment broker inserts the right for a memory object into the 228 // The attachment broker inserts the right for a memory object into the
229 // destination task twice. 229 // destination task twice.
230 TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertSameRightTwice) { 230 TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertSameRightTwice) {
231 SetUpChild("InsertSameRightTwiceClient"); 231 SetUpChild("InsertSameRightTwiceClient");
232 mach_msg_type_number_t original_name_count = GetActiveNameCount(); 232 mach_msg_type_number_t original_name_count = GetActiveNameCount();
233 IPC::AttachmentBrokerPrivilegedMac broker; 233 IPC::AttachmentBrokerPrivilegedMac broker(nullptr);
234 234
235 // Create some shared memory. 235 // Create some shared memory.
236 scoped_ptr<base::SharedMemory> shared_memory = 236 scoped_ptr<base::SharedMemory> shared_memory =
237 CreateAndPopulateSharedMemoryHandle(s_memory_size); 237 CreateAndPopulateSharedMemoryHandle(s_memory_size);
238 ASSERT_TRUE(shared_memory->handle().IsValid()); 238 ASSERT_TRUE(shared_memory->handle().IsValid());
239 239
240 // Insert the memory object into the destination task, via an intermediate 240 // Insert the memory object into the destination task, via an intermediate
241 // port, twice. 241 // port, twice.
242 for (int i = 0; i < 2; ++i) { 242 for (int i = 0; i < 2; ++i) {
243 IncrementMachRefCount(shared_memory->handle().GetMemoryObject(), 243 IncrementMachRefCount(shared_memory->handle().GetMemoryObject(),
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 EXPECT_EQ(original_name_count, GetActiveNameCount()); 315 EXPECT_EQ(original_name_count, GetActiveNameCount());
316 316
317 return 0; 317 return 0;
318 } 318 }
319 319
320 // The attachment broker inserts the rights for two memory objects into the 320 // The attachment broker inserts the rights for two memory objects into the
321 // destination task. 321 // destination task.
322 TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertTwoRights) { 322 TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertTwoRights) {
323 SetUpChild("InsertTwoRightsClient"); 323 SetUpChild("InsertTwoRightsClient");
324 mach_msg_type_number_t original_name_count = GetActiveNameCount(); 324 mach_msg_type_number_t original_name_count = GetActiveNameCount();
325 IPC::AttachmentBrokerPrivilegedMac broker; 325 IPC::AttachmentBrokerPrivilegedMac broker(nullptr);
326 326
327 for (int i = 0; i < 2; ++i) { 327 for (int i = 0; i < 2; ++i) {
328 // Create some shared memory. 328 // Create some shared memory.
329 scoped_ptr<base::SharedMemory> shared_memory = 329 scoped_ptr<base::SharedMemory> shared_memory =
330 CreateAndPopulateSharedMemoryHandle(s_memory_size); 330 CreateAndPopulateSharedMemoryHandle(s_memory_size);
331 ASSERT_TRUE(shared_memory->handle().IsValid()); 331 ASSERT_TRUE(shared_memory->handle().IsValid());
332 332
333 // Insert the memory object into the destination task, via an intermediate 333 // Insert the memory object into the destination task, via an intermediate
334 // port. 334 // port.
335 IncrementMachRefCount(shared_memory->handle().GetMemoryObject(), 335 IncrementMachRefCount(shared_memory->handle().GetMemoryObject(),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 // After releasing one shared memory region, the name count should decrement. 398 // After releasing one shared memory region, the name count should decrement.
399 shared_memory.reset(); 399 shared_memory.reset();
400 EXPECT_EQ(original_name_count + 1, GetActiveNameCount()); 400 EXPECT_EQ(original_name_count + 1, GetActiveNameCount());
401 shared_memory2.reset(); 401 shared_memory2.reset();
402 EXPECT_EQ(original_name_count, GetActiveNameCount()); 402 EXPECT_EQ(original_name_count, GetActiveNameCount());
403 403
404 return 0; 404 return 0;
405 } 405 }
406 406
407 } // namespace IPC 407 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/attachment_broker_privileged_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698