OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/shared_memory.h" | 5 #include "base/memory/shared_memory.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 SharedMemory memory; | 215 SharedMemory memory; |
216 ASSERT_TRUE(memory.CreateAndMapAnonymous(kDataSize)); | 216 ASSERT_TRUE(memory.CreateAndMapAnonymous(kDataSize)); |
217 char* ptr = static_cast<char*>(memory.memory()); | 217 char* ptr = static_cast<char*>(memory.memory()); |
218 ASSERT_NE(ptr, static_cast<void*>(NULL)); | 218 ASSERT_NE(ptr, static_cast<void*>(NULL)); |
219 memset(ptr, 'G', kDataSize); | 219 memset(ptr, 'G', kDataSize); |
220 | 220 |
221 memory.Close(); | 221 memory.Close(); |
222 | 222 |
223 EXPECT_EQ(ptr, memory.memory()); | 223 EXPECT_EQ(ptr, memory.memory()); |
224 EXPECT_EQ(SharedMemory::NULLHandle(), memory.handle()); | 224 EXPECT_TRUE(!memory.handle().IsValid()); |
225 | 225 |
226 for (size_t i = 0; i < kDataSize; i++) { | 226 for (size_t i = 0; i < kDataSize; i++) { |
227 EXPECT_EQ('G', ptr[i]); | 227 EXPECT_EQ('G', ptr[i]); |
228 } | 228 } |
229 | 229 |
230 memory.Unmap(); | 230 memory.Unmap(); |
231 EXPECT_EQ(nullptr, memory.memory()); | 231 EXPECT_EQ(nullptr, memory.memory()); |
232 } | 232 } |
233 | 233 |
234 #if !defined(OS_MACOSX) | 234 #if !defined(OS_MACOSX) |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 memory.Close(); | 701 memory.Close(); |
702 SharedMemoryProcessTest::CleanUp(); | 702 SharedMemoryProcessTest::CleanUp(); |
703 } | 703 } |
704 | 704 |
705 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) { | 705 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) { |
706 return SharedMemoryProcessTest::TaskTestMain(); | 706 return SharedMemoryProcessTest::TaskTestMain(); |
707 } | 707 } |
708 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 708 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
709 | 709 |
710 } // namespace base | 710 } // namespace base |
OLD | NEW |