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

Side by Side Diff: chrome/browser/search_engines/template_url_service_unittest.cc

Issue 9811022: Misc. small cleanups to minimize TemplateURL refactoring diffs: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 143
144 std::string TestSearchTermsData::GoogleBaseURLValue() const { 144 std::string TestSearchTermsData::GoogleBaseURLValue() const {
145 return google_base_url_; 145 return google_base_url_;
146 } 146 }
147 147
148 }; // namespace 148 }; // namespace
149 149
150 150
151 // TemplateURLServiceTest ----------------------------------------------------- 151 // TemplateURLServiceTest -----------------------------------------------------
152
152 class TemplateURLServiceTest : public testing::Test { 153 class TemplateURLServiceTest : public testing::Test {
153 public: 154 public:
154 TemplateURLServiceTest(); 155 TemplateURLServiceTest();
155 156
156 // testing::Test 157 // testing::Test
157 virtual void SetUp(); 158 virtual void SetUp();
158 virtual void TearDown(); 159 virtual void TearDown();
159 160
160 TemplateURL* AddKeywordWithDate(const std::string& keyword, 161 TemplateURL* AddKeywordWithDate(const std::string& keyword,
161 bool autogenerate_keyword, 162 bool autogenerate_keyword,
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 // Wait for any saves to finish. 1156 // Wait for any saves to finish.
1156 test_util_.BlockTillServiceProcessesRequests(); 1157 test_util_.BlockTillServiceProcessesRequests();
1157 } 1158 }
1158 1159
1159 // Simulates failing to load the webdb and makes sure the default search 1160 // Simulates failing to load the webdb and makes sure the default search
1160 // provider is valid. 1161 // provider is valid.
1161 TEST_F(TemplateURLServiceTest, FailedInit) { 1162 TEST_F(TemplateURLServiceTest, FailedInit) {
1162 test_util_.VerifyLoad(); 1163 test_util_.VerifyLoad();
1163 1164
1164 test_util_.ClearModel(); 1165 test_util_.ClearModel();
1165 WebDataService* web_service = test_util_.GetWebDataService(); 1166 WebDataService* web_service =
1167 test_util_.profile()->GetWebDataService(Profile::EXPLICIT_ACCESS);
1166 web_service->UnloadDatabase(); 1168 web_service->UnloadDatabase();
1167 web_service->set_failed_init(true); 1169 web_service->set_failed_init(true);
1168 1170
1169 test_util_.ResetModel(false); 1171 test_util_.ResetModel(false);
1170 model()->Load(); 1172 model()->Load();
1171 test_util_.BlockTillServiceProcessesRequests(); 1173 test_util_.BlockTillServiceProcessesRequests();
1172 1174
1173 ASSERT_TRUE(model()->GetDefaultSearchProvider()); 1175 ASSERT_TRUE(model()->GetDefaultSearchProvider());
1174 } 1176 }
1175 1177
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 1246
1245 // Remove all the managed prefs and check that we are no longer managed. 1247 // Remove all the managed prefs and check that we are no longer managed.
1246 RemoveManagedDefaultSearchPreferences(); 1248 RemoveManagedDefaultSearchPreferences();
1247 VerifyObserverFired(); 1249 VerifyObserverFired();
1248 EXPECT_FALSE(model()->is_default_search_managed()); 1250 EXPECT_FALSE(model()->is_default_search_managed());
1249 EXPECT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); 1251 EXPECT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1250 1252
1251 // The default should now be the first URL added 1253 // The default should now be the first URL added
1252 const TemplateURL* actual_final_managed_default = 1254 const TemplateURL* actual_final_managed_default =
1253 model()->GetDefaultSearchProvider(); 1255 model()->GetDefaultSearchProvider();
1254 ExpectSimilar(actual_final_managed_default, 1256 ExpectSimilar(model()->GetTemplateURLs()[0], actual_final_managed_default);
1255 model()->GetTemplateURLs()[0]);
1256 EXPECT_EQ(actual_final_managed_default->show_in_default_list(), true); 1257 EXPECT_EQ(actual_final_managed_default->show_in_default_list(), true);
1257 1258
1258 // Disable the default search provider through policy. 1259 // Disable the default search provider through policy.
1259 SetManagedDefaultSearchPreferences(false, std::string(), std::string(), 1260 SetManagedDefaultSearchPreferences(false, std::string(), std::string(),
1260 std::string(), std::string(), std::string(), std::string()); 1261 std::string(), std::string(), std::string(), std::string());
1261 VerifyObserverFired(); 1262 VerifyObserverFired();
1262 EXPECT_TRUE(model()->is_default_search_managed()); 1263 EXPECT_TRUE(model()->is_default_search_managed());
1263 EXPECT_TRUE(NULL == model()->GetDefaultSearchProvider()); 1264 EXPECT_TRUE(NULL == model()->GetDefaultSearchProvider());
1264 EXPECT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); 1265 EXPECT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1265 1266
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 1318
1318 // Reload the model to verify it was actually saved to the database and 1319 // Reload the model to verify it was actually saved to the database and
1319 // assigned a new GUID when brought back. 1320 // assigned a new GUID when brought back.
1320 test_util_.ResetModel(true); 1321 test_util_.ResetModel(true);
1321 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); 1322 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1322 const TemplateURL* loaded_url = 1323 const TemplateURL* loaded_url =
1323 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); 1324 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword"));
1324 ASSERT_TRUE(loaded_url != NULL); 1325 ASSERT_TRUE(loaded_url != NULL);
1325 ASSERT_FALSE(loaded_url->sync_guid().empty()); 1326 ASSERT_FALSE(loaded_url->sync_guid().empty());
1326 } 1327 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698