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 "chrome/browser/history/android/android_provider_backend.h" | 5 #include "chrome/browser/history/android/android_provider_backend.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 URLRow url_row; | 241 URLRow url_row; |
242 | 242 |
243 ASSERT_TRUE(history_backend->GetURL(url1, &url_row)); | 243 ASSERT_TRUE(history_backend->GetURL(url1, &url_row)); |
244 url_id1 = url_row.id(); | 244 url_id1 = url_row.id(); |
245 ASSERT_TRUE(history_backend->GetURL(url2, &url_row)); | 245 ASSERT_TRUE(history_backend->GetURL(url2, &url_row)); |
246 url_id2 = url_row.id(); | 246 url_id2 = url_row.id(); |
247 | 247 |
248 // Set favicon to url2. | 248 // Set favicon to url2. |
249 std::vector<unsigned char> data; | 249 std::vector<unsigned char> data; |
250 data.push_back('1'); | 250 data.push_back('1'); |
251 history_backend->SetFavicon(url2, | 251 history::FaviconBitmapData bitmap_data_element; |
252 GURL(), | 252 bitmap_data_element.bitmap_data = new base::RefCountedBytes(data); |
253 new base::RefCountedBytes(data), | 253 bitmap_data_element.pixel_size = gfx::Size(); |
254 FAVICON); | 254 bitmap_data_element.icon_url = GURL(); |
| 255 std::vector<history::FaviconBitmapData> favicon_bitmap_data; |
| 256 favicon_bitmap_data.push_back(bitmap_data_element); |
| 257 |
| 258 FaviconSizes favicon_sizes; |
| 259 favicon_sizes.push_back(gfx::Size()); |
| 260 IconURLSizesMap icon_url_sizes; |
| 261 icon_url_sizes[GURL()] = favicon_sizes; |
| 262 |
| 263 history_backend->SetFavicons(url2, |
| 264 FAVICON, |
| 265 favicon_bitmap_data, |
| 266 icon_url_sizes); |
255 history_backend->Closing(); | 267 history_backend->Closing(); |
256 } | 268 } |
257 | 269 |
258 // The history_db_name and thumbnail_db_name files should be created by | 270 // The history_db_name and thumbnail_db_name files should be created by |
259 // HistoryBackend. We need to open the same database files. | 271 // HistoryBackend. We need to open the same database files. |
260 ASSERT_TRUE(file_util::PathExists(history_db_name_)); | 272 ASSERT_TRUE(file_util::PathExists(history_db_name_)); |
261 ASSERT_TRUE(file_util::PathExists(thumbnail_db_name_)); | 273 ASSERT_TRUE(file_util::PathExists(thumbnail_db_name_)); |
262 | 274 |
263 ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_)); | 275 ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_)); |
264 ASSERT_EQ(sql::INIT_OK, thumbnail_db_.Init(thumbnail_db_name_, NULL, | 276 ASSERT_EQ(sql::INIT_OK, thumbnail_db_.Init(thumbnail_db_name_, NULL, |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 ASSERT_TRUE(history_backend->UpdateURL(url_id1, url_row)); | 399 ASSERT_TRUE(history_backend->UpdateURL(url_id1, url_row)); |
388 | 400 |
389 ASSERT_TRUE(history_backend->GetURL(url2, &url_row)); | 401 ASSERT_TRUE(history_backend->GetURL(url2, &url_row)); |
390 url_id2 = url_row.id(); | 402 url_id2 = url_row.id(); |
391 url_row.set_title(title2); | 403 url_row.set_title(title2); |
392 ASSERT_TRUE(history_backend->UpdateURL(url_id2, url_row)); | 404 ASSERT_TRUE(history_backend->UpdateURL(url_id2, url_row)); |
393 | 405 |
394 // Set favicon to url2. | 406 // Set favicon to url2. |
395 std::vector<unsigned char> data; | 407 std::vector<unsigned char> data; |
396 data.push_back('1'); | 408 data.push_back('1'); |
397 history_backend->SetFavicon(url2, | 409 history::FaviconBitmapData bitmap_data_element; |
398 GURL(), | 410 bitmap_data_element.bitmap_data = new base::RefCountedBytes(data); |
399 new base::RefCountedBytes(data), | 411 bitmap_data_element.pixel_size = gfx::Size(); |
400 FAVICON); | 412 bitmap_data_element.icon_url = GURL(); |
| 413 std::vector<history::FaviconBitmapData> favicon_bitmap_data; |
| 414 favicon_bitmap_data.push_back(bitmap_data_element); |
| 415 |
| 416 FaviconSizes favicon_sizes; |
| 417 favicon_sizes.push_back(gfx::Size()); |
| 418 IconURLSizesMap icon_url_sizes; |
| 419 icon_url_sizes[GURL()] = favicon_sizes; |
| 420 |
| 421 history_backend->SetFavicons(url2, |
| 422 FAVICON, |
| 423 favicon_bitmap_data, |
| 424 icon_url_sizes); |
401 history_backend->Closing(); | 425 history_backend->Closing(); |
402 } | 426 } |
403 | 427 |
404 // The history_db_name and thumbnail_db_name files should be created by | 428 // The history_db_name and thumbnail_db_name files should be created by |
405 // HistoryBackend. We need to open the same database files. | 429 // HistoryBackend. We need to open the same database files. |
406 ASSERT_TRUE(file_util::PathExists(history_db_name_)); | 430 ASSERT_TRUE(file_util::PathExists(history_db_name_)); |
407 ASSERT_TRUE(file_util::PathExists(thumbnail_db_name_)); | 431 ASSERT_TRUE(file_util::PathExists(thumbnail_db_name_)); |
408 | 432 |
409 ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_)); | 433 ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_)); |
410 ASSERT_EQ(sql::INIT_OK, thumbnail_db_.Init(thumbnail_db_name_, NULL, | 434 ASSERT_EQ(sql::INIT_OK, thumbnail_db_.Init(thumbnail_db_name_, NULL, |
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 // Query by folder=1, the row2 should returned. | 1775 // Query by folder=1, the row2 should returned. |
1752 statement.reset(backend->QueryHistoryAndBookmarks( | 1776 statement.reset(backend->QueryHistoryAndBookmarks( |
1753 projections, std::string("folder=1"), std::vector<string16>(), | 1777 projections, std::string("folder=1"), std::vector<string16>(), |
1754 std::string("url ASC"))); | 1778 std::string("url ASC"))); |
1755 ASSERT_TRUE(statement->statement()->Step()); | 1779 ASSERT_TRUE(statement->statement()->Step()); |
1756 EXPECT_EQ(row2.url(), GURL(statement->statement()->ColumnString(0))); | 1780 EXPECT_EQ(row2.url(), GURL(statement->statement()->ColumnString(0))); |
1757 EXPECT_FALSE(statement->statement()->Step()); | 1781 EXPECT_FALSE(statement->statement()->Step()); |
1758 } | 1782 } |
1759 | 1783 |
1760 } // namespace history | 1784 } // namespace history |
OLD | NEW |