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 // History unit tests come in two flavors: | 5 // History unit tests come in two flavors: |
6 // | 6 // |
7 // 1. The more complicated style is that the unit test creates a full history | 7 // 1. The more complicated style is that the unit test creates a full history |
8 // service. This spawns a background thread for the history backend, and | 8 // service. This spawns a background thread for the history backend, and |
9 // all communication is asynchronous. This is useful for testing more | 9 // all communication is asynchronous. This is useful for testing more |
10 // complicated things or end-to-end behavior. | 10 // complicated things or end-to-end behavior. |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 } | 891 } |
892 } | 892 } |
893 | 893 |
894 EXPECT_TRUE(found) | 894 EXPECT_TRUE(found) |
895 << "Error \"" << cur_reason.name << "\" not found in historical list." | 895 << "Error \"" << cur_reason.name << "\" not found in historical list." |
896 << std::endl | 896 << std::endl |
897 << "Please add it."; | 897 << "Please add it."; |
898 } | 898 } |
899 } | 899 } |
900 | 900 |
901 // The tracker uses RenderProcessHost pointers for scoping but never | |
902 // dereferences them. We use ints because it's easier. This function converts | |
903 // between the two. | |
904 static void* MakeFakeHost(int id) { | |
905 void* host = 0; | |
906 memcpy(&host, &id, sizeof(id)); | |
907 return host; | |
908 } | |
909 | |
910 class HistoryTest : public testing::Test { | 901 class HistoryTest : public testing::Test { |
911 public: | 902 public: |
912 HistoryTest() | 903 HistoryTest() |
913 : got_thumbnail_callback_(false), | 904 : got_thumbnail_callback_(false), |
914 redirect_query_success_(false), | 905 redirect_query_success_(false), |
915 query_url_success_(false) { | 906 query_url_success_(false) { |
916 } | 907 } |
917 | 908 |
918 virtual ~HistoryTest() { | 909 virtual ~HistoryTest() { |
919 } | 910 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 // Make sure we don't have any event pending that could disrupt the next | 947 // Make sure we don't have any event pending that could disrupt the next |
957 // test. | 948 // test. |
958 base::MessageLoop::current()->PostTask(FROM_HERE, | 949 base::MessageLoop::current()->PostTask(FROM_HERE, |
959 base::MessageLoop::QuitClosure()); | 950 base::MessageLoop::QuitClosure()); |
960 base::MessageLoop::current()->Run(); | 951 base::MessageLoop::current()->Run(); |
961 } | 952 } |
962 | 953 |
963 void CleanupHistoryService() { | 954 void CleanupHistoryService() { |
964 DCHECK(history_service_); | 955 DCHECK(history_service_); |
965 | 956 |
966 history_service_->NotifyRenderProcessHostDestruction(0); | 957 history_service_->ClearCachedDataForContextID(0); |
967 history_service_->SetOnBackendDestroyTask(base::MessageLoop::QuitClosure()); | 958 history_service_->SetOnBackendDestroyTask(base::MessageLoop::QuitClosure()); |
968 history_service_->Cleanup(); | 959 history_service_->Cleanup(); |
969 history_service_.reset(); | 960 history_service_.reset(); |
970 | 961 |
971 // Wait for the backend class to terminate before deleting the files and | 962 // Wait for the backend class to terminate before deleting the files and |
972 // moving to the next test. Note: if this never terminates, somebody is | 963 // moving to the next test. Note: if this never terminates, somebody is |
973 // probably leaking a reference to the history backend, so it never calls | 964 // probably leaking a reference to the history backend, so it never calls |
974 // our destroy task. | 965 // our destroy task. |
975 base::MessageLoop::current()->Run(); | 966 base::MessageLoop::current()->Run(); |
976 } | 967 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 "http://first.page.com/", | 1082 "http://first.page.com/", |
1092 "http://second.page.com/"}; | 1083 "http://second.page.com/"}; |
1093 int first_count = arraysize(first_sequence); | 1084 int first_count = arraysize(first_sequence); |
1094 history::RedirectList first_redirects; | 1085 history::RedirectList first_redirects; |
1095 for (int i = 0; i < first_count; i++) | 1086 for (int i = 0; i < first_count; i++) |
1096 first_redirects.push_back(GURL(first_sequence[i])); | 1087 first_redirects.push_back(GURL(first_sequence[i])); |
1097 | 1088 |
1098 // Add the sequence of pages as a server with no referrer. Note that we need | 1089 // Add the sequence of pages as a server with no referrer. Note that we need |
1099 // to have a non-NULL page ID scope. | 1090 // to have a non-NULL page ID scope. |
1100 history_service_->AddPage( | 1091 history_service_->AddPage( |
1101 first_redirects.back(), base::Time::Now(), MakeFakeHost(1), | 1092 first_redirects.back(), base::Time::Now(), |
1102 0, GURL(), first_redirects, content::PAGE_TRANSITION_LINK, | 1093 reinterpret_cast<ContextID>(1), 0, GURL(), first_redirects, |
1103 history::SOURCE_BROWSED, true); | 1094 content::PAGE_TRANSITION_LINK, history::SOURCE_BROWSED, true); |
1104 | 1095 |
1105 // The first page should be added once with a link visit type (because we set | 1096 // The first page should be added once with a link visit type (because we set |
1106 // LINK when we added the original URL, and a referrer of nowhere (0). | 1097 // LINK when we added the original URL, and a referrer of nowhere (0). |
1107 EXPECT_TRUE(QueryURL(history_service_.get(), first_redirects[0])); | 1098 EXPECT_TRUE(QueryURL(history_service_.get(), first_redirects[0])); |
1108 EXPECT_EQ(1, query_url_row_.visit_count()); | 1099 EXPECT_EQ(1, query_url_row_.visit_count()); |
1109 ASSERT_EQ(1U, query_url_visits_.size()); | 1100 ASSERT_EQ(1U, query_url_visits_.size()); |
1110 int64 first_visit = query_url_visits_[0].visit_id; | 1101 int64 first_visit = query_url_visits_[0].visit_id; |
1111 EXPECT_EQ(content::PAGE_TRANSITION_LINK | | 1102 EXPECT_EQ(content::PAGE_TRANSITION_LINK | |
1112 content::PAGE_TRANSITION_CHAIN_START, | 1103 content::PAGE_TRANSITION_CHAIN_START, |
1113 query_url_visits_[0].transition); | 1104 query_url_visits_[0].transition); |
(...skipping 16 matching lines...) Expand all Loading... |
1130 ASSERT_EQ(1U, saved_redirects_.size()); | 1121 ASSERT_EQ(1U, saved_redirects_.size()); |
1131 EXPECT_EQ(first_redirects[1], saved_redirects_[0]); | 1122 EXPECT_EQ(first_redirects[1], saved_redirects_[0]); |
1132 | 1123 |
1133 // Now add a client redirect from that second visit to a third, client | 1124 // Now add a client redirect from that second visit to a third, client |
1134 // redirects are tracked by the RenderView prior to updating history, | 1125 // redirects are tracked by the RenderView prior to updating history, |
1135 // so we pass in a CLIENT_REDIRECT qualifier to mock that behavior. | 1126 // so we pass in a CLIENT_REDIRECT qualifier to mock that behavior. |
1136 history::RedirectList second_redirects; | 1127 history::RedirectList second_redirects; |
1137 second_redirects.push_back(first_redirects[1]); | 1128 second_redirects.push_back(first_redirects[1]); |
1138 second_redirects.push_back(GURL("http://last.page.com/")); | 1129 second_redirects.push_back(GURL("http://last.page.com/")); |
1139 history_service_->AddPage(second_redirects[1], base::Time::Now(), | 1130 history_service_->AddPage(second_redirects[1], base::Time::Now(), |
1140 MakeFakeHost(1), 1, second_redirects[0], second_redirects, | 1131 reinterpret_cast<ContextID>(1), 1, |
| 1132 second_redirects[0], second_redirects, |
1141 static_cast<content::PageTransition>( | 1133 static_cast<content::PageTransition>( |
1142 content::PAGE_TRANSITION_LINK | | 1134 content::PAGE_TRANSITION_LINK | |
1143 content::PAGE_TRANSITION_CLIENT_REDIRECT), | 1135 content::PAGE_TRANSITION_CLIENT_REDIRECT), |
1144 history::SOURCE_BROWSED, true); | 1136 history::SOURCE_BROWSED, true); |
1145 | 1137 |
1146 // The last page (source of the client redirect) should NOT have an | 1138 // The last page (source of the client redirect) should NOT have an |
1147 // additional visit added, because it was a client redirect (normally it | 1139 // additional visit added, because it was a client redirect (normally it |
1148 // would). We should only have 1 left over from the first sequence. | 1140 // would). We should only have 1 left over from the first sequence. |
1149 EXPECT_TRUE(QueryURL(history_service_.get(), second_redirects[0])); | 1141 EXPECT_TRUE(QueryURL(history_service_.get(), second_redirects[0])); |
1150 EXPECT_EQ(1, query_url_row_.visit_count()); | 1142 EXPECT_EQ(1, query_url_row_.visit_count()); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 EXPECT_EQ(base::string16(), query_url_row_.title()); | 1312 EXPECT_EQ(base::string16(), query_url_row_.title()); |
1321 | 1313 |
1322 // TODO(brettw) this should also test redirects, which get the title of the | 1314 // TODO(brettw) this should also test redirects, which get the title of the |
1323 // destination page. | 1315 // destination page. |
1324 } | 1316 } |
1325 | 1317 |
1326 // crbug.com/159387: This test fails when daylight savings time ends. | 1318 // crbug.com/159387: This test fails when daylight savings time ends. |
1327 TEST_F(HistoryTest, DISABLED_Segments) { | 1319 TEST_F(HistoryTest, DISABLED_Segments) { |
1328 ASSERT_TRUE(history_service_.get()); | 1320 ASSERT_TRUE(history_service_.get()); |
1329 | 1321 |
1330 static const void* scope = static_cast<void*>(this); | 1322 static ContextID context_id = static_cast<ContextID>(this); |
1331 | 1323 |
1332 // Add a URL. | 1324 // Add a URL. |
1333 const GURL existing_url("http://www.google.com/"); | 1325 const GURL existing_url("http://www.google.com/"); |
1334 history_service_->AddPage( | 1326 history_service_->AddPage( |
1335 existing_url, base::Time::Now(), scope, 0, GURL(), | 1327 existing_url, base::Time::Now(), context_id, 0, GURL(), |
1336 history::RedirectList(), content::PAGE_TRANSITION_TYPED, | 1328 history::RedirectList(), content::PAGE_TRANSITION_TYPED, |
1337 history::SOURCE_BROWSED, false); | 1329 history::SOURCE_BROWSED, false); |
1338 | 1330 |
1339 // Make sure a segment was created. | 1331 // Make sure a segment was created. |
1340 history_service_->QuerySegmentUsageSince( | 1332 history_service_->QuerySegmentUsageSince( |
1341 &consumer_, Time::Now() - TimeDelta::FromDays(1), 10, | 1333 &consumer_, Time::Now() - TimeDelta::FromDays(1), 10, |
1342 base::Bind(&HistoryTest::OnSegmentUsageAvailable, | 1334 base::Bind(&HistoryTest::OnSegmentUsageAvailable, |
1343 base::Unretained(this))); | 1335 base::Unretained(this))); |
1344 | 1336 |
1345 // Wait for processing. | 1337 // Wait for processing. |
1346 base::MessageLoop::current()->Run(); | 1338 base::MessageLoop::current()->Run(); |
1347 | 1339 |
1348 ASSERT_EQ(1U, page_usage_data_.size()); | 1340 ASSERT_EQ(1U, page_usage_data_.size()); |
1349 EXPECT_TRUE(page_usage_data_[0]->GetURL() == existing_url); | 1341 EXPECT_TRUE(page_usage_data_[0]->GetURL() == existing_url); |
1350 EXPECT_DOUBLE_EQ(3.0, page_usage_data_[0]->GetScore()); | 1342 EXPECT_DOUBLE_EQ(3.0, page_usage_data_[0]->GetScore()); |
1351 | 1343 |
1352 // Add a URL which doesn't create a segment. | 1344 // Add a URL which doesn't create a segment. |
1353 const GURL link_url("http://yahoo.com/"); | 1345 const GURL link_url("http://yahoo.com/"); |
1354 history_service_->AddPage( | 1346 history_service_->AddPage( |
1355 link_url, base::Time::Now(), scope, 0, GURL(), | 1347 link_url, base::Time::Now(), context_id, 0, GURL(), |
1356 history::RedirectList(), content::PAGE_TRANSITION_LINK, | 1348 history::RedirectList(), content::PAGE_TRANSITION_LINK, |
1357 history::SOURCE_BROWSED, false); | 1349 history::SOURCE_BROWSED, false); |
1358 | 1350 |
1359 // Query again | 1351 // Query again |
1360 history_service_->QuerySegmentUsageSince( | 1352 history_service_->QuerySegmentUsageSince( |
1361 &consumer_, Time::Now() - TimeDelta::FromDays(1), 10, | 1353 &consumer_, Time::Now() - TimeDelta::FromDays(1), 10, |
1362 base::Bind(&HistoryTest::OnSegmentUsageAvailable, | 1354 base::Bind(&HistoryTest::OnSegmentUsageAvailable, |
1363 base::Unretained(this))); | 1355 base::Unretained(this))); |
1364 | 1356 |
1365 // Wait for processing. | 1357 // Wait for processing. |
1366 base::MessageLoop::current()->Run(); | 1358 base::MessageLoop::current()->Run(); |
1367 | 1359 |
1368 // Make sure we still have one segment. | 1360 // Make sure we still have one segment. |
1369 ASSERT_EQ(1U, page_usage_data_.size()); | 1361 ASSERT_EQ(1U, page_usage_data_.size()); |
1370 EXPECT_TRUE(page_usage_data_[0]->GetURL() == existing_url); | 1362 EXPECT_TRUE(page_usage_data_[0]->GetURL() == existing_url); |
1371 | 1363 |
1372 // Add a page linked from existing_url. | 1364 // Add a page linked from existing_url. |
1373 history_service_->AddPage( | 1365 history_service_->AddPage( |
1374 GURL("http://www.google.com/foo"), base::Time::Now(), | 1366 GURL("http://www.google.com/foo"), base::Time::Now(), |
1375 scope, 3, existing_url, history::RedirectList(), | 1367 context_id, 3, existing_url, history::RedirectList(), |
1376 content::PAGE_TRANSITION_LINK, history::SOURCE_BROWSED, | 1368 content::PAGE_TRANSITION_LINK, history::SOURCE_BROWSED, |
1377 false); | 1369 false); |
1378 | 1370 |
1379 // Query again | 1371 // Query again |
1380 history_service_->QuerySegmentUsageSince( | 1372 history_service_->QuerySegmentUsageSince( |
1381 &consumer_, Time::Now() - TimeDelta::FromDays(1), 10, | 1373 &consumer_, Time::Now() - TimeDelta::FromDays(1), 10, |
1382 base::Bind(&HistoryTest::OnSegmentUsageAvailable, | 1374 base::Bind(&HistoryTest::OnSegmentUsageAvailable, |
1383 base::Unretained(this))); | 1375 base::Unretained(this))); |
1384 | 1376 |
1385 // Wait for processing. | 1377 // Wait for processing. |
1386 base::MessageLoop::current()->Run(); | 1378 base::MessageLoop::current()->Run(); |
1387 | 1379 |
1388 // Make sure we still have one segment. | 1380 // Make sure we still have one segment. |
1389 ASSERT_EQ(1U, page_usage_data_.size()); | 1381 ASSERT_EQ(1U, page_usage_data_.size()); |
1390 EXPECT_TRUE(page_usage_data_[0]->GetURL() == existing_url); | 1382 EXPECT_TRUE(page_usage_data_[0]->GetURL() == existing_url); |
1391 | 1383 |
1392 // However, the score should have increased. | 1384 // However, the score should have increased. |
1393 EXPECT_GT(page_usage_data_[0]->GetScore(), 5.0); | 1385 EXPECT_GT(page_usage_data_[0]->GetScore(), 5.0); |
1394 } | 1386 } |
1395 | 1387 |
1396 TEST_F(HistoryTest, MostVisitedURLs) { | 1388 TEST_F(HistoryTest, MostVisitedURLs) { |
1397 ASSERT_TRUE(history_service_.get()); | 1389 ASSERT_TRUE(history_service_.get()); |
1398 | 1390 |
1399 const GURL url0("http://www.google.com/url0/"); | 1391 const GURL url0("http://www.google.com/url0/"); |
1400 const GURL url1("http://www.google.com/url1/"); | 1392 const GURL url1("http://www.google.com/url1/"); |
1401 const GURL url2("http://www.google.com/url2/"); | 1393 const GURL url2("http://www.google.com/url2/"); |
1402 const GURL url3("http://www.google.com/url3/"); | 1394 const GURL url3("http://www.google.com/url3/"); |
1403 const GURL url4("http://www.google.com/url4/"); | 1395 const GURL url4("http://www.google.com/url4/"); |
1404 | 1396 |
1405 static const void* scope = static_cast<void*>(this); | 1397 static ContextID context_id = static_cast<ContextID>(this); |
1406 | 1398 |
1407 // Add two pages. | 1399 // Add two pages. |
1408 history_service_->AddPage( | 1400 history_service_->AddPage( |
1409 url0, base::Time::Now(), scope, 0, GURL(), | 1401 url0, base::Time::Now(), context_id, 0, GURL(), |
1410 history::RedirectList(), content::PAGE_TRANSITION_TYPED, | 1402 history::RedirectList(), content::PAGE_TRANSITION_TYPED, |
1411 history::SOURCE_BROWSED, false); | 1403 history::SOURCE_BROWSED, false); |
1412 history_service_->AddPage( | 1404 history_service_->AddPage( |
1413 url1, base::Time::Now(), scope, 0, GURL(), | 1405 url1, base::Time::Now(), context_id, 0, GURL(), |
1414 history::RedirectList(), content::PAGE_TRANSITION_TYPED, | 1406 history::RedirectList(), content::PAGE_TRANSITION_TYPED, |
1415 history::SOURCE_BROWSED, false); | 1407 history::SOURCE_BROWSED, false); |
1416 history_service_->QueryMostVisitedURLs( | 1408 history_service_->QueryMostVisitedURLs( |
1417 20, 90, &consumer_, | 1409 20, 90, &consumer_, |
1418 base::Bind( | 1410 base::Bind( |
1419 &HistoryTest::OnMostVisitedURLsAvailable, | 1411 &HistoryTest::OnMostVisitedURLsAvailable, |
1420 base::Unretained(this))); | 1412 base::Unretained(this))); |
1421 base::MessageLoop::current()->Run(); | 1413 base::MessageLoop::current()->Run(); |
1422 | 1414 |
1423 EXPECT_EQ(2U, most_visited_urls_.size()); | 1415 EXPECT_EQ(2U, most_visited_urls_.size()); |
1424 EXPECT_EQ(url0, most_visited_urls_[0].url); | 1416 EXPECT_EQ(url0, most_visited_urls_[0].url); |
1425 EXPECT_EQ(url1, most_visited_urls_[1].url); | 1417 EXPECT_EQ(url1, most_visited_urls_[1].url); |
1426 | 1418 |
1427 // Add another page. | 1419 // Add another page. |
1428 history_service_->AddPage( | 1420 history_service_->AddPage( |
1429 url2, base::Time::Now(), scope, 0, GURL(), | 1421 url2, base::Time::Now(), context_id, 0, GURL(), |
1430 history::RedirectList(), content::PAGE_TRANSITION_TYPED, | 1422 history::RedirectList(), content::PAGE_TRANSITION_TYPED, |
1431 history::SOURCE_BROWSED, false); | 1423 history::SOURCE_BROWSED, false); |
1432 history_service_->QueryMostVisitedURLs( | 1424 history_service_->QueryMostVisitedURLs( |
1433 20, 90, &consumer_, | 1425 20, 90, &consumer_, |
1434 base::Bind( | 1426 base::Bind( |
1435 &HistoryTest::OnMostVisitedURLsAvailable, | 1427 &HistoryTest::OnMostVisitedURLsAvailable, |
1436 base::Unretained(this))); | 1428 base::Unretained(this))); |
1437 base::MessageLoop::current()->Run(); | 1429 base::MessageLoop::current()->Run(); |
1438 | 1430 |
1439 EXPECT_EQ(3U, most_visited_urls_.size()); | 1431 EXPECT_EQ(3U, most_visited_urls_.size()); |
1440 EXPECT_EQ(url0, most_visited_urls_[0].url); | 1432 EXPECT_EQ(url0, most_visited_urls_[0].url); |
1441 EXPECT_EQ(url1, most_visited_urls_[1].url); | 1433 EXPECT_EQ(url1, most_visited_urls_[1].url); |
1442 EXPECT_EQ(url2, most_visited_urls_[2].url); | 1434 EXPECT_EQ(url2, most_visited_urls_[2].url); |
1443 | 1435 |
1444 // Revisit url2, making it the top URL. | 1436 // Revisit url2, making it the top URL. |
1445 history_service_->AddPage( | 1437 history_service_->AddPage( |
1446 url2, base::Time::Now(), scope, 0, GURL(), | 1438 url2, base::Time::Now(), context_id, 0, GURL(), |
1447 history::RedirectList(), content::PAGE_TRANSITION_TYPED, | 1439 history::RedirectList(), content::PAGE_TRANSITION_TYPED, |
1448 history::SOURCE_BROWSED, false); | 1440 history::SOURCE_BROWSED, false); |
1449 history_service_->QueryMostVisitedURLs( | 1441 history_service_->QueryMostVisitedURLs( |
1450 20, 90, &consumer_, | 1442 20, 90, &consumer_, |
1451 base::Bind( | 1443 base::Bind( |
1452 &HistoryTest::OnMostVisitedURLsAvailable, | 1444 &HistoryTest::OnMostVisitedURLsAvailable, |
1453 base::Unretained(this))); | 1445 base::Unretained(this))); |
1454 base::MessageLoop::current()->Run(); | 1446 base::MessageLoop::current()->Run(); |
1455 | 1447 |
1456 EXPECT_EQ(3U, most_visited_urls_.size()); | 1448 EXPECT_EQ(3U, most_visited_urls_.size()); |
1457 EXPECT_EQ(url2, most_visited_urls_[0].url); | 1449 EXPECT_EQ(url2, most_visited_urls_[0].url); |
1458 EXPECT_EQ(url0, most_visited_urls_[1].url); | 1450 EXPECT_EQ(url0, most_visited_urls_[1].url); |
1459 EXPECT_EQ(url1, most_visited_urls_[2].url); | 1451 EXPECT_EQ(url1, most_visited_urls_[2].url); |
1460 | 1452 |
1461 // Revisit url1, making it the top URL. | 1453 // Revisit url1, making it the top URL. |
1462 history_service_->AddPage( | 1454 history_service_->AddPage( |
1463 url1, base::Time::Now(), scope, 0, GURL(), | 1455 url1, base::Time::Now(), context_id, 0, GURL(), |
1464 history::RedirectList(), content::PAGE_TRANSITION_TYPED, | 1456 history::RedirectList(), content::PAGE_TRANSITION_TYPED, |
1465 history::SOURCE_BROWSED, false); | 1457 history::SOURCE_BROWSED, false); |
1466 history_service_->QueryMostVisitedURLs( | 1458 history_service_->QueryMostVisitedURLs( |
1467 20, 90, &consumer_, | 1459 20, 90, &consumer_, |
1468 base::Bind( | 1460 base::Bind( |
1469 &HistoryTest::OnMostVisitedURLsAvailable, | 1461 &HistoryTest::OnMostVisitedURLsAvailable, |
1470 base::Unretained(this))); | 1462 base::Unretained(this))); |
1471 base::MessageLoop::current()->Run(); | 1463 base::MessageLoop::current()->Run(); |
1472 | 1464 |
1473 EXPECT_EQ(3U, most_visited_urls_.size()); | 1465 EXPECT_EQ(3U, most_visited_urls_.size()); |
1474 EXPECT_EQ(url1, most_visited_urls_[0].url); | 1466 EXPECT_EQ(url1, most_visited_urls_[0].url); |
1475 EXPECT_EQ(url2, most_visited_urls_[1].url); | 1467 EXPECT_EQ(url2, most_visited_urls_[1].url); |
1476 EXPECT_EQ(url0, most_visited_urls_[2].url); | 1468 EXPECT_EQ(url0, most_visited_urls_[2].url); |
1477 | 1469 |
1478 // Redirects | 1470 // Redirects |
1479 history::RedirectList redirects; | 1471 history::RedirectList redirects; |
1480 redirects.push_back(url3); | 1472 redirects.push_back(url3); |
1481 redirects.push_back(url4); | 1473 redirects.push_back(url4); |
1482 | 1474 |
1483 // Visit url4 using redirects. | 1475 // Visit url4 using redirects. |
1484 history_service_->AddPage( | 1476 history_service_->AddPage( |
1485 url4, base::Time::Now(), scope, 0, GURL(), | 1477 url4, base::Time::Now(), context_id, 0, GURL(), |
1486 redirects, content::PAGE_TRANSITION_TYPED, | 1478 redirects, content::PAGE_TRANSITION_TYPED, |
1487 history::SOURCE_BROWSED, false); | 1479 history::SOURCE_BROWSED, false); |
1488 history_service_->QueryMostVisitedURLs( | 1480 history_service_->QueryMostVisitedURLs( |
1489 20, 90, &consumer_, | 1481 20, 90, &consumer_, |
1490 base::Bind( | 1482 base::Bind( |
1491 &HistoryTest::OnMostVisitedURLsAvailable, | 1483 &HistoryTest::OnMostVisitedURLsAvailable, |
1492 base::Unretained(this))); | 1484 base::Unretained(this))); |
1493 base::MessageLoop::current()->Run(); | 1485 base::MessageLoop::current()->Run(); |
1494 | 1486 |
1495 EXPECT_EQ(4U, most_visited_urls_.size()); | 1487 EXPECT_EQ(4U, most_visited_urls_.size()); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1868 std::vector<PageUsageData*> results; | 1860 std::vector<PageUsageData*> results; |
1869 db_->QuerySegmentUsage(segment_time, 10, &results); | 1861 db_->QuerySegmentUsage(segment_time, 10, &results); |
1870 ASSERT_EQ(1u, results.size()); | 1862 ASSERT_EQ(1u, results.size()); |
1871 EXPECT_EQ(url, results[0]->GetURL()); | 1863 EXPECT_EQ(url, results[0]->GetURL()); |
1872 EXPECT_EQ(segment_id, results[0]->GetID()); | 1864 EXPECT_EQ(segment_id, results[0]->GetID()); |
1873 EXPECT_EQ(title, results[0]->GetTitle()); | 1865 EXPECT_EQ(title, results[0]->GetTitle()); |
1874 STLDeleteElements(&results); | 1866 STLDeleteElements(&results); |
1875 } | 1867 } |
1876 | 1868 |
1877 } // namespace history | 1869 } // namespace history |
OLD | NEW |