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/command_line.h" | 9 #include "base/command_line.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/history_unittest_base.h" | 15 #include "chrome/browser/history/history_unittest_base.h" |
16 #include "chrome/browser/history/thumbnail_database.h" | 16 #include "chrome/browser/history/thumbnail_database.h" |
17 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
19 #include "chrome/common/thumbnail_score.h" | 19 #include "chrome/common/thumbnail_score.h" |
20 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
21 #include "chrome/tools/profiles/thumbnail-inl.h" | 21 #include "chrome/tools/profiles/thumbnail-inl.h" |
| 22 #include "content/public/test/test_browser_thread_bundle.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "third_party/skia/include/core/SkBitmap.h" | 24 #include "third_party/skia/include/core/SkBitmap.h" |
24 #include "ui/gfx/codec/jpeg_codec.h" | 25 #include "ui/gfx/codec/jpeg_codec.h" |
25 #include "url/gurl.h" | 26 #include "url/gurl.h" |
26 | 27 |
27 using base::Time; | 28 using base::Time; |
28 using base::TimeDelta; | 29 using base::TimeDelta; |
29 | 30 |
30 namespace history { | 31 namespace history { |
31 | 32 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 72 |
72 scoped_ptr<SkBitmap> google_bitmap_; | 73 scoped_ptr<SkBitmap> google_bitmap_; |
73 | 74 |
74 base::ScopedTempDir temp_dir_; | 75 base::ScopedTempDir temp_dir_; |
75 base::FilePath file_name_; | 76 base::FilePath file_name_; |
76 base::FilePath new_file_name_; | 77 base::FilePath new_file_name_; |
77 base::FilePath history_db_name_; | 78 base::FilePath history_db_name_; |
78 }; | 79 }; |
79 | 80 |
80 class IconMappingMigrationTest : public HistoryUnitTestBase { | 81 class IconMappingMigrationTest : public HistoryUnitTestBase { |
81 public: | |
82 IconMappingMigrationTest() { | |
83 } | |
84 virtual ~IconMappingMigrationTest() { | |
85 } | |
86 | |
87 protected: | 82 protected: |
88 virtual void SetUp() { | 83 virtual void SetUp() { |
89 profile_.reset(new TestingProfile); | |
90 | |
91 base::FilePath data_path; | 84 base::FilePath data_path; |
92 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 85 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); |
93 data_path = data_path.AppendASCII("History"); | 86 data_path = data_path.AppendASCII("History"); |
94 | 87 |
95 history_db_name_ = profile_->GetPath().Append(chrome::kHistoryFilename); | 88 history_db_name_ = profile_.GetPath().Append(chrome::kHistoryFilename); |
96 // Set up history and thumbnails as they would be before migration. | 89 // Set up history and thumbnails as they would be before migration. |
97 ASSERT_NO_FATAL_FAILURE( | 90 ASSERT_NO_FATAL_FAILURE( |
98 ExecuteSQLScript(data_path.AppendASCII("history.20.sql"), | 91 ExecuteSQLScript(data_path.AppendASCII("history.20.sql"), |
99 history_db_name_)); | 92 history_db_name_)); |
100 thumbnail_db_name_ = | 93 thumbnail_db_name_ = |
101 profile_->GetPath().Append(chrome::kThumbnailsFilename); | 94 profile_.GetPath().Append(chrome::kThumbnailsFilename); |
102 ASSERT_NO_FATAL_FAILURE( | 95 ASSERT_NO_FATAL_FAILURE( |
103 ExecuteSQLScript(data_path.AppendASCII("thumbnails.3.sql"), | 96 ExecuteSQLScript(data_path.AppendASCII("thumbnails.3.sql"), |
104 thumbnail_db_name_)); | 97 thumbnail_db_name_)); |
105 } | 98 } |
106 | 99 |
107 protected: | 100 protected: |
108 base::FilePath history_db_name_; | 101 base::FilePath history_db_name_; |
109 base::FilePath thumbnail_db_name_; | 102 base::FilePath thumbnail_db_name_; |
110 | 103 |
111 private: | 104 private: |
112 scoped_ptr<TestingProfile> profile_; | 105 content::TestBrowserThreadBundle thread_bundle_; |
| 106 TestingProfile profile_; |
113 }; | 107 }; |
114 | 108 |
115 TEST_F(ThumbnailDatabaseTest, GetFaviconAfterMigrationToTopSites) { | 109 TEST_F(ThumbnailDatabaseTest, GetFaviconAfterMigrationToTopSites) { |
116 ThumbnailDatabase db; | 110 ThumbnailDatabase db; |
117 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_, NULL, NULL)); | 111 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_, NULL, NULL)); |
118 db.BeginTransaction(); | 112 db.BeginTransaction(); |
119 | 113 |
120 std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); | 114 std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); |
121 scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); | 115 scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); |
122 | 116 |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 EXPECT_EQ(touch_mapping_id1, icon_mapping.mapping_id); | 907 EXPECT_EQ(touch_mapping_id1, icon_mapping.mapping_id); |
914 EXPECT_EQ(url, icon_mapping.page_url); | 908 EXPECT_EQ(url, icon_mapping.page_url); |
915 EXPECT_EQ(touch_icon_id1, icon_mapping.icon_id); | 909 EXPECT_EQ(touch_icon_id1, icon_mapping.icon_id); |
916 EXPECT_EQ(icon_url1, icon_mapping.icon_url); | 910 EXPECT_EQ(icon_url1, icon_mapping.icon_url); |
917 EXPECT_EQ(chrome::TOUCH_ICON, icon_mapping.icon_type); | 911 EXPECT_EQ(chrome::TOUCH_ICON, icon_mapping.icon_type); |
918 | 912 |
919 EXPECT_FALSE(enumerator2.GetNextIconMapping(&icon_mapping)); | 913 EXPECT_FALSE(enumerator2.GetNextIconMapping(&icon_mapping)); |
920 } | 914 } |
921 | 915 |
922 } // namespace history | 916 } // namespace history |
OLD | NEW |