| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/memory/scoped_temp_dir.h" | 8 #include "base/memory/scoped_temp_dir.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 // Don't store thumbnails for Javascript URLs. | 1088 // Don't store thumbnails for Javascript URLs. |
| 1089 EXPECT_FALSE(top_sites()->SetPageThumbnail(invalid_url, | 1089 EXPECT_FALSE(top_sites()->SetPageThumbnail(invalid_url, |
| 1090 thumbnail, | 1090 thumbnail, |
| 1091 medium_score)); | 1091 medium_score)); |
| 1092 // Store thumbnails for unknown (but valid) URLs temporarily - calls | 1092 // Store thumbnails for unknown (but valid) URLs temporarily - calls |
| 1093 // AddTemporaryThumbnail. | 1093 // AddTemporaryThumbnail. |
| 1094 EXPECT_TRUE(top_sites()->SetPageThumbnail(unknown_url, | 1094 EXPECT_TRUE(top_sites()->SetPageThumbnail(unknown_url, |
| 1095 thumbnail, | 1095 thumbnail, |
| 1096 medium_score)); | 1096 medium_score)); |
| 1097 | 1097 |
| 1098 // We shouldn't get the thumnail back though (the url isn't in to sites yet). | 1098 // The URL is unknown. |
| 1099 EXPECT_FALSE(top_sites()->IsKnownURL(unknown_url)); |
| 1100 // We should be able to get the thumnail back even if the url isn't in |
| 1101 // to sites yet. |
| 1099 scoped_refptr<RefCountedBytes> out; | 1102 scoped_refptr<RefCountedBytes> out; |
| 1100 EXPECT_FALSE(top_sites()->GetPageThumbnail(unknown_url, &out)); | 1103 EXPECT_TRUE(top_sites()->GetPageThumbnail(unknown_url, &out)); |
| 1104 EXPECT_TRUE(ThumbnailEqualsBytes(thumbnail, out.get())); |
| 1105 ThumbnailScore out_score; |
| 1106 EXPECT_TRUE(top_sites()->GetPageThumbnailScore(unknown_url, &out_score)); |
| 1107 EXPECT_TRUE(medium_score.Equals(out_score)); |
| 1101 | 1108 |
| 1102 std::vector<MostVisitedURL> list; | 1109 std::vector<MostVisitedURL> list; |
| 1103 | 1110 |
| 1104 MostVisitedURL mv; | 1111 MostVisitedURL mv; |
| 1105 mv.url = unknown_url; | 1112 mv.url = unknown_url; |
| 1106 mv.redirects.push_back(mv.url); | 1113 mv.redirects.push_back(mv.url); |
| 1107 mv.redirects.push_back(url1a); | 1114 mv.redirects.push_back(url1a); |
| 1108 mv.redirects.push_back(url1b); | 1115 mv.redirects.push_back(url1b); |
| 1109 list.push_back(mv); | 1116 list.push_back(mv); |
| 1110 | 1117 |
| 1111 // Update URLs. This should result in using thumbnail. | 1118 // Update URLs. This should result in making the URL known. |
| 1112 SetTopSites(list); | 1119 SetTopSites(list); |
| 1113 | 1120 |
| 1114 ASSERT_TRUE(top_sites()->GetPageThumbnail(unknown_url, &out)); | 1121 EXPECT_TRUE(top_sites()->IsKnownURL(unknown_url)); |
| 1115 EXPECT_TRUE(ThumbnailEqualsBytes(thumbnail, out.get())); | |
| 1116 } | 1122 } |
| 1117 | 1123 |
| 1118 // Tests variations of blacklisting. | 1124 // Tests variations of blacklisting. |
| 1119 TEST_F(TopSitesTest, Blacklisting) { | 1125 TEST_F(TopSitesTest, Blacklisting) { |
| 1120 MostVisitedURLList pages; | 1126 MostVisitedURLList pages; |
| 1121 MostVisitedURL url, url1; | 1127 MostVisitedURL url, url1; |
| 1122 url.url = GURL("http://bbc.com/"); | 1128 url.url = GURL("http://bbc.com/"); |
| 1123 url.redirects.push_back(url.url); | 1129 url.redirects.push_back(url.url); |
| 1124 pages.push_back(url); | 1130 pages.push_back(url); |
| 1125 url1.url = GURL("http://google.com/"); | 1131 url1.url = GURL("http://google.com/"); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 WaitForTopSites(); | 1335 WaitForTopSites(); |
| 1330 EXPECT_FALSE(IsTopSitesLoaded()); | 1336 EXPECT_FALSE(IsTopSitesLoaded()); |
| 1331 | 1337 |
| 1332 // Load history, which should make TopSites finish loading too. | 1338 // Load history, which should make TopSites finish loading too. |
| 1333 profile()->CreateHistoryService(false, false); | 1339 profile()->CreateHistoryService(false, false); |
| 1334 profile()->BlockUntilTopSitesLoaded(); | 1340 profile()->BlockUntilTopSitesLoaded(); |
| 1335 EXPECT_TRUE(IsTopSitesLoaded()); | 1341 EXPECT_TRUE(IsTopSitesLoaded()); |
| 1336 } | 1342 } |
| 1337 | 1343 |
| 1338 } // namespace history | 1344 } // namespace history |
| OLD | NEW |