Index: chrome/browser/webdata/keyword_table_unittest.cc |
=================================================================== |
--- chrome/browser/webdata/keyword_table_unittest.cc (revision 101377) |
+++ chrome/browser/webdata/keyword_table_unittest.cc (working copy) |
@@ -252,3 +252,33 @@ |
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; |
+} |