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

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

Issue 10006037: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reverted one unneeded change Created 8 years, 8 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"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/test/mock_time_provider.h" 12 #include "base/test/mock_time_provider.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/history/history.h" 15 #include "chrome/browser/history/history.h"
16 #include "chrome/browser/history/history_notifications.h" 16 #include "chrome/browser/history/history_notifications.h"
17 #include "chrome/browser/search_engines/search_host_to_urls_map.h" 17 #include "chrome/browser/search_engines/search_host_to_urls_map.h"
18 #include "chrome/browser/search_engines/search_terms_data.h" 18 #include "chrome/browser/search_engines/search_terms_data.h"
19 #include "chrome/browser/search_engines/template_url.h" 19 #include "chrome/browser/search_engines/template_url.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/search_engines/template_url_service.h" 21 #include "chrome/browser/search_engines/template_url_service.h"
22 #include "chrome/browser/search_engines/template_url_service_test_util.h" 22 #include "chrome/browser/search_engines/template_url_service_test_util.h"
23 #include "chrome/browser/webdata/web_database.h" 23 #include "chrome/browser/webdata/web_database.h"
24 #include "chrome/browser/webdata/web_data_service.h"
25 #include "chrome/browser/webdata/web_data_service_factory.h"
24 #include "chrome/common/chrome_notification_types.h" 26 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
26 #include "chrome/test/base/testing_pref_service.h" 28 #include "chrome/test/base/testing_pref_service.h"
27 #include "chrome/test/base/testing_profile.h" 29 #include "chrome/test/base/testing_profile.h"
28 #include "content/public/browser/notification_details.h" 30 #include "content/public/browser/notification_details.h"
29 #include "content/public/browser/notification_source.h" 31 #include "content/public/browser/notification_source.h"
30 #include "content/test/test_browser_thread.h" 32 #include "content/test/test_browser_thread.h"
31 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
32 34
33 using base::Time; 35 using base::Time;
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 // Wait for any saves to finish. 1173 // Wait for any saves to finish.
1172 test_util_.BlockTillServiceProcessesRequests(); 1174 test_util_.BlockTillServiceProcessesRequests();
1173 } 1175 }
1174 1176
1175 // Simulates failing to load the webdb and makes sure the default search 1177 // Simulates failing to load the webdb and makes sure the default search
1176 // provider is valid. 1178 // provider is valid.
1177 TEST_F(TemplateURLServiceTest, FailedInit) { 1179 TEST_F(TemplateURLServiceTest, FailedInit) {
1178 test_util_.VerifyLoad(); 1180 test_util_.VerifyLoad();
1179 1181
1180 test_util_.ClearModel(); 1182 test_util_.ClearModel();
1181 WebDataService* web_service = 1183 scoped_refptr<WebDataService> web_service =
1182 test_util_.profile()->GetWebDataService(Profile::EXPLICIT_ACCESS); 1184 WebDataServiceFactory::GetForProfile(test_util_.profile(),
1185 Profile::EXPLICIT_ACCESS);
1183 web_service->UnloadDatabase(); 1186 web_service->UnloadDatabase();
1184 web_service->set_failed_init(true); 1187 web_service->set_failed_init(true);
1185 1188
1186 test_util_.ResetModel(false); 1189 test_util_.ResetModel(false);
1187 model()->Load(); 1190 model()->Load();
1188 test_util_.BlockTillServiceProcessesRequests(); 1191 test_util_.BlockTillServiceProcessesRequests();
1189 1192
1190 ASSERT_TRUE(model()->GetDefaultSearchProvider()); 1193 ASSERT_TRUE(model()->GetDefaultSearchProvider());
1191 } 1194 }
1192 1195
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 1336
1334 // Reload the model to verify it was actually saved to the database and 1337 // Reload the model to verify it was actually saved to the database and
1335 // assigned a new GUID when brought back. 1338 // assigned a new GUID when brought back.
1336 test_util_.ResetModel(true); 1339 test_util_.ResetModel(true);
1337 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); 1340 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1338 const TemplateURL* loaded_url = 1341 const TemplateURL* loaded_url =
1339 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); 1342 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword"));
1340 ASSERT_TRUE(loaded_url != NULL); 1343 ASSERT_TRUE(loaded_url != NULL);
1341 ASSERT_FALSE(loaded_url->sync_guid().empty()); 1344 ASSERT_FALSE(loaded_url->sync_guid().empty());
1342 } 1345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698