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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_edit_unittest.cc

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android webview init fix merged in. Created 7 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 | 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 "base/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" 6 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
7 #include "chrome/browser/search_engines/template_url_service_factory.h" 7 #include "chrome/browser/search_engines/template_url_service_factory.h"
8 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" 8 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
9 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" 9 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
10 #include "chrome/browser/ui/omnibox/omnibox_view.h" 10 #include "chrome/browser/ui/omnibox/omnibox_view.h"
11 #include "chrome/browser/ui/toolbar/test_toolbar_model.h" 11 #include "chrome/browser/ui/toolbar/test_toolbar_model.h"
12 #include "chrome/test/base/testing_browser_process.h" 12 #include "chrome/test/base/testing_browser_process.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread_bundle.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/gfx/font.h" 16 #include "ui/gfx/font.h"
16 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
17 18
18 using content::WebContents; 19 using content::WebContents;
19 20
20 namespace { 21 namespace {
21 22
22 class TestingOmniboxView : public OmniboxView { 23 class TestingOmniboxView : public OmniboxView {
23 public: 24 public:
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 175
175 // Verifies a search term 'foo' doesn't end up with http. 176 // Verifies a search term 'foo' doesn't end up with http.
176 { "www.google.com/search?", 0, false, "foo", "foo", false, "", false }, 177 { "www.google.com/search?", 0, false, "foo", "foo", false, "", false },
177 178
178 // Makes sure extracted search terms are not modified. 179 // Makes sure extracted search terms are not modified.
179 { "www.google.com/webhp?", 0, true, "hello world", "hello world", false, 180 { "www.google.com/webhp?", 0, true, "hello world", "hello world", false,
180 "", true }, 181 "", true },
181 }; 182 };
182 TestingOmniboxEditController controller(toolbar_model()); 183 TestingOmniboxEditController controller(toolbar_model());
183 TestingOmniboxView view(&controller); 184 TestingOmniboxView view(&controller);
185 content::TestBrowserThreadBundle thread_bundle;
184 TestingProfile profile; 186 TestingProfile profile;
185 // NOTE: The TemplateURLService must be created before the 187 // NOTE: The TemplateURLService must be created before the
186 // AutocompleteClassifier so that the SearchProvider gets a non-NULL 188 // AutocompleteClassifier so that the SearchProvider gets a non-NULL
187 // TemplateURLService at construction time. 189 // TemplateURLService at construction time.
188 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 190 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
189 &profile, &TemplateURLServiceFactory::BuildInstanceFor); 191 &profile, &TemplateURLServiceFactory::BuildInstanceFor);
190 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse( 192 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse(
191 &profile, &AutocompleteClassifierFactory::BuildInstanceFor); 193 &profile, &AutocompleteClassifierFactory::BuildInstanceFor);
192 OmniboxEditModel model(&view, &controller, &profile); 194 OmniboxEditModel model(&view, &controller, &profile);
193 195
194 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input); ++i) { 196 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input); ++i) {
195 model.UpdatePermanentText(ASCIIToUTF16(input[i].perm_text)); 197 model.UpdatePermanentText(ASCIIToUTF16(input[i].perm_text));
196 198
197 toolbar_model()->set_replace_search_url_with_search_terms( 199 toolbar_model()->set_replace_search_url_with_search_terms(
198 input[i].extracted_search_terms); 200 input[i].extracted_search_terms);
199 201
200 string16 result = ASCIIToUTF16(input[i].input); 202 string16 result = ASCIIToUTF16(input[i].input);
201 GURL url; 203 GURL url;
202 bool write_url; 204 bool write_url;
203 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, 205 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected,
204 &result, &url, &write_url); 206 &result, &url, &write_url);
205 EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i; 207 EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i;
206 EXPECT_EQ(input[i].write_url, write_url) << " @" << i; 208 EXPECT_EQ(input[i].write_url, write_url) << " @" << i;
207 if (write_url) 209 if (write_url)
208 EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i; 210 EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i;
209 } 211 }
210 } 212 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_controller_unittest.cc ('k') | chrome/browser/ui/sync/one_click_signin_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698