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

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

Issue 9949024: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-base 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 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 // Wait for any saves to finish. 1170 // Wait for any saves to finish.
1169 test_util_.BlockTillServiceProcessesRequests(); 1171 test_util_.BlockTillServiceProcessesRequests();
1170 } 1172 }
1171 1173
1172 // Simulates failing to load the webdb and makes sure the default search 1174 // Simulates failing to load the webdb and makes sure the default search
1173 // provider is valid. 1175 // provider is valid.
1174 TEST_F(TemplateURLServiceTest, FailedInit) { 1176 TEST_F(TemplateURLServiceTest, FailedInit) {
1175 test_util_.VerifyLoad(); 1177 test_util_.VerifyLoad();
1176 1178
1177 test_util_.ClearModel(); 1179 test_util_.ClearModel();
1178 WebDataService* web_service = 1180 scoped_refptr<WebDataService> web_service =
1179 test_util_.profile()->GetWebDataService(Profile::EXPLICIT_ACCESS); 1181 WebDataServiceFactory::GetForProfile(test_util_.profile(),
1182 Profile::EXPLICIT_ACCESS);
1180 web_service->UnloadDatabase(); 1183 web_service->UnloadDatabase();
1181 web_service->set_failed_init(true); 1184 web_service->set_failed_init(true);
1182 1185
1183 test_util_.ResetModel(false); 1186 test_util_.ResetModel(false);
1184 model()->Load(); 1187 model()->Load();
1185 test_util_.BlockTillServiceProcessesRequests(); 1188 test_util_.BlockTillServiceProcessesRequests();
1186 1189
1187 ASSERT_TRUE(model()->GetDefaultSearchProvider()); 1190 ASSERT_TRUE(model()->GetDefaultSearchProvider());
1188 } 1191 }
1189 1192
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 1333
1331 // Reload the model to verify it was actually saved to the database and 1334 // Reload the model to verify it was actually saved to the database and
1332 // assigned a new GUID when brought back. 1335 // assigned a new GUID when brought back.
1333 test_util_.ResetModel(true); 1336 test_util_.ResetModel(true);
1334 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); 1337 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1335 const TemplateURL* loaded_url = 1338 const TemplateURL* loaded_url =
1336 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); 1339 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword"));
1337 ASSERT_TRUE(loaded_url != NULL); 1340 ASSERT_TRUE(loaded_url != NULL);
1338 ASSERT_FALSE(loaded_url->sync_guid().empty()); 1341 ASSERT_FALSE(loaded_url->sync_guid().empty());
1339 } 1342 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service_test_util.cc ('k') | chrome/browser/signin/token_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698