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/test/base/testing_profile.h" | 26 #include "chrome/test/base/testing_profile.h" |
25 #include "content/test/test_browser_thread.h" | 27 #include "content/test/test_browser_thread.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
27 | 29 |
28 using base::Time; | 30 using base::Time; |
29 using base::TimeDelta; | 31 using base::TimeDelta; |
30 using content::BrowserThread; | 32 using content::BrowserThread; |
31 using ::testing::Return; | 33 using ::testing::Return; |
32 using ::testing::StrictMock; | 34 using ::testing::StrictMock; |
33 | 35 |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 // Wait for any saves to finish. | 1129 // Wait for any saves to finish. |
1128 test_util_.BlockTillServiceProcessesRequests(); | 1130 test_util_.BlockTillServiceProcessesRequests(); |
1129 } | 1131 } |
1130 | 1132 |
1131 // Simulates failing to load the webdb and makes sure the default search | 1133 // Simulates failing to load the webdb and makes sure the default search |
1132 // provider is valid. | 1134 // provider is valid. |
1133 TEST_F(TemplateURLServiceTest, FailedInit) { | 1135 TEST_F(TemplateURLServiceTest, FailedInit) { |
1134 test_util_.VerifyLoad(); | 1136 test_util_.VerifyLoad(); |
1135 | 1137 |
1136 test_util_.ClearModel(); | 1138 test_util_.ClearModel(); |
1137 WebDataService* web_service = | 1139 scoped_refptr<WebDataService> web_service = |
1138 test_util_.profile()->GetWebDataService(Profile::EXPLICIT_ACCESS); | 1140 WebDataServiceFactory::GetForProfile(test_util_.profile(), |
| 1141 Profile::EXPLICIT_ACCESS); |
1139 web_service->UnloadDatabase(); | 1142 web_service->UnloadDatabase(); |
1140 web_service->set_failed_init(true); | 1143 web_service->set_failed_init(true); |
1141 | 1144 |
1142 test_util_.ResetModel(false); | 1145 test_util_.ResetModel(false); |
1143 model()->Load(); | 1146 model()->Load(); |
1144 test_util_.BlockTillServiceProcessesRequests(); | 1147 test_util_.BlockTillServiceProcessesRequests(); |
1145 | 1148 |
1146 ASSERT_TRUE(model()->GetDefaultSearchProvider()); | 1149 ASSERT_TRUE(model()->GetDefaultSearchProvider()); |
1147 } | 1150 } |
1148 | 1151 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 | 1295 |
1293 // Reload the model to verify it was actually saved to the database and | 1296 // Reload the model to verify it was actually saved to the database and |
1294 // assigned a new GUID when brought back. | 1297 // assigned a new GUID when brought back. |
1295 test_util_.ResetModel(true); | 1298 test_util_.ResetModel(true); |
1296 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); | 1299 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); |
1297 const TemplateURL* loaded_url = | 1300 const TemplateURL* loaded_url = |
1298 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); | 1301 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); |
1299 ASSERT_TRUE(loaded_url != NULL); | 1302 ASSERT_TRUE(loaded_url != NULL); |
1300 ASSERT_FALSE(loaded_url->sync_guid().empty()); | 1303 ASSERT_FALSE(loaded_url->sync_guid().empty()); |
1301 } | 1304 } |
OLD | NEW |