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

Side by Side Diff: ipc/attachment_broker_privileged_mac_unittest.cc

Issue 1849343003: mac: Remove IsOSSnowLeopard(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: err Created 4 years, 8 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
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 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // Dummy port provider. 175 // Dummy port provider.
176 MockPortProvider port_provider_; 176 MockPortProvider port_provider_;
177 177
178 base::Process child_process_; 178 base::Process child_process_;
179 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerPrivilegedMacMultiProcessTest); 179 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerPrivilegedMacMultiProcessTest);
180 }; 180 };
181 181
182 // The attachment broker inserts a right for a memory object into the 182 // The attachment broker inserts a right for a memory object into the
183 // destination task. 183 // destination task.
184 TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertRight) { 184 TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertRight) {
185 // Mach-based SharedMemory isn't support on OSX 10.6.
186 if (base::mac::IsOSSnowLeopard())
187 return;
188
189 SetUpChild("InsertRightClient"); 185 SetUpChild("InsertRightClient");
190 mach_msg_type_number_t original_name_count = GetActiveNameCount(); 186 mach_msg_type_number_t original_name_count = GetActiveNameCount();
191 IPC::AttachmentBrokerPrivilegedMac broker(&port_provider_); 187 IPC::AttachmentBrokerPrivilegedMac broker(&port_provider_);
192 188
193 // Create some shared memory. 189 // Create some shared memory.
194 scoped_ptr<base::SharedMemory> shared_memory = 190 scoped_ptr<base::SharedMemory> shared_memory =
195 CreateAndPopulateSharedMemoryHandle(s_memory_size); 191 CreateAndPopulateSharedMemoryHandle(s_memory_size);
196 ASSERT_TRUE(shared_memory->handle().IsValid()); 192 ASSERT_TRUE(shared_memory->handle().IsValid());
197 193
198 // Insert the memory object into the destination task, via an intermediate 194 // Insert the memory object into the destination task, via an intermediate
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // Check that no names have been leaked. 239 // Check that no names have been leaked.
244 shared_memory.reset(); 240 shared_memory.reset();
245 EXPECT_EQ(original_name_count, GetActiveNameCount()); 241 EXPECT_EQ(original_name_count, GetActiveNameCount());
246 242
247 return 0; 243 return 0;
248 } 244 }
249 245
250 // The attachment broker inserts the right for a memory object into the 246 // The attachment broker inserts the right for a memory object into the
251 // destination task twice. 247 // destination task twice.
252 TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertSameRightTwice) { 248 TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertSameRightTwice) {
253 // Mach-based SharedMemory isn't support on OSX 10.6.
254 if (base::mac::IsOSSnowLeopard())
255 return;
256
257 SetUpChild("InsertSameRightTwiceClient"); 249 SetUpChild("InsertSameRightTwiceClient");
258 mach_msg_type_number_t original_name_count = GetActiveNameCount(); 250 mach_msg_type_number_t original_name_count = GetActiveNameCount();
259 IPC::AttachmentBrokerPrivilegedMac broker(&port_provider_); 251 IPC::AttachmentBrokerPrivilegedMac broker(&port_provider_);
260 252
261 // Create some shared memory. 253 // Create some shared memory.
262 scoped_ptr<base::SharedMemory> shared_memory = 254 scoped_ptr<base::SharedMemory> shared_memory =
263 CreateAndPopulateSharedMemoryHandle(s_memory_size); 255 CreateAndPopulateSharedMemoryHandle(s_memory_size);
264 ASSERT_TRUE(shared_memory->handle().IsValid()); 256 ASSERT_TRUE(shared_memory->handle().IsValid());
265 257
266 // Insert the memory object into the destination task, via an intermediate 258 // Insert the memory object into the destination task, via an intermediate
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // as if no names were ever inserted 332 // as if no names were ever inserted
341 shared_memory2.reset(); 333 shared_memory2.reset();
342 EXPECT_EQ(original_name_count, GetActiveNameCount()); 334 EXPECT_EQ(original_name_count, GetActiveNameCount());
343 335
344 return 0; 336 return 0;
345 } 337 }
346 338
347 // The attachment broker inserts the rights for two memory objects into the 339 // The attachment broker inserts the rights for two memory objects into the
348 // destination task. 340 // destination task.
349 TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertTwoRights) { 341 TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertTwoRights) {
350 // Mach-based SharedMemory isn't support on OSX 10.6.
351 if (base::mac::IsOSSnowLeopard())
352 return;
353
354 SetUpChild("InsertTwoRightsClient"); 342 SetUpChild("InsertTwoRightsClient");
355 mach_msg_type_number_t original_name_count = GetActiveNameCount(); 343 mach_msg_type_number_t original_name_count = GetActiveNameCount();
356 IPC::AttachmentBrokerPrivilegedMac broker(&port_provider_); 344 IPC::AttachmentBrokerPrivilegedMac broker(&port_provider_);
357 345
358 for (int i = 0; i < 2; ++i) { 346 for (int i = 0; i < 2; ++i) {
359 // Create some shared memory. 347 // Create some shared memory.
360 scoped_ptr<base::SharedMemory> shared_memory = 348 scoped_ptr<base::SharedMemory> shared_memory =
361 CreateAndPopulateSharedMemoryHandle(s_memory_size); 349 CreateAndPopulateSharedMemoryHandle(s_memory_size);
362 ASSERT_TRUE(shared_memory->handle().IsValid()); 350 ASSERT_TRUE(shared_memory->handle().IsValid());
363 351
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // After releasing one shared memory region, the name count should decrement. 418 // After releasing one shared memory region, the name count should decrement.
431 shared_memory.reset(); 419 shared_memory.reset();
432 EXPECT_EQ(original_name_count + 1, GetActiveNameCount()); 420 EXPECT_EQ(original_name_count + 1, GetActiveNameCount());
433 shared_memory2.reset(); 421 shared_memory2.reset();
434 EXPECT_EQ(original_name_count, GetActiveNameCount()); 422 EXPECT_EQ(original_name_count, GetActiveNameCount());
435 423
436 return 0; 424 return 0;
437 } 425 }
438 426
439 } // namespace IPC 427 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698