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

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

Issue 10185008: Taking over issue 10006037: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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_factory.h"
24 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
25 #include "chrome/test/base/testing_profile.h" 26 #include "chrome/test/base/testing_profile.h"
26 #include "content/test/test_browser_thread.h" 27 #include "content/test/test_browser_thread.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 29
29 using base::Time; 30 using base::Time;
30 using base::TimeDelta; 31 using base::TimeDelta;
31 using content::BrowserThread; 32 using content::BrowserThread;
32 using ::testing::Return; 33 using ::testing::Return;
33 using ::testing::StrictMock; 34 using ::testing::StrictMock;
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 ASSERT_TRUE(model()->GetDefaultSearchProvider()); 1250 ASSERT_TRUE(model()->GetDefaultSearchProvider());
1250 EXPECT_TRUE(model()->GetDefaultSearchProvider()->SupportsReplacement()); 1251 EXPECT_TRUE(model()->GetDefaultSearchProvider()->SupportsReplacement());
1251 } 1252 }
1252 1253
1253 // Simulates failing to load the webdb and makes sure the default search 1254 // Simulates failing to load the webdb and makes sure the default search
1254 // provider is valid. 1255 // provider is valid.
1255 TEST_F(TemplateURLServiceTest, FailedInit) { 1256 TEST_F(TemplateURLServiceTest, FailedInit) {
1256 test_util_.VerifyLoad(); 1257 test_util_.VerifyLoad();
1257 1258
1258 test_util_.ClearModel(); 1259 test_util_.ClearModel();
1259 WebDataService* web_service = 1260 scoped_refptr<WebDataService> web_service =
1260 test_util_.profile()->GetWebDataService(Profile::EXPLICIT_ACCESS); 1261 WebDataServiceFactory::GetForProfile(test_util_.profile(),
1262 Profile::EXPLICIT_ACCESS);
1261 web_service->UnloadDatabase(); 1263 web_service->UnloadDatabase();
1262 web_service->set_failed_init(true); 1264 web_service->set_failed_init(true);
1263 1265
1264 test_util_.ResetModel(false); 1266 test_util_.ResetModel(false);
1265 model()->Load(); 1267 model()->Load();
1266 test_util_.BlockTillServiceProcessesRequests(); 1268 test_util_.BlockTillServiceProcessesRequests();
1267 1269
1268 ASSERT_TRUE(model()->GetDefaultSearchProvider()); 1270 ASSERT_TRUE(model()->GetDefaultSearchProvider());
1269 } 1271 }
1270 1272
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 1419
1418 // Reload the model to verify it was actually saved to the database and 1420 // Reload the model to verify it was actually saved to the database and
1419 // assigned a new GUID when brought back. 1421 // assigned a new GUID when brought back.
1420 test_util_.ResetModel(true); 1422 test_util_.ResetModel(true);
1421 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); 1423 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1422 const TemplateURL* loaded_url = 1424 const TemplateURL* loaded_url =
1423 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); 1425 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword"));
1424 ASSERT_TRUE(loaded_url != NULL); 1426 ASSERT_TRUE(loaded_url != NULL);
1425 ASSERT_FALSE(loaded_url->sync_guid().empty()); 1427 ASSERT_FALSE(loaded_url->sync_guid().empty());
1426 } 1428 }
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