| 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 "components/omnibox/browser/keyword_provider.h" | 5 #include "components/omnibox/browser/keyword_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 // Exact keyword matches with remaining text when the keyword is an | 393 // Exact keyword matches with remaining text when the keyword is an |
| 394 // extension keyword should return something. This is tested in | 394 // extension keyword should return something. This is tested in |
| 395 // chrome/browser/extensions/api/omnibox/omnibox_apitest.cc's | 395 // chrome/browser/extensions/api/omnibox/omnibox_apitest.cc's |
| 396 // in OmniboxApiTest's Basic test. | 396 // in OmniboxApiTest's Basic test. |
| 397 | 397 |
| 398 // Substitution should work with various locations of the "%s". | 398 // Substitution should work with various locations of the "%s". |
| 399 { ASCIIToUTF16("aaa"), 2, | 399 { ASCIIToUTF16("aaa"), 2, |
| 400 { { ASCIIToUTF16("Search aaaa for <enter query>"), false }, | 400 { { ASCIIToUTF16("Search aaaa for <enter query>"), false }, |
| 401 { ASCIIToUTF16("Search aaaaa for <enter query>"), false }, | 401 { ASCIIToUTF16("Search aaaaa for <enter query>"), false }, |
| 402 kEmptyMatch} }, | 402 kEmptyMatch} }, |
| 403 // When there is a search string, simply display it, not Search ... for ... |
| 404 // These suggestions will be disambiguated by the description "www Search", |
| 405 // "weasel Search", etc. We do not test the description value here |
| 406 // because KeywordProvider doesn't set descriptions; these are populated |
| 407 // later by AutocompleteController. |
| 403 { ASCIIToUTF16("www.w w"), 2, | 408 { ASCIIToUTF16("www.w w"), 2, |
| 404 { { ASCIIToUTF16("Search www for w"), false }, | 409 { { ASCIIToUTF16("w"), false }, |
| 405 { ASCIIToUTF16("Search weasel for w"), false }, | 410 { ASCIIToUTF16("w"), false }, |
| 406 kEmptyMatch } }, | 411 kEmptyMatch } }, |
| 407 // Also, check that tokenization only collapses whitespace between first | 412 // Also, check that tokenization only collapses whitespace between first |
| 408 // tokens and contents are not escaped or unescaped. | 413 // tokens and contents are not escaped or unescaped. |
| 409 { ASCIIToUTF16("a 1 2+ 3"), 3, | 414 { ASCIIToUTF16("a 1 2+ 3"), 3, |
| 410 { { ASCIIToUTF16("Search aa for 1 2+ 3"), false }, | 415 { { ASCIIToUTF16("1 2+ 3"), false }, |
| 411 { ASCIIToUTF16("Search ab for 1 2+ 3"), false }, | 416 { ASCIIToUTF16("1 2+ 3"), false }, |
| 412 { ASCIIToUTF16("Search aaaa for 1 2+ 3"), false } } }, | 417 { ASCIIToUTF16("1 2+ 3"), false } } }, |
| 413 }; | 418 }; |
| 414 | 419 |
| 415 SetUpClientAndKeywordProvider(); | 420 SetUpClientAndKeywordProvider(); |
| 416 RunTest<base::string16>(contents_cases, arraysize(contents_cases), | 421 RunTest<base::string16>(contents_cases, arraysize(contents_cases), |
| 417 &AutocompleteMatch::contents); | 422 &AutocompleteMatch::contents); |
| 418 } | 423 } |
| 419 | 424 |
| 420 TEST_F(KeywordProviderTest, AddKeyword) { | 425 TEST_F(KeywordProviderTest, AddKeyword) { |
| 421 SetUpClientAndKeywordProvider(); | 426 SetUpClientAndKeywordProvider(); |
| 422 TemplateURLData data; | 427 TemplateURLData data; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 | 536 |
| 532 TEST_F(KeywordProviderTest, DoesNotProvideMatchesOnFocus) { | 537 TEST_F(KeywordProviderTest, DoesNotProvideMatchesOnFocus) { |
| 533 SetUpClientAndKeywordProvider(); | 538 SetUpClientAndKeywordProvider(); |
| 534 AutocompleteInput input(ASCIIToUTF16("aaa"), base::string16::npos, | 539 AutocompleteInput input(ASCIIToUTF16("aaa"), base::string16::npos, |
| 535 std::string(), GURL(), | 540 std::string(), GURL(), |
| 536 metrics::OmniboxEventProto::INVALID_SPEC, true, false, | 541 metrics::OmniboxEventProto::INVALID_SPEC, true, false, |
| 537 true, true, true, TestingSchemeClassifier()); | 542 true, true, true, TestingSchemeClassifier()); |
| 538 kw_provider_->Start(input, false); | 543 kw_provider_->Start(input, false); |
| 539 ASSERT_TRUE(kw_provider_->matches().empty()); | 544 ASSERT_TRUE(kw_provider_->matches().empty()); |
| 540 } | 545 } |
| OLD | NEW |