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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "sql/connection.h" | 10 #include "sql/connection.h" |
11 #include "sql/meta_table.h" | 11 #include "sql/meta_table.h" |
12 #include "sql/statement.h" | 12 #include "sql/statement.h" |
13 #include "sql/transaction.h" | 13 #include "sql/transaction.h" |
14 #include "webkit/appcache/appcache_database.h" | 14 #include "webkit/appcache/appcache_database.h" |
15 #include "webkit/appcache/appcache_entry.h" | 15 #include "webkit/appcache/appcache_entry.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 EXPECT_EQ(0, response_id); | 56 EXPECT_EQ(0, response_id); |
57 EXPECT_EQ(0, deleteable_response_rowid); | 57 EXPECT_EQ(0, deleteable_response_rowid); |
58 | 58 |
59 std::set<GURL> origins; | 59 std::set<GURL> origins; |
60 EXPECT_TRUE(db.FindOriginsWithGroups(&origins)); | 60 EXPECT_TRUE(db.FindOriginsWithGroups(&origins)); |
61 EXPECT_TRUE(origins.empty()); | 61 EXPECT_TRUE(origins.empty()); |
62 } | 62 } |
63 | 63 |
64 TEST(AppCacheDatabaseTest, ReCreate) { | 64 TEST(AppCacheDatabaseTest, ReCreate) { |
65 // Real files on disk for this test. | 65 // Real files on disk for this test. |
66 ScopedTempDir temp_dir; | 66 base::ScopedTempDir temp_dir; |
67 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 67 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
68 const FilePath kDbFile = temp_dir.path().AppendASCII("appcache.db"); | 68 const FilePath kDbFile = temp_dir.path().AppendASCII("appcache.db"); |
69 const FilePath kNestedDir = temp_dir.path().AppendASCII("nested"); | 69 const FilePath kNestedDir = temp_dir.path().AppendASCII("nested"); |
70 const FilePath kOtherFile = kNestedDir.AppendASCII("other_file"); | 70 const FilePath kOtherFile = kNestedDir.AppendASCII("other_file"); |
71 EXPECT_TRUE(file_util::CreateDirectory(kNestedDir)); | 71 EXPECT_TRUE(file_util::CreateDirectory(kNestedDir)); |
72 EXPECT_EQ(3, file_util::WriteFile(kOtherFile, "foo", 3)); | 72 EXPECT_EQ(3, file_util::WriteFile(kOtherFile, "foo", 3)); |
73 | 73 |
74 AppCacheDatabase db(kDbFile); | 74 AppCacheDatabase db(kDbFile); |
75 EXPECT_FALSE(db.LazyOpen(false)); | 75 EXPECT_FALSE(db.LazyOpen(false)); |
76 EXPECT_TRUE(db.LazyOpen(true)); | 76 EXPECT_TRUE(db.LazyOpen(true)); |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 | 612 |
613 std::map<GURL, int64> usage_map; | 613 std::map<GURL, int64> usage_map; |
614 EXPECT_TRUE(db.GetAllOriginUsage(&usage_map)); | 614 EXPECT_TRUE(db.GetAllOriginUsage(&usage_map)); |
615 EXPECT_EQ(2U, usage_map.size()); | 615 EXPECT_EQ(2U, usage_map.size()); |
616 EXPECT_EQ(1100, usage_map[kOrigin]); | 616 EXPECT_EQ(1100, usage_map[kOrigin]); |
617 EXPECT_EQ(5000, usage_map[kOtherOrigin]); | 617 EXPECT_EQ(5000, usage_map[kOtherOrigin]); |
618 } | 618 } |
619 | 619 |
620 TEST(AppCacheDatabaseTest, UpgradeSchema3to4) { | 620 TEST(AppCacheDatabaseTest, UpgradeSchema3to4) { |
621 // Real file on disk for this test. | 621 // Real file on disk for this test. |
622 ScopedTempDir temp_dir; | 622 base::ScopedTempDir temp_dir; |
623 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 623 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
624 const FilePath kDbFile = temp_dir.path().AppendASCII("upgrade.db"); | 624 const FilePath kDbFile = temp_dir.path().AppendASCII("upgrade.db"); |
625 | 625 |
626 const GURL kMockOrigin("http://mockorigin/"); | 626 const GURL kMockOrigin("http://mockorigin/"); |
627 const char kNamespaceUrlFormat[] = "namespace%d"; | 627 const char kNamespaceUrlFormat[] = "namespace%d"; |
628 const char kTargetUrlFormat[] = "target%d"; | 628 const char kTargetUrlFormat[] = "target%d"; |
629 const int kNumNamespaces = 10; | 629 const int kNumNamespaces = 10; |
630 | 630 |
631 // Create a v3 schema based database containing some fallback records. | 631 // Create a v3 schema based database containing some fallback records. |
632 { | 632 { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 | 827 |
828 EXPECT_EQ(i, fallbacks[i].cache_id); | 828 EXPECT_EQ(i, fallbacks[i].cache_id); |
829 EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[i].type); | 829 EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[i].type); |
830 EXPECT_EQ(kMockOrigin, fallbacks[i].origin); | 830 EXPECT_EQ(kMockOrigin, fallbacks[i].origin); |
831 EXPECT_EQ(expected_namespace_url, fallbacks[i].namespace_url); | 831 EXPECT_EQ(expected_namespace_url, fallbacks[i].namespace_url); |
832 EXPECT_EQ(expected_target_url, fallbacks[i].target_url); | 832 EXPECT_EQ(expected_target_url, fallbacks[i].target_url); |
833 } | 833 } |
834 } | 834 } |
835 | 835 |
836 } // namespace appcache | 836 } // namespace appcache |
OLD | NEW |