| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 280 |
| 281 // The failed purge attempt should have updated usage time to the correct | 281 // The failed purge attempt should have updated usage time to the correct |
| 282 // value. | 282 // value. |
| 283 EXPECT_EQ(Time::FromDoubleT(5), memory1.last_known_usage()); | 283 EXPECT_EQ(Time::FromDoubleT(5), memory1.last_known_usage()); |
| 284 | 284 |
| 285 // Purge should now succeed. | 285 // Purge should now succeed. |
| 286 rv = memory1.Purge(Time::FromDoubleT(7)); | 286 rv = memory1.Purge(Time::FromDoubleT(7)); |
| 287 EXPECT_TRUE(rv); | 287 EXPECT_TRUE(rv); |
| 288 } | 288 } |
| 289 | 289 |
| 290 TEST(DiscardableSharedMemoryTest, MappedSize) { |
| 291 const uint32 kDataSize = 1024; |
| 292 |
| 293 TestDiscardableSharedMemory memory; |
| 294 bool rv = memory.CreateAndMap(kDataSize); |
| 295 ASSERT_TRUE(rv); |
| 296 |
| 297 EXPECT_LE(kDataSize, memory.mapped_size()); |
| 298 |
| 299 // Mapped size should be 0 after memory segment has been closed. |
| 300 memory.Close(); |
| 301 EXPECT_EQ(0u, memory.mapped_size()); |
| 302 } |
| 303 |
| 290 } // namespace | 304 } // namespace |
| 291 } // namespace base | 305 } // namespace base |
| OLD | NEW |