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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "chrome/browser/history/history_database.h" | 14 #include "chrome/browser/history/history_database.h" |
15 #include "chrome/browser/history/thumbnail_database.h" | 15 #include "chrome/browser/history/thumbnail_database.h" |
16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
19 #include "sql/connection.h" | 19 #include "sql/connection.h" |
| 20 #include "sql/recovery.h" // For FullRecoverySupported(). |
20 #include "sql/statement.h" | 21 #include "sql/statement.h" |
21 #include "sql/test/scoped_error_ignorer.h" | 22 #include "sql/test/scoped_error_ignorer.h" |
22 #include "sql/test/test_helpers.h" | 23 #include "sql/test/test_helpers.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "third_party/sqlite/sqlite3.h" | 25 #include "third_party/sqlite/sqlite3.h" |
25 #include "url/gurl.h" | 26 #include "url/gurl.h" |
26 | 27 |
27 namespace history { | 28 namespace history { |
28 | 29 |
29 namespace { | 30 namespace { |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); | 833 kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); |
833 EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl2, chrome::FAVICON, | 834 EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl2, chrome::FAVICON, |
834 kIconUrl2, kLargeSize, sizeof(kBlob2), kBlob2)); | 835 kIconUrl2, kLargeSize, sizeof(kBlob2), kBlob2)); |
835 EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl3, chrome::FAVICON, | 836 EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl3, chrome::FAVICON, |
836 kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); | 837 kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); |
837 EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl3, chrome::TOUCH_ICON, | 838 EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl3, chrome::TOUCH_ICON, |
838 kIconUrl3, kLargeSize, sizeof(kBlob2), kBlob2)); | 839 kIconUrl3, kLargeSize, sizeof(kBlob2), kBlob2)); |
839 } | 840 } |
840 | 841 |
841 TEST_F(ThumbnailDatabaseTest, Recovery) { | 842 TEST_F(ThumbnailDatabaseTest, Recovery) { |
| 843 // This code tests the recovery module in concert with Chromium's |
| 844 // custom recover virtual table. Under USE_SYSTEM_SQLITE, this is |
| 845 // not available. This is detected dynamically because corrupt |
| 846 // databases still need to be handled, perhaps by Raze(), and the |
| 847 // recovery module is an obvious layer to abstract that to. |
| 848 // TODO(shess): Handle that case for real! |
| 849 if (!sql::Recovery::FullRecoverySupported()) |
| 850 return; |
| 851 |
842 chrome::FaviconID id1, id2; | 852 chrome::FaviconID id1, id2; |
843 GURL page_url1("http://www.google.com"); | 853 GURL page_url1("http://www.google.com"); |
844 GURL page_url2("http://news.google.com"); | 854 GURL page_url2("http://news.google.com"); |
845 GURL favicon_url("http://www.google.com/favicon.png"); | 855 GURL favicon_url("http://www.google.com/favicon.png"); |
846 | 856 |
847 // Create an example database. | 857 // Create an example database. |
848 // TODO(shess): Merge with the load-dump code when that lands. | 858 // TODO(shess): Merge with the load-dump code when that lands. |
849 { | 859 { |
850 ThumbnailDatabase db; | 860 ThumbnailDatabase db; |
851 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_, NULL)); | 861 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_, NULL)); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 | 1008 |
999 EXPECT_TRUE(db.GetIconMappingsForPageURL(page_url1, &icon_mappings)); | 1009 EXPECT_TRUE(db.GetIconMappingsForPageURL(page_url1, &icon_mappings)); |
1000 ASSERT_EQ(2u, icon_mappings.size()); | 1010 ASSERT_EQ(2u, icon_mappings.size()); |
1001 EXPECT_EQ(id1, icon_mappings[0].icon_id); | 1011 EXPECT_EQ(id1, icon_mappings[0].icon_id); |
1002 EXPECT_EQ(id2, icon_mappings[1].icon_id); | 1012 EXPECT_EQ(id2, icon_mappings[1].icon_id); |
1003 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); | 1013 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); |
1004 } | 1014 } |
1005 } | 1015 } |
1006 | 1016 |
1007 } // namespace history | 1017 } // namespace history |
OLD | NEW |