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()); |