Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: chrome/browser/search_engines/template_url_service_sync_unittest.cc

Issue 2682453002: Changed keywords conflicts resolution for extensions search engines. (Closed)
Patch Set: Fixed auto variable type must not deduce to a raw pointer type Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 std::unique_ptr<TemplateURL> deserialized(Deserialize(*iter)); 411 std::unique_ptr<TemplateURL> deserialized(Deserialize(*iter));
412 AssertEquals(*service_turl, *deserialized); 412 AssertEquals(*service_turl, *deserialized);
413 } 413 }
414 } 414 }
415 415
416 TEST_F(TemplateURLServiceSyncTest, GetAllSyncDataWithExtension) { 416 TEST_F(TemplateURLServiceSyncTest, GetAllSyncDataWithExtension) {
417 model()->Add(CreateTestTemplateURL(ASCIIToUTF16("key1"), "http://key1.com")); 417 model()->Add(CreateTestTemplateURL(ASCIIToUTF16("key1"), "http://key1.com"));
418 model()->Add(CreateTestTemplateURL(ASCIIToUTF16("key2"), "http://key2.com")); 418 model()->Add(CreateTestTemplateURL(ASCIIToUTF16("key2"), "http://key2.com"));
419 std::string fake_id("blahblahblah"); 419 std::string fake_id("blahblahblah");
420 std::string fake_url = std::string(kOmniboxScheme) + "://" + fake_id; 420 std::string fake_url = std::string(kOmniboxScheme) + "://" + fake_id;
421 model()->RegisterOmniboxKeyword(fake_id, "unittest", "key3", fake_url); 421 model()->RegisterOmniboxKeyword(fake_id, "unittest", "key3", fake_url,
422 Time());
422 syncer::SyncDataList all_sync_data = 423 syncer::SyncDataList all_sync_data =
423 model()->GetAllSyncData(syncer::SEARCH_ENGINES); 424 model()->GetAllSyncData(syncer::SEARCH_ENGINES);
424 425
425 EXPECT_EQ(2U, all_sync_data.size()); 426 EXPECT_EQ(2U, all_sync_data.size());
426 427
427 for (syncer::SyncDataList::const_iterator iter = all_sync_data.begin(); 428 for (syncer::SyncDataList::const_iterator iter = all_sync_data.begin();
428 iter != all_sync_data.end(); ++iter) { 429 iter != all_sync_data.end(); ++iter) {
429 std::string guid = GetGUID(*iter); 430 std::string guid = GetGUID(*iter);
430 const TemplateURL* service_turl = model()->GetTemplateURLForGUID(guid); 431 const TemplateURL* service_turl = model()->GetTemplateURLForGUID(guid);
431 std::unique_ptr<TemplateURL> deserialized(Deserialize(*iter)); 432 std::unique_ptr<TemplateURL> deserialized(Deserialize(*iter));
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, change.change_type()); 1070 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, change.change_type());
1070 } 1071 }
1071 1072
1072 TEST_F(TemplateURLServiceSyncTest, ProcessChangesWithLocalExtensions) { 1073 TEST_F(TemplateURLServiceSyncTest, ProcessChangesWithLocalExtensions) {
1073 model()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES, 1074 model()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES,
1074 CreateInitialSyncData(), PassProcessor(), 1075 CreateInitialSyncData(), PassProcessor(),
1075 CreateAndPassSyncErrorFactory()); 1076 CreateAndPassSyncErrorFactory());
1076 1077
1077 // Add some extension keywords locally. 1078 // Add some extension keywords locally.
1078 model()->RegisterOmniboxKeyword("extension1", "unittest", "keyword1", 1079 model()->RegisterOmniboxKeyword("extension1", "unittest", "keyword1",
1079 "http://extension1"); 1080 "http://extension1", Time());
1080 TemplateURL* extension1 = 1081 TemplateURL* extension1 =
1081 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword1")); 1082 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword1"));
1082 ASSERT_TRUE(extension1); 1083 ASSERT_TRUE(extension1);
1083 EXPECT_EQ(0U, processor()->change_list_size()); 1084 EXPECT_EQ(0U, processor()->change_list_size());
1084 1085
1085 model()->RegisterOmniboxKeyword("extension2", "unittest", "keyword2", 1086 model()->RegisterOmniboxKeyword("extension2", "unittest", "keyword2",
1086 "http://extension2"); 1087 "http://extension2", Time());
1087 TemplateURL* extension2 = 1088 TemplateURL* extension2 =
1088 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword2")); 1089 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword2"));
1089 ASSERT_TRUE(extension2); 1090 ASSERT_TRUE(extension2);
1090 EXPECT_EQ(0U, processor()->change_list_size()); 1091 EXPECT_EQ(0U, processor()->change_list_size());
1091 1092
1092 // Create some sync changes that will conflict with the extension keywords. 1093 // Create some sync changes that will conflict with the extension keywords.
1093 syncer::SyncChangeList changes; 1094 syncer::SyncChangeList changes;
1094 changes.push_back(CreateTestSyncChange( 1095 changes.push_back(CreateTestSyncChange(
1095 syncer::SyncChange::ACTION_ADD, 1096 syncer::SyncChange::ACTION_ADD,
1096 CreateTestTemplateURL(ASCIIToUTF16("keyword1"), "http://aaa.com", 1097 CreateTestTemplateURL(ASCIIToUTF16("keyword1"), "http://aaa.com",
1097 std::string(), 100, true, false, 0))); 1098 std::string(), 100, true, false, 0)));
1098 changes.push_back(CreateTestSyncChange(syncer::SyncChange::ACTION_ADD, 1099 changes.push_back(CreateTestSyncChange(syncer::SyncChange::ACTION_ADD,
1099 CreateTestTemplateURL(ASCIIToUTF16("keyword2"), "http://bbb.com"))); 1100 CreateTestTemplateURL(ASCIIToUTF16("keyword2"), "http://bbb.com")));
1100 model()->ProcessSyncChanges(FROM_HERE, changes); 1101 model()->ProcessSyncChanges(FROM_HERE, changes);
1101 1102
1102 EXPECT_FALSE(model()->GetTemplateURLForHost("aaa.com") == NULL); 1103 EXPECT_TRUE(model()->GetTemplateURLForHost("aaa.com"));
1104 EXPECT_TRUE(model()->GetTemplateURLForHost("bbb.com"));
1103 EXPECT_EQ(extension1, 1105 EXPECT_EQ(extension1,
1104 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword1"))); 1106 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword1")));
1105 TemplateURL* url_for_keyword2 = 1107 EXPECT_EQ(extension2,
1106 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword2"));
1107 EXPECT_NE(extension2, url_for_keyword2);
1108 EXPECT_EQ("http://bbb.com", url_for_keyword2->url());
1109
1110 EXPECT_EQ(extension1,
1111 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword1")));
1112 EXPECT_EQ(model()->GetTemplateURLForHost("bbb.com"),
1113 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword2"))); 1108 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword2")));
1114 } 1109 }
1115 1110
1116 TEST_F(TemplateURLServiceSyncTest, AutogeneratedKeywordMigrated) { 1111 TEST_F(TemplateURLServiceSyncTest, AutogeneratedKeywordMigrated) {
1117 // Create a couple of sync entries with autogenerated keywords. 1112 // Create a couple of sync entries with autogenerated keywords.
1118 syncer::SyncDataList initial_data; 1113 syncer::SyncDataList initial_data;
1119 std::unique_ptr<TemplateURL> turl = 1114 std::unique_ptr<TemplateURL> turl =
1120 CreateTestTemplateURL(ASCIIToUTF16("key1"), "http://key1.com", "key1"); 1115 CreateTestTemplateURL(ASCIIToUTF16("key1"), "http://key1.com", "key1");
1121 initial_data.push_back( 1116 initial_data.push_back(
1122 CreateCustomSyncData(*turl, true, turl->url(), turl->sync_guid())); 1117 CreateCustomSyncData(*turl, true, turl->url(), turl->sync_guid()));
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 2309
2315 TEST_F(TemplateURLServiceSyncTest, NonAsciiKeywordDoesNotCrash) { 2310 TEST_F(TemplateURLServiceSyncTest, NonAsciiKeywordDoesNotCrash) {
2316 model()->Add(CreateTestTemplateURL(UTF8ToUTF16("\xf0\xaf\xa6\x8d"), 2311 model()->Add(CreateTestTemplateURL(UTF8ToUTF16("\xf0\xaf\xa6\x8d"),
2317 "http://key1.com")); 2312 "http://key1.com"));
2318 syncer::SyncDataList initial_data = CreateInitialSyncData(); 2313 syncer::SyncDataList initial_data = CreateInitialSyncData();
2319 2314
2320 model()->MergeDataAndStartSyncing( 2315 model()->MergeDataAndStartSyncing(
2321 syncer::SEARCH_ENGINES, initial_data, PassProcessor(), 2316 syncer::SEARCH_ENGINES, initial_data, PassProcessor(),
2322 CreateAndPassSyncErrorFactory()); 2317 CreateAndPassSyncErrorFactory());
2323 } 2318 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/omnibox/omnibox_api.cc ('k') | chrome/browser/search_engines/template_url_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698