Commit 6a773250 authored by stevet@chromium.org's avatar stevet@chromium.org

Ensure that TemplateURLs created from old database entries without sync_guids...

Ensure that TemplateURLs created from old database entries without sync_guids generate their own GUIDs.

BUG=96992
TEST=Ensure that KeywordTableTest.KeywordWithEmptySyncGUID passes.
Review URL: http://codereview.chromium.org/7980028

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102119 0039d316-1c4b-4281-b951-d872f2087c98
parent 49edb09c
......@@ -189,7 +189,10 @@ bool KeywordTable::GetKeywords(std::vector<TemplateURL*>* urls) {
template_url->set_last_modified(Time::FromTimeT(s.ColumnInt64(17)));
template_url->set_sync_guid(s.ColumnString(18));
// If the persisted sync_guid was empty, we ignore it and allow the TURL to
// keep its generated GUID.
if (!s.ColumnString(18).empty())
template_url->set_sync_guid(s.ColumnString(18));
urls->push_back(template_url);
}
......
......@@ -252,3 +252,33 @@ TEST_F(KeywordTableTest, KeywordWithNoFavicon) {
EXPECT_EQ(GetID(&template_url), GetID(restored_url));
delete restored_url;
}
TEST_F(KeywordTableTest, KeywordWithEmptySyncGUID) {
WebDatabase db;
ASSERT_EQ(sql::INIT_OK, db.Init(file_));
TemplateURL template_url;
template_url.set_short_name(ASCIIToUTF16("short_name"));
template_url.set_keyword(ASCIIToUTF16("keyword"));
template_url.SetURL("http://url/", 0, 0);
template_url.set_safe_for_autoreplace(true);
SetID(-100, &template_url);
// A GUID should be generated when |template_url| was created. Clear it.
ASSERT_FALSE(template_url.sync_guid().empty());
template_url.set_sync_guid(std::string());
EXPECT_TRUE(db.GetKeywordTable()->AddKeyword(template_url));
std::vector<TemplateURL*> template_urls;
EXPECT_TRUE(db.GetKeywordTable()->GetKeywords(&template_urls));
EXPECT_EQ(1U, template_urls.size());
const TemplateURL* restored_url = template_urls.front();
EXPECT_EQ(template_url.short_name(), restored_url->short_name());
EXPECT_EQ(template_url.keyword(), restored_url->keyword());
EXPECT_EQ(GetID(&template_url), GetID(restored_url));
EXPECT_FALSE(restored_url->sync_guid().empty());
delete restored_url;
}
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