| Index: chrome/browser/predictors/resource_prefetch_predictor_tables_unittest.cc
|
| diff --git a/chrome/browser/predictors/resource_prefetch_predictor_tables_unittest.cc b/chrome/browser/predictors/resource_prefetch_predictor_tables_unittest.cc
|
| index ad81c3d11f82ccddc99c825d2dd991103a3ea307..aaa4b085d7fb4e5afeb0934fc2bfbea6b889cfc5 100644
|
| --- a/chrome/browser/predictors/resource_prefetch_predictor_tables_unittest.cc
|
| +++ b/chrome/browser/predictors/resource_prefetch_predictor_tables_unittest.cc
|
| @@ -41,11 +41,13 @@ class ResourcePrefetchPredictorTablesTest : public testing::Test {
|
| scoped_refptr<ResourcePrefetchPredictorTables> tables_;
|
|
|
| using PrefetchDataMap = ResourcePrefetchPredictorTables::PrefetchDataMap;
|
| + using RedirectDataMap = ResourcePrefetchPredictorTables::RedirectDataMap;
|
|
|
| private:
|
| using ResourceRow = ResourcePrefetchPredictorTables::ResourceRow;
|
| - using ResourceRows = std::vector<ResourceRow>;
|
| + using RedirectRow = ResourcePrefetchPredictorTables::RedirectRow;
|
| using PrefetchData = ResourcePrefetchPredictorTables::PrefetchData;
|
| + using RedirectData = ResourcePrefetchPredictorTables::RedirectData;
|
|
|
| // Initializes the tables, |test_url_data_| and |test_host_data_|.
|
| void InitializeSampleData();
|
| @@ -54,10 +56,26 @@ class ResourcePrefetchPredictorTablesTest : public testing::Test {
|
| // can be in different order.
|
| void TestPrefetchDataAreEqual(const PrefetchDataMap& lhs,
|
| const PrefetchDataMap& rhs) const;
|
| - void TestResourceRowsAreEqual(const ResourceRows& lhs,
|
| - const ResourceRows& rhs) const;
|
| + void TestResourceRowsAreEqual(const std::vector<ResourceRow>& lhs,
|
| + const std::vector<ResourceRow>& rhs) const;
|
| +
|
| + // Checks that the input RedirectData are the same, although the redirects
|
| + // can be in different order.
|
| + void TestRedirectDataAreEqual(const RedirectDataMap& lhs,
|
| + const RedirectDataMap& rhs) const;
|
| + void TestRedirectRowsAreEqual(const std::vector<RedirectRow>& lhs,
|
| + const std::vector<RedirectRow>& rhs) const;
|
|
|
| void AddKey(PrefetchDataMap* m, const std::string& key) const;
|
| + void AddKey(RedirectDataMap* m, const std::string& key) const;
|
| +
|
| + // Useful for debugging tests.
|
| + static void PrintPrefetchData(const PrefetchData& data) {
|
| + LOG(ERROR) << "[" << data.key_type << "," << data.primary_key << ","
|
| + << data.last_visit.ToInternalValue() << "]";
|
| + for (const ResourceRow& resource : data.resources)
|
| + LogResource(resource);
|
| + }
|
|
|
| static void LogResource(const ResourceRow& row) {
|
| LOG(ERROR) << "\t\t" << row.resource_url << "\t" << row.resource_type
|
| @@ -67,16 +85,22 @@ class ResourcePrefetchPredictorTablesTest : public testing::Test {
|
| << row.always_revalidate << "\t" << row.score;
|
| }
|
|
|
| - // Useful for debugging tests.
|
| - void PrintPrefetchData(const PrefetchData& data) const {
|
| + static void PrintRedirectData(const RedirectData& data) {
|
| LOG(ERROR) << "[" << data.key_type << "," << data.primary_key
|
| << "," << data.last_visit.ToInternalValue() << "]";
|
| - for (const ResourceRow& resource : data.resources)
|
| - LogResource(resource);
|
| + for (const RedirectRow& redirect : data.redirects)
|
| + LogRedirect(redirect);
|
| + }
|
| +
|
| + static void LogRedirect(const RedirectRow& row) {
|
| + LOG(ERROR) << "\t\t" << row.url << "\t" << row.number_of_hits << "\t"
|
| + << row.number_of_misses << "\t" << row.consecutive_misses;
|
| }
|
|
|
| PrefetchDataMap test_url_data_;
|
| PrefetchDataMap test_host_data_;
|
| + RedirectDataMap test_url_redirect_data_;
|
| + RedirectDataMap test_host_redirect_data_;
|
| };
|
|
|
| class ResourcePrefetchPredictorTablesReopenTest
|
| @@ -115,38 +139,57 @@ void ResourcePrefetchPredictorTablesTest::TearDown() {
|
|
|
| void ResourcePrefetchPredictorTablesTest::TestGetAllData() {
|
| PrefetchDataMap actual_url_data, actual_host_data;
|
| - tables_->GetAllData(&actual_url_data, &actual_host_data);
|
| + RedirectDataMap actual_url_redirect_data, actual_host_redirect_data;
|
| + tables_->GetAllData(&actual_url_data, &actual_host_data,
|
| + &actual_url_redirect_data, &actual_host_redirect_data);
|
|
|
| TestPrefetchDataAreEqual(test_url_data_, actual_url_data);
|
| TestPrefetchDataAreEqual(test_host_data_, actual_host_data);
|
| + TestRedirectDataAreEqual(test_url_redirect_data_, actual_url_redirect_data);
|
| + TestRedirectDataAreEqual(test_host_redirect_data_, actual_host_redirect_data);
|
| }
|
|
|
| void ResourcePrefetchPredictorTablesTest::TestDeleteData() {
|
| - std::vector<std::string> urls_to_delete, hosts_to_delete;
|
| - urls_to_delete.push_back("http://www.google.com");
|
| - urls_to_delete.push_back("http://www.yahoo.com");
|
| - hosts_to_delete.push_back("www.yahoo.com");
|
| + std::vector<std::string> urls_to_delete = {"http://www.google.com",
|
| + "http://www.yahoo.com"};
|
| + std::vector<std::string> hosts_to_delete = {"www.yahoo.com"};
|
|
|
| - tables_->DeleteData(urls_to_delete, hosts_to_delete);
|
| + tables_->DeleteResourceData(urls_to_delete, hosts_to_delete);
|
| +
|
| + urls_to_delete = {"http://fb.com/google", "http://google.com"};
|
| + hosts_to_delete = {"microsoft.com"};
|
| +
|
| + tables_->DeleteRedirectData(urls_to_delete, hosts_to_delete);
|
|
|
| PrefetchDataMap actual_url_data, actual_host_data;
|
| - tables_->GetAllData(&actual_url_data, &actual_host_data);
|
| + RedirectDataMap actual_url_redirect_data, actual_host_redirect_data;
|
| + tables_->GetAllData(&actual_url_data, &actual_host_data,
|
| + &actual_url_redirect_data, &actual_host_redirect_data);
|
|
|
| PrefetchDataMap expected_url_data, expected_host_data;
|
| + RedirectDataMap expected_url_redirect_data, expected_host_redirect_data;
|
| AddKey(&expected_url_data, "http://www.reddit.com");
|
| AddKey(&expected_host_data, "www.facebook.com");
|
| + AddKey(&expected_url_redirect_data, "http://nyt.com");
|
| + AddKey(&expected_host_redirect_data, "bbc.com");
|
|
|
| TestPrefetchDataAreEqual(expected_url_data, actual_url_data);
|
| TestPrefetchDataAreEqual(expected_host_data, actual_host_data);
|
| + TestRedirectDataAreEqual(expected_url_redirect_data,
|
| + actual_url_redirect_data);
|
| + TestRedirectDataAreEqual(expected_host_redirect_data,
|
| + actual_host_redirect_data);
|
| }
|
|
|
| void ResourcePrefetchPredictorTablesTest::TestDeleteSingleDataPoint() {
|
| // Delete a URL.
|
| - tables_->DeleteSingleDataPoint("http://www.reddit.com",
|
| - PREFETCH_KEY_TYPE_URL);
|
| + tables_->DeleteSingleResourceDataPoint("http://www.reddit.com",
|
| + PREFETCH_KEY_TYPE_URL);
|
|
|
| PrefetchDataMap actual_url_data, actual_host_data;
|
| - tables_->GetAllData(&actual_url_data, &actual_host_data);
|
| + RedirectDataMap actual_url_redirect_data, actual_host_redirect_data;
|
| + tables_->GetAllData(&actual_url_data, &actual_host_data,
|
| + &actual_url_redirect_data, &actual_host_redirect_data);
|
|
|
| PrefetchDataMap expected_url_data;
|
| AddKey(&expected_url_data, "http://www.google.com");
|
| @@ -154,18 +197,65 @@ void ResourcePrefetchPredictorTablesTest::TestDeleteSingleDataPoint() {
|
|
|
| TestPrefetchDataAreEqual(expected_url_data, actual_url_data);
|
| TestPrefetchDataAreEqual(test_host_data_, actual_host_data);
|
| + TestRedirectDataAreEqual(test_url_redirect_data_, actual_url_redirect_data);
|
| + TestRedirectDataAreEqual(test_host_redirect_data_, actual_host_redirect_data);
|
|
|
| // Delete a host.
|
| - tables_->DeleteSingleDataPoint("www.facebook.com", PREFETCH_KEY_TYPE_HOST);
|
| + tables_->DeleteSingleResourceDataPoint("www.facebook.com",
|
| + PREFETCH_KEY_TYPE_HOST);
|
| actual_url_data.clear();
|
| actual_host_data.clear();
|
| - tables_->GetAllData(&actual_url_data, &actual_host_data);
|
| + actual_url_redirect_data.clear();
|
| + actual_host_redirect_data.clear();
|
| + tables_->GetAllData(&actual_url_data, &actual_host_data,
|
| + &actual_url_redirect_data, &actual_host_redirect_data);
|
|
|
| PrefetchDataMap expected_host_data;
|
| AddKey(&expected_host_data, "www.yahoo.com");
|
|
|
| TestPrefetchDataAreEqual(expected_url_data, actual_url_data);
|
| TestPrefetchDataAreEqual(expected_host_data, actual_host_data);
|
| + TestRedirectDataAreEqual(test_url_redirect_data_, actual_url_redirect_data);
|
| + TestRedirectDataAreEqual(test_host_redirect_data_, actual_host_redirect_data);
|
| +
|
| + // Delete a URL redirect.
|
| + tables_->DeleteSingleRedirectDataPoint("http://nyt.com",
|
| + PREFETCH_KEY_TYPE_URL);
|
| + actual_url_data.clear();
|
| + actual_host_data.clear();
|
| + actual_url_redirect_data.clear();
|
| + actual_host_redirect_data.clear();
|
| + tables_->GetAllData(&actual_url_data, &actual_host_data,
|
| + &actual_url_redirect_data, &actual_host_redirect_data);
|
| +
|
| + RedirectDataMap expected_url_redirect_data;
|
| + AddKey(&expected_url_redirect_data, "http://fb.com/google");
|
| + AddKey(&expected_url_redirect_data, "http://google.com");
|
| +
|
| + TestPrefetchDataAreEqual(expected_url_data, actual_url_data);
|
| + TestPrefetchDataAreEqual(expected_host_data, actual_host_data);
|
| + TestRedirectDataAreEqual(expected_url_redirect_data,
|
| + actual_url_redirect_data);
|
| + TestRedirectDataAreEqual(test_host_redirect_data_, actual_host_redirect_data);
|
| +
|
| + // Delete a host redirect.
|
| + tables_->DeleteSingleRedirectDataPoint("bbc.com", PREFETCH_KEY_TYPE_HOST);
|
| + actual_url_data.clear();
|
| + actual_host_data.clear();
|
| + actual_url_redirect_data.clear();
|
| + actual_host_redirect_data.clear();
|
| + tables_->GetAllData(&actual_url_data, &actual_host_data,
|
| + &actual_url_redirect_data, &actual_host_redirect_data);
|
| +
|
| + RedirectDataMap expected_host_redirect_data;
|
| + AddKey(&expected_host_redirect_data, "microsoft.com");
|
| +
|
| + TestPrefetchDataAreEqual(expected_url_data, actual_url_data);
|
| + TestPrefetchDataAreEqual(expected_host_data, actual_host_data);
|
| + TestRedirectDataAreEqual(expected_url_redirect_data,
|
| + actual_url_redirect_data);
|
| + TestRedirectDataAreEqual(expected_host_redirect_data,
|
| + actual_host_redirect_data);
|
| }
|
|
|
| void ResourcePrefetchPredictorTablesTest::TestUpdateData() {
|
| @@ -190,12 +280,25 @@ void ResourcePrefetchPredictorTablesTest::TestUpdateData() {
|
| content::RESOURCE_TYPE_IMAGE, 120, 1, 1,
|
| 10.0, net::MEDIUM, true, false));
|
|
|
| - tables_->UpdateData(google, yahoo);
|
| + RedirectData facebook(PREFETCH_KEY_TYPE_URL, "http://fb.com/google");
|
| + facebook.last_visit = base::Time::FromInternalValue(20);
|
| + facebook.redirects.push_back(
|
| + RedirectRow("https://facebook.fr/google", 4, 2, 1));
|
| +
|
| + RedirectData microsoft(PREFETCH_KEY_TYPE_HOST, "microsoft.com");
|
| + microsoft.last_visit = base::Time::FromInternalValue(21);
|
| + microsoft.redirects.push_back(RedirectRow("m.microsoft.com", 5, 7, 1));
|
| + microsoft.redirects.push_back(RedirectRow("microsoft.org", 7, 2, 0));
|
| +
|
| + tables_->UpdateData(google, yahoo, facebook, microsoft);
|
|
|
| PrefetchDataMap actual_url_data, actual_host_data;
|
| - tables_->GetAllData(&actual_url_data, &actual_host_data);
|
| + RedirectDataMap actual_url_redirect_data, actual_host_redirect_data;
|
| + tables_->GetAllData(&actual_url_data, &actual_host_data,
|
| + &actual_url_redirect_data, &actual_host_redirect_data);
|
|
|
| PrefetchDataMap expected_url_data, expected_host_data;
|
| + RedirectDataMap expected_url_redirect_data, expected_host_redirect_data;
|
| AddKey(&expected_url_data, "http://www.reddit.com");
|
| AddKey(&expected_url_data, "http://www.yahoo.com");
|
| expected_url_data.insert(std::make_pair("http://www.google.com", google));
|
| @@ -203,17 +306,34 @@ void ResourcePrefetchPredictorTablesTest::TestUpdateData() {
|
| AddKey(&expected_host_data, "www.facebook.com");
|
| expected_host_data.insert(std::make_pair("www.yahoo.com", yahoo));
|
|
|
| + AddKey(&expected_url_redirect_data, "http://nyt.com");
|
| + AddKey(&expected_url_redirect_data, "http://google.com");
|
| + expected_url_redirect_data.insert(
|
| + std::make_pair("http://fb.com/google", facebook));
|
| +
|
| + AddKey(&expected_host_redirect_data, "bbc.com");
|
| + expected_host_redirect_data.insert(
|
| + std::make_pair("microsoft.com", microsoft));
|
| +
|
| TestPrefetchDataAreEqual(expected_url_data, actual_url_data);
|
| TestPrefetchDataAreEqual(expected_host_data, actual_host_data);
|
| + TestRedirectDataAreEqual(expected_url_redirect_data,
|
| + actual_url_redirect_data);
|
| + TestRedirectDataAreEqual(expected_host_redirect_data,
|
| + actual_host_redirect_data);
|
| }
|
|
|
| void ResourcePrefetchPredictorTablesTest::TestDeleteAllData() {
|
| tables_->DeleteAllData();
|
|
|
| PrefetchDataMap actual_url_data, actual_host_data;
|
| - tables_->GetAllData(&actual_url_data, &actual_host_data);
|
| + RedirectDataMap actual_url_redirect_data, actual_host_redirect_data;
|
| + tables_->GetAllData(&actual_url_data, &actual_host_data,
|
| + &actual_url_redirect_data, &actual_host_redirect_data);
|
| EXPECT_TRUE(actual_url_data.empty());
|
| EXPECT_TRUE(actual_host_data.empty());
|
| + EXPECT_TRUE(actual_url_redirect_data.empty());
|
| + EXPECT_TRUE(actual_host_redirect_data.empty());
|
| }
|
|
|
| void ResourcePrefetchPredictorTablesTest::TestPrefetchDataAreEqual(
|
| @@ -224,25 +344,25 @@ void ResourcePrefetchPredictorTablesTest::TestPrefetchDataAreEqual(
|
| for (const std::pair<std::string, PrefetchData>& p : rhs) {
|
| PrefetchDataMap::const_iterator lhs_it = lhs.find(p.first);
|
| ASSERT_TRUE(lhs_it != lhs.end()) << p.first;
|
| + EXPECT_TRUE(lhs_it->second.key_type == p.second.key_type);
|
| + EXPECT_TRUE(lhs_it->second.last_visit == p.second.last_visit);
|
|
|
| TestResourceRowsAreEqual(lhs_it->second.resources, p.second.resources);
|
| }
|
| }
|
|
|
| void ResourcePrefetchPredictorTablesTest::TestResourceRowsAreEqual(
|
| - const ResourceRows& lhs,
|
| - const ResourceRows& rhs) const {
|
| + const std::vector<ResourceRow>& lhs,
|
| + const std::vector<ResourceRow>& rhs) const {
|
| EXPECT_EQ(lhs.size(), rhs.size());
|
|
|
| std::set<GURL> resources_seen;
|
| - for (ResourceRows::const_iterator rhs_it = rhs.begin();
|
| - rhs_it != rhs.end(); ++rhs_it) {
|
| - const GURL& resource = rhs_it->resource_url;
|
| + for (const ResourceRow& rhs_row : rhs) {
|
| + const GURL& resource = rhs_row.resource_url;
|
| EXPECT_FALSE(base::ContainsKey(resources_seen, resource));
|
|
|
| - for (ResourceRows::const_iterator lhs_it = lhs.begin();
|
| - lhs_it != lhs.end(); ++lhs_it) {
|
| - if (*rhs_it == *lhs_it) {
|
| + for (const ResourceRow& lhs_row : lhs) {
|
| + if (rhs_row == lhs_row) {
|
| resources_seen.insert(resource);
|
| break;
|
| }
|
| @@ -252,19 +372,75 @@ void ResourcePrefetchPredictorTablesTest::TestResourceRowsAreEqual(
|
| EXPECT_EQ(lhs.size(), resources_seen.size());
|
| }
|
|
|
| +void ResourcePrefetchPredictorTablesTest::TestRedirectDataAreEqual(
|
| + const RedirectDataMap& lhs,
|
| + const RedirectDataMap& rhs) const {
|
| + EXPECT_EQ(lhs.size(), rhs.size());
|
| +
|
| + for (const auto& p : rhs) {
|
| + auto lhs_it = lhs.find(p.first);
|
| + ASSERT_TRUE(lhs_it != lhs.end()) << p.first;
|
| + EXPECT_TRUE(lhs_it->second.key_type == p.second.key_type);
|
| + EXPECT_TRUE(lhs_it->second.last_visit == p.second.last_visit);
|
| +
|
| + TestRedirectRowsAreEqual(lhs_it->second.redirects, p.second.redirects);
|
| + }
|
| +}
|
| +
|
| +void ResourcePrefetchPredictorTablesTest::TestRedirectRowsAreEqual(
|
| + const std::vector<RedirectRow>& lhs,
|
| + const std::vector<RedirectRow>& rhs) const {
|
| + EXPECT_EQ(lhs.size(), rhs.size());
|
| +
|
| + std::map<std::string, RedirectRow> lhs_index;
|
| + for (const auto& row : lhs) {
|
| + // Repeated redirects are not allowed
|
| + EXPECT_TRUE(lhs_index.insert(std::make_pair(row.url, row)).second);
|
| + }
|
| +
|
| + for (const auto& row : rhs) {
|
| + auto lhs_it = lhs_index.find(row.url);
|
| + if (lhs_it != lhs_index.end()) {
|
| + EXPECT_EQ(row, lhs_it->second);
|
| + lhs_index.erase(lhs_it);
|
| + } else {
|
| + ADD_FAILURE() << row.url;
|
| + }
|
| + }
|
| +
|
| + EXPECT_TRUE(lhs_index.empty());
|
| +}
|
| +
|
| void ResourcePrefetchPredictorTablesTest::AddKey(PrefetchDataMap* m,
|
| const std::string& key) const {
|
| PrefetchDataMap::const_iterator it = test_url_data_.find(key);
|
| if (it != test_url_data_.end()) {
|
| - m->insert(std::make_pair(it->first, it->second));
|
| + m->insert(*it);
|
| return;
|
| }
|
| it = test_host_data_.find(key);
|
| ASSERT_TRUE(it != test_host_data_.end());
|
| - m->insert(std::make_pair(it->first, it->second));
|
| + m->insert(*it);
|
| +}
|
| +
|
| +void ResourcePrefetchPredictorTablesTest::AddKey(RedirectDataMap* m,
|
| + const std::string& key) const {
|
| + auto it = test_url_redirect_data_.find(key);
|
| + if (it != test_url_redirect_data_.end()) {
|
| + m->insert(*it);
|
| + return;
|
| + }
|
| + it = test_host_redirect_data_.find(key);
|
| + ASSERT_TRUE(it != test_host_redirect_data_.end());
|
| + m->insert(*it);
|
| }
|
|
|
| void ResourcePrefetchPredictorTablesTest::InitializeSampleData() {
|
| + PrefetchData empty_url_data(PREFETCH_KEY_TYPE_URL, std::string());
|
| + PrefetchData empty_host_data(PREFETCH_KEY_TYPE_HOST, std::string());
|
| + RedirectData empty_url_redirect_data(PREFETCH_KEY_TYPE_URL, std::string());
|
| + RedirectData empty_host_redirect_data(PREFETCH_KEY_TYPE_HOST, std::string());
|
| +
|
| { // Url data.
|
| PrefetchData google(PREFETCH_KEY_TYPE_URL, "http://www.google.com");
|
| google.last_visit = base::Time::FromInternalValue(1);
|
| @@ -305,10 +481,12 @@ void ResourcePrefetchPredictorTablesTest::InitializeSampleData() {
|
| test_url_data_.insert(std::make_pair("http://www.reddit.com", reddit));
|
| test_url_data_.insert(std::make_pair("http://www.yahoo.com", yahoo));
|
|
|
| - PrefetchData empty_host_data(PREFETCH_KEY_TYPE_HOST, std::string());
|
| - tables_->UpdateData(google, empty_host_data);
|
| - tables_->UpdateData(reddit, empty_host_data);
|
| - tables_->UpdateData(yahoo, empty_host_data);
|
| + tables_->UpdateData(google, empty_host_data, empty_url_redirect_data,
|
| + empty_host_redirect_data);
|
| + tables_->UpdateData(reddit, empty_host_data, empty_url_redirect_data,
|
| + empty_host_redirect_data);
|
| + tables_->UpdateData(yahoo, empty_host_data, empty_url_redirect_data,
|
| + empty_host_redirect_data);
|
| }
|
|
|
| { // Host data.
|
| @@ -341,9 +519,62 @@ void ResourcePrefetchPredictorTablesTest::InitializeSampleData() {
|
| test_host_data_.insert(std::make_pair("www.facebook.com", facebook));
|
| test_host_data_.insert(std::make_pair("www.yahoo.com", yahoo));
|
|
|
| - PrefetchData empty_url_data(PREFETCH_KEY_TYPE_URL, std::string());
|
| - tables_->UpdateData(empty_url_data, facebook);
|
| - tables_->UpdateData(empty_url_data, yahoo);
|
| + tables_->UpdateData(empty_url_data, facebook, empty_url_redirect_data,
|
| + empty_host_redirect_data);
|
| + tables_->UpdateData(empty_url_data, yahoo, empty_url_redirect_data,
|
| + empty_host_redirect_data);
|
| + }
|
| +
|
| + { // Url redirect data.
|
| + RedirectData facebook(PREFETCH_KEY_TYPE_URL, "http://fb.com/google");
|
| + facebook.last_visit = base::Time::FromInternalValue(6);
|
| + facebook.redirects.push_back(
|
| + RedirectRow("https://facebook.com/google", 5, 1, 0));
|
| + facebook.redirects.push_back(
|
| + RedirectRow("https://facebook.com/login", 3, 5, 1));
|
| +
|
| + RedirectData nytimes(PREFETCH_KEY_TYPE_URL, "http://nyt.com");
|
| + nytimes.last_visit = base::Time::FromInternalValue(7);
|
| + nytimes.redirects.push_back(RedirectRow("https://nytimes.com", 2, 0, 0));
|
| +
|
| + RedirectData google(PREFETCH_KEY_TYPE_URL, "http://google.com");
|
| + google.last_visit = base::Time::FromInternalValue(8);
|
| + google.redirects.push_back(RedirectRow("https://google.com", 3, 0, 0));
|
| +
|
| + test_url_redirect_data_.clear();
|
| + test_url_redirect_data_.insert(
|
| + std::make_pair(facebook.primary_key, facebook));
|
| + test_url_redirect_data_.insert(
|
| + std::make_pair(nytimes.primary_key, nytimes));
|
| + test_url_redirect_data_.insert(std::make_pair(google.primary_key, google));
|
| +
|
| + tables_->UpdateData(empty_url_data, empty_host_data, facebook,
|
| + empty_host_redirect_data);
|
| + tables_->UpdateData(empty_url_data, empty_host_data, nytimes,
|
| + empty_host_redirect_data);
|
| + tables_->UpdateData(empty_url_data, empty_host_data, google,
|
| + empty_host_redirect_data);
|
| + }
|
| +
|
| + { // Host redirect data.
|
| + RedirectData bbc(PREFETCH_KEY_TYPE_HOST, "bbc.com");
|
| + bbc.last_visit = base::Time::FromInternalValue(9);
|
| + bbc.redirects.push_back(RedirectRow("www.bbc.com", 8, 4, 1));
|
| + bbc.redirects.push_back(RedirectRow("m.bbc.com", 5, 8, 0));
|
| + bbc.redirects.push_back(RedirectRow("bbc.co.uk", 1, 3, 0));
|
| +
|
| + RedirectData microsoft(PREFETCH_KEY_TYPE_HOST, "microsoft.com");
|
| + microsoft.last_visit = base::Time::FromInternalValue(10);
|
| + microsoft.redirects.push_back(RedirectRow("www.microsoft.com", 10, 0, 0));
|
| +
|
| + test_host_redirect_data_.clear();
|
| + test_host_redirect_data_.insert(std::make_pair(bbc.primary_key, bbc));
|
| + test_host_redirect_data_.insert(
|
| + std::make_pair(microsoft.primary_key, microsoft));
|
| + tables_->UpdateData(empty_url_data, empty_host_data,
|
| + empty_url_redirect_data, bbc);
|
| + tables_->UpdateData(empty_url_data, empty_host_data,
|
| + empty_url_redirect_data, microsoft);
|
| }
|
| }
|
|
|
| @@ -415,7 +646,9 @@ TEST_F(ResourcePrefetchPredictorTablesTest, DatabaseIsResetWhenIncompatible) {
|
| ASSERT_EQ(version, ResourcePrefetchPredictorTables::GetDatabaseVersion(db));
|
|
|
| PrefetchDataMap url_data, host_data;
|
| - tables_->GetAllData(&url_data, &host_data);
|
| + RedirectDataMap url_redirect_data, host_redirect_data;
|
| + tables_->GetAllData(&url_data, &host_data, &url_redirect_data,
|
| + &host_redirect_data);
|
| EXPECT_TRUE(url_data.empty());
|
| EXPECT_TRUE(host_data.empty());
|
| }
|
|
|