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

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

Issue 285233007: Remove built-in pages that don't work on Android from suggest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed builtin provider unit test Created 6 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 | 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/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/autocomplete/autocomplete_input.h" 9 #include "chrome/browser/autocomplete/autocomplete_input.h"
10 #include "chrome/browser/autocomplete/autocomplete_match.h" 10 #include "chrome/browser/autocomplete/autocomplete_match.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (matches.size() == builtin_cases[i].num_results) { 66 if (matches.size() == builtin_cases[i].num_results) {
67 for (size_t j = 0; j < builtin_cases[i].num_results; ++j) { 67 for (size_t j = 0; j < builtin_cases[i].num_results; ++j) {
68 EXPECT_EQ(builtin_cases[i].output[j], matches[j].*member) << 68 EXPECT_EQ(builtin_cases[i].output[j], matches[j].*member) <<
69 ASCIIToUTF16("Input was: ") << builtin_cases[i].input; 69 ASCIIToUTF16("Input was: ") << builtin_cases[i].input;
70 EXPECT_FALSE(matches[j].allowed_to_be_default_match); 70 EXPECT_FALSE(matches[j].allowed_to_be_default_match);
71 } 71 }
72 } 72 }
73 } 73 }
74 } 74 }
75 75
76 #if !defined(OS_ANDROID)
76 TEST_F(BuiltinProviderTest, TypingScheme) { 77 TEST_F(BuiltinProviderTest, TypingScheme) {
77 const base::string16 kAbout = ASCIIToUTF16(content::kAboutScheme); 78 const base::string16 kAbout = ASCIIToUTF16(content::kAboutScheme);
78 const base::string16 kChrome = ASCIIToUTF16(content::kChromeUIScheme); 79 const base::string16 kChrome = ASCIIToUTF16(content::kChromeUIScheme);
79 const base::string16 kSeparator1 = ASCIIToUTF16(":"); 80 const base::string16 kSeparator1 = ASCIIToUTF16(":");
80 const base::string16 kSeparator2 = ASCIIToUTF16(":/"); 81 const base::string16 kSeparator2 = ASCIIToUTF16(":/");
81 const base::string16 kSeparator3 = 82 const base::string16 kSeparator3 =
82 ASCIIToUTF16(content::kStandardSchemeSeparator); 83 ASCIIToUTF16(content::kStandardSchemeSeparator);
83 84
84 // These default URLs should correspond with those in BuiltinProvider::Start. 85 // These default URLs should correspond with those in BuiltinProvider::Start.
85 const GURL kURL1 = GURL(chrome::kChromeUIChromeURLsURL); 86 const GURL kURL1 = GURL(chrome::kChromeUIChromeURLsURL);
(...skipping 27 matching lines...) Expand all
113 {kChrome, 3, {kURL1, kURL2, kURL3}}, 114 {kChrome, 3, {kURL1, kURL2, kURL3}},
114 {kChrome + kSeparator1, 3, {kURL1, kURL2, kURL3}}, 115 {kChrome + kSeparator1, 3, {kURL1, kURL2, kURL3}},
115 {kChrome + kSeparator2, 3, {kURL1, kURL2, kURL3}}, 116 {kChrome + kSeparator2, 3, {kURL1, kURL2, kURL3}},
116 {kChrome + kSeparator3, 3, {kURL1, kURL2, kURL3}}, 117 {kChrome + kSeparator3, 3, {kURL1, kURL2, kURL3}},
117 {ASCIIToUTF16("ChRoMe://"), 3, {kURL1, kURL2, kURL3}}, 118 {ASCIIToUTF16("ChRoMe://"), 3, {kURL1, kURL2, kURL3}},
118 }; 119 };
119 120
120 RunTest<GURL>(typing_scheme_cases, arraysize(typing_scheme_cases), 121 RunTest<GURL>(typing_scheme_cases, arraysize(typing_scheme_cases),
121 &AutocompleteMatch::destination_url); 122 &AutocompleteMatch::destination_url);
122 } 123 }
124 #else // Android uses a subset of the URLs
125 TEST_F(BuiltinProviderTest, TypingScheme) {
126 const base::string16 kAbout = ASCIIToUTF16(content::kAboutScheme);
127 const base::string16 kChrome = ASCIIToUTF16(content::kChromeUIScheme);
128 const base::string16 kSeparator1 = ASCIIToUTF16(":");
129 const base::string16 kSeparator2 = ASCIIToUTF16(":/");
130 const base::string16 kSeparator3 =
131 ASCIIToUTF16(content::kStandardSchemeSeparator);
132
133 // These default URLs should correspond with those in BuiltinProvider::Start.
134 const GURL kURL1 = GURL(chrome::kChromeUIChromeURLsURL);
135 const GURL kURL2 = GURL(chrome::kChromeUIVersionURL);
136
137 test_data<GURL> typing_scheme_cases[] = {
138 // Typing an unrelated scheme should give nothing.
139 {ASCIIToUTF16("h"), 0, {}},
140 {ASCIIToUTF16("http"), 0, {}},
141 {ASCIIToUTF16("file"), 0, {}},
142 {ASCIIToUTF16("abouz"), 0, {}},
143 {ASCIIToUTF16("aboutt"), 0, {}},
144 {ASCIIToUTF16("aboutt:"), 0, {}},
145 {ASCIIToUTF16("chroma"), 0, {}},
146 {ASCIIToUTF16("chromee"), 0, {}},
147 {ASCIIToUTF16("chromee:"), 0, {}},
148
149 // Typing a portion of about:// should give the default urls.
150 {kAbout.substr(0, 1), 2, {kURL1, kURL2}},
151 {ASCIIToUTF16("A"), 2, {kURL1, kURL2}},
152 {kAbout, 2, {kURL1, kURL2}},
153 {kAbout + kSeparator1, 2, {kURL1, kURL2}},
154 {kAbout + kSeparator2, 2, {kURL1, kURL2}},
155 {kAbout + kSeparator3, 2, {kURL1, kURL2}},
156 {ASCIIToUTF16("aBoUT://"), 2, {kURL1, kURL2}},
157
158 // Typing a portion of chrome:// should give the default urls.
159 {kChrome.substr(0, 1), 2, {kURL1, kURL2}},
160 {ASCIIToUTF16("C"), 2, {kURL1, kURL2}},
161 {kChrome, 2, {kURL1, kURL2}},
162 {kChrome + kSeparator1, 2, {kURL1, kURL2}},
163 {kChrome + kSeparator2, 2, {kURL1, kURL2}},
164 {kChrome + kSeparator3, 2, {kURL1, kURL2}},
165 {ASCIIToUTF16("ChRoMe://"), 2, {kURL1, kURL2}},
166 };
167
168 RunTest<GURL>(typing_scheme_cases, arraysize(typing_scheme_cases),
169 &AutocompleteMatch::destination_url);
170 }
171 #endif
123 172
124 TEST_F(BuiltinProviderTest, NonChromeURLs) { 173 TEST_F(BuiltinProviderTest, NonChromeURLs) {
125 test_data<GURL> non_chrome_url_cases[] = { 174 test_data<GURL> non_chrome_url_cases[] = {
126 // Typing an unrelated scheme should give nothing. 175 // Typing an unrelated scheme should give nothing.
127 {ASCIIToUTF16("g@rb@g3"), 0, {}}, 176 {ASCIIToUTF16("g@rb@g3"), 0, {}},
128 {ASCIIToUTF16("www.google.com"), 0, {}}, 177 {ASCIIToUTF16("www.google.com"), 0, {}},
129 {ASCIIToUTF16("http:www.google.com"), 0, {}}, 178 {ASCIIToUTF16("http:www.google.com"), 0, {}},
130 {ASCIIToUTF16("http://www.google.com"), 0, {}}, 179 {ASCIIToUTF16("http://www.google.com"), 0, {}},
131 {ASCIIToUTF16("file:filename"), 0, {}}, 180 {ASCIIToUTF16("file:filename"), 0, {}},
132 {ASCIIToUTF16("scheme:"), 0, {}}, 181 {ASCIIToUTF16("scheme:"), 0, {}},
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 {kSettings + kPage1.substr(0, 2), 1, {kURL1}}, 268 {kSettings + kPage1.substr(0, 2), 1, {kURL1}},
220 {kSettings + kPage1.substr(0, kPage1.length() - 1), 1, {kURL1}}, 269 {kSettings + kPage1.substr(0, kPage1.length() - 1), 1, {kURL1}},
221 {kSettings + kPage1, 1, {kURL1}}, 270 {kSettings + kPage1, 1, {kURL1}},
222 {kSettings + kPage2, 1, {kURL2}}, 271 {kSettings + kPage2, 1, {kURL2}},
223 }; 272 };
224 273
225 RunTest<GURL>(settings_subpage_cases, arraysize(settings_subpage_cases), 274 RunTest<GURL>(settings_subpage_cases, arraysize(settings_subpage_cases),
226 &AutocompleteMatch::destination_url); 275 &AutocompleteMatch::destination_url);
227 } 276 }
228 #endif 277 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698