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

Side by Side 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: 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 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 TestGetInstallState test_get_install_state(install_data_); 235 TestGetInstallState test_get_install_state(install_data_);
236 test_get_install_state.RunTests(host, host2); 236 test_get_install_state.RunTests(host, host2);
237 } 237 }
238 238
239 TEST_F(SearchProviderInstallDataTest, GoogleBaseUrlChange) { 239 TEST_F(SearchProviderInstallDataTest, GoogleBaseUrlChange) {
240 TestGetInstallState test_get_install_state(install_data_); 240 TestGetInstallState test_get_install_state(install_data_);
241 241
242 // Set up the database. 242 // Set up the database.
243 util_.ChangeModelToLoadState(); 243 util_.ChangeModelToLoadState();
244 std::string google_host = "w.com"; 244 std::string google_host = "w.com";
245 util_.SetGoogleBaseURL(GURL("http://" + google_host + "/")); 245 GURL new_url = GURL("http://" + google_host + "/");
246 util_.SetGoogleBaseURL(new_url);
247 BrowserThread::PostTask(
blundell 2014/05/15 20:58:00 This was the most straightforward way that I could
Peter Kasting 2014/05/15 21:12:52 At least put all this code in a protected helper i
blundell 2014/05/16 09:09:55 Done.
248 BrowserThread::IO,
249 FROM_HERE,
250 base::Bind(&SearchProviderInstallData::OnGoogleURLChange,
251 base::Unretained(install_data_),
252 new_url.spec()));
246 // Wait for the I/O thread to process the update notification. 253 // Wait for the I/O thread to process the update notification.
247 base::RunLoop().RunUntilIdle(); 254 base::RunLoop().RunUntilIdle();
248 255
249 AddNewTemplateURL("{google:baseURL}?q={searchTerms}", 256 AddNewTemplateURL("{google:baseURL}?q={searchTerms}",
250 base::ASCIIToUTF16("t")); 257 base::ASCIIToUTF16("t"));
251 TemplateURL* default_url = 258 TemplateURL* default_url =
252 AddNewTemplateURL("http://d.com/", base::ASCIIToUTF16("d")); 259 AddNewTemplateURL("http://d.com/", base::ASCIIToUTF16("d"));
253 util_.model()->SetUserSelectedDefaultSearchProvider(default_url); 260 util_.model()->SetUserSelectedDefaultSearchProvider(default_url);
254 261
255 // Wait for the changes to be saved. 262 // Wait for the changes to be saved.
256 base::RunLoop().RunUntilIdle(); 263 base::RunLoop().RunUntilIdle();
257 264
258 // Verify the search providers install state (with no default set). 265 // Verify the search providers install state (with no default set).
259 test_get_install_state.RunTests(google_host, std::string()); 266 test_get_install_state.RunTests(google_host, std::string());
260 267
261 // Change the Google base url. 268 // Change the Google base url.
262 google_host = "foo.com"; 269 google_host = "foo.com";
263 util_.SetGoogleBaseURL(GURL("http://" + google_host + "/")); 270 new_url = GURL("http://" + google_host + "/");
271 util_.SetGoogleBaseURL(new_url);
272 BrowserThread::PostTask(
273 BrowserThread::IO,
274 FROM_HERE,
275 base::Bind(&SearchProviderInstallData::OnGoogleURLChange,
276 base::Unretained(install_data_),
277 new_url.spec()));
264 // Wait for the I/O thread to process the update notification. 278 // Wait for the I/O thread to process the update notification.
265 base::RunLoop().RunUntilIdle(); 279 base::RunLoop().RunUntilIdle();
266 280
267 // Verify that the change got picked up. 281 // Verify that the change got picked up.
268 test_get_install_state.RunTests(google_host, std::string()); 282 test_get_install_state.RunTests(google_host, std::string());
269 } 283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698