OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
6 #include "base/scoped_temp_dir.h" | 6 #include "base/scoped_temp_dir.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/history/top_sites.h" | 8 #include "chrome/browser/history/top_sites.h" |
9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
10 #include "chrome/browser/dom_ui/most_visited_handler.h" | 10 #include "chrome/browser/dom_ui/most_visited_handler.h" |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 top_sites().GetMostVisitedURLs( | 1108 top_sites().GetMostVisitedURLs( |
1109 &c, | 1109 &c, |
1110 NewCallback(static_cast<TopSitesTest*>(this), | 1110 NewCallback(static_cast<TopSitesTest*>(this), |
1111 &TopSitesTest::OnTopSitesAvailable)); | 1111 &TopSitesTest::OnTopSitesAvailable)); |
1112 | 1112 |
1113 ASSERT_EQ(4u, urls().size()); | 1113 ASSERT_EQ(4u, urls().size()); |
1114 EXPECT_EQ("http://bbc.com/", urls()[0].url.spec()); | 1114 EXPECT_EQ("http://bbc.com/", urls()[0].url.spec()); |
1115 EXPECT_EQ("http://google.com/", urls()[1].url.spec()); | 1115 EXPECT_EQ("http://google.com/", urls()[1].url.spec()); |
1116 EXPECT_EQ(welcome_url(), urls()[2].url); | 1116 EXPECT_EQ(welcome_url(), urls()[2].url); |
1117 EXPECT_EQ(themes_url(), urls()[3].url); | 1117 EXPECT_EQ(themes_url(), urls()[3].url); |
| 1118 |
| 1119 top_sites().AddPinnedURL(GURL("http://bbc.com"), 1); |
| 1120 top_sites().AddPinnedURL(themes_url(), 0); |
| 1121 top_sites().GetMostVisitedURLs( |
| 1122 &c, |
| 1123 NewCallback(static_cast<TopSitesTest*>(this), |
| 1124 &TopSitesTest::OnTopSitesAvailable)); |
| 1125 |
| 1126 ASSERT_EQ(4u, urls().size()); |
| 1127 EXPECT_EQ(themes_url(), urls()[0].url); |
| 1128 EXPECT_EQ("http://bbc.com/", urls()[1].url.spec()); |
| 1129 EXPECT_EQ("http://google.com/", urls()[2].url.spec()); |
| 1130 EXPECT_EQ(welcome_url(), urls()[3].url); |
| 1131 |
| 1132 top_sites().RemovePinnedURL(GURL("http://bbc.com")); |
| 1133 top_sites().RemovePinnedURL(themes_url()); |
| 1134 |
| 1135 top_sites().AddPinnedURL(welcome_url(), 1); |
| 1136 top_sites().AddPinnedURL(GURL("http://bbc.com"), 3); |
| 1137 |
| 1138 top_sites().GetMostVisitedURLs( |
| 1139 &c, |
| 1140 NewCallback(static_cast<TopSitesTest*>(this), |
| 1141 &TopSitesTest::OnTopSitesAvailable)); |
| 1142 |
| 1143 ASSERT_EQ(4u, urls().size()); |
| 1144 EXPECT_EQ("http://google.com/", urls()[0].url.spec()); |
| 1145 EXPECT_EQ(welcome_url(), urls()[1].url); |
| 1146 EXPECT_EQ(themes_url(), urls()[2].url); |
| 1147 EXPECT_EQ("http://bbc.com/", urls()[3].url.spec()); |
1118 } | 1148 } |
1119 | 1149 |
1120 TEST_F(TopSitesTest, BlacklistingAndPinnedURLs) { | 1150 TEST_F(TopSitesTest, BlacklistingAndPinnedURLs) { |
1121 ChromeThread db_loop(ChromeThread::DB, MessageLoop::current()); | 1151 ChromeThread db_loop(ChromeThread::DB, MessageLoop::current()); |
1122 MostVisitedURLList pages; | 1152 MostVisitedURLList pages; |
1123 CancelableRequestConsumer c; | 1153 CancelableRequestConsumer c; |
1124 top_sites().GetMostVisitedURLs( | 1154 top_sites().GetMostVisitedURLs( |
1125 &c, | 1155 &c, |
1126 NewCallback(static_cast<TopSitesTest*>(this), | 1156 NewCallback(static_cast<TopSitesTest*>(this), |
1127 &TopSitesTest::OnTopSitesAvailable)); | 1157 &TopSitesTest::OnTopSitesAvailable)); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 | 1238 |
1209 top_sites().RemoveBlacklistedURL(store_url); | 1239 top_sites().RemoveBlacklistedURL(store_url); |
1210 EXPECT_EQ(6, top_sites().GetIndexForChromeStore(pages)); | 1240 EXPECT_EQ(6, top_sites().GetIndexForChromeStore(pages)); |
1211 | 1241 |
1212 top_sites().AddPinnedURL(GURL("http://bbc.com"), 2); | 1242 top_sites().AddPinnedURL(GURL("http://bbc.com"), 2); |
1213 // All pinned - can't add store. | 1243 // All pinned - can't add store. |
1214 EXPECT_EQ(-1, top_sites().GetIndexForChromeStore(pages)); | 1244 EXPECT_EQ(-1, top_sites().GetIndexForChromeStore(pages)); |
1215 } | 1245 } |
1216 | 1246 |
1217 } // namespace history | 1247 } // namespace history |
OLD | NEW |