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

Unified Diff: chrome/browser/search_engines/search_provider_install_data_unittest.cc

Issue 287103002: Introduce ability to register callback with GoogleURLTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to review Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search_engines/search_provider_install_data_unittest.cc
diff --git a/chrome/browser/search_engines/search_provider_install_data_unittest.cc b/chrome/browser/search_engines/search_provider_install_data_unittest.cc
index a55425580be38960b97d2a4407ea9631e90c1299..39548141842854c57fe83ed858b41018fd3885e7 100644
--- a/chrome/browser/search_engines/search_provider_install_data_unittest.cc
+++ b/chrome/browser/search_engines/search_provider_install_data_unittest.cc
@@ -129,6 +129,10 @@ class SearchProviderInstallDataTest : public testing::Test {
TemplateURL* AddNewTemplateURL(const std::string& url,
const base::string16& keyword);
+ // Sets the Google base URL to |base_url| and runs the IO thread for
+ // |SearchProviderInstallData| to process the update.
+ void SetGoogleBaseURLAndProcessOnIOThread(GURL base_url);
+
TemplateURLServiceTestUtil util_;
// Provides the search provider install state on the I/O thread. It must be
@@ -182,6 +186,20 @@ TemplateURL* SearchProviderInstallDataTest::AddNewTemplateURL(
return t_url;
}
+void SearchProviderInstallDataTest::SetGoogleBaseURLAndProcessOnIOThread(
+ GURL base_url) {
+ util_.SetGoogleBaseURL(base_url);
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&SearchProviderInstallData::OnGoogleURLChange,
+ base::Unretained(install_data_),
+ base_url.spec()));
+
+ // Wait for the I/O thread to process the update notification.
+ base::RunLoop().RunUntilIdle();
+}
+
// Actual tests ---------------------------------------------------------------
TEST_F(SearchProviderInstallDataTest, GetInstallState) {
@@ -242,9 +260,7 @@ TEST_F(SearchProviderInstallDataTest, GoogleBaseUrlChange) {
// Set up the database.
util_.ChangeModelToLoadState();
std::string google_host = "w.com";
- util_.SetGoogleBaseURL(GURL("http://" + google_host + "/"));
- // Wait for the I/O thread to process the update notification.
- base::RunLoop().RunUntilIdle();
+ SetGoogleBaseURLAndProcessOnIOThread(GURL("http://" + google_host + "/"));
AddNewTemplateURL("{google:baseURL}?q={searchTerms}",
base::ASCIIToUTF16("t"));
@@ -260,9 +276,7 @@ TEST_F(SearchProviderInstallDataTest, GoogleBaseUrlChange) {
// Change the Google base url.
google_host = "foo.com";
- util_.SetGoogleBaseURL(GURL("http://" + google_host + "/"));
- // Wait for the I/O thread to process the update notification.
- base::RunLoop().RunUntilIdle();
+ SetGoogleBaseURLAndProcessOnIOThread(GURL("http://" + google_host + "/"));
// Verify that the change got picked up.
test_get_install_state.RunTests(google_host, std::string());
« no previous file with comments | « chrome/browser/search_engines/search_provider_install_data.cc ('k') | chrome/browser/search_engines/template_url_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698