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/browser/search_provider.h" | 5 #include "components/omnibox/browser/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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 | 969 |
970 ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("gan"), | 970 ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("gan"), |
971 &wyt_match)); | 971 &wyt_match)); |
972 ASSERT_EQ(2u, provider_->matches().size()); | 972 ASSERT_EQ(2u, provider_->matches().size()); |
973 | 973 |
974 ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("gans"), | 974 ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("gans"), |
975 &wyt_match)); | 975 &wyt_match)); |
976 ASSERT_EQ(1u, provider_->matches().size()); | 976 ASSERT_EQ(1u, provider_->matches().size()); |
977 } | 977 } |
978 | 978 |
979 // This test is identical to the previous one except that it enables the Answers | |
980 // in Suggest field trial which triggers a different code path in | |
981 // SearchProvider. When Answers launches, this can be removed. | |
982 TEST_F(SearchProviderTest, ResetResultsBetweenRunsAnswersInSuggestEnabled) { | |
983 CreateFieldTrial(OmniboxFieldTrial::kAnswersInSuggestRule, true); | |
984 | |
985 GURL term_url_a(AddSearchToHistory(default_t_url_, | |
986 ASCIIToUTF16("games"), 1)); | |
987 GURL term_url_b(AddSearchToHistory(default_t_url_, | |
988 ASCIIToUTF16("gangnam style"), 1)); | |
989 GURL term_url_c(AddSearchToHistory(default_t_url_, | |
990 ASCIIToUTF16("gundam"), 1)); | |
991 profile_.BlockUntilHistoryProcessesPendingRequests(); | |
992 | |
993 AutocompleteMatch wyt_match; | |
994 ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("f"), | |
995 &wyt_match)); | |
996 ASSERT_EQ(1u, provider_->matches().size()); | |
997 | |
998 ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("g"), | |
999 &wyt_match)); | |
1000 ASSERT_EQ(4u, provider_->matches().size()); | |
1001 | |
1002 ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("ga"), | |
1003 &wyt_match)); | |
1004 ASSERT_EQ(3u, provider_->matches().size()); | |
1005 | |
1006 ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("gan"), | |
1007 &wyt_match)); | |
1008 ASSERT_EQ(2u, provider_->matches().size()); | |
1009 | |
1010 ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("gans"), | |
1011 &wyt_match)); | |
1012 ASSERT_EQ(1u, provider_->matches().size()); | |
1013 } | |
1014 | |
1015 // An autocompleted multiword search should not be replaced by a different | 979 // An autocompleted multiword search should not be replaced by a different |
1016 // autocompletion while the user is still typing a valid prefix unless the | 980 // autocompletion while the user is still typing a valid prefix unless the |
1017 // user has typed the prefix as a query before. | 981 // user has typed the prefix as a query before. |
1018 TEST_F(SearchProviderTest, DontReplacePreviousAutocompletion) { | 982 TEST_F(SearchProviderTest, DontReplacePreviousAutocompletion) { |
1019 GURL term_url_a(AddSearchToHistory(default_t_url_, | 983 GURL term_url_a(AddSearchToHistory(default_t_url_, |
1020 ASCIIToUTF16("four searches aaa"), 3)); | 984 ASCIIToUTF16("four searches aaa"), 3)); |
1021 GURL term_url_b(AddSearchToHistory(default_t_url_, | 985 GURL term_url_b(AddSearchToHistory(default_t_url_, |
1022 ASCIIToUTF16("four searches bbb"), 1)); | 986 ASCIIToUTF16("four searches bbb"), 1)); |
1023 GURL term_url_c(AddSearchToHistory(default_t_url_, | 987 GURL term_url_c(AddSearchToHistory(default_t_url_, |
1024 ASCIIToUTF16("four searches"), 1)); | 988 ASCIIToUTF16("four searches"), 1)); |
(...skipping 2583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3608 } | 3572 } |
3609 | 3573 |
3610 TEST_F(SearchProviderTest, DoesNotProvideOnFocus) { | 3574 TEST_F(SearchProviderTest, DoesNotProvideOnFocus) { |
3611 AutocompleteInput input( | 3575 AutocompleteInput input( |
3612 base::ASCIIToUTF16("f"), base::string16::npos, std::string(), GURL(), | 3576 base::ASCIIToUTF16("f"), base::string16::npos, std::string(), GURL(), |
3613 metrics::OmniboxEventProto::INVALID_SPEC, false, true, true, true, true, | 3577 metrics::OmniboxEventProto::INVALID_SPEC, false, true, true, true, true, |
3614 ChromeAutocompleteSchemeClassifier(&profile_)); | 3578 ChromeAutocompleteSchemeClassifier(&profile_)); |
3615 provider_->Start(input, false); | 3579 provider_->Start(input, false); |
3616 EXPECT_TRUE(provider_->matches().empty()); | 3580 EXPECT_TRUE(provider_->matches().empty()); |
3617 } | 3581 } |
OLD | NEW |