| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/discardable_memory.h" | 5 #include "base/memory/discardable_memory.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 const size_t kSize = 1024; | 32 const size_t kSize = 1024; |
| 33 | 33 |
| 34 TEST_P(DiscardableMemoryTest, IsNamed) { | 34 TEST_P(DiscardableMemoryTest, IsNamed) { |
| 35 std::string type_name(DiscardableMemory::GetTypeName(GetParam())); | 35 std::string type_name(DiscardableMemory::GetTypeName(GetParam())); |
| 36 EXPECT_NE("unknown", type_name); | 36 EXPECT_NE("unknown", type_name); |
| 37 EXPECT_EQ(GetParam(), DiscardableMemory::GetNamedType(type_name)); | 37 EXPECT_EQ(GetParam(), DiscardableMemory::GetNamedType(type_name)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool IsNativeType(DiscardableMemoryType type) { | 40 bool IsNativeType(DiscardableMemoryType type) { |
| 41 return | |
| 42 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) |
| 43 // SHMEM is backed by native discardable memory on Android. | 42 // SHMEM is backed by native discardable memory on Android. |
| 44 type == DISCARDABLE_MEMORY_TYPE_SHMEM || | 43 return type == DISCARDABLE_MEMORY_TYPE_SHMEM; |
| 44 #else |
| 45 return false; |
| 45 #endif | 46 #endif |
| 46 type == DISCARDABLE_MEMORY_TYPE_MACH; | |
| 47 } | 47 } |
| 48 | 48 |
| 49 TEST_P(DiscardableMemoryTest, SupportedNatively) { | 49 TEST_P(DiscardableMemoryTest, SupportedNatively) { |
| 50 std::vector<DiscardableMemoryType> supported_types; | 50 std::vector<DiscardableMemoryType> supported_types; |
| 51 DiscardableMemory::GetSupportedTypes(&supported_types); | 51 DiscardableMemory::GetSupportedTypes(&supported_types); |
| 52 #if defined(DISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY) | 52 #if defined(DISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY) |
| 53 EXPECT_NE(0, std::count_if(supported_types.begin(), | 53 EXPECT_NE(0, std::count_if(supported_types.begin(), |
| 54 supported_types.end(), | 54 supported_types.end(), |
| 55 IsNativeType)); | 55 IsNativeType)); |
| 56 #else | 56 #else |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return supported_types; | 123 return supported_types; |
| 124 } | 124 } |
| 125 | 125 |
| 126 INSTANTIATE_TEST_CASE_P( | 126 INSTANTIATE_TEST_CASE_P( |
| 127 DiscardableMemoryTests, | 127 DiscardableMemoryTests, |
| 128 DiscardableMemoryTest, | 128 DiscardableMemoryTest, |
| 129 ::testing::ValuesIn(GetSupportedDiscardableMemoryTypes())); | 129 ::testing::ValuesIn(GetSupportedDiscardableMemoryTypes())); |
| 130 | 130 |
| 131 } // namespace | 131 } // namespace |
| 132 } // namespace base | 132 } // namespace base |
| OLD | NEW |