| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/callback.h" | 5 #include "base/callback.h" | 
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" | 
| 7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" | 
| 8 #include "base/test/mock_time_provider.h" | 8 #include "base/test/mock_time_provider.h" | 
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" | 
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" | 
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" | 
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" | 
| 13 #include "chrome/browser/history/history.h" | 13 #include "chrome/browser/history/history.h" | 
| 14 #include "chrome/browser/history/history_notifications.h" | 14 #include "chrome/browser/history/history_notifications.h" | 
| 15 #include "chrome/browser/search_engines/search_host_to_urls_map.h" | 15 #include "chrome/browser/search_engines/search_host_to_urls_map.h" | 
| 16 #include "chrome/browser/search_engines/search_terms_data.h" | 16 #include "chrome/browser/search_engines/search_terms_data.h" | 
| 17 #include "chrome/browser/search_engines/template_url.h" | 17 #include "chrome/browser/search_engines/template_url.h" | 
| 18 #include "chrome/browser/search_engines/template_url_service.h" | 18 #include "chrome/browser/search_engines/template_url_service.h" | 
| 19 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 19 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 
| 20 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 20 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 
| 21 #include "chrome/browser/webdata/web_database.h" | 21 #include "chrome/browser/webdata/web_database.h" | 
|  | 22 #include "chrome/common/chrome_notification_types.h" | 
| 22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" | 
| 23 #include "chrome/test/testing_pref_service.h" | 24 #include "chrome/test/testing_pref_service.h" | 
| 24 #include "chrome/test/testing_profile.h" | 25 #include "chrome/test/testing_profile.h" | 
| 25 #include "content/browser/browser_thread.h" | 26 #include "content/browser/browser_thread.h" | 
| 26 #include "content/common/notification_details.h" | 27 #include "content/common/notification_details.h" | 
| 27 #include "content/common/notification_source.h" | 28 #include "content/common/notification_source.h" | 
| 28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" | 
| 29 | 30 | 
| 30 using base::Time; | 31 using base::Time; | 
| 31 using base::TimeDelta; | 32 using base::TimeDelta; | 
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 138     template_url->set_safe_for_autoreplace(safe_for_autoreplace); | 139     template_url->set_safe_for_autoreplace(safe_for_autoreplace); | 
| 139     model()->Add(template_url); | 140     model()->Add(template_url); | 
| 140     EXPECT_NE(0, template_url->id()); | 141     EXPECT_NE(0, template_url->id()); | 
| 141     return template_url; | 142     return template_url; | 
| 142   } | 143   } | 
| 143 | 144 | 
| 144   // Simulate firing by the prefs service specifying that the managed | 145   // Simulate firing by the prefs service specifying that the managed | 
| 145   // preferences have changed. | 146   // preferences have changed. | 
| 146   void NotifyManagedPrefsHaveChanged() { | 147   void NotifyManagedPrefsHaveChanged() { | 
| 147     model()->Observe( | 148     model()->Observe( | 
| 148         NotificationType::PREF_CHANGED, | 149         chrome::NOTIFICATION_PREF_CHANGED, | 
| 149         Source<PrefService>(profile()->GetTestingPrefService()), | 150         Source<PrefService>(profile()->GetTestingPrefService()), | 
| 150         Details<std::string>(NULL)); | 151         Details<std::string>(NULL)); | 
| 151   } | 152   } | 
| 152 | 153 | 
| 153   // Verifies the two TemplateURLs are equal. | 154   // Verifies the two TemplateURLs are equal. | 
| 154   void AssertEquals(const TemplateURL& expected, const TemplateURL& actual) { | 155   void AssertEquals(const TemplateURL& expected, const TemplateURL& actual) { | 
| 155     ASSERT_TRUE(TemplateURLRef::SameUrlRefs(expected.url(), actual.url())); | 156     ASSERT_TRUE(TemplateURLRef::SameUrlRefs(expected.url(), actual.url())); | 
| 156     ASSERT_TRUE(TemplateURLRef::SameUrlRefs(expected.suggestions_url(), | 157     ASSERT_TRUE(TemplateURLRef::SameUrlRefs(expected.suggestions_url(), | 
| 157                                             actual.suggestions_url())); | 158                                             actual.suggestions_url())); | 
| 158     ASSERT_EQ(expected.keyword(), actual.keyword()); | 159     ASSERT_EQ(expected.keyword(), actual.keyword()); | 
| (...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1234   model()->SetDefaultSearchProvider(t_url); | 1235   model()->SetDefaultSearchProvider(t_url); | 
| 1235   EXPECT_EQ(t_url, model()->GetDefaultSearchProvider()); | 1236   EXPECT_EQ(t_url, model()->GetDefaultSearchProvider()); | 
| 1236 | 1237 | 
| 1237   // Now reset the model again but load it after setting the preferences. | 1238   // Now reset the model again but load it after setting the preferences. | 
| 1238   ResetModel(false); | 1239   ResetModel(false); | 
| 1239   SetManagedDefaultSearchPreferences(false, "", "", "", "", "", ""); | 1240   SetManagedDefaultSearchPreferences(false, "", "", "", "", "", ""); | 
| 1240   VerifyLoad(); | 1241   VerifyLoad(); | 
| 1241   EXPECT_TRUE(model()->is_default_search_managed()); | 1242   EXPECT_TRUE(model()->is_default_search_managed()); | 
| 1242   EXPECT_TRUE(model()->GetDefaultSearchProvider() == NULL); | 1243   EXPECT_TRUE(model()->GetDefaultSearchProvider() == NULL); | 
| 1243 } | 1244 } | 
| OLD | NEW | 
|---|