| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/search_engines/search_engines_test_util.h" | 5 #include "components/search_engines/search_engines_test_util.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/search_engines/default_search_manager.h" | 10 #include "components/search_engines/default_search_manager.h" |
| 11 #include "components/search_engines/template_url.h" | 11 #include "components/search_engines/template_url.h" |
| 12 #include "components/search_engines/template_url_data.h" | 12 #include "components/search_engines/template_url_data.h" |
| 13 #include "components/search_engines/template_url_data_util.h" | 13 #include "components/search_engines/template_url_data_util.h" |
| 14 #include "components/sync_preferences/testing_pref_service_syncable.h" | 14 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 std::unique_ptr<TemplateURLData> GenerateDummyTemplateURLData( | 17 std::unique_ptr<TemplateURLData> GenerateDummyTemplateURLData( |
| 18 const std::string& provider_name) { | 18 const std::string& keyword) { |
| 19 auto data = base::MakeUnique<TemplateURLData>(); | 19 auto data = base::MakeUnique<TemplateURLData>(); |
| 20 data->SetShortName(base::UTF8ToUTF16(provider_name + "name")); | 20 data->SetShortName(base::UTF8ToUTF16(keyword + "name")); |
| 21 data->SetKeyword(base::UTF8ToUTF16(provider_name + "key")); | 21 data->SetKeyword(base::UTF8ToUTF16(keyword)); |
| 22 data->SetURL(std::string("http://") + provider_name + "foo/{searchTerms}"); | 22 data->SetURL(std::string("http://") + keyword + "foo/{searchTerms}"); |
| 23 data->suggestions_url = std::string("http://") + provider_name + "sugg"; | 23 data->suggestions_url = std::string("http://") + keyword + "sugg"; |
| 24 data->alternate_urls.push_back(std::string("http://") + provider_name + | 24 data->alternate_urls.push_back(std::string("http://") + keyword + "foo/alt"); |
| 25 "foo/alt"); | |
| 26 data->favicon_url = GURL("http://icon1"); | 25 data->favicon_url = GURL("http://icon1"); |
| 27 data->safe_for_autoreplace = true; | 26 data->safe_for_autoreplace = true; |
| 28 data->input_encodings = {"UTF-8", "UTF-16"}; | 27 data->input_encodings = {"UTF-8", "UTF-16"}; |
| 29 data->date_created = base::Time(); | 28 data->date_created = base::Time(); |
| 30 data->last_modified = base::Time(); | 29 data->last_modified = base::Time(); |
| 31 return data; | 30 return data; |
| 32 } | 31 } |
| 33 | 32 |
| 34 void ExpectSimilar(const TemplateURLData* expected, | 33 void ExpectSimilar(const TemplateURLData* expected, |
| 35 const TemplateURLData* actual) { | 34 const TemplateURLData* actual) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 prefs->SetExtensionPref( | 66 prefs->SetExtensionPref( |
| 68 DefaultSearchManager::kDefaultSearchProviderDataPrefName, | 67 DefaultSearchManager::kDefaultSearchProviderDataPrefName, |
| 69 entry.release()); | 68 entry.release()); |
| 70 } | 69 } |
| 71 | 70 |
| 72 void RemoveExtensionDefaultSearchFromPrefs( | 71 void RemoveExtensionDefaultSearchFromPrefs( |
| 73 sync_preferences::TestingPrefServiceSyncable* prefs) { | 72 sync_preferences::TestingPrefServiceSyncable* prefs) { |
| 74 prefs->RemoveExtensionPref( | 73 prefs->RemoveExtensionPref( |
| 75 DefaultSearchManager::kDefaultSearchProviderDataPrefName); | 74 DefaultSearchManager::kDefaultSearchProviderDataPrefName); |
| 76 } | 75 } |
| OLD | NEW |