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

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

Issue 62094: Emaphasize "https" instead of "view-source" when user accesses secure/insecur... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 8 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_view_win.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "chrome/browser/autocomplete/autocomplete.h" 7 #include "chrome/browser/autocomplete/autocomplete.h"
8 #include "chrome/common/notification_registrar.h" 8 #include "chrome/common/notification_registrar.h"
9 #include "chrome/common/notification_service.h" 9 #include "chrome/common/notification_service.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 AutocompleteMatch m2(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED); 271 AutocompleteMatch m2(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED);
272 272
273 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 273 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
274 m1.relevance = cases[i].r1; 274 m1.relevance = cases[i].r1;
275 m2.relevance = cases[i].r2; 275 m2.relevance = cases[i].r2;
276 EXPECT_EQ(cases[i].expected_result, 276 EXPECT_EQ(cases[i].expected_result,
277 AutocompleteMatch::MoreRelevant(m1, m2)); 277 AutocompleteMatch::MoreRelevant(m1, m2));
278 } 278 }
279 } 279 }
280 280
281 TEST(AutocompleteInput, ParseForEmphasizeComponent) {
282 using url_parse::Component;
283 Component kInvalidComponent(0, -1);
284 struct test_data {
285 const wchar_t* input;
286 const Component scheme;
287 const Component host;
288 } input_cases[] = {
289 { L"", kInvalidComponent, kInvalidComponent },
290 { L"?", kInvalidComponent, kInvalidComponent },
291 { L"?http://foo.com/bar", kInvalidComponent, kInvalidComponent },
292 { L"foo/bar baz", kInvalidComponent, Component(0, 3) },
293 { L"http://foo/bar baz", Component(0, 4), Component(7, 3) },
294 { L"link:foo.com", Component(0, 4), kInvalidComponent },
295 { L"www.foo.com:81", kInvalidComponent, Component(0, 11) },
296 { L"\u6d4b\u8bd5", kInvalidComponent, Component(0, 2) },
297 { L"view-source:http://www.foo.com/", Component(12, 4), Component(19, 11) },
298 { L"view-source:https://example.com/",
299 Component(12, 5), Component(20, 11) },
300 { L"view-source:", Component(0, 11), kInvalidComponent },
301 { L"view-source:garbage", kInvalidComponent, Component(12, 7) },
302 { L"view-source:http://http://foo", Component(12, 4), Component(19, 4) },
303 { L"view-source:view-source:http://example.com/",
304 Component(12, 11), kInvalidComponent }
305 };
306
307 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_cases); ++i) {
308 Component scheme, host;
309 AutocompleteInput::ParseForEmphasizeComponents(input_cases[i].input,
310 std::wstring(),
311 &scheme,
312 &host);
313 AutocompleteInput input(input_cases[i].input, std::wstring(), true, false,
314 false);
315 EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin) << "Input: " <<
316 input_cases[i].input;
317 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " <<
318 input_cases[i].input;
319 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " <<
320 input_cases[i].input;
321 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " <<
322 input_cases[i].input;
323 }
324 }
325
281 } // namespace 326 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698