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

Side by Side Diff: chrome/browser/search/instant_unittest_base.cc

Issue 2290503003: Remove use of stl_util in search_engines. (Closed)
Patch Set: ios for reals Created 4 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/search/instant_unittest_base.h" 5 #include "chrome/browser/search/instant_unittest_base.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 TemplateURLData data; 53 TemplateURLData data;
54 data.SetShortName(base::UTF8ToUTF16(base_url)); 54 data.SetShortName(base::UTF8ToUTF16(base_url));
55 data.SetKeyword(base::UTF8ToUTF16(base_url)); 55 data.SetKeyword(base::UTF8ToUTF16(base_url));
56 data.SetURL(base_url + "url?bar={searchTerms}"); 56 data.SetURL(base_url + "url?bar={searchTerms}");
57 data.instant_url = 57 data.instant_url =
58 base_url + "instant?{google:forceInstantResults}foo=foo#foo=foo&strk"; 58 base_url + "instant?{google:forceInstantResults}foo=foo#foo=foo&strk";
59 data.new_tab_url = base_url + "newtab"; 59 data.new_tab_url = base_url + "newtab";
60 data.alternate_urls.push_back(base_url + "alt#quux={searchTerms}"); 60 data.alternate_urls.push_back(base_url + "alt#quux={searchTerms}");
61 data.search_terms_replacement_key = "strk"; 61 data.search_terms_replacement_key = "strk";
62 62
63 TemplateURL* template_url = new TemplateURL(data); 63 std::unique_ptr<TemplateURL> template_url_ptr =
64 // Takes ownership of |template_url|. 64 base::MakeUnique<TemplateURL>(data);
65 template_url_service_->Add(template_url); 65 TemplateURL* template_url = template_url_ptr.get();
66 template_url_service_->Add(std::move(template_url_ptr));
Peter Kasting 2016/08/31 04:12:55 Nit: Just use the old code and add a WrapUnique()
Avi (use Gerrit) 2016/09/01 00:34:25 Fixed.
66 template_url_service_->SetUserSelectedDefaultSearchProvider(template_url); 67 template_url_service_->SetUserSelectedDefaultSearchProvider(template_url);
67 } 68 }
68 69
69 void InstantUnitTestBase::NotifyGoogleBaseURLUpdate( 70 void InstantUnitTestBase::NotifyGoogleBaseURLUpdate(
70 const std::string& new_google_base_url) { 71 const std::string& new_google_base_url) {
71 // GoogleURLTracker is not created in tests. 72 // GoogleURLTracker is not created in tests.
72 // (See GoogleURLTrackerFactory::ServiceIsNULLWhileTesting()) 73 // (See GoogleURLTrackerFactory::ServiceIsNULLWhileTesting())
73 // For determining google:baseURL for NTP, the following is used: 74 // For determining google:baseURL for NTP, the following is used:
74 // UIThreadSearchTermsData::GoogleBaseURLValue() 75 // UIThreadSearchTermsData::GoogleBaseURLValue()
75 // For simulating test behavior, this is overridden below. 76 // For simulating test behavior, this is overridden below.
76 UIThreadSearchTermsData::SetGoogleBaseURL(new_google_base_url); 77 UIThreadSearchTermsData::SetGoogleBaseURL(new_google_base_url);
77 TemplateURLServiceFactory::GetForProfile(profile())->GoogleBaseURLChanged(); 78 TemplateURLServiceFactory::GetForProfile(profile())->GoogleBaseURLChanged();
78 } 79 }
79 80
80 bool InstantUnitTestBase::IsInstantServiceObserver( 81 bool InstantUnitTestBase::IsInstantServiceObserver(
81 const InstantServiceObserver* observer) const { 82 const InstantServiceObserver* observer) const {
82 return instant_service_->observers_.HasObserver(observer); 83 return instant_service_->observers_.HasObserver(observer);
83 } 84 }
84 85
85 TestingProfile* InstantUnitTestBase::CreateProfile() { 86 TestingProfile* InstantUnitTestBase::CreateProfile() {
86 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); 87 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile();
87 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 88 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
88 profile, &TemplateURLServiceFactory::BuildInstanceFor); 89 profile, &TemplateURLServiceFactory::BuildInstanceFor);
89 return profile; 90 return profile;
90 } 91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698