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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 void KeywordProviderTest::RunTest(TestData<ResultType>* keyword_cases, | 90 void KeywordProviderTest::RunTest(TestData<ResultType>* keyword_cases, |
91 int num_cases, | 91 int num_cases, |
92 ResultType AutocompleteMatch::* member) { | 92 ResultType AutocompleteMatch::* member) { |
93 ACMatches matches; | 93 ACMatches matches; |
94 for (int i = 0; i < num_cases; ++i) { | 94 for (int i = 0; i < num_cases; ++i) { |
95 SCOPED_TRACE(keyword_cases[i].input); | 95 SCOPED_TRACE(keyword_cases[i].input); |
96 AutocompleteInput input(keyword_cases[i].input, base::string16::npos, | 96 AutocompleteInput input(keyword_cases[i].input, base::string16::npos, |
97 std::string(), GURL(), | 97 std::string(), GURL(), |
98 metrics::OmniboxEventProto::INVALID_SPEC, true, | 98 metrics::OmniboxEventProto::INVALID_SPEC, true, |
99 false, true, true, TestingSchemeClassifier()); | 99 false, true, true, TestingSchemeClassifier()); |
100 kw_provider_->Start(input, false); | 100 kw_provider_->Start(input, false, false); |
101 EXPECT_TRUE(kw_provider_->done()); | 101 EXPECT_TRUE(kw_provider_->done()); |
102 matches = kw_provider_->matches(); | 102 matches = kw_provider_->matches(); |
103 ASSERT_EQ(keyword_cases[i].num_results, matches.size()); | 103 ASSERT_EQ(keyword_cases[i].num_results, matches.size()); |
104 for (size_t j = 0; j < matches.size(); ++j) { | 104 for (size_t j = 0; j < matches.size(); ++j) { |
105 EXPECT_EQ(keyword_cases[i].output[j].member, matches[j].*member); | 105 EXPECT_EQ(keyword_cases[i].output[j].member, matches[j].*member); |
106 EXPECT_EQ(keyword_cases[i].output[j].allowed_to_be_default_match, | 106 EXPECT_EQ(keyword_cases[i].output[j].allowed_to_be_default_match, |
107 matches[j].allowed_to_be_default_match); | 107 matches[j].allowed_to_be_default_match); |
108 } | 108 } |
109 } | 109 } |
110 } | 110 } |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 } |
| 370 |
| 371 TEST_F(KeywordProviderTest, DoesNotProvideMatchesOnFocus) { |
| 372 AutocompleteInput input(ASCIIToUTF16("aaa"), base::string16::npos, |
| 373 std::string(), GURL(), |
| 374 metrics::OmniboxEventProto::INVALID_SPEC, true, |
| 375 false, true, true, TestingSchemeClassifier()); |
| 376 kw_provider_->Start(input, false, true); |
| 377 ASSERT_TRUE(kw_provider_->matches().empty()); |
| 378 } |
OLD | NEW |