OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/autocomplete/builtin_provider.h" | 5 #include "chrome/browser/autocomplete/builtin_provider.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/autocomplete/autocomplete_input.h" | 10 #include "chrome/browser/autocomplete/autocomplete_input.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 virtual void SetUp() OVERRIDE { provider_ = new BuiltinProvider(NULL, NULL); } | 30 virtual void SetUp() OVERRIDE { provider_ = new BuiltinProvider(NULL, NULL); } |
31 virtual void TearDown() OVERRIDE { provider_ = NULL; } | 31 virtual void TearDown() OVERRIDE { provider_ = NULL; } |
32 | 32 |
33 void RunTest(const TestData cases[], size_t num_cases) { | 33 void RunTest(const TestData cases[], size_t num_cases) { |
34 ACMatches matches; | 34 ACMatches matches; |
35 for (size_t i = 0; i < num_cases; ++i) { | 35 for (size_t i = 0; i < num_cases; ++i) { |
36 SCOPED_TRACE(base::StringPrintf( | 36 SCOPED_TRACE(base::StringPrintf( |
37 "case %" PRIuS ": %s", i, base::UTF16ToUTF8(cases[i].input).c_str())); | 37 "case %" PRIuS ": %s", i, base::UTF16ToUTF8(cases[i].input).c_str())); |
38 const AutocompleteInput input(cases[i].input, base::string16::npos, | 38 const AutocompleteInput input(cases[i].input, base::string16::npos, |
39 base::string16(), GURL(), | 39 base::string16(), GURL(), |
40 AutocompleteInput::INVALID_SPEC, | 40 metrics::OmniboxEventProto::INVALID_SPEC, |
41 true, false, true, true); | 41 true, false, true, true); |
42 provider_->Start(input, false); | 42 provider_->Start(input, false); |
43 EXPECT_TRUE(provider_->done()); | 43 EXPECT_TRUE(provider_->done()); |
44 matches = provider_->matches(); | 44 matches = provider_->matches(); |
45 EXPECT_EQ(cases[i].num_results, matches.size()); | 45 EXPECT_EQ(cases[i].num_results, matches.size()); |
46 if (matches.size() == cases[i].num_results) { | 46 if (matches.size() == cases[i].num_results) { |
47 for (size_t j = 0; j < cases[i].num_results; ++j) { | 47 for (size_t j = 0; j < cases[i].num_results; ++j) { |
48 EXPECT_EQ(cases[i].output[j], matches[j].destination_url); | 48 EXPECT_EQ(cases[i].output[j], matches[j].destination_url); |
49 EXPECT_FALSE(matches[j].allowed_to_be_default_match); | 49 EXPECT_FALSE(matches[j].allowed_to_be_default_match); |
50 } | 50 } |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 {kSettings + kPage1.substr(0, 1), 2, {kURL1, kURL2}}, | 303 {kSettings + kPage1.substr(0, 1), 2, {kURL1, kURL2}}, |
304 {kSettings + kPage1.substr(0, 2), 1, {kURL1}}, | 304 {kSettings + kPage1.substr(0, 2), 1, {kURL1}}, |
305 {kSettings + kPage1.substr(0, kPage1.length() - 1), 1, {kURL1}}, | 305 {kSettings + kPage1.substr(0, kPage1.length() - 1), 1, {kURL1}}, |
306 {kSettings + kPage1, 1, {kURL1}}, | 306 {kSettings + kPage1, 1, {kURL1}}, |
307 {kSettings + kPage2, 1, {kURL2}}, | 307 {kSettings + kPage2, 1, {kURL2}}, |
308 }; | 308 }; |
309 | 309 |
310 RunTest(settings_subpage_cases, arraysize(settings_subpage_cases)); | 310 RunTest(settings_subpage_cases, arraysize(settings_subpage_cases)); |
311 } | 311 } |
312 #endif | 312 #endif |
OLD | NEW |