| 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 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 ASSERT_TRUE(id1); | 1131 ASSERT_TRUE(id1); |
| 1132 | 1132 |
| 1133 int update_count; | 1133 int update_count; |
| 1134 std::vector<string16> update_args; | 1134 std::vector<string16> update_args; |
| 1135 // Update the last visit time to a value greater than current one. | 1135 // Update the last visit time to a value greater than current one. |
| 1136 HistoryAndBookmarkRow update_row1; | 1136 HistoryAndBookmarkRow update_row1; |
| 1137 | 1137 |
| 1138 // Set favicon. | 1138 // Set favicon. |
| 1139 std::vector<unsigned char> data; | 1139 std::vector<unsigned char> data; |
| 1140 data.push_back('1'); | 1140 data.push_back('1'); |
| 1141 update_row1.set_favicon(base::RefCountedBytes::TakeVector(&data)); | 1141 // Keep the pointer of RefCountedBytes for it's the expected result |
| 1142 // which will be compared with the result of GetFavicon |
| 1143 base::RefCountedBytes *data_bytes = base::RefCountedBytes::TakeVector(&data); |
| 1144 update_row1.set_favicon(data_bytes); |
| 1142 update_args.push_back(UTF8ToUTF16(row1.raw_url())); | 1145 update_args.push_back(UTF8ToUTF16(row1.raw_url())); |
| 1143 delegate_.ResetDetails(); | 1146 delegate_.ResetDetails(); |
| 1144 ASSERT_TRUE(backend->UpdateHistoryAndBookmarks(update_row1, "url = ?", | 1147 ASSERT_TRUE(backend->UpdateHistoryAndBookmarks(update_row1, "url = ?", |
| 1145 update_args, &update_count)); | 1148 update_args, &update_count)); |
| 1146 // Verify notifications. | 1149 // Verify notifications. |
| 1147 EXPECT_FALSE(delegate_.deleted_details()); | 1150 EXPECT_FALSE(delegate_.deleted_details()); |
| 1148 EXPECT_FALSE(delegate_.modified_details()); | 1151 EXPECT_FALSE(delegate_.modified_details()); |
| 1149 ASSERT_TRUE(delegate_.favicon_details()); | 1152 ASSERT_TRUE(delegate_.favicon_details()); |
| 1150 ASSERT_EQ(1u, delegate_.favicon_details()->urls.size()); | 1153 ASSERT_EQ(1u, delegate_.favicon_details()->urls.size()); |
| 1151 ASSERT_TRUE(delegate_.favicon_details()->urls.end() != | 1154 ASSERT_TRUE(delegate_.favicon_details()->urls.end() != |
| 1152 delegate_.favicon_details()->urls.find(row1.url())); | 1155 delegate_.favicon_details()->urls.find(row1.url())); |
| 1153 | 1156 |
| 1154 IconMapping icon_mapping; | 1157 IconMapping icon_mapping; |
| 1155 EXPECT_TRUE(thumbnail_db_.GetIconMappingForPageURL(row1.url(), FAVICON, | 1158 EXPECT_TRUE(thumbnail_db_.GetIconMappingForPageURL(row1.url(), FAVICON, |
| 1156 &icon_mapping)); | 1159 &icon_mapping)); |
| 1157 Time last_updated; | 1160 Time last_updated; |
| 1158 std::vector<unsigned char> png_icon_data; | 1161 std::vector<unsigned char> png_icon_data; |
| 1159 EXPECT_TRUE(thumbnail_db_.GetFavicon(icon_mapping.icon_id, &last_updated, | 1162 EXPECT_TRUE(thumbnail_db_.GetFavicon(icon_mapping.icon_id, &last_updated, |
| 1160 &png_icon_data, NULL, NULL)); | 1163 &png_icon_data, NULL, NULL)); |
| 1161 EXPECT_EQ(data, png_icon_data); | 1164 EXPECT_EQ(data_bytes->data(), png_icon_data); |
| 1162 | 1165 |
| 1163 // Remove favicon. | 1166 // Remove favicon. |
| 1164 HistoryAndBookmarkRow update_row2; | 1167 HistoryAndBookmarkRow update_row2; |
| 1165 | 1168 |
| 1166 // Set favicon. | 1169 // Set favicon. |
| 1167 update_row1.set_favicon(new base::RefCountedBytes()); | 1170 update_row1.set_favicon(new base::RefCountedBytes()); |
| 1168 update_args.clear(); | 1171 update_args.clear(); |
| 1169 update_args.push_back(UTF8ToUTF16(row1.raw_url())); | 1172 update_args.push_back(UTF8ToUTF16(row1.raw_url())); |
| 1170 delegate_.ResetDetails(); | 1173 delegate_.ResetDetails(); |
| 1171 ASSERT_TRUE(backend->UpdateHistoryAndBookmarks(update_row1, "url = ?", | 1174 ASSERT_TRUE(backend->UpdateHistoryAndBookmarks(update_row1, "url = ?", |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1751 // Query by folder=1, the row2 should returned. | 1754 // Query by folder=1, the row2 should returned. |
| 1752 statement.reset(backend->QueryHistoryAndBookmarks( | 1755 statement.reset(backend->QueryHistoryAndBookmarks( |
| 1753 projections, std::string("folder=1"), std::vector<string16>(), | 1756 projections, std::string("folder=1"), std::vector<string16>(), |
| 1754 std::string("url ASC"))); | 1757 std::string("url ASC"))); |
| 1755 ASSERT_TRUE(statement->statement()->Step()); | 1758 ASSERT_TRUE(statement->statement()->Step()); |
| 1756 EXPECT_EQ(row2.url(), GURL(statement->statement()->ColumnString(0))); | 1759 EXPECT_EQ(row2.url(), GURL(statement->statement()->ColumnString(0))); |
| 1757 EXPECT_FALSE(statement->statement()->Step()); | 1760 EXPECT_FALSE(statement->statement()->Step()); |
| 1758 } | 1761 } |
| 1759 | 1762 |
| 1760 } // namespace history | 1763 } // namespace history |
| OLD | NEW |