Index: chrome/browser/sync/profile_sync_service_typed_url_unittest.cc |
=================================================================== |
--- chrome/browser/sync/profile_sync_service_typed_url_unittest.cc (revision 149878) |
+++ chrome/browser/sync/profile_sync_service_typed_url_unittest.cc (working copy) |
@@ -947,3 +947,54 @@ |
// Can't check GetErrorPercentage(), because generating an unrecoverable |
// error will free the model associator. |
} |
+TEST_F(ProfileSyncServiceTypedUrlTest, IgnoreLocalFileURL) { |
+ history::VisitVector original_visits; |
+ // Create http and file url. |
+ history::URLRow url_entry(MakeTypedUrlEntry("http://yey.com", |
+ "yey", 12, 15, false, |
+ &original_visits)); |
+ history::URLRow file_entry(MakeTypedUrlEntry("file:///kitty.jpg", |
+ "kitteh", 12, 15, false, |
+ &original_visits)); |
+ |
+ history::URLRows original_entries; |
+ original_entries.push_back(url_entry); |
+ original_entries.push_back(file_entry); |
+ |
+ EXPECT_CALL((*history_backend_.get()), GetAllTypedURLs(_)). |
+ WillRepeatedly(DoAll(SetArgumentPointee<0>(original_entries), |
+ Return(true))); |
+ EXPECT_CALL((*history_backend_.get()), GetMostRecentVisitsForURL(_, _, _)). |
+ WillRepeatedly(DoAll(SetArgumentPointee<2>(original_visits), |
+ Return(true))); |
+ CreateRootHelper create_root(this, syncer::TYPED_URLS); |
+ StartSyncService(create_root.callback()); |
+ |
+ history::VisitVector updated_visits; |
+ // Create updates for the previous urls + a new file one. |
+ history::URLRow updated_url_entry(MakeTypedUrlEntry("http://yey.com", |
+ "yey", 20, 15, false, |
+ &updated_visits)); |
+ history::URLRow updated_file_entry(MakeTypedUrlEntry("file:///cat.jpg", |
+ "cat", 20, 15, false, |
+ &updated_visits)); |
+ history::URLRow new_file_entry(MakeTypedUrlEntry("file:///dog.jpg", |
+ "dog", 20, 15, false, |
+ &updated_visits)); |
+ history::URLsModifiedDetails details; |
+ details.changed_urls.push_back(updated_url_entry); |
+ details.changed_urls.push_back(updated_file_entry); |
+ details.changed_urls.push_back(new_file_entry); |
+ scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&history_thread_)); |
+ notifier->Notify(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
+ content::Source<Profile>(&profile_), |
+ content::Details<history::URLsModifiedDetails>(&details)); |
+ |
+ history::URLRows new_sync_entries; |
+ GetTypedUrlsFromSyncDB(&new_sync_entries); |
+ |
+ // We should ignore the local file urls (existing and updated), |
+ // and only be left with the updated http url. |
+ ASSERT_EQ(1U, new_sync_entries.size()); |
+ EXPECT_TRUE(URLsEqual(updated_url_entry, new_sync_entries[0])); |
+} |