OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/search_provider.h" | 5 #include "components/omnibox/search_provider.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2488 { "a.com", "[\"a.com\",[\"info\"],[],[]," | 2488 { "a.com", "[\"a.com\",[\"info\"],[],[]," |
2489 "{\"google:suggestrelevance\":[9999]}]", | 2489 "{\"google:suggestrelevance\":[9999]}]", |
2490 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2490 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
2491 { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, | 2491 { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, |
2492 kEmptyMatch, kEmptyMatch } }, | 2492 kEmptyMatch, kEmptyMatch } }, |
2493 { "a.com", "[\"a.com\",[\"info\"],[],[]," | 2493 { "a.com", "[\"a.com\",[\"info\"],[],[]," |
2494 "{\"google:suggestrelevance\":[9999]}]", | 2494 "{\"google:suggestrelevance\":[9999]}]", |
2495 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2495 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
2496 { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, | 2496 { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, |
2497 kEmptyMatch, kEmptyMatch } }, | 2497 kEmptyMatch, kEmptyMatch } }, |
| 2498 |
| 2499 // Ensure that if the user explicitly enters a scheme, a navsuggest |
| 2500 // result for a URL with a different scheme is not inlineable. |
| 2501 { "http://a.com", "[\"http://a.com\"," |
| 2502 "[\"http://a.com/1\", \"https://a.com/\"],[],[]," |
| 2503 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 2504 "\"google:suggestrelevance\":[9000, 8000]}]", |
| 2505 { { "http://a.com/1", AutocompleteMatchType::NAVSUGGEST, true }, |
| 2506 { "https://a.com", AutocompleteMatchType::NAVSUGGEST, false }, |
| 2507 { "http://a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
| 2508 true }, |
| 2509 kEmptyMatch } }, |
2498 }; | 2510 }; |
2499 | 2511 |
2500 for (size_t i = 0; i < arraysize(cases); ++i) { | 2512 for (size_t i = 0; i < arraysize(cases); ++i) { |
2501 // Send the query twice in order to have a synchronous pass after the first | 2513 // Send the query twice in order to have a synchronous pass after the first |
2502 // response is received. This is necessary because SearchProvider doesn't | 2514 // response is received. This is necessary because SearchProvider doesn't |
2503 // allow an asynchronous response to change the default match. | 2515 // allow an asynchronous response to change the default match. |
2504 for (size_t j = 0; j < 2; ++j) { | 2516 for (size_t j = 0; j < 2; ++j) { |
2505 QueryForInputAndWaitForFetcherResponses( | 2517 QueryForInputAndWaitForFetcherResponses( |
2506 ASCIIToUTF16(cases[i].input), false, cases[i].json, std::string()); | 2518 ASCIIToUTF16(cases[i].input), false, cases[i].json, std::string()); |
2507 } | 2519 } |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3509 provider_->GetSessionToken(); | 3521 provider_->GetSessionToken(); |
3510 base::TimeTicks expiration_time_1 = provider_->token_expiration_time_; | 3522 base::TimeTicks expiration_time_1 = provider_->token_expiration_time_; |
3511 base::PlatformThread::Sleep(kSmallDelta); | 3523 base::PlatformThread::Sleep(kSmallDelta); |
3512 provider_->GetSessionToken(); | 3524 provider_->GetSessionToken(); |
3513 base::TimeTicks expiration_time_2 = provider_->token_expiration_time_; | 3525 base::TimeTicks expiration_time_2 = provider_->token_expiration_time_; |
3514 EXPECT_GT(expiration_time_2, expiration_time_1); | 3526 EXPECT_GT(expiration_time_2, expiration_time_1); |
3515 EXPECT_GE(expiration_time_2, expiration_time_1 + kSmallDelta); | 3527 EXPECT_GE(expiration_time_2, expiration_time_1 + kSmallDelta); |
3516 } | 3528 } |
3517 | 3529 |
3518 TEST_F(SearchProviderTest, AnswersCache) { | 3530 TEST_F(SearchProviderTest, AnswersCache) { |
3519 AutocompleteResult result; | 3531 AutocompleteResult result(client_.get()); |
3520 ACMatches matches; | 3532 ACMatches matches; |
3521 AutocompleteMatch match1; | 3533 AutocompleteMatch match1; |
3522 match1.answer_contents = base::ASCIIToUTF16("m1"); | 3534 match1.answer_contents = base::ASCIIToUTF16("m1"); |
3523 match1.answer_type = base::ASCIIToUTF16("2334"); | 3535 match1.answer_type = base::ASCIIToUTF16("2334"); |
3524 match1.fill_into_edit = base::ASCIIToUTF16("weather los angeles"); | 3536 match1.fill_into_edit = base::ASCIIToUTF16("weather los angeles"); |
3525 | 3537 |
3526 AutocompleteMatch non_answer_match1; | 3538 AutocompleteMatch non_answer_match1; |
3527 non_answer_match1.fill_into_edit = base::ASCIIToUTF16("weather laguna beach"); | 3539 non_answer_match1.fill_into_edit = base::ASCIIToUTF16("weather laguna beach"); |
3528 | 3540 |
3529 // Test that an answer in the first slot populates the cache. | 3541 // Test that an answer in the first slot populates the cache. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3596 } | 3608 } |
3597 | 3609 |
3598 TEST_F(SearchProviderTest, DoesNotProvideOnFocus) { | 3610 TEST_F(SearchProviderTest, DoesNotProvideOnFocus) { |
3599 AutocompleteInput input( | 3611 AutocompleteInput input( |
3600 base::ASCIIToUTF16("f"), base::string16::npos, std::string(), GURL(), | 3612 base::ASCIIToUTF16("f"), base::string16::npos, std::string(), GURL(), |
3601 metrics::OmniboxEventProto::INVALID_SPEC, false, true, true, true, true, | 3613 metrics::OmniboxEventProto::INVALID_SPEC, false, true, true, true, true, |
3602 ChromeAutocompleteSchemeClassifier(&profile_)); | 3614 ChromeAutocompleteSchemeClassifier(&profile_)); |
3603 provider_->Start(input, false); | 3615 provider_->Start(input, false); |
3604 EXPECT_TRUE(provider_->matches().empty()); | 3616 EXPECT_TRUE(provider_->matches().empty()); |
3605 } | 3617 } |
OLD | NEW |