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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc

Issue 14821005: [RFP, Autofill] Switching dialog field identification to int. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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) 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 10 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 105
106 virtual std::vector<AutofillFieldType> InputsAreValid( 106 virtual std::vector<AutofillFieldType> InputsAreValid(
107 const DetailOutputMap& inputs, 107 const DetailOutputMap& inputs,
108 ValidationType validation_type) const OVERRIDE { 108 ValidationType validation_type) const OVERRIDE {
109 return std::vector<AutofillFieldType>(); 109 return std::vector<AutofillFieldType>();
110 } 110 }
111 111
112 // Increase visibility for testing. 112 // Increase visibility for testing.
113 AutofillDialogView* view() { return AutofillDialogControllerImpl::view(); } 113 AutofillDialogView* view() { return AutofillDialogControllerImpl::view(); }
114 const DetailInput* input_showing_popup() const { 114 const AutofillFieldType input_showing_popup_type() const {
115 return AutofillDialogControllerImpl::input_showing_popup(); 115 return AutofillDialogControllerImpl::input_showing_popup_type();
116 } 116 }
117 117
118 TestPersonalDataManager* GetTestingManager() { 118 TestPersonalDataManager* GetTestingManager() {
119 return &test_manager_; 119 return &test_manager_;
120 } 120 }
121 121
122 protected: 122 protected:
123 virtual PersonalDataManager* GetManager() OVERRIDE { 123 virtual PersonalDataManager* GetManager() OVERRIDE {
124 return &test_manager_; 124 return &test_manager_;
125 } 125 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 258 }
259 259
260 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { 260 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) {
261 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 261 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE);
262 262
263 AutofillProfile full_profile(test::GetFullProfile()); 263 AutofillProfile full_profile(test::GetFullProfile());
264 controller()->GetTestingManager()->AddTestingProfile(&full_profile); 264 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
265 265
266 const DetailInputs& inputs = 266 const DetailInputs& inputs =
267 controller()->RequestedFieldsForSection(SECTION_SHIPPING); 267 controller()->RequestedFieldsForSection(SECTION_SHIPPING);
268 const DetailInput& triggering_input = inputs[0]; 268 AutofillFieldType triggering_input = inputs[0].type;
269 string16 value = full_profile.GetRawInfo(triggering_input.type); 269 string16 value = full_profile.GetRawInfo(triggering_input);
270 TestableAutofillDialogView* view = controller()->view()->GetTestableView(); 270 TestableAutofillDialogView* view = controller()->view()->GetTestableView();
271 view->SetTextContentsOfInput(triggering_input, 271 view->SetTextContentsOfInput(
272 value.substr(0, value.size() / 2)); 272 SECTION_SHIPPING, triggering_input, value.substr(0, value.size() / 2));
273 view->ActivateInput(triggering_input); 273 view->ActivateInput(SECTION_SHIPPING, triggering_input);
274 274
275 ASSERT_EQ(&triggering_input, controller()->input_showing_popup()); 275 ASSERT_EQ(triggering_input, controller()->input_showing_popup_type());
276 controller()->DidAcceptSuggestion(string16(), 0); 276 controller()->DidAcceptSuggestion(string16(), 0);
277 277
278 // All inputs should be filled. 278 // All inputs should be filled.
279 AutofillProfileWrapper wrapper(&full_profile, 0); 279 AutofillProfileWrapper wrapper(&full_profile, 0);
280 for (size_t i = 0; i < inputs.size(); ++i) { 280 for (size_t i = 0; i < inputs.size(); ++i) {
281 EXPECT_EQ(wrapper.GetInfo(inputs[i].type), 281 EXPECT_EQ(wrapper.GetInfo(inputs[i].type),
282 view->GetTextContentsOfInput(inputs[i])); 282 view->GetTextContentsOfInput(SECTION_SHIPPING, inputs[i].type));
283 } 283 }
284 284
285 // Now simulate some user edits and try again. 285 // Now simulate some user edits and try again.
286 std::vector<string16> expectations; 286 std::vector<string16> expectations;
287 for (size_t i = 0; i < inputs.size(); ++i) { 287 for (size_t i = 0; i < inputs.size(); ++i) {
288 string16 users_input = i % 2 == 0 ? string16() : ASCIIToUTF16("dummy"); 288 string16 users_input = i % 2 == 0 ? string16() : ASCIIToUTF16("dummy");
289 view->SetTextContentsOfInput(inputs[i], users_input); 289 view->SetTextContentsOfInput(SECTION_SHIPPING, inputs[i].type, users_input);
290 // Empty inputs should be filled, others should be left alone. 290 // Empty inputs should be filled, others should be left alone.
291 string16 expectation = 291 string16 expectation =
292 &inputs[i] == &triggering_input || users_input.empty() ? 292 inputs[i].type == triggering_input || users_input.empty()
293 wrapper.GetInfo(inputs[i].type) : 293 ? wrapper.GetInfo(inputs[i].type)
294 users_input; 294 : users_input;
295 expectations.push_back(expectation); 295 expectations.push_back(expectation);
296 } 296 }
297 297
298 view->SetTextContentsOfInput(triggering_input, 298 view->SetTextContentsOfInput(
299 value.substr(0, value.size() / 2)); 299 SECTION_SHIPPING, triggering_input, value.substr(0, value.size() / 2));
300 view->ActivateInput(triggering_input); 300 view->ActivateInput(SECTION_SHIPPING, triggering_input);
301 ASSERT_EQ(&triggering_input, controller()->input_showing_popup()); 301 ASSERT_EQ(triggering_input, controller()->input_showing_popup_type());
302 controller()->DidAcceptSuggestion(string16(), 0); 302 controller()->DidAcceptSuggestion(string16(), 0);
303 303
304 for (size_t i = 0; i < inputs.size(); ++i) { 304 for (size_t i = 0; i < inputs.size(); ++i) {
305 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i])); 305 EXPECT_EQ(expectations[i],
306 view->GetTextContentsOfInput(SECTION_SHIPPING, inputs[i].type));
306 } 307 }
307 } 308 }
308 #endif // defined(TOOLKIT_VIEWS) 309 #endif // defined(TOOLKIT_VIEWS)
309 310
310 } // namespace autofill 311 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller.h ('k') | chrome/browser/ui/autofill/autofill_dialog_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698