| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "components/metrics/proto/omnibox_event.pb.h" | 8 #include "components/metrics/proto/omnibox_event.pb.h" |
| 9 #include "components/omnibox/autocomplete_match.h" | 9 #include "components/omnibox/autocomplete_match.h" |
| 10 #include "components/omnibox/autocomplete_scheme_classifier.h" | 10 #include "components/omnibox/autocomplete_scheme_classifier.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 { "aa foo ", 3u, true, "aa.com?foo={searchTerms}", "foo ", 0 }, | 327 { "aa foo ", 3u, true, "aa.com?foo={searchTerms}", "foo ", 0 }, |
| 328 // Extra space after keyword, no trailing space, cursor at the end. | 328 // Extra space after keyword, no trailing space, cursor at the end. |
| 329 { "aa foo", 7u, true, "aa.com?foo={searchTerms}", "foo", 3u }, | 329 { "aa foo", 7u, true, "aa.com?foo={searchTerms}", "foo", 3u }, |
| 330 // Extra space after keyword, no trailing space, cursor in the middle. | 330 // Extra space after keyword, no trailing space, cursor in the middle. |
| 331 { "aa foo", 5u, true, "aa.com?foo={searchTerms}", "foo", 1u }, | 331 { "aa foo", 5u, true, "aa.com?foo={searchTerms}", "foo", 1u }, |
| 332 | 332 |
| 333 // Disallow exact keyword match. | 333 // Disallow exact keyword match. |
| 334 { "aa foo", base::string16::npos, false, "", "aa foo", | 334 { "aa foo", base::string16::npos, false, "", "aa foo", |
| 335 base::string16::npos }, | 335 base::string16::npos }, |
| 336 }; | 336 }; |
| 337 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 337 for (size_t i = 0; i < arraysize(cases); i++) { |
| 338 AutocompleteInput input( | 338 AutocompleteInput input( |
| 339 ASCIIToUTF16(cases[i].text), cases[i].cursor_position, std::string(), | 339 ASCIIToUTF16(cases[i].text), cases[i].cursor_position, std::string(), |
| 340 GURL(), metrics::OmniboxEventProto::INVALID_SPEC, false, false, | 340 GURL(), metrics::OmniboxEventProto::INVALID_SPEC, false, false, |
| 341 cases[i].allow_exact_keyword_match, true, TestingSchemeClassifier()); | 341 cases[i].allow_exact_keyword_match, true, TestingSchemeClassifier()); |
| 342 const TemplateURL* url = | 342 const TemplateURL* url = |
| 343 KeywordProvider::GetSubstitutingTemplateURLForInput(model_.get(), | 343 KeywordProvider::GetSubstitutingTemplateURLForInput(model_.get(), |
| 344 &input); | 344 &input); |
| 345 if (cases[i].expected_url.empty()) | 345 if (cases[i].expected_url.empty()) |
| 346 EXPECT_FALSE(url); | 346 EXPECT_FALSE(url); |
| 347 else | 347 else |
| (...skipping 12 matching lines...) Expand all Loading... |
| 360 TestData<GURL> url_cases[] = { | 360 TestData<GURL> url_cases[] = { |
| 361 { ASCIIToUTF16("a 1 2 3"), 3, | 361 { ASCIIToUTF16("a 1 2 3"), 3, |
| 362 { { GURL("aa.com?a=b&foo=1+2+3"), false }, | 362 { { GURL("aa.com?a=b&foo=1+2+3"), false }, |
| 363 { GURL("bogus URL 1+2+3"), false }, | 363 { GURL("bogus URL 1+2+3"), false }, |
| 364 { GURL("http://aaaa/?aaaa=1&b=1+2+3&c"), false } } }, | 364 { GURL("http://aaaa/?aaaa=1&b=1+2+3&c"), false } } }, |
| 365 }; | 365 }; |
| 366 | 366 |
| 367 RunTest<GURL>(url_cases, arraysize(url_cases), | 367 RunTest<GURL>(url_cases, arraysize(url_cases), |
| 368 &AutocompleteMatch::destination_url); | 368 &AutocompleteMatch::destination_url); |
| 369 } | 369 } |
| OLD | NEW |