OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "chrome/browser/android/locale/special_locale_handler.h" | 5 #include "chrome/browser/android/locale/special_locale_handler.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 9 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
11 #include "components/search_engines/prepopulated_engines.h" | 11 #include "components/search_engines/prepopulated_engines.h" |
12 #include "components/search_engines/template_url.h" | 12 #include "components/search_engines/template_url.h" |
| 13 #include "components/search_engines/template_url_data_util.h" |
13 #include "components/search_engines/template_url_prepopulate_data.h" | 14 #include "components/search_engines/template_url_prepopulate_data.h" |
14 #include "components/search_engines/template_url_service.h" | 15 #include "components/search_engines/template_url_service.h" |
15 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 class MockSpecialLocaleHandler : public SpecialLocaleHandler { | 19 class MockSpecialLocaleHandler : public SpecialLocaleHandler { |
19 public: | 20 public: |
20 MockSpecialLocaleHandler(Profile* profile, | 21 MockSpecialLocaleHandler(Profile* profile, |
21 std::string locale, | 22 std::string locale, |
22 TemplateURLService* service) | 23 TemplateURLService* service) |
23 : SpecialLocaleHandler(profile, locale, service) {} | 24 : SpecialLocaleHandler(profile, locale, service) {} |
24 | 25 |
25 ~MockSpecialLocaleHandler() override {} | 26 ~MockSpecialLocaleHandler() override {} |
26 | 27 |
27 protected: | 28 protected: |
28 std::vector<std::unique_ptr<TemplateURLData>> GetLocalPrepopulatedEngines( | 29 std::vector<std::unique_ptr<TemplateURLData>> GetLocalPrepopulatedEngines( |
29 Profile* profile) override { | 30 Profile* profile) override { |
30 std::vector<std::unique_ptr<TemplateURLData>> result; | 31 std::vector<std::unique_ptr<TemplateURLData>> result; |
31 result.push_back( | 32 result.push_back(TemplateURLDataFromPrepopulatedEngine( |
32 TemplateURLPrepopulateData::MakeTemplateURLDataFromPrepopulatedEngine( | 33 TemplateURLPrepopulateData::so_360)); |
33 TemplateURLPrepopulateData::so_360)); | 34 result.push_back(TemplateURLDataFromPrepopulatedEngine( |
34 result.push_back( | 35 TemplateURLPrepopulateData::naver)); |
35 TemplateURLPrepopulateData::MakeTemplateURLDataFromPrepopulatedEngine( | |
36 TemplateURLPrepopulateData::naver)); | |
37 return result; | 36 return result; |
38 } | 37 } |
39 | 38 |
40 int GetDesignatedSearchEngine() override { | 39 int GetDesignatedSearchEngine() override { |
41 return TemplateURLPrepopulateData::naver.id; | 40 return TemplateURLPrepopulateData::naver.id; |
42 } | 41 } |
43 }; | 42 }; |
44 | 43 |
45 class SpecialLocaleHandlerTest : public testing::Test { | 44 class SpecialLocaleHandlerTest : public testing::Test { |
46 public: | 45 public: |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // Set one of the local search engine as default. | 116 // Set one of the local search engine as default. |
118 handler()->OverrideDefaultSearchProvider(NULL, JavaParamRef<jobject>(NULL)); | 117 handler()->OverrideDefaultSearchProvider(NULL, JavaParamRef<jobject>(NULL)); |
119 ASSERT_EQ(TemplateURLPrepopulateData::naver.id, | 118 ASSERT_EQ(TemplateURLPrepopulateData::naver.id, |
120 model()->GetDefaultSearchProvider()->prepopulate_id()); | 119 model()->GetDefaultSearchProvider()->prepopulate_id()); |
121 | 120 |
122 // Revert the default search engine tweak. | 121 // Revert the default search engine tweak. |
123 handler()->SetGoogleAsDefaultSearch(NULL, JavaParamRef<jobject>(NULL)); | 122 handler()->SetGoogleAsDefaultSearch(NULL, JavaParamRef<jobject>(NULL)); |
124 ASSERT_EQ(TemplateURLPrepopulateData::google.id, | 123 ASSERT_EQ(TemplateURLPrepopulateData::google.id, |
125 model()->GetDefaultSearchProvider()->prepopulate_id()); | 124 model()->GetDefaultSearchProvider()->prepopulate_id()); |
126 } | 125 } |
OLD | NEW |