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 ASSERT_NO_FATAL_FAILURE( | 89 ASSERT_NO_FATAL_FAILURE( |
97 ExecuteSQLScript(data_path.AppendASCII("history.20.sql"), | 90 ExecuteSQLScript(data_path.AppendASCII("history.20.sql"), |
98 history_db_name_)); | 91 history_db_name_)); |
99 thumbnail_db_name_ = | 92 thumbnail_db_name_ = |
100 profile_->GetPath().Append(chrome::kFaviconsFilename); | 93 profile_.GetPath().Append(chrome::kFaviconsFilename); |
101 ASSERT_NO_FATAL_FAILURE( | 94 ASSERT_NO_FATAL_FAILURE( |
102 ExecuteSQLScript(data_path.AppendASCII("thumbnails.3.sql"), | 95 ExecuteSQLScript(data_path.AppendASCII("thumbnails.3.sql"), |
103 thumbnail_db_name_)); | 96 thumbnail_db_name_)); |
104 } | 97 } |
105 | 98 |
106 protected: | 99 protected: |
107 base::FilePath history_db_name_; | 100 base::FilePath history_db_name_; |
108 base::FilePath thumbnail_db_name_; | 101 base::FilePath thumbnail_db_name_; |
109 | 102 |
110 private: | 103 private: |
111 scoped_ptr<TestingProfile> profile_; | 104 content::TestBrowserThreadBundle thread_bundle_; |
| 105 TestingProfile profile_; |
112 }; | 106 }; |
113 | 107 |
114 TEST_F(ThumbnailDatabaseTest, AddIconMapping) { | 108 TEST_F(ThumbnailDatabaseTest, AddIconMapping) { |
115 ThumbnailDatabase db; | 109 ThumbnailDatabase db; |
116 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_, NULL, NULL)); | 110 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_, NULL, NULL)); |
117 db.BeginTransaction(); | 111 db.BeginTransaction(); |
118 | 112 |
119 std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); | 113 std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); |
120 scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); | 114 scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); |
121 | 115 |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 EXPECT_EQ(touch_mapping_id1, icon_mapping.mapping_id); | 846 EXPECT_EQ(touch_mapping_id1, icon_mapping.mapping_id); |
853 EXPECT_EQ(url, icon_mapping.page_url); | 847 EXPECT_EQ(url, icon_mapping.page_url); |
854 EXPECT_EQ(touch_icon_id1, icon_mapping.icon_id); | 848 EXPECT_EQ(touch_icon_id1, icon_mapping.icon_id); |
855 EXPECT_EQ(icon_url1, icon_mapping.icon_url); | 849 EXPECT_EQ(icon_url1, icon_mapping.icon_url); |
856 EXPECT_EQ(chrome::TOUCH_ICON, icon_mapping.icon_type); | 850 EXPECT_EQ(chrome::TOUCH_ICON, icon_mapping.icon_type); |
857 | 851 |
858 EXPECT_FALSE(enumerator2.GetNextIconMapping(&icon_mapping)); | 852 EXPECT_FALSE(enumerator2.GetNextIconMapping(&icon_mapping)); |
859 } | 853 } |
860 | 854 |
861 } // namespace history | 855 } // namespace history |
OLD | NEW |