OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 6 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
7 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 7 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
8 #include "chrome/test/base/testing_browser_process.h" | 8 #include "chrome/test/base/testing_browser_process.h" |
9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 // Tests that http:// isn't inserted for an https url after the user nukes | 128 // Tests that http:// isn't inserted for an https url after the user nukes |
129 // https. | 129 // https. |
130 { "https://a.com/", 0, false, "a.com/", "a.com/", false, "" }, | 130 { "https://a.com/", 0, false, "a.com/", "a.com/", false, "" }, |
131 | 131 |
132 // Tests that http:// isn't inserted if the user adds to the host. | 132 // Tests that http:// isn't inserted if the user adds to the host. |
133 { "a.de/", 0, false, "a.de.com/", "a.de.com/", false, "" }, | 133 { "a.de/", 0, false, "a.de.com/", "a.de.com/", false, "" }, |
134 | 134 |
135 // Tests that we don't get double http if the user manually inserts http. | 135 // Tests that we don't get double http if the user manually inserts http. |
136 { "a.de/", 0, false, "http://a.de/", "http://a.de/", true, "http://a.de/" }, | 136 { "a.de/", 0, false, "http://a.de/", "http://a.de/", true, "http://a.de/" }, |
| 137 |
| 138 // Makes sure intranet urls get 'http://' prefixed to them. |
| 139 { "b/foo", 0, true, "b/foo", "http://b/foo", true, "http://b/foo" }, |
| 140 |
| 141 // Verifies a search term 'foo' doesn't end up with http. |
| 142 { "www.google.com/search?", 0, false, "foo", "foo", false, "" }, |
137 }; | 143 }; |
138 TestingOmniboxView view; | 144 TestingOmniboxView view; |
139 TestingAutocompleteEditController controller; | 145 TestingAutocompleteEditController controller; |
140 TestingProfile profile; | 146 TestingProfile profile; |
141 AutocompleteEditModel model(&view, &controller, &profile); | 147 AutocompleteEditModel model(&view, &controller, &profile); |
| 148 profile.CreateAutocompleteClassifier(); |
| 149 profile.CreateTemplateURLService(); |
142 | 150 |
143 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input); ++i) { | 151 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input); ++i) { |
144 model.UpdatePermanentText(ASCIIToUTF16(input[i].perm_text)); | 152 model.UpdatePermanentText(ASCIIToUTF16(input[i].perm_text)); |
145 | 153 |
146 string16 result = ASCIIToUTF16(input[i].input); | 154 string16 result = ASCIIToUTF16(input[i].input); |
147 GURL url; | 155 GURL url; |
148 bool write_url; | 156 bool write_url; |
149 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, | 157 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, |
150 &result, &url, &write_url); | 158 &result, &url, &write_url); |
151 EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i; | 159 EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i; |
152 EXPECT_EQ(input[i].write_url, write_url) << " @" << i; | 160 EXPECT_EQ(input[i].write_url, write_url) << " @" << i; |
153 if (write_url) | 161 if (write_url) |
154 EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i; | 162 EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i; |
155 } | 163 } |
156 } | 164 } |
OLD | NEW |