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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_unittest.cc

Issue 7806001: Makes copying text in the omnibox always use permanent text is the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate feedback and add test Created 9 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
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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" },
Peter Kasting 2011/08/30 23:04:05 Will this test actually work? I'd think the class
137 }; 140 };
138 TestingOmniboxView view; 141 TestingOmniboxView view;
139 TestingAutocompleteEditController controller; 142 TestingAutocompleteEditController controller;
140 TestingProfile profile; 143 TestingProfile profile;
141 AutocompleteEditModel model(&view, &controller, &profile); 144 AutocompleteEditModel model(&view, &controller, &profile);
145 profile.CreateAutocompleteClassifier();
146 profile.CreateTemplateURLService();
142 147
143 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input); ++i) { 148 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input); ++i) {
144 model.UpdatePermanentText(ASCIIToUTF16(input[i].perm_text)); 149 model.UpdatePermanentText(ASCIIToUTF16(input[i].perm_text));
145 150
146 string16 result = ASCIIToUTF16(input[i].input); 151 string16 result = ASCIIToUTF16(input[i].input);
147 GURL url; 152 GURL url;
148 bool write_url; 153 bool write_url;
149 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, 154 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected,
150 &result, &url, &write_url); 155 &result, &url, &write_url);
151 EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i; 156 EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i;
152 EXPECT_EQ(input[i].write_url, write_url) << " @" << i; 157 EXPECT_EQ(input[i].write_url, write_url) << " @" << i;
153 if (write_url) 158 if (write_url)
154 EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i; 159 EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i;
155 } 160 }
156 } 161 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698