| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 ASSERT_EQ(3UL, origins.size()); | 134 ASSERT_EQ(3UL, origins.size()); |
| 135 ASSERT_TRUE(origins.find(kProtectedManifestURL.GetOrigin()) != origins.end()); | 135 ASSERT_TRUE(origins.find(kProtectedManifestURL.GetOrigin()) != origins.end()); |
| 136 ASSERT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) != origins.end()); | 136 ASSERT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) != origins.end()); |
| 137 ASSERT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) != | 137 ASSERT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) != |
| 138 origins.end()); | 138 origins.end()); |
| 139 } | 139 } |
| 140 | 140 |
| 141 TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) { | 141 TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) { |
| 142 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 142 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 143 base::FilePath appcache_path = | 143 base::FilePath appcache_path = |
| 144 temp_dir_.path().Append(kTestingAppCacheDirname); | 144 temp_dir_.GetPath().Append(kTestingAppCacheDirname); |
| 145 | 145 |
| 146 // Create a ChromeAppCacheService and insert data into it | 146 // Create a ChromeAppCacheService and insert data into it |
| 147 scoped_refptr<ChromeAppCacheService> appcache_service = | 147 scoped_refptr<ChromeAppCacheService> appcache_service = |
| 148 CreateAppCacheServiceImpl(appcache_path, true); | 148 CreateAppCacheServiceImpl(appcache_path, true); |
| 149 ASSERT_TRUE(base::PathExists(appcache_path)); | 149 ASSERT_TRUE(base::PathExists(appcache_path)); |
| 150 ASSERT_TRUE(base::PathExists(appcache_path.AppendASCII("Index"))); | 150 ASSERT_TRUE(base::PathExists(appcache_path.AppendASCII("Index"))); |
| 151 InsertDataIntoAppCache(appcache_service.get()); | 151 InsertDataIntoAppCache(appcache_service.get()); |
| 152 | 152 |
| 153 // Test: delete the ChromeAppCacheService | 153 // Test: delete the ChromeAppCacheService |
| 154 appcache_service = NULL; | 154 appcache_service = NULL; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 171 origins.end()); | 171 origins.end()); |
| 172 | 172 |
| 173 // Delete and let cleanup tasks run prior to returning. | 173 // Delete and let cleanup tasks run prior to returning. |
| 174 appcache_service = NULL; | 174 appcache_service = NULL; |
| 175 base::RunLoop().RunUntilIdle(); | 175 base::RunLoop().RunUntilIdle(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 TEST_F(ChromeAppCacheServiceTest, SaveSessionState) { | 178 TEST_F(ChromeAppCacheServiceTest, SaveSessionState) { |
| 179 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 179 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 180 base::FilePath appcache_path = | 180 base::FilePath appcache_path = |
| 181 temp_dir_.path().Append(kTestingAppCacheDirname); | 181 temp_dir_.GetPath().Append(kTestingAppCacheDirname); |
| 182 | 182 |
| 183 // Create a ChromeAppCacheService and insert data into it | 183 // Create a ChromeAppCacheService and insert data into it |
| 184 scoped_refptr<ChromeAppCacheService> appcache_service = | 184 scoped_refptr<ChromeAppCacheService> appcache_service = |
| 185 CreateAppCacheServiceImpl(appcache_path, true); | 185 CreateAppCacheServiceImpl(appcache_path, true); |
| 186 ASSERT_TRUE(base::PathExists(appcache_path)); | 186 ASSERT_TRUE(base::PathExists(appcache_path)); |
| 187 ASSERT_TRUE(base::PathExists(appcache_path.AppendASCII("Index"))); | 187 ASSERT_TRUE(base::PathExists(appcache_path.AppendASCII("Index"))); |
| 188 InsertDataIntoAppCache(appcache_service.get()); | 188 InsertDataIntoAppCache(appcache_service.get()); |
| 189 | 189 |
| 190 // Save session state. This should bypass the destruction-time deletion. | 190 // Save session state. This should bypass the destruction-time deletion. |
| 191 appcache_service->set_force_keep_session_state(); | 191 appcache_service->set_force_keep_session_state(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 209 EXPECT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) != origins.end()); | 209 EXPECT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) != origins.end()); |
| 210 EXPECT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) != | 210 EXPECT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) != |
| 211 origins.end()); | 211 origins.end()); |
| 212 | 212 |
| 213 // Delete and let cleanup tasks run prior to returning. | 213 // Delete and let cleanup tasks run prior to returning. |
| 214 appcache_service = NULL; | 214 appcache_service = NULL; |
| 215 base::RunLoop().RunUntilIdle(); | 215 base::RunLoop().RunUntilIdle(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 } // namespace content | 218 } // namespace content |
| OLD | NEW |