Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(788)

Side by Side Diff: chrome/browser/autocomplete/builtin_provider_unittest.cc

Issue 343523003: Remove AutocompleteInput Type and PageClassification. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/browser/autocomplete/autocomplete_match.h" 11 #include "chrome/browser/autocomplete/autocomplete_match.h"
12 #include "chrome/browser/autocomplete/autocomplete_provider.h" 12 #include "chrome/browser/autocomplete/autocomplete_provider.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "components/metrics/proto/omnibox_event.pb.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 using base::ASCIIToUTF16; 18 using base::ASCIIToUTF16;
18 19
19 class BuiltinProviderTest : public testing::Test { 20 class BuiltinProviderTest : public testing::Test {
20 protected: 21 protected:
21 struct TestData { 22 struct TestData {
22 const base::string16 input; 23 const base::string16 input;
23 const size_t num_results; 24 const size_t num_results;
24 const GURL output[3]; 25 const GURL output[3];
25 }; 26 };
26 27
27 BuiltinProviderTest() : provider_(NULL) {} 28 BuiltinProviderTest() : provider_(NULL) {}
28 virtual ~BuiltinProviderTest() {} 29 virtual ~BuiltinProviderTest() {}
29 30
30 virtual void SetUp() OVERRIDE { provider_ = new BuiltinProvider(NULL, NULL); } 31 virtual void SetUp() OVERRIDE { provider_ = new BuiltinProvider(NULL, NULL); }
31 virtual void TearDown() OVERRIDE { provider_ = NULL; } 32 virtual void TearDown() OVERRIDE { provider_ = NULL; }
32 33
33 void RunTest(const TestData cases[], size_t num_cases) { 34 void RunTest(const TestData cases[], size_t num_cases) {
34 ACMatches matches; 35 ACMatches matches;
35 for (size_t i = 0; i < num_cases; ++i) { 36 for (size_t i = 0; i < num_cases; ++i) {
36 SCOPED_TRACE(base::StringPrintf( 37 SCOPED_TRACE(base::StringPrintf(
37 "case %" PRIuS ": %s", i, base::UTF16ToUTF8(cases[i].input).c_str())); 38 "case %" PRIuS ": %s", i, base::UTF16ToUTF8(cases[i].input).c_str()));
38 const AutocompleteInput input(cases[i].input, base::string16::npos, 39 const AutocompleteInput input(cases[i].input, base::string16::npos,
39 base::string16(), GURL(), 40 base::string16(), GURL(),
40 AutocompleteInput::INVALID_SPEC, 41 metrics::OmniboxEventProto::INVALID_SPEC,
41 true, false, true, true); 42 true, false, true, true);
42 provider_->Start(input, false); 43 provider_->Start(input, false);
43 EXPECT_TRUE(provider_->done()); 44 EXPECT_TRUE(provider_->done());
44 matches = provider_->matches(); 45 matches = provider_->matches();
45 EXPECT_EQ(cases[i].num_results, matches.size()); 46 EXPECT_EQ(cases[i].num_results, matches.size());
46 if (matches.size() == cases[i].num_results) { 47 if (matches.size() == cases[i].num_results) {
47 for (size_t j = 0; j < cases[i].num_results; ++j) { 48 for (size_t j = 0; j < cases[i].num_results; ++j) {
48 EXPECT_EQ(cases[i].output[j], matches[j].destination_url); 49 EXPECT_EQ(cases[i].output[j], matches[j].destination_url);
49 EXPECT_FALSE(matches[j].allowed_to_be_default_match); 50 EXPECT_FALSE(matches[j].allowed_to_be_default_match);
50 } 51 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 {kSettings + kPage1.substr(0, 1), 2, {kURL1, kURL2}}, 304 {kSettings + kPage1.substr(0, 1), 2, {kURL1, kURL2}},
304 {kSettings + kPage1.substr(0, 2), 1, {kURL1}}, 305 {kSettings + kPage1.substr(0, 2), 1, {kURL1}},
305 {kSettings + kPage1.substr(0, kPage1.length() - 1), 1, {kURL1}}, 306 {kSettings + kPage1.substr(0, kPage1.length() - 1), 1, {kURL1}},
306 {kSettings + kPage1, 1, {kURL1}}, 307 {kSettings + kPage1, 1, {kURL1}},
307 {kSettings + kPage2, 1, {kURL2}}, 308 {kSettings + kPage2, 1, {kURL2}},
308 }; 309 };
309 310
310 RunTest(settings_subpage_cases, arraysize(settings_subpage_cases)); 311 RunTest(settings_subpage_cases, arraysize(settings_subpage_cases));
311 } 312 }
312 #endif 313 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698