| Index: chrome/browser/sync/glue/typed_url_model_associator_unittest.cc
|
| diff --git a/chrome/browser/sync/glue/typed_url_model_associator_unittest.cc b/chrome/browser/sync/glue/typed_url_model_associator_unittest.cc
|
| index b75d102733796e202ddc9a3d393c3ac9dea223a2..46b81ad500c741da353ae5dd3b77c812bc420c0b 100644
|
| --- a/chrome/browser/sync/glue/typed_url_model_associator_unittest.cc
|
| +++ b/chrome/browser/sync/glue/typed_url_model_associator_unittest.cc
|
| @@ -36,24 +36,22 @@ class TypedUrlModelAssociatorTest : public testing::Test {
|
|
|
| static sync_pb::TypedUrlSpecifics MakeTypedUrlSpecifics(const char* url,
|
| const char* title,
|
| - int typed_count,
|
| int64 last_visit,
|
| bool hidden) {
|
| sync_pb::TypedUrlSpecifics typed_url;
|
| typed_url.set_url(url);
|
| typed_url.set_title(title);
|
| - typed_url.set_typed_count(typed_count);
|
| typed_url.set_hidden(hidden);
|
| - typed_url.add_visit(last_visit);
|
| - typed_url.set_visited_count(typed_url.visit_size());
|
| + typed_url.add_visits(last_visit);
|
| + typed_url.add_visit_transitions(PageTransition::TYPED);
|
| return typed_url;
|
| }
|
|
|
| static bool URLsEqual(history::URLRow& lhs, history::URLRow& rhs) {
|
| + // Only compare synced fields (ignore typed_count and visit_count as those
|
| + // are maintained by the history subsystem).
|
| return (lhs.url().spec().compare(rhs.url().spec()) == 0) &&
|
| (lhs.title().compare(rhs.title()) == 0) &&
|
| - (lhs.visit_count() == rhs.visit_count()) &&
|
| - (lhs.typed_count() == rhs.typed_count()) &&
|
| (lhs.hidden() == rhs.hidden());
|
| }
|
| };
|
| @@ -64,9 +62,9 @@ TEST_F(TypedUrlModelAssociatorTest, MergeUrls) {
|
| 2, 3, false, &visits1));
|
| sync_pb::TypedUrlSpecifics specs1(MakeTypedUrlSpecifics("http://pie.com/",
|
| "pie",
|
| - 2, 3, false));
|
| + 3, false));
|
| history::URLRow new_row1(GURL("http://pie.com/"));
|
| - std::vector<base::Time> new_visits1;
|
| + std::vector<history::VisitInfo> new_visits1;
|
| EXPECT_EQ(TypedUrlModelAssociator::DIFF_NONE,
|
| TypedUrlModelAssociator::MergeUrls(specs1, row1, &visits1,
|
| &new_row1, &new_visits1));
|
| @@ -76,13 +74,13 @@ TEST_F(TypedUrlModelAssociatorTest, MergeUrls) {
|
| 2, 3, false, &visits2));
|
| sync_pb::TypedUrlSpecifics specs2(MakeTypedUrlSpecifics("http://pie.com/",
|
| "pie",
|
| - 2, 3, true));
|
| + 3, true));
|
| history::VisitVector expected_visits2;
|
| history::URLRow expected2(MakeTypedUrlRow("http://pie.com/", "pie",
|
| 2, 3, true, &expected_visits2));
|
| history::URLRow new_row2(GURL("http://pie.com/"));
|
| - std::vector<base::Time> new_visits2;
|
| - EXPECT_EQ(TypedUrlModelAssociator::DIFF_ROW_CHANGED,
|
| + std::vector<history::VisitInfo> new_visits2;
|
| + EXPECT_EQ(TypedUrlModelAssociator::DIFF_LOCAL_ROW_CHANGED,
|
| TypedUrlModelAssociator::MergeUrls(specs2, row2, &visits2,
|
| &new_row2, &new_visits2));
|
| EXPECT_TRUE(URLsEqual(new_row2, expected2));
|
| @@ -92,14 +90,14 @@ TEST_F(TypedUrlModelAssociatorTest, MergeUrls) {
|
| 2, 3, false, &visits3));
|
| sync_pb::TypedUrlSpecifics specs3(MakeTypedUrlSpecifics("http://pie.com/",
|
| "pie2",
|
| - 2, 3, true));
|
| + 3, true));
|
| history::VisitVector expected_visits3;
|
| history::URLRow expected3(MakeTypedUrlRow("http://pie.com/", "pie2",
|
| 2, 3, true, &expected_visits3));
|
| history::URLRow new_row3(GURL("http://pie.com/"));
|
| - std::vector<base::Time> new_visits3;
|
| - EXPECT_EQ(TypedUrlModelAssociator::DIFF_ROW_CHANGED |
|
| - TypedUrlModelAssociator::DIFF_TITLE_CHANGED,
|
| + std::vector<history::VisitInfo> new_visits3;
|
| + EXPECT_EQ(TypedUrlModelAssociator::DIFF_LOCAL_ROW_CHANGED |
|
| + TypedUrlModelAssociator::DIFF_LOCAL_TITLE_CHANGED,
|
| TypedUrlModelAssociator::MergeUrls(specs3, row3, &visits3,
|
| &new_row3, &new_visits3));
|
| EXPECT_TRUE(URLsEqual(new_row3, expected3));
|
| @@ -109,16 +107,14 @@ TEST_F(TypedUrlModelAssociatorTest, MergeUrls) {
|
| 2, 4, false, &visits4));
|
| sync_pb::TypedUrlSpecifics specs4(MakeTypedUrlSpecifics("http://pie.com/",
|
| "pie2",
|
| - 2, 3, true));
|
| + 3, true));
|
| history::VisitVector expected_visits4;
|
| history::URLRow expected4(MakeTypedUrlRow("http://pie.com/", "pie",
|
| 2, 4, false, &expected_visits4));
|
| - expected4.set_visit_count(2);
|
| history::URLRow new_row4(GURL("http://pie.com/"));
|
| - std::vector<base::Time> new_visits4;
|
| - EXPECT_EQ(TypedUrlModelAssociator::DIFF_NODE_CHANGED |
|
| - TypedUrlModelAssociator::DIFF_ROW_CHANGED |
|
| - TypedUrlModelAssociator::DIFF_VISITS_ADDED,
|
| + std::vector<history::VisitInfo> new_visits4;
|
| + EXPECT_EQ(TypedUrlModelAssociator::DIFF_UPDATE_NODE |
|
| + TypedUrlModelAssociator::DIFF_LOCAL_VISITS_ADDED,
|
| TypedUrlModelAssociator::MergeUrls(specs4, row4, &visits4,
|
| &new_row4, &new_visits4));
|
| EXPECT_EQ(1U, new_visits4.size());
|
| @@ -129,19 +125,21 @@ TEST_F(TypedUrlModelAssociatorTest, MergeUrls) {
|
| 1, 4, false, &visits5));
|
| sync_pb::TypedUrlSpecifics specs5(MakeTypedUrlSpecifics("http://pie.com/",
|
| "pie",
|
| - 2, 3, false));
|
| + 3, false));
|
| history::VisitVector expected_visits5;
|
| history::URLRow expected5(MakeTypedUrlRow("http://pie.com/", "pie",
|
| 2, 3, false, &expected_visits5));
|
| - expected5.set_visit_count(2);
|
| history::URLRow new_row5(GURL("http://pie.com/"));
|
| - std::vector<base::Time> new_visits5;
|
| - EXPECT_EQ(TypedUrlModelAssociator::DIFF_ROW_CHANGED |
|
| - TypedUrlModelAssociator::DIFF_NODE_CHANGED |
|
| - TypedUrlModelAssociator::DIFF_VISITS_ADDED,
|
| + std::vector<history::VisitInfo> new_visits5;
|
| +
|
| + // UPDATE_NODE should be set because row5 has a newer last_visit timestamp.
|
| + // LOCAL_VISITS_ADDED should be set because there now should be two visits.
|
| + EXPECT_EQ(TypedUrlModelAssociator::DIFF_UPDATE_NODE |
|
| + TypedUrlModelAssociator::DIFF_LOCAL_VISITS_ADDED,
|
| TypedUrlModelAssociator::MergeUrls(specs5, row5, &visits5,
|
| &new_row5, &new_visits5));
|
| EXPECT_TRUE(URLsEqual(new_row5, expected5));
|
| + EXPECT_EQ(1U, new_visits5.size());
|
|
|
| }
|
|
|
| @@ -153,11 +151,13 @@ TEST_F(TypedUrlModelAssociatorTest, DiffVisitsSame) {
|
|
|
| for (size_t c = 0; c < arraysize(visits); ++c) {
|
| old_visits.push_back(history::VisitRow(
|
| - 0, base::Time::FromInternalValue(visits[c]), 0, 0, 0));
|
| - new_url.add_visit(visits[c]);
|
| + 0, base::Time::FromInternalValue(visits[c]), 0, PageTransition::TYPED,
|
| + 0));
|
| + new_url.add_visits(visits[c]);
|
| + new_url.add_visit_transitions(PageTransition::TYPED);
|
| }
|
|
|
| - std::vector<base::Time> new_visits;
|
| + std::vector<history::VisitInfo> new_visits;
|
| history::VisitVector removed_visits;
|
|
|
| TypedUrlModelAssociator::DiffVisits(old_visits, new_url,
|
| @@ -178,14 +178,16 @@ TEST_F(TypedUrlModelAssociatorTest, DiffVisitsRemove) {
|
|
|
| for (size_t c = 0; c < arraysize(visits_left); ++c) {
|
| old_visits.push_back(history::VisitRow(
|
| - 0, base::Time::FromInternalValue(visits_left[c]), 0, 0, 0));
|
| + 0, base::Time::FromInternalValue(visits_left[c]), 0,
|
| + PageTransition::TYPED, 0));
|
| }
|
|
|
| for (size_t c = 0; c < arraysize(visits_right); ++c) {
|
| - new_url.add_visit(visits_right[c]);
|
| + new_url.add_visits(visits_right[c]);
|
| + new_url.add_visit_transitions(PageTransition::TYPED);
|
| }
|
|
|
| - std::vector<base::Time> new_visits;
|
| + std::vector<history::VisitInfo> new_visits;
|
| history::VisitVector removed_visits;
|
|
|
| TypedUrlModelAssociator::DiffVisits(old_visits, new_url,
|
| @@ -210,14 +212,16 @@ TEST_F(TypedUrlModelAssociatorTest, DiffVisitsAdd) {
|
|
|
| for (size_t c = 0; c < arraysize(visits_left); ++c) {
|
| old_visits.push_back(history::VisitRow(
|
| - 0, base::Time::FromInternalValue(visits_left[c]), 0, 0, 0));
|
| + 0, base::Time::FromInternalValue(visits_left[c]), 0,
|
| + PageTransition::TYPED, 0));
|
| }
|
|
|
| for (size_t c = 0; c < arraysize(visits_right); ++c) {
|
| - new_url.add_visit(visits_right[c]);
|
| + new_url.add_visits(visits_right[c]);
|
| + new_url.add_visit_transitions(PageTransition::TYPED);
|
| }
|
|
|
| - std::vector<base::Time> new_visits;
|
| + std::vector<history::VisitInfo> new_visits;
|
| history::VisitVector removed_visits;
|
|
|
| TypedUrlModelAssociator::DiffVisits(old_visits, new_url,
|
| @@ -225,7 +229,8 @@ TEST_F(TypedUrlModelAssociatorTest, DiffVisitsAdd) {
|
| EXPECT_TRUE(removed_visits.empty());
|
| ASSERT_TRUE(new_visits.size() == arraysize(visits_added));
|
| for (size_t c = 0; c < arraysize(visits_added); ++c) {
|
| - EXPECT_EQ(new_visits[c].ToInternalValue(),
|
| + EXPECT_EQ(new_visits[c].first.ToInternalValue(),
|
| visits_added[c]);
|
| + EXPECT_EQ(new_visits[c].second, PageTransition::TYPED);
|
| }
|
| }
|
|
|