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

Side by Side Diff: chrome/browser/ui/search/instant_test_utils.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/ui/search/instant_test_utils.h" 5 #include "chrome/browser/ui/search/instant_test_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h"
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/search_engines/template_url_service_factory.h" 14 #include "chrome/browser/search_engines/template_url_service_factory.h"
14 #include "chrome/browser/ui/search/search_tab_helper.h" 15 #include "chrome/browser/ui/search/search_tab_helper.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
17 #include "chrome/test/base/interactive_test_utils.h" 18 #include "chrome/test/base/interactive_test_utils.h"
18 #include "chrome/test/base/search_test_utils.h" 19 #include "chrome/test/base/search_test_utils.h"
19 #include "components/omnibox/browser/omnibox_edit_model.h" 20 #include "components/omnibox/browser/omnibox_edit_model.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 data.SetShortName(base::ASCIIToUTF16("name")); 58 data.SetShortName(base::ASCIIToUTF16("name"));
58 data.SetURL(instant_url_.spec() + "q={searchTerms}&is_search"); 59 data.SetURL(instant_url_.spec() + "q={searchTerms}&is_search");
59 data.instant_url = instant_url_.spec(); 60 data.instant_url = instant_url_.spec();
60 data.new_tab_url = ntp_url_.spec(); 61 data.new_tab_url = ntp_url_.spec();
61 if (init_suggestions_url_) 62 if (init_suggestions_url_)
62 data.suggestions_url = instant_url_.spec() + "#q={searchTerms}"; 63 data.suggestions_url = instant_url_.spec() + "#q={searchTerms}";
63 data.alternate_urls.push_back(instant_url_.spec() + "#q={searchTerms}"); 64 data.alternate_urls.push_back(instant_url_.spec() + "#q={searchTerms}");
64 data.search_terms_replacement_key = "strk"; 65 data.search_terms_replacement_key = "strk";
65 66
66 TemplateURL* template_url = new TemplateURL(data); 67 TemplateURL* template_url = new TemplateURL(data);
67 service->Add(template_url); // Takes ownership of |template_url|. 68 service->Add(base::WrapUnique(template_url));
68 service->SetUserSelectedDefaultSearchProvider(template_url); 69 service->SetUserSelectedDefaultSearchProvider(template_url);
69 } 70 }
70 71
71 void InstantTestBase::SetInstantURL(const std::string& url) { 72 void InstantTestBase::SetInstantURL(const std::string& url) {
72 TemplateURLService* service = 73 TemplateURLService* service =
73 TemplateURLServiceFactory::GetForProfile(browser_->profile()); 74 TemplateURLServiceFactory::GetForProfile(browser_->profile());
74 search_test_utils::WaitForTemplateURLServiceToLoad(service); 75 search_test_utils::WaitForTemplateURLServiceToLoad(service);
75 76
76 TemplateURLData data; 77 TemplateURLData data;
77 data.SetShortName(base::ASCIIToUTF16("name")); 78 data.SetShortName(base::ASCIIToUTF16("name"));
78 data.SetURL(url); 79 data.SetURL(url);
79 data.instant_url = url; 80 data.instant_url = url;
80 81
81 TemplateURL* template_url = new TemplateURL(data); 82 TemplateURL* template_url = new TemplateURL(data);
82 service->Add(template_url); // Takes ownership of |template_url|. 83 service->Add(base::WrapUnique(template_url));
83 service->SetUserSelectedDefaultSearchProvider(template_url); 84 service->SetUserSelectedDefaultSearchProvider(template_url);
84 } 85 }
85 86
86 void InstantTestBase::Init(const GURL& instant_url, 87 void InstantTestBase::Init(const GURL& instant_url,
87 const GURL& ntp_url, 88 const GURL& ntp_url,
88 bool init_suggestions_url) { 89 bool init_suggestions_url) {
89 instant_url_ = instant_url; 90 instant_url_ = instant_url;
90 ntp_url_ = ntp_url; 91 ntp_url_ = ntp_url;
91 init_suggestions_url_ = init_suggestions_url; 92 init_suggestions_url_ = init_suggestions_url;
92 } 93 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded); 170 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded);
170 } 171 }
171 172
172 base::string16 InstantTestBase::GetBlueText() { 173 base::string16 InstantTestBase::GetBlueText() {
173 size_t start = 0, end = 0; 174 size_t start = 0, end = 0;
174 omnibox()->GetSelectionBounds(&start, &end); 175 omnibox()->GetSelectionBounds(&start, &end);
175 if (start > end) 176 if (start > end)
176 std::swap(start, end); 177 std::swap(start, end);
177 return omnibox()->GetText().substr(start, end - start); 178 return omnibox()->GetText().substr(start, end - start);
178 } 179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698