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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
8 #include "base/port.h" | 8 #include "base/port.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 BackendBasics(); | 342 BackendBasics(); |
343 } | 343 } |
344 | 344 |
345 TEST_F(DiskCacheBackendTest, ShaderCacheBasics) { | 345 TEST_F(DiskCacheBackendTest, ShaderCacheBasics) { |
346 SetCacheType(net::SHADER_CACHE); | 346 SetCacheType(net::SHADER_CACHE); |
347 BackendBasics(); | 347 BackendBasics(); |
348 } | 348 } |
349 | 349 |
350 void DiskCacheBackendTest::BackendKeying() { | 350 void DiskCacheBackendTest::BackendKeying() { |
351 InitCache(); | 351 InitCache(); |
352 const char* kName1 = "the first key"; | 352 const char kName1[] = "the first key"; |
353 const char* kName2 = "the first Key"; | 353 const char kName2[] = "the first Key"; |
354 disk_cache::Entry *entry1, *entry2; | 354 disk_cache::Entry *entry1, *entry2; |
355 ASSERT_EQ(net::OK, CreateEntry(kName1, &entry1)); | 355 ASSERT_EQ(net::OK, CreateEntry(kName1, &entry1)); |
356 | 356 |
357 ASSERT_EQ(net::OK, CreateEntry(kName2, &entry2)); | 357 ASSERT_EQ(net::OK, CreateEntry(kName2, &entry2)); |
358 EXPECT_TRUE(entry1 != entry2) << "Case sensitive"; | 358 EXPECT_TRUE(entry1 != entry2) << "Case sensitive"; |
359 entry2->Close(); | 359 entry2->Close(); |
360 | 360 |
361 char buffer[30]; | 361 char buffer[30]; |
362 base::strlcpy(buffer, kName1, arraysize(buffer)); | 362 base::strlcpy(buffer, kName1, arraysize(buffer)); |
363 ASSERT_EQ(net::OK, OpenEntry(buffer, &entry2)); | 363 ASSERT_EQ(net::OK, OpenEntry(buffer, &entry2)); |
(...skipping 2860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3224 TEST_F(DiskCacheBackendTest, SimpleCacheAppCacheOnlyDoomAll) { | 3224 TEST_F(DiskCacheBackendTest, SimpleCacheAppCacheOnlyDoomAll) { |
3225 SetCacheType(net::APP_CACHE); | 3225 SetCacheType(net::APP_CACHE); |
3226 SetSimpleCacheMode(); | 3226 SetSimpleCacheMode(); |
3227 BackendDoomAll(); | 3227 BackendDoomAll(); |
3228 } | 3228 } |
3229 | 3229 |
3230 TEST_F(DiskCacheBackendTest, SimpleCacheOpenMissingFile) { | 3230 TEST_F(DiskCacheBackendTest, SimpleCacheOpenMissingFile) { |
3231 SetSimpleCacheMode(); | 3231 SetSimpleCacheMode(); |
3232 InitCache(); | 3232 InitCache(); |
3233 | 3233 |
3234 const char* key = "the first key"; | 3234 const char key[] = "the first key"; |
3235 disk_cache::Entry* entry = NULL; | 3235 disk_cache::Entry* entry = NULL; |
3236 | 3236 |
3237 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); | 3237 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); |
3238 ASSERT_TRUE(entry != NULL); | 3238 ASSERT_TRUE(entry != NULL); |
3239 entry->Close(); | 3239 entry->Close(); |
3240 entry = NULL; | 3240 entry = NULL; |
3241 | 3241 |
3242 // To make sure the file creation completed we need to call open again so that | 3242 // To make sure the file creation completed we need to call open again so that |
3243 // we block until it actually created the files. | 3243 // we block until it actually created the files. |
3244 ASSERT_EQ(net::OK, OpenEntry(key, &entry)); | 3244 ASSERT_EQ(net::OK, OpenEntry(key, &entry)); |
(...skipping 15 matching lines...) Expand all Loading... |
3260 base::FilePath should_be_gone_file(cache_path_.AppendASCII( | 3260 base::FilePath should_be_gone_file(cache_path_.AppendASCII( |
3261 disk_cache::simple_util::GetFilenameFromKeyAndFileIndex(key, i))); | 3261 disk_cache::simple_util::GetFilenameFromKeyAndFileIndex(key, i))); |
3262 EXPECT_FALSE(base::PathExists(should_be_gone_file)); | 3262 EXPECT_FALSE(base::PathExists(should_be_gone_file)); |
3263 } | 3263 } |
3264 } | 3264 } |
3265 | 3265 |
3266 TEST_F(DiskCacheBackendTest, SimpleCacheOpenBadFile) { | 3266 TEST_F(DiskCacheBackendTest, SimpleCacheOpenBadFile) { |
3267 SetSimpleCacheMode(); | 3267 SetSimpleCacheMode(); |
3268 InitCache(); | 3268 InitCache(); |
3269 | 3269 |
3270 const char* key = "the first key"; | 3270 const char key[] = "the first key"; |
3271 disk_cache::Entry* entry = NULL; | 3271 disk_cache::Entry* entry = NULL; |
3272 | 3272 |
3273 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); | 3273 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); |
3274 disk_cache::Entry* null = NULL; | 3274 disk_cache::Entry* null = NULL; |
3275 ASSERT_NE(null, entry); | 3275 ASSERT_NE(null, entry); |
3276 entry->Close(); | 3276 entry->Close(); |
3277 entry = NULL; | 3277 entry = NULL; |
3278 | 3278 |
3279 // To make sure the file creation completed we need to call open again so that | 3279 // To make sure the file creation completed we need to call open again so that |
3280 // we block until it actually created the files. | 3280 // we block until it actually created the files. |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3491 // after closing. | 3491 // after closing. |
3492 // NOTE: IF THIS TEST IS FLAKY THEN IT IS FAILING. See https://crbug.com/416940 | 3492 // NOTE: IF THIS TEST IS FLAKY THEN IT IS FAILING. See https://crbug.com/416940 |
3493 TEST_F(DiskCacheBackendTest, SimpleCacheDeleteQuickly) { | 3493 TEST_F(DiskCacheBackendTest, SimpleCacheDeleteQuickly) { |
3494 SetSimpleCacheMode(); | 3494 SetSimpleCacheMode(); |
3495 for (int i = 0; i < 100; ++i) { | 3495 for (int i = 0; i < 100; ++i) { |
3496 InitCache(); | 3496 InitCache(); |
3497 cache_.reset(); | 3497 cache_.reset(); |
3498 EXPECT_TRUE(CleanupCacheDir()); | 3498 EXPECT_TRUE(CleanupCacheDir()); |
3499 } | 3499 } |
3500 } | 3500 } |
OLD | NEW |