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

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

Issue 9834056: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed unchanged file 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"
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 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 // Wait for any saves to finish. 1158 // Wait for any saves to finish.
1157 test_util_.BlockTillServiceProcessesRequests(); 1159 test_util_.BlockTillServiceProcessesRequests();
1158 } 1160 }
1159 1161
1160 // Simulates failing to load the webdb and makes sure the default search 1162 // Simulates failing to load the webdb and makes sure the default search
1161 // provider is valid. 1163 // provider is valid.
1162 TEST_F(TemplateURLServiceTest, FailedInit) { 1164 TEST_F(TemplateURLServiceTest, FailedInit) {
1163 test_util_.VerifyLoad(); 1165 test_util_.VerifyLoad();
1164 1166
1165 test_util_.ClearModel(); 1167 test_util_.ClearModel();
1166 WebDataService* web_service = 1168 scoped_refptr<WebDataService> web_service =
1167 test_util_.profile()->GetWebDataService(Profile::EXPLICIT_ACCESS); 1169 WebDataServiceFactory::GetForProfile(test_util_.profile(),
1170 Profile::EXPLICIT_ACCESS);
1168 web_service->UnloadDatabase(); 1171 web_service->UnloadDatabase();
1169 web_service->set_failed_init(true); 1172 web_service->set_failed_init(true);
1170 1173
1171 test_util_.ResetModel(false); 1174 test_util_.ResetModel(false);
1172 model()->Load(); 1175 model()->Load();
1173 test_util_.BlockTillServiceProcessesRequests(); 1176 test_util_.BlockTillServiceProcessesRequests();
1174 1177
1175 ASSERT_TRUE(model()->GetDefaultSearchProvider()); 1178 ASSERT_TRUE(model()->GetDefaultSearchProvider());
1176 } 1179 }
1177 1180
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 1321
1319 // Reload the model to verify it was actually saved to the database and 1322 // Reload the model to verify it was actually saved to the database and
1320 // assigned a new GUID when brought back. 1323 // assigned a new GUID when brought back.
1321 test_util_.ResetModel(true); 1324 test_util_.ResetModel(true);
1322 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); 1325 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1323 const TemplateURL* loaded_url = 1326 const TemplateURL* loaded_url =
1324 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); 1327 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword"));
1325 ASSERT_TRUE(loaded_url != NULL); 1328 ASSERT_TRUE(loaded_url != NULL);
1326 ASSERT_FALSE(loaded_url->sync_guid().empty()); 1329 ASSERT_FALSE(loaded_url->sync_guid().empty());
1327 } 1330 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698