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

Side by Side Diff: chrome/browser/autofill/autofill_xml_parser_unittest.cc

Issue 11539003: Pop up requestAutocomplete UI when autofill server hints chrome client that it is in a multipage au… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed Albert's comments Created 7 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/autofill/autofill_xml_parser.h" 9 #include "chrome/browser/autofill/autofill_xml_parser.h"
10 #include "chrome/browser/autofill/field_types.h" 10 #include "chrome/browser/autofill/field_types.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 &experiment_id)); 147 &experiment_id));
148 parser.reset(new buzz::XmlParser(parse_handler.get())); 148 parser.reset(new buzz::XmlParser(parse_handler.get()));
149 parser->Parse(xml.c_str(), xml.length(), true); 149 parser->Parse(xml.c_str(), xml.length(), true);
150 EXPECT_TRUE(parse_handler->succeeded()); 150 EXPECT_TRUE(parse_handler->succeeded());
151 EXPECT_EQ(UPLOAD_NOT_REQUIRED, upload_required); 151 EXPECT_EQ(UPLOAD_NOT_REQUIRED, upload_required);
152 ASSERT_EQ(1U, field_types.size()); 152 ASSERT_EQ(1U, field_types.size());
153 EXPECT_EQ(NO_SERVER_DATA, field_types[0]); 153 EXPECT_EQ(NO_SERVER_DATA, field_types[0]);
154 EXPECT_EQ(std::string("ServerSmartyPants"), experiment_id); 154 EXPECT_EQ(std::string("ServerSmartyPants"), experiment_id);
155 } 155 }
156 156
157 // Test XML response with autofill_flow information.
158 TEST(AutofillQueryXmlParserTest, ParseAutofillFlow) {
159 std::vector<AutofillFieldType> field_types;
160 UploadRequired upload_required = USE_UPLOAD_RATES;
161 std::string experiment_id;
162
163 std::string xml = "<autofillqueryresponse>"
164 "<field autofilltype=\"55\"/>"
165 "<autofill_flow page_no=\"1\" total_pages=\"10\"/>"
166 "</autofillqueryresponse>";
167
168 scoped_ptr<AutofillQueryXmlParser> parse_handler(
169 new AutofillQueryXmlParser(&field_types, &upload_required,
170 &experiment_id));
171 scoped_ptr<buzz::XmlParser> parser(new buzz::XmlParser(parse_handler.get()));
172 parser->Parse(xml.c_str(), xml.length(), true);
173 EXPECT_TRUE(parse_handler->succeeded());
174 EXPECT_EQ(1U, field_types.size());
175 EXPECT_EQ(1, parse_handler->page_number());
176 EXPECT_EQ(10, parse_handler->total_pages());
177 }
178
157 // Test badly formed XML queries. 179 // Test badly formed XML queries.
158 TEST(AutofillQueryXmlParserTest, ParseErrors) { 180 TEST(AutofillQueryXmlParserTest, ParseErrors) {
159 std::vector<AutofillFieldType> field_types; 181 std::vector<AutofillFieldType> field_types;
160 UploadRequired upload_required = USE_UPLOAD_RATES; 182 UploadRequired upload_required = USE_UPLOAD_RATES;
161 std::string experiment_id; 183 std::string experiment_id;
162 184
163 // Test no Autofill type. 185 // Test no Autofill type.
164 std::string xml = "<autofillqueryresponse>" 186 std::string xml = "<autofillqueryresponse>"
165 "<field/>" 187 "<field/>"
166 "</autofillqueryresponse>"; 188 "</autofillqueryresponse>";
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 xml = ""; 280 xml = "";
259 parse_handler.reset(new AutofillUploadXmlParser(&positive, &negative)); 281 parse_handler.reset(new AutofillUploadXmlParser(&positive, &negative));
260 parser.reset(new buzz::XmlParser(parse_handler.get())); 282 parser.reset(new buzz::XmlParser(parse_handler.get()));
261 parser->Parse(xml.c_str(), xml.length(), true); 283 parser->Parse(xml.c_str(), xml.length(), true);
262 EXPECT_TRUE(!parse_handler->succeeded()); 284 EXPECT_TRUE(!parse_handler->succeeded());
263 EXPECT_DOUBLE_EQ(0, positive); 285 EXPECT_DOUBLE_EQ(0, positive);
264 EXPECT_DOUBLE_EQ(0, negative); 286 EXPECT_DOUBLE_EQ(0, negative);
265 } 287 }
266 288
267 } // namespace 289 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698