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

Side by Side Diff: components/omnibox/browser/titled_url_match_utils_unittest.cc

Issue 2738003002: Add title to current page in zero suggest. (Closed)
Patch Set: Remove debugging info. Created 3 years, 7 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
OLDNEW
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 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/titled_url_match_utils.h" 5 #include "components/omnibox/browser/titled_url_match_utils.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "components/bookmarks/browser/titled_url_match.h" 9 #include "components/bookmarks/browser/titled_url_match.h"
10 #include "components/bookmarks/browser/titled_url_node.h" 10 #include "components/bookmarks/browser/titled_url_node.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 MockTitledUrlNode node(match_title, match_url); 69 MockTitledUrlNode node(match_title, match_url);
70 bookmarks::TitledUrlMatch titled_url_match; 70 bookmarks::TitledUrlMatch titled_url_match;
71 titled_url_match.node = &node; 71 titled_url_match.node = &node;
72 titled_url_match.title_match_positions = title_match_positions; 72 titled_url_match.title_match_positions = title_match_positions;
73 titled_url_match.url_match_positions = url_match_positions; 73 titled_url_match.url_match_positions = url_match_positions;
74 74
75 scoped_refptr<MockAutocompleteProvider> provider = 75 scoped_refptr<MockAutocompleteProvider> provider =
76 new MockAutocompleteProvider(AutocompleteProvider::Type::TYPE_BOOKMARK); 76 new MockAutocompleteProvider(AutocompleteProvider::Type::TYPE_BOOKMARK);
77 TestSchemeClassifier classifier; 77 TestSchemeClassifier classifier;
78 AutocompleteInput input(input_text, base::string16::npos, std::string(), 78 AutocompleteInput input(input_text, base::string16::npos, std::string(),
79 GURL(), metrics::OmniboxEventProto::NTP, false, false, 79 GURL(), base::string16(),
80 true, true, false, classifier); 80 metrics::OmniboxEventProto::NTP, false, false, true,
81 true, false, classifier);
81 const base::string16 fixed_up_input(input_text); 82 const base::string16 fixed_up_input(input_text);
82 83
83 AutocompleteMatch autocomplete_match = TitledUrlMatchToAutocompleteMatch( 84 AutocompleteMatch autocomplete_match = TitledUrlMatchToAutocompleteMatch(
84 titled_url_match, type, relevance, provider.get(), classifier, input, 85 titled_url_match, type, relevance, provider.get(), classifier, input,
85 fixed_up_input); 86 fixed_up_input);
86 87
87 ACMatchClassifications expected_contents_class = { 88 ACMatchClassifications expected_contents_class = {
88 {0, ACMatchClassification::URL}, 89 {0, ACMatchClassification::URL},
89 {12, ACMatchClassification::URL | ACMatchClassification::MATCH}, 90 {12, ACMatchClassification::URL | ACMatchClassification::MATCH},
90 {15, ACMatchClassification::URL}, 91 {15, ACMatchClassification::URL},
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 MockTitledUrlNode node(match_title, match_url); 130 MockTitledUrlNode node(match_title, match_url);
130 bookmarks::TitledUrlMatch titled_url_match; 131 bookmarks::TitledUrlMatch titled_url_match;
131 titled_url_match.node = &node; 132 titled_url_match.node = &node;
132 titled_url_match.title_match_positions = title_match_positions; 133 titled_url_match.title_match_positions = title_match_positions;
133 titled_url_match.url_match_positions = url_match_positions; 134 titled_url_match.url_match_positions = url_match_positions;
134 135
135 scoped_refptr<MockAutocompleteProvider> provider = 136 scoped_refptr<MockAutocompleteProvider> provider =
136 new MockAutocompleteProvider(AutocompleteProvider::Type::TYPE_BOOKMARK); 137 new MockAutocompleteProvider(AutocompleteProvider::Type::TYPE_BOOKMARK);
137 TestSchemeClassifier classifier; 138 TestSchemeClassifier classifier;
138 AutocompleteInput input(input_text, base::string16::npos, std::string(), 139 AutocompleteInput input(input_text, base::string16::npos, std::string(),
139 GURL(), metrics::OmniboxEventProto::NTP, false, false, 140 GURL(), base::string16(),
140 true, true, false, classifier); 141 metrics::OmniboxEventProto::NTP, false, false, true,
142 true, false, classifier);
141 const base::string16 fixed_up_input(input_text); 143 const base::string16 fixed_up_input(input_text);
142 144
143 AutocompleteMatch autocomplete_match = TitledUrlMatchToAutocompleteMatch( 145 AutocompleteMatch autocomplete_match = TitledUrlMatchToAutocompleteMatch(
144 titled_url_match, type, relevance, provider.get(), classifier, input, 146 titled_url_match, type, relevance, provider.get(), classifier, input,
145 fixed_up_input); 147 fixed_up_input);
146 148
147 ACMatchClassifications expected_contents_class = { 149 ACMatchClassifications expected_contents_class = {
148 {0, ACMatchClassification::URL}, 150 {0, ACMatchClassification::URL},
149 }; 151 };
150 ACMatchClassifications expected_description_class = { 152 ACMatchClassifications expected_description_class = {
(...skipping 25 matching lines...) Expand all
176 {10, 15}}; 178 {10, 15}};
177 base::string16 title = base::ASCIIToUTF16(" Leading whitespace"); 179 base::string16 title = base::ASCIIToUTF16(" Leading whitespace");
178 bookmarks::TitledUrlMatch::MatchPositions expected_match_positions = { 180 bookmarks::TitledUrlMatch::MatchPositions expected_match_positions = {
179 {0, 4}, {8, 13}}; 181 {0, 4}, {8, 13}};
180 base::string16 expected_title = base::ASCIIToUTF16("Leading whitespace"); 182 base::string16 expected_title = base::ASCIIToUTF16("Leading whitespace");
181 CorrectTitleAndMatchPositions(&title, &match_positions); 183 CorrectTitleAndMatchPositions(&title, &match_positions);
182 EXPECT_EQ(expected_title, title); 184 EXPECT_EQ(expected_title, title);
183 EXPECT_TRUE(std::equal(match_positions.begin(), match_positions.end(), 185 EXPECT_TRUE(std::equal(match_positions.begin(), match_positions.end(),
184 expected_match_positions.begin())); 186 expected_match_positions.begin()));
185 } 187 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/shortcuts_provider_unittest.cc ('k') | components/omnibox/browser/verbatim_match.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698