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