Commit 9a74a267 authored by zea@chromium.org's avatar zea@chromium.org

[Sync] Verify writing to history backend in typed urls.

BUG=94140
TEST=unit_tests --gtest_filter="*FailWriteToHistoryBackend*"


Review URL: http://codereview.chromium.org/7753008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98358 0039d316-1c4b-4281-b951-d872f2087c98
parent e0ae5193
......@@ -265,8 +265,14 @@ bool TypedUrlModelAssociator::AssociateModels(SyncError* error) {
// this is the only thread that writes to the database. We also don't have
// to worry about the sync model getting out of sync, because changes are
// propagated to the ChangeProcessor on this thread.
return WriteToHistoryBackend(&titles, &new_urls, &updated_urls,
&new_visits, NULL);
if (!WriteToHistoryBackend(&titles, &new_urls, &updated_urls,
&new_visits, NULL)) {
error->Reset(FROM_HERE,
"Failed to write to history backend",
model_type());
return false;
}
return true;
}
bool TypedUrlModelAssociator::DeleteAllNodes(
......
......@@ -682,3 +682,30 @@ TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeRemoveAll) {
GetTypedUrlsFromSyncDB(&new_sync_entries);
ASSERT_EQ(0U, new_sync_entries.size());
}
TEST_F(ProfileSyncServiceTypedUrlTest, FailWriteToHistoryBackend) {
history::VisitVector native_visits;
history::VisitVector sync_visits;
history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "entry",
2, 15, false, &native_visits));
history::URLRow sync_entry(MakeTypedUrlEntry("http://sync.com", "entry",
3, 16, false, &sync_visits));
std::vector<history::URLRow> native_entries;
native_entries.push_back(native_entry);
EXPECT_CALL((*history_backend_.get()), GetAllTypedURLs(_)).
WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true)));
EXPECT_CALL((*history_backend_.get()), GetVisitsForURL(_, _)).
WillRepeatedly(DoAll(SetArgumentPointee<1>(native_visits), Return(true)));
EXPECT_CALL((*history_backend_.get()),
AddVisits(_, _, history::SOURCE_SYNCED)).WillRepeatedly(Return(false));
std::vector<history::URLRow> sync_entries;
sync_entries.push_back(sync_entry);
AddTypedUrlEntriesTask task(this, sync_entries);
EXPECT_CALL((*history_backend_.get()), UpdateURL(_, _)).
WillRepeatedly(Return(false));
StartSyncService(&task);
ASSERT_TRUE(service_->unrecoverable_error_detected());
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment