Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/memory/discardable_shared_memory.h" | 6 #include "base/memory/discardable_shared_memory.h" |
| 7 #include "base/process/process_metrics.h" | 7 #include "base/process/process_metrics.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 bool rv = memory.CreateAndMap(kDataSize); | 304 bool rv = memory.CreateAndMap(kDataSize); |
| 305 ASSERT_TRUE(rv); | 305 ASSERT_TRUE(rv); |
| 306 | 306 |
| 307 EXPECT_LE(kDataSize, memory.mapped_size()); | 307 EXPECT_LE(kDataSize, memory.mapped_size()); |
| 308 | 308 |
| 309 // Mapped size should be 0 after memory segment has been closed. | 309 // Mapped size should be 0 after memory segment has been closed. |
| 310 memory.Close(); | 310 memory.Close(); |
| 311 EXPECT_EQ(0u, memory.mapped_size()); | 311 EXPECT_EQ(0u, memory.mapped_size()); |
| 312 } | 312 } |
| 313 | 313 |
| 314 TEST(DiscardableSharedMemoryTest, Shrink) { | |
| 315 if (!DiscardableSharedMemory::IsShrinkingSupported()) | |
|
danakj
2015/03/18 23:18:52
Do you think you could add platform #ifs here inst
reveman
2015/03/19 02:21:54
I removed IsShrinkingSupported from latest patch a
| |
| 316 return; | |
| 317 | |
| 318 const uint32 kDataSize = 1024; | |
| 319 | |
| 320 TestDiscardableSharedMemory memory; | |
| 321 bool rv = memory.CreateAndMap(kDataSize); | |
| 322 ASSERT_TRUE(rv); | |
| 323 | |
| 324 EXPECT_NE(0u, memory.mapped_size()); | |
| 325 | |
| 326 // Mapped size should be 0 after shrinking memory segment. | |
| 327 memory.Shrink(); | |
| 328 EXPECT_EQ(0u, memory.mapped_size()); | |
| 329 } | |
| 330 | |
| 314 } // namespace | 331 } // namespace |
| 315 } // namespace base | 332 } // namespace base |
| OLD | NEW |