| 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 <string> | 6 #include <string> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 // Four times for each visit. | 199 // Four times for each visit. |
| 200 visit_times[3] = Time::Now(); | 200 visit_times[3] = Time::Now(); |
| 201 visit_times[2] = visit_times[3] - TimeDelta::FromDays(1); | 201 visit_times[2] = visit_times[3] - TimeDelta::FromDays(1); |
| 202 visit_times[1] = visit_times[3] - TimeDelta::FromDays(2); | 202 visit_times[1] = visit_times[3] - TimeDelta::FromDays(2); |
| 203 visit_times[0] = visit_times[3] - TimeDelta::FromDays(3); | 203 visit_times[0] = visit_times[3] - TimeDelta::FromDays(3); |
| 204 | 204 |
| 205 // Two favicons. The first two URLs will share the same one, while the last | 205 // Two favicons. The first two URLs will share the same one, while the last |
| 206 // one will have a unique favicon. | 206 // one will have a unique favicon. |
| 207 FaviconID favicon1 = thumb_db_->AddFavicon(GURL("http://favicon/url1"), | 207 FaviconID favicon1 = thumb_db_->AddFavicon(GURL("http://favicon/url1"), |
| 208 FAVICON); | 208 FAVICON, GetDefaultFaviconSizes()); |
| 209 FaviconID favicon2 = thumb_db_->AddFavicon(GURL("http://favicon/url2"), | 209 FaviconID favicon2 = thumb_db_->AddFavicon(GURL("http://favicon/url2"), |
| 210 FAVICON); | 210 FAVICON, GetDefaultFaviconSizes()); |
| 211 | 211 |
| 212 // Three URLs. | 212 // Three URLs. |
| 213 URLRow url_row1(GURL("http://www.google.com/1")); | 213 URLRow url_row1(GURL("http://www.google.com/1")); |
| 214 url_row1.set_last_visit(visit_times[0]); | 214 url_row1.set_last_visit(visit_times[0]); |
| 215 url_row1.set_visit_count(1); | 215 url_row1.set_visit_count(1); |
| 216 url_ids[0] = main_db_->AddURL(url_row1); | 216 url_ids[0] = main_db_->AddURL(url_row1); |
| 217 thumb_db_->AddIconMapping(url_row1.url(), favicon1); | 217 thumb_db_->AddIconMapping(url_row1.url(), favicon1); |
| 218 | 218 |
| 219 URLRow url_row2(GURL("http://www.google.com/2")); | 219 URLRow url_row2(GURL("http://www.google.com/2")); |
| 220 url_row2.set_last_visit(visit_times[2]); | 220 url_row2.set_last_visit(visit_times[2]); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 EXPECT_NE(notifications_[i].first, | 396 EXPECT_NE(notifications_[i].first, |
| 397 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED); | 397 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED); |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 EXPECT_TRUE(found_delete_notification); | 400 EXPECT_TRUE(found_delete_notification); |
| 401 } | 401 } |
| 402 | 402 |
| 403 TEST_F(ExpireHistoryTest, DeleteFaviconsIfPossible) { | 403 TEST_F(ExpireHistoryTest, DeleteFaviconsIfPossible) { |
| 404 // Add a favicon record. | 404 // Add a favicon record. |
| 405 const GURL favicon_url("http://www.google.com/favicon.ico"); | 405 const GURL favicon_url("http://www.google.com/favicon.ico"); |
| 406 FaviconID icon_id = thumb_db_->AddFavicon(favicon_url, FAVICON); | 406 FaviconID icon_id = thumb_db_->AddFavicon(favicon_url, FAVICON, |
| 407 GetDefaultFaviconSizes()); |
| 407 EXPECT_TRUE(icon_id); | 408 EXPECT_TRUE(icon_id); |
| 408 EXPECT_TRUE(HasFavicon(icon_id)); | 409 EXPECT_TRUE(HasFavicon(icon_id)); |
| 409 | 410 |
| 410 // The favicon should be deletable with no users. | 411 // The favicon should be deletable with no users. |
| 411 std::set<FaviconID> favicon_set; | 412 std::set<FaviconID> favicon_set; |
| 412 favicon_set.insert(icon_id); | 413 favicon_set.insert(icon_id); |
| 413 expirer_.DeleteFaviconsIfPossible(favicon_set); | 414 expirer_.DeleteFaviconsIfPossible(favicon_set); |
| 414 EXPECT_FALSE(HasFavicon(icon_id)); | 415 EXPECT_FALSE(HasFavicon(icon_id)); |
| 415 | 416 |
| 416 // Add back the favicon. | 417 // Add back the favicon. |
| 417 icon_id = thumb_db_->AddFavicon(favicon_url, TOUCH_ICON); | 418 icon_id = thumb_db_->AddFavicon(favicon_url, TOUCH_ICON, |
| 419 GetDefaultFaviconSizes()); |
| 418 EXPECT_TRUE(icon_id); | 420 EXPECT_TRUE(icon_id); |
| 419 EXPECT_TRUE(HasFavicon(icon_id)); | 421 EXPECT_TRUE(HasFavicon(icon_id)); |
| 420 | 422 |
| 421 // Add a page that references the favicon. | 423 // Add a page that references the favicon. |
| 422 URLRow row(GURL("http://www.google.com/2")); | 424 URLRow row(GURL("http://www.google.com/2")); |
| 423 row.set_visit_count(1); | 425 row.set_visit_count(1); |
| 424 EXPECT_TRUE(main_db_->AddURL(row)); | 426 EXPECT_TRUE(main_db_->AddURL(row)); |
| 425 thumb_db_->AddIconMapping(row.url(), icon_id); | 427 thumb_db_->AddIconMapping(row.url(), icon_id); |
| 426 | 428 |
| 427 // Favicon should not be deletable. | 429 // Favicon should not be deletable. |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 main_db_->GetVisitsForURL(url_id, &archived_visits); | 957 main_db_->GetVisitsForURL(url_id, &archived_visits); |
| 956 EXPECT_EQ(0U, archived_visits.size()); | 958 EXPECT_EQ(0U, archived_visits.size()); |
| 957 } | 959 } |
| 958 | 960 |
| 959 // TODO(brettw) add some visits with no URL to make sure everything is updated | 961 // TODO(brettw) add some visits with no URL to make sure everything is updated |
| 960 // properly. Have the visits also refer to nonexistent FTS rows. | 962 // properly. Have the visits also refer to nonexistent FTS rows. |
| 961 // | 963 // |
| 962 // Maybe also refer to invalid favicons. | 964 // Maybe also refer to invalid favicons. |
| 963 | 965 |
| 964 } // namespace history | 966 } // namespace history |
| OLD | NEW |