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

Unified Diff: chrome/browser/search_engines/template_url_service_unittest.cc

Issue 2659353002: Fix TemplateUrl::MatchesData comparison of search_terms_replacement_key (reland) (Closed)
Patch Set: Fixed TemplateUrlService not updating sync guid after Repair Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/search_engines/template_url.cc » ('j') | components/search_engines/template_url.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search_engines/template_url_service_unittest.cc
diff --git a/chrome/browser/search_engines/template_url_service_unittest.cc b/chrome/browser/search_engines/template_url_service_unittest.cc
index ddc06380b068dc5a15b115a81b7277584f0d54a4..439eda928af13fc9546ad5b287b041128e2d751b 100644
--- a/chrome/browser/search_engines/template_url_service_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_unittest.cc
@@ -28,10 +28,12 @@
#include "chrome/test/base/testing_profile.h"
#include "components/history/core/browser/history_service.h"
#include "components/search_engines/keyword_web_data_service.h"
+#include "components/search_engines/search_engines_pref_names.h"
#include "components/search_engines/search_host_to_urls_map.h"
#include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_prepopulate_data.h"
+#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -893,6 +895,46 @@ TEST_F(TemplateURLServiceTest, RepairSearchEnginesWithManagedDefault) {
ExpectSimilar(expected_managed_default.get(), actual_managed_default);
}
+TEST_F(TemplateURLServiceTest, RepairPrepopulatedEnginesUpdatesSyncGuid) {
+ test_util()->VerifyLoad();
+
+ // Expect no synced DSE guid until user selected something or sync come in.
+ EXPECT_TRUE(test_util()
+ ->profile()
+ ->GetTestingPrefService()
+ ->GetString(prefs::kSyncedDefaultSearchProviderGUID)
+ .empty());
+
+ // Google engine must exist.
+ TemplateURL* google =
+ model()->GetTemplateURLForKeyword(ASCIIToUTF16("google.com"));
+ ASSERT_TRUE(google);
+ // Add third-party default search engine.
+ TemplateURL* user_dse = AddKeywordWithDate(
+ "user_dse", "user_dse.com", "http://www.user_dse.com/s?q={searchTerms}",
+ std::string(), std::string(), std::string(), true, "UTF-8", Time(),
+ Time(), Time());
+ model()->SetUserSelectedDefaultSearchProvider(user_dse);
+ EXPECT_EQ(user_dse, model()->GetDefaultSearchProvider());
+
+ // Check that user DSE guid is stored in kSyncedDefaultSearchProviderGUID.
+ EXPECT_EQ(user_dse->sync_guid(),
+ test_util()->profile()->GetTestingPrefService()->GetString(
+ prefs::kSyncedDefaultSearchProviderGUID));
+
+ model()->RepairPrepopulatedSearchEngines();
+
+ // Check that Google is default after repair.
+ ASSERT_EQ(google, model()->GetDefaultSearchProvider());
+ // Check that google guid is stored in kSyncedDefaultSearchProviderGUID.
+ const std::string dse_guid =
+ test_util()->profile()->GetTestingPrefService()->GetString(
+ prefs::kSyncedDefaultSearchProviderGUID);
+ EXPECT_EQ(google->sync_guid(), dse_guid);
+ EXPECT_EQ(google->keyword(),
+ model()->GetTemplateURLForGUID(dse_guid)->keyword());
+}
+
TEST_F(TemplateURLServiceTest, UpdateKeywordSearchTermsForURL) {
struct TestData {
const std::string url;
« no previous file with comments | « no previous file | components/search_engines/template_url.cc » ('j') | components/search_engines/template_url.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698