OLD | NEW |
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 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 // Wait for any saves to finish. | 1151 // Wait for any saves to finish. |
1150 test_util_.BlockTillServiceProcessesRequests(); | 1152 test_util_.BlockTillServiceProcessesRequests(); |
1151 } | 1153 } |
1152 | 1154 |
1153 // Simulates failing to load the webdb and makes sure the default search | 1155 // Simulates failing to load the webdb and makes sure the default search |
1154 // provider is valid. | 1156 // provider is valid. |
1155 TEST_F(TemplateURLServiceTest, FailedInit) { | 1157 TEST_F(TemplateURLServiceTest, FailedInit) { |
1156 test_util_.VerifyLoad(); | 1158 test_util_.VerifyLoad(); |
1157 | 1159 |
1158 test_util_.ClearModel(); | 1160 test_util_.ClearModel(); |
1159 WebDataService* web_service = | 1161 scoped_refptr<WebDataService> web_service = |
1160 test_util_.profile()->GetWebDataService(Profile::EXPLICIT_ACCESS); | 1162 WebDataServiceFactory::GetForProfile(test_util_.profile(), |
| 1163 Profile::EXPLICIT_ACCESS); |
1161 web_service->UnloadDatabase(); | 1164 web_service->UnloadDatabase(); |
1162 web_service->set_failed_init(true); | 1165 web_service->set_failed_init(true); |
1163 | 1166 |
1164 test_util_.ResetModel(false); | 1167 test_util_.ResetModel(false); |
1165 model()->Load(); | 1168 model()->Load(); |
1166 test_util_.BlockTillServiceProcessesRequests(); | 1169 test_util_.BlockTillServiceProcessesRequests(); |
1167 | 1170 |
1168 ASSERT_TRUE(model()->GetDefaultSearchProvider()); | 1171 ASSERT_TRUE(model()->GetDefaultSearchProvider()); |
1169 } | 1172 } |
1170 | 1173 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 | 1314 |
1312 // Reload the model to verify it was actually saved to the database and | 1315 // Reload the model to verify it was actually saved to the database and |
1313 // assigned a new GUID when brought back. | 1316 // assigned a new GUID when brought back. |
1314 test_util_.ResetModel(true); | 1317 test_util_.ResetModel(true); |
1315 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); | 1318 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); |
1316 const TemplateURL* loaded_url = | 1319 const TemplateURL* loaded_url = |
1317 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); | 1320 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); |
1318 ASSERT_TRUE(loaded_url != NULL); | 1321 ASSERT_TRUE(loaded_url != NULL); |
1319 ASSERT_FALSE(loaded_url->sync_guid().empty()); | 1322 ASSERT_FALSE(loaded_url->sync_guid().empty()); |
1320 } | 1323 } |
OLD | NEW |