OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 }; | 63 }; |
64 | 64 |
65 TEST_F(ExtensionCacheTest, SizePolicy) { | 65 TEST_F(ExtensionCacheTest, SizePolicy) { |
66 settings_helper_.ReplaceProvider(chromeos::kExtensionCacheSize); | 66 settings_helper_.ReplaceProvider(chromeos::kExtensionCacheSize); |
67 settings_helper_.SetInteger(chromeos::kExtensionCacheSize, kMaxCacheSize); | 67 settings_helper_.SetInteger(chromeos::kExtensionCacheSize, kMaxCacheSize); |
68 | 68 |
69 // Create and initialize local cache. | 69 // Create and initialize local cache. |
70 const base::Time now = base::Time::Now(); | 70 const base::Time now = base::Time::Now(); |
71 base::ScopedTempDir cache_dir; | 71 base::ScopedTempDir cache_dir; |
72 ASSERT_TRUE(cache_dir.CreateUniqueTempDir()); | 72 ASSERT_TRUE(cache_dir.CreateUniqueTempDir()); |
73 const base::FilePath cache_path = cache_dir.path(); | 73 const base::FilePath cache_path = cache_dir.GetPath(); |
74 CreateFile(cache_path.Append(LocalExtensionCache::kCacheReadyFlagFileName), 0, | 74 CreateFile(cache_path.Append(LocalExtensionCache::kCacheReadyFlagFileName), 0, |
75 now); | 75 now); |
76 | 76 |
77 // The extension cache only has enough space for two of the three extensions. | 77 // The extension cache only has enough space for two of the three extensions. |
78 const base::FilePath file1 = | 78 const base::FilePath file1 = |
79 CreateExtensionFile(cache_path, kTestExtensionId1, "1.0", kExtensionSize1, | 79 CreateExtensionFile(cache_path, kTestExtensionId1, "1.0", kExtensionSize1, |
80 now - base::TimeDelta::FromSeconds(1)); | 80 now - base::TimeDelta::FromSeconds(1)); |
81 const base::FilePath file2 = | 81 const base::FilePath file2 = |
82 CreateExtensionFile(cache_path, kTestExtensionId2, "2.0", kExtensionSize2, | 82 CreateExtensionFile(cache_path, kTestExtensionId2, "2.0", kExtensionSize2, |
83 now - base::TimeDelta::FromSeconds(2)); | 83 now - base::TimeDelta::FromSeconds(2)); |
(...skipping 11 matching lines...) Expand all Loading... |
95 run_loop.reset(new base::RunLoop); | 95 run_loop.reset(new base::RunLoop); |
96 cache_impl.Shutdown(run_loop->QuitClosure()); | 96 cache_impl.Shutdown(run_loop->QuitClosure()); |
97 run_loop->Run(); | 97 run_loop->Run(); |
98 | 98 |
99 EXPECT_TRUE(base::PathExists(file1)); | 99 EXPECT_TRUE(base::PathExists(file1)); |
100 EXPECT_TRUE(base::PathExists(file2)); | 100 EXPECT_TRUE(base::PathExists(file2)); |
101 EXPECT_FALSE(base::PathExists(file3)); | 101 EXPECT_FALSE(base::PathExists(file3)); |
102 } | 102 } |
103 | 103 |
104 } // namespace extensions | 104 } // namespace extensions |
OLD | NEW |