| 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/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 // Favicon bitmaps do not need to be in particular order. | 161 // Favicon bitmaps do not need to be in particular order. |
| 162 if (favicon_bitmap1.bitmap_id == bitmap2_id) { | 162 if (favicon_bitmap1.bitmap_id == bitmap2_id) { |
| 163 FaviconBitmap tmp_favicon_bitmap = favicon_bitmap1; | 163 FaviconBitmap tmp_favicon_bitmap = favicon_bitmap1; |
| 164 favicon_bitmap1 = favicon_bitmap2; | 164 favicon_bitmap1 = favicon_bitmap2; |
| 165 favicon_bitmap2 = tmp_favicon_bitmap; | 165 favicon_bitmap2 = tmp_favicon_bitmap; |
| 166 } | 166 } |
| 167 | 167 |
| 168 EXPECT_EQ(bitmap1_id, favicon_bitmap1.bitmap_id); | 168 EXPECT_EQ(bitmap1_id, favicon_bitmap1.bitmap_id); |
| 169 EXPECT_EQ(icon_id, favicon_bitmap1.icon_id); | 169 EXPECT_EQ(icon_id, favicon_bitmap1.icon_id); |
| 170 EXPECT_EQ(time.ToTimeT(), favicon_bitmap1.last_updated.ToTimeT()); | 170 EXPECT_EQ(time.ToInternalValue(), |
| 171 favicon_bitmap1.last_updated.ToInternalValue()); |
| 171 EXPECT_EQ(data.size(), favicon_bitmap1.bitmap_data->size()); | 172 EXPECT_EQ(data.size(), favicon_bitmap1.bitmap_data->size()); |
| 172 EXPECT_TRUE(std::equal(data.begin(), | 173 EXPECT_TRUE(std::equal(data.begin(), |
| 173 data.end(), | 174 data.end(), |
| 174 favicon_bitmap1.bitmap_data->front())); | 175 favicon_bitmap1.bitmap_data->front())); |
| 175 EXPECT_EQ(kSmallSize, favicon_bitmap1.pixel_size); | 176 EXPECT_EQ(kSmallSize, favicon_bitmap1.pixel_size); |
| 176 | 177 |
| 177 EXPECT_EQ(bitmap2_id, favicon_bitmap2.bitmap_id); | 178 EXPECT_EQ(bitmap2_id, favicon_bitmap2.bitmap_id); |
| 178 EXPECT_EQ(icon_id, favicon_bitmap2.icon_id); | 179 EXPECT_EQ(icon_id, favicon_bitmap2.icon_id); |
| 179 EXPECT_EQ(time.ToTimeT(), favicon_bitmap2.last_updated.ToTimeT()); | 180 EXPECT_EQ(time.ToInternalValue(), |
| 181 favicon_bitmap2.last_updated.ToInternalValue()); |
| 180 EXPECT_EQ(data.size(), favicon_bitmap2.bitmap_data->size()); | 182 EXPECT_EQ(data.size(), favicon_bitmap2.bitmap_data->size()); |
| 181 EXPECT_TRUE(std::equal(data.begin(), | 183 EXPECT_TRUE(std::equal(data.begin(), |
| 182 data.end(), | 184 data.end(), |
| 183 favicon_bitmap2.bitmap_data->front())); | 185 favicon_bitmap2.bitmap_data->front())); |
| 184 EXPECT_EQ(kLargeSize, favicon_bitmap2.pixel_size); | 186 EXPECT_EQ(kLargeSize, favicon_bitmap2.pixel_size); |
| 185 } | 187 } |
| 186 | 188 |
| 187 TEST_F(ThumbnailDatabaseTest, AddIconMapping) { | 189 TEST_F(ThumbnailDatabaseTest, AddIconMapping) { |
| 188 ThumbnailDatabase db; | 190 ThumbnailDatabase db; |
| 189 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_, NULL, NULL)); | 191 ASSERT_EQ(sql::INIT_OK, db.Init(file_name_, NULL, NULL)); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 "id INTEGER PRIMARY KEY," | 387 "id INTEGER PRIMARY KEY," |
| 386 "url LONGVARCHAR NOT NULL," | 388 "url LONGVARCHAR NOT NULL," |
| 387 "last_updated INTEGER DEFAULT 0," | 389 "last_updated INTEGER DEFAULT 0," |
| 388 "image_data BLOB," | 390 "image_data BLOB," |
| 389 "icon_type INTEGER DEFAULT 1," | 391 "icon_type INTEGER DEFAULT 1," |
| 390 "sizes LONGVARCHAR)"); | 392 "sizes LONGVARCHAR)"); |
| 391 EXPECT_TRUE(db.db_.Execute(sql.c_str())); | 393 EXPECT_TRUE(db.db_.Execute(sql.c_str())); |
| 392 | 394 |
| 393 int favicon_id = 1; | 395 int favicon_id = 1; |
| 394 GURL url("http://google.com"); | 396 GURL url("http://google.com"); |
| 395 time_t last_updated = Time::Now().ToTimeT(); | 397 int64 last_updated = Time::Now().ToInternalValue(); |
| 396 std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); | 398 std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); |
| 397 scoped_refptr<base::RefCountedBytes> bitmap_data( | 399 scoped_refptr<base::RefCountedBytes> bitmap_data( |
| 398 new base::RefCountedBytes(data)); | 400 new base::RefCountedBytes(data)); |
| 399 | 401 |
| 400 sql::Statement statement; | 402 sql::Statement statement; |
| 401 statement.Assign(db.db_.GetCachedStatement(SQL_FROM_HERE, | 403 statement.Assign(db.db_.GetCachedStatement(SQL_FROM_HERE, |
| 402 "INSERT INTO favicons (id, url, last_updated, image_data, icon_type, " | 404 "INSERT INTO favicons (id, url, last_updated, image_data, icon_type, " |
| 403 "sizes) VALUES (?, ?, ?, ?, ?, ?)")); | 405 "sizes) VALUES (?, ?, ?, ?, ?, ?)")); |
| 404 statement.BindInt(0, favicon_id); | 406 statement.BindInt(0, favicon_id); |
| 405 statement.BindString(1, URLDatabase::GURLToDatabaseURL(url)); | 407 statement.BindString(1, URLDatabase::GURLToDatabaseURL(url)); |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 } | 846 } |
| 845 | 847 |
| 846 std::string sizes_as_string; | 848 std::string sizes_as_string; |
| 847 ThumbnailDatabase::FaviconSizesToDatabaseString(sizes_valid, | 849 ThumbnailDatabase::FaviconSizesToDatabaseString(sizes_valid, |
| 848 &sizes_as_string); | 850 &sizes_as_string); |
| 849 EXPECT_TRUE(sizes_as_string == "10 15 20 25" || | 851 EXPECT_TRUE(sizes_as_string == "10 15 20 25" || |
| 850 sizes_as_string == "20 25 10 15"); | 852 sizes_as_string == "20 25 10 15"); |
| 851 } | 853 } |
| 852 | 854 |
| 853 } // namespace history | 855 } // namespace history |
| OLD | NEW |