| Index: chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
|
| diff --git a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
|
| index 3826287feb3400a8e9ce3c0502c3ce99160cb313..c5092e44c033d2d5562717bf60377fcc09a083e5 100644
|
| --- a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
|
| +++ b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
|
| @@ -106,6 +106,8 @@ class HistoryBackendMock : public HistoryBackend {
|
| MOCK_METHOD1(DeleteURL, void(const GURL& url));
|
|
|
| private:
|
| + friend class ProfileSyncServiceTypedUrlTest;
|
| +
|
| virtual ~HistoryBackendMock() {}
|
| };
|
|
|
| @@ -325,6 +327,23 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest {
|
| EXPECT_CALL((*history_backend_.get()), DeleteURL(_)).Times(0);
|
| }
|
|
|
| + void SendNotificationAddVisit(ui::PageTransition transition,
|
| + const history::URLRow& row) {
|
| + base::Time visit_time;
|
| + history::RedirectList redirects;
|
| + history_thread_->task_runner()->PostTaskAndReply(
|
| + FROM_HERE,
|
| + base::Bind(&HistoryBackendMock::NotifyAddVisit,
|
| + base::Unretained(history_backend_.get()),
|
| + transition,
|
| + row,
|
| + redirects,
|
| + visit_time),
|
| + base::Bind(&base::MessageLoop::QuitNow,
|
| + base::Unretained(base::MessageLoop::current())));
|
| + base::MessageLoop::current()->Run();
|
| + }
|
| +
|
| static bool URLsEqual(history::URLRow& lhs, history::URLRow& rhs) {
|
| // Only verify the fields we explicitly sync (i.e. don't verify typed_count
|
| // or visit_count because we rely on the history DB to manage those values
|
| @@ -702,14 +721,7 @@ TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeAddFromVisit) {
|
| CreateRootHelper create_root(this, syncer::TYPED_URLS);
|
| StartSyncService(create_root.callback());
|
|
|
| - history::URLVisitedDetails details;
|
| - details.row = added_entry;
|
| - details.transition = ui::PAGE_TRANSITION_TYPED;
|
| - scoped_refptr<ThreadNotifier> notifier(
|
| - new ThreadNotifier(history_thread_.get()));
|
| - notifier->Notify(chrome::NOTIFICATION_HISTORY_URL_VISITED,
|
| - content::Source<Profile>(profile_),
|
| - content::Details<history::URLVisitedDetails>(&details));
|
| + SendNotificationAddVisit(ui::PAGE_TRANSITION_TYPED, added_entry);
|
|
|
| history::URLRows new_sync_entries;
|
| GetTypedUrlsFromSyncDB(&new_sync_entries);
|
| @@ -741,14 +753,7 @@ TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeUpdateFromVisit) {
|
| WillOnce(DoAll(SetArgumentPointee<2>(updated_visits),
|
| Return(true)));
|
|
|
| - history::URLVisitedDetails details;
|
| - details.row = updated_entry;
|
| - details.transition = ui::PAGE_TRANSITION_TYPED;
|
| - scoped_refptr<ThreadNotifier> notifier(
|
| - new ThreadNotifier(history_thread_.get()));
|
| - notifier->Notify(chrome::NOTIFICATION_HISTORY_URL_VISITED,
|
| - content::Source<Profile>(profile_),
|
| - content::Details<history::URLVisitedDetails>(&details));
|
| + SendNotificationAddVisit(ui::PAGE_TRANSITION_TYPED, updated_entry);
|
|
|
| history::URLRows new_sync_entries;
|
| GetTypedUrlsFromSyncDB(&new_sync_entries);
|
| @@ -780,17 +785,9 @@ TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserIgnoreChangeUpdateFromVisit) {
|
| history::URLRow updated_entry(MakeTypedUrlEntry("http://mine.com", "entry",
|
| 7, 15, false,
|
| &updated_visits));
|
| - history::URLVisitedDetails details;
|
| - details.row = updated_entry;
|
|
|
| // Should ignore this change because it's not TYPED.
|
| - details.transition = ui::PAGE_TRANSITION_RELOAD;
|
| - scoped_refptr<ThreadNotifier> notifier(
|
| - new ThreadNotifier(history_thread_.get()));
|
| - notifier->Notify(chrome::NOTIFICATION_HISTORY_URL_VISITED,
|
| - content::Source<Profile>(profile_),
|
| - content::Details<history::URLVisitedDetails>(&details));
|
| -
|
| + SendNotificationAddVisit(ui::PAGE_TRANSITION_RELOAD, updated_entry);
|
| GetTypedUrlsFromSyncDB(&new_sync_entries);
|
|
|
| // Should be no changes to the sync DB from this notification.
|
| @@ -802,12 +799,9 @@ TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserIgnoreChangeUpdateFromVisit) {
|
| history::URLRow twelve_visits(MakeTypedUrlEntry("http://mine.com", "entry",
|
| 12, 15, false,
|
| &updated_visits));
|
| - details.row = twelve_visits;
|
| - details.transition = ui::PAGE_TRANSITION_TYPED;
|
| - notifier->Notify(chrome::NOTIFICATION_HISTORY_URL_VISITED,
|
| - content::Source<Profile>(profile_),
|
| - content::Details<history::URLVisitedDetails>(&details));
|
| + SendNotificationAddVisit(ui::PAGE_TRANSITION_TYPED, twelve_visits);
|
| GetTypedUrlsFromSyncDB(&new_sync_entries);
|
| +
|
| // Should be no changes to the sync DB from this notification.
|
| ASSERT_EQ(1U, new_sync_entries.size());
|
| EXPECT_TRUE(URLsEqual(original_entry, new_sync_entries[0]));
|
| @@ -817,12 +811,9 @@ TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserIgnoreChangeUpdateFromVisit) {
|
| history::URLRow twenty_visits(MakeTypedUrlEntry("http://mine.com", "entry",
|
| 20, 15, false,
|
| &updated_visits));
|
| - details.row = twenty_visits;
|
| - details.transition = ui::PAGE_TRANSITION_TYPED;
|
| - notifier->Notify(chrome::NOTIFICATION_HISTORY_URL_VISITED,
|
| - content::Source<Profile>(profile_),
|
| - content::Details<history::URLVisitedDetails>(&details));
|
| + SendNotificationAddVisit(ui::PAGE_TRANSITION_TYPED, twenty_visits);
|
| GetTypedUrlsFromSyncDB(&new_sync_entries);
|
| +
|
| ASSERT_EQ(1U, new_sync_entries.size());
|
| EXPECT_TRUE(URLsEqual(twenty_visits, new_sync_entries[0]));
|
| }
|
|
|