OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "app/sql/connection.h" | 7 #include "app/sql/connection.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "webkit/appcache/appcache_database.h" | 10 #include "webkit/appcache/appcache_database.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 EXPECT_EQ(0, deleteable_response_rowid); | 47 EXPECT_EQ(0, deleteable_response_rowid); |
48 | 48 |
49 std::set<GURL> origins; | 49 std::set<GURL> origins; |
50 EXPECT_TRUE(db.FindOriginsWithGroups(&origins)); | 50 EXPECT_TRUE(db.FindOriginsWithGroups(&origins)); |
51 EXPECT_TRUE(origins.empty()); | 51 EXPECT_TRUE(origins.empty()); |
52 } | 52 } |
53 | 53 |
54 TEST(AppCacheDatabaseTest, ReCreate) { | 54 TEST(AppCacheDatabaseTest, ReCreate) { |
55 // Real files on disk for this test. | 55 // Real files on disk for this test. |
56 ScopedTempDir temp_dir; | 56 ScopedTempDir temp_dir; |
57 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); | 57 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
58 const FilePath kDbFile = temp_dir.path().AppendASCII("appcache.db"); | 58 const FilePath kDbFile = temp_dir.path().AppendASCII("appcache.db"); |
59 const FilePath kNestedDir = temp_dir.path().AppendASCII("nested"); | 59 const FilePath kNestedDir = temp_dir.path().AppendASCII("nested"); |
60 const FilePath kOtherFile = kNestedDir.AppendASCII("other_file"); | 60 const FilePath kOtherFile = kNestedDir.AppendASCII("other_file"); |
61 EXPECT_TRUE(file_util::CreateDirectory(kNestedDir)); | 61 EXPECT_TRUE(file_util::CreateDirectory(kNestedDir)); |
62 EXPECT_EQ(3, file_util::WriteFile(kOtherFile, "foo", 3)); | 62 EXPECT_EQ(3, file_util::WriteFile(kOtherFile, "foo", 3)); |
63 | 63 |
64 AppCacheDatabase db(kDbFile); | 64 AppCacheDatabase db(kDbFile); |
65 EXPECT_FALSE(db.LazyOpen(false)); | 65 EXPECT_FALSE(db.LazyOpen(false)); |
66 EXPECT_TRUE(db.LazyOpen(true)); | 66 EXPECT_TRUE(db.LazyOpen(true)); |
67 | 67 |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 EXPECT_EQ(5000, db.GetOriginUsage(kOtherOrigin)); | 602 EXPECT_EQ(5000, db.GetOriginUsage(kOtherOrigin)); |
603 | 603 |
604 EXPECT_TRUE(db.FindCachesForOrigin(kOrigin, &cache_records)); | 604 EXPECT_TRUE(db.FindCachesForOrigin(kOrigin, &cache_records)); |
605 EXPECT_EQ(2U, cache_records.size()); | 605 EXPECT_EQ(2U, cache_records.size()); |
606 cache_records.clear(); | 606 cache_records.clear(); |
607 EXPECT_TRUE(db.FindCachesForOrigin(kOtherOrigin, &cache_records)); | 607 EXPECT_TRUE(db.FindCachesForOrigin(kOtherOrigin, &cache_records)); |
608 EXPECT_EQ(1U, cache_records.size()); | 608 EXPECT_EQ(1U, cache_records.size()); |
609 } | 609 } |
610 | 610 |
611 } // namespace appcache | 611 } // namespace appcache |
OLD | NEW |