OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/search_engines/default_search_pref_migration.h" | 5 #include "chrome/browser/search_engines/default_search_pref_migration.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
19 #include "chrome/test/base/testing_pref_service_syncable.h" | 19 #include "chrome/test/base/testing_pref_service_syncable.h" |
20 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
21 #include "components/search_engines/search_engines_pref_names.h" | 21 #include "components/search_engines/search_engines_pref_names.h" |
22 #include "components/search_engines/template_url.h" | 22 #include "components/search_engines/template_url.h" |
23 #include "components/search_engines/template_url_service.h" | 23 #include "components/search_engines/template_url_service.h" |
| 24 #include "content/public/test/test_browser_thread_bundle.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "url/gurl.h" | 26 #include "url/gurl.h" |
26 | 27 |
27 class DefaultSearchPrefMigrationTest : public testing::Test { | 28 class DefaultSearchPrefMigrationTest : public testing::Test { |
28 public: | 29 public: |
29 DefaultSearchPrefMigrationTest(); | 30 DefaultSearchPrefMigrationTest(); |
30 | 31 |
31 // testing::Test: | 32 // testing::Test: |
32 void SetUp() override; | 33 void SetUp() override; |
33 | 34 |
34 void SaveDefaultSearchProviderToLegacyPrefs(const TemplateURL* t_url); | 35 void SaveDefaultSearchProviderToLegacyPrefs(const TemplateURL* t_url); |
35 | 36 |
36 scoped_ptr<TemplateURL> CreateKeyword(const std::string& short_name, | 37 scoped_ptr<TemplateURL> CreateKeyword(const std::string& short_name, |
37 const std::string& keyword, | 38 const std::string& keyword, |
38 const std::string& url); | 39 const std::string& url); |
39 | 40 |
40 TestingProfile* profile() { return profile_.get(); } | 41 TestingProfile* profile() { return profile_.get(); } |
41 | 42 |
42 DefaultSearchManager* default_search_manager() { | 43 DefaultSearchManager* default_search_manager() { |
43 return default_search_manager_.get(); | 44 return default_search_manager_.get(); |
44 } | 45 } |
45 | 46 |
46 private: | 47 private: |
| 48 content::TestBrowserThreadBundle thread_bundle_; |
47 base::ScopedTempDir temp_dir_; | 49 base::ScopedTempDir temp_dir_; |
48 scoped_ptr<TestingProfile> profile_; | 50 scoped_ptr<TestingProfile> profile_; |
49 scoped_ptr<DefaultSearchManager> default_search_manager_; | 51 scoped_ptr<DefaultSearchManager> default_search_manager_; |
50 | 52 |
51 DISALLOW_COPY_AND_ASSIGN(DefaultSearchPrefMigrationTest); | 53 DISALLOW_COPY_AND_ASSIGN(DefaultSearchPrefMigrationTest); |
52 }; | 54 }; |
53 | 55 |
54 DefaultSearchPrefMigrationTest::DefaultSearchPrefMigrationTest() { | 56 DefaultSearchPrefMigrationTest::DefaultSearchPrefMigrationTest() { |
55 } | 57 } |
56 | 58 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // Store a value in the legacy location. | 232 // Store a value in the legacy location. |
231 SaveDefaultSearchProviderToLegacyPrefs(&prepopulated_turl); | 233 SaveDefaultSearchProviderToLegacyPrefs(&prepopulated_turl); |
232 | 234 |
233 // Run the migration. | 235 // Run the migration. |
234 ConfigureDefaultSearchPrefMigrationToDictionaryValue(profile()->GetPrefs()); | 236 ConfigureDefaultSearchPrefMigrationToDictionaryValue(profile()->GetPrefs()); |
235 | 237 |
236 // Test that the legacy value is not migrated, as it is not user-selected. | 238 // Test that the legacy value is not migrated, as it is not user-selected. |
237 default_search_manager()->GetDefaultSearchEngine(&source); | 239 default_search_manager()->GetDefaultSearchEngine(&source); |
238 EXPECT_EQ(DefaultSearchManager::FROM_FALLBACK, source); | 240 EXPECT_EQ(DefaultSearchManager::FROM_FALLBACK, source); |
239 } | 241 } |
OLD | NEW |