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

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

Issue 23537014: rAc: Get rid of dialog type in rAc, there is only one type left now. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 29 matching lines...) Expand all
40 40
41 namespace autofill { 41 namespace autofill {
42 42
43 namespace { 43 namespace {
44 44
45 void MockCallback(const FormStructure*, const std::string&) {} 45 void MockCallback(const FormStructure*, const std::string&) {}
46 46
47 class MockAutofillMetrics : public AutofillMetrics { 47 class MockAutofillMetrics : public AutofillMetrics {
48 public: 48 public:
49 MockAutofillMetrics() 49 MockAutofillMetrics()
50 : dialog_type_(static_cast<DialogType>(-1)), 50 : dialog_dismissal_action_(
51 dialog_dismissal_action_(
52 static_cast<AutofillMetrics::DialogDismissalAction>(-1)) {} 51 static_cast<AutofillMetrics::DialogDismissalAction>(-1)) {}
53 virtual ~MockAutofillMetrics() {} 52 virtual ~MockAutofillMetrics() {}
54 53
55 virtual void LogDialogUiDuration( 54 virtual void LogDialogUiDuration(
56 const base::TimeDelta& duration, 55 const base::TimeDelta& duration,
57 DialogType dialog_type,
58 DialogDismissalAction dismissal_action) const OVERRIDE { 56 DialogDismissalAction dismissal_action) const OVERRIDE {
59 // Ignore constness for testing. 57 // Ignore constness for testing.
60 MockAutofillMetrics* mutable_this = const_cast<MockAutofillMetrics*>(this); 58 MockAutofillMetrics* mutable_this = const_cast<MockAutofillMetrics*>(this);
61 mutable_this->dialog_type_ = dialog_type;
62 mutable_this->dialog_dismissal_action_ = dismissal_action; 59 mutable_this->dialog_dismissal_action_ = dismissal_action;
63 } 60 }
64 61
65 DialogType dialog_type() const { return dialog_type_; }
66 AutofillMetrics::DialogDismissalAction dialog_dismissal_action() const { 62 AutofillMetrics::DialogDismissalAction dialog_dismissal_action() const {
67 return dialog_dismissal_action_; 63 return dialog_dismissal_action_;
68 } 64 }
69 65
70 MOCK_CONST_METHOD2(LogDialogDismissalState, 66 MOCK_CONST_METHOD1(LogDialogDismissalState,
71 void(DialogType dialog_type, DialogDismissalState state)); 67 void(DialogDismissalState state));
72 68
73 private: 69 private:
74 DialogType dialog_type_;
75 AutofillMetrics::DialogDismissalAction dialog_dismissal_action_; 70 AutofillMetrics::DialogDismissalAction dialog_dismissal_action_;
76 71
77 DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics); 72 DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics);
78 }; 73 };
79 74
80 class TestAutofillDialogController : public AutofillDialogControllerImpl { 75 class TestAutofillDialogController : public AutofillDialogControllerImpl {
81 public: 76 public:
82 TestAutofillDialogController(content::WebContents* contents, 77 TestAutofillDialogController(content::WebContents* contents,
83 const FormData& form_data, 78 const FormData& form_data,
84 const AutofillMetrics& metric_logger, 79 const AutofillMetrics& metric_logger,
85 scoped_refptr<content::MessageLoopRunner> runner, 80 scoped_refptr<content::MessageLoopRunner> runner)
86 const DialogType dialog_type)
87 : AutofillDialogControllerImpl(contents, 81 : AutofillDialogControllerImpl(contents,
88 form_data, 82 form_data,
89 GURL(), 83 GURL(),
90 dialog_type,
91 base::Bind(&MockCallback)), 84 base::Bind(&MockCallback)),
92 metric_logger_(metric_logger), 85 metric_logger_(metric_logger),
93 mock_wallet_client_( 86 mock_wallet_client_(
94 Profile::FromBrowserContext(contents->GetBrowserContext())-> 87 Profile::FromBrowserContext(contents->GetBrowserContext())->
95 GetRequestContext(), this), 88 GetRequestContext(), this),
96 message_loop_runner_(runner), 89 message_loop_runner_(runner),
97 use_validation_(false), 90 use_validation_(false),
98 weak_ptr_factory_(this) {} 91 weak_ptr_factory_(this) {}
99 92
100 virtual ~TestAutofillDialogController() {} 93 virtual ~TestAutofillDialogController() {}
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 194
202 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 195 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
203 #if defined(OS_MACOSX) 196 #if defined(OS_MACOSX)
204 // OSX support for requestAutocomplete is still hidden behind a switch. 197 // OSX support for requestAutocomplete is still hidden behind a switch.
205 // Pending resolution of http://crbug.com/157274 198 // Pending resolution of http://crbug.com/157274
206 CommandLine::ForCurrentProcess()->AppendSwitch( 199 CommandLine::ForCurrentProcess()->AppendSwitch(
207 switches::kEnableInteractiveAutocomplete); 200 switches::kEnableInteractiveAutocomplete);
208 #endif 201 #endif
209 } 202 }
210 203
211 void InitializeControllerOfType(DialogType dialog_type) { 204 void InitializeControllerOfType() {
Ilya Sherman 2013/09/03 20:57:05 nit: Rename to InitializeController()
Evan Stade 2013/09/03 20:57:36 this fn name no longer makes sense. Also, you shou
Raman Kakilate 2013/09/03 21:50:31 Done.
Raman Kakilate 2013/09/03 21:50:31 Done.
212 FormData form; 205 FormData form;
213 form.name = ASCIIToUTF16("TestForm"); 206 form.name = ASCIIToUTF16("TestForm");
214 form.method = ASCIIToUTF16("POST"); 207 form.method = ASCIIToUTF16("POST");
215 form.origin = GURL("http://example.com/form.html"); 208 form.origin = GURL("http://example.com/form.html");
216 form.action = GURL("http://example.com/submit.html"); 209 form.action = GURL("http://example.com/submit.html");
217 form.user_submitted = true; 210 form.user_submitted = true;
218 211
219 FormFieldData field; 212 FormFieldData field;
220 field.autocomplete_attribute = "shipping tel"; 213 field.autocomplete_attribute = "shipping tel";
221 form.fields.push_back(field); 214 form.fields.push_back(field);
222 215
223 message_loop_runner_ = new content::MessageLoopRunner; 216 message_loop_runner_ = new content::MessageLoopRunner;
224 controller_ = new TestAutofillDialogController( 217 controller_ = new TestAutofillDialogController(
225 GetActiveWebContents(), 218 GetActiveWebContents(),
226 form, 219 form,
227 metric_logger_, 220 metric_logger_,
228 message_loop_runner_, 221 message_loop_runner_);
229 dialog_type);
230 controller_->Show(); 222 controller_->Show();
231 } 223 }
232 224
233 content::WebContents* GetActiveWebContents() { 225 content::WebContents* GetActiveWebContents() {
234 return browser()->tab_strip_model()->GetActiveWebContents(); 226 return browser()->tab_strip_model()->GetActiveWebContents();
235 } 227 }
236 228
237 const MockAutofillMetrics& metric_logger() { return metric_logger_; } 229 const MockAutofillMetrics& metric_logger() { return metric_logger_; }
238 TestAutofillDialogController* controller() { return controller_; } 230 TestAutofillDialogController* controller() { return controller_; }
239 231
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 MockAutofillMetrics metric_logger_; 312 MockAutofillMetrics metric_logger_;
321 TestAutofillDialogController* controller_; // Weak reference. 313 TestAutofillDialogController* controller_; // Weak reference.
322 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 314 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
323 scoped_ptr<content::DOMMessageQueue> dom_message_queue_; 315 scoped_ptr<content::DOMMessageQueue> dom_message_queue_;
324 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest); 316 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest);
325 }; 317 };
326 318
327 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) 319 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX)
328 // Submit the form data. 320 // Submit the form data.
329 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { 321 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) {
330 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 322 InitializeControllerOfType();
331 controller()->GetTestableView()->SubmitForTesting(); 323 controller()->GetTestableView()->SubmitForTesting();
332 324
333 RunMessageLoop(); 325 RunMessageLoop();
334 326
335 EXPECT_EQ(AutofillMetrics::DIALOG_ACCEPTED, 327 EXPECT_EQ(AutofillMetrics::DIALOG_ACCEPTED,
336 metric_logger().dialog_dismissal_action()); 328 metric_logger().dialog_dismissal_action());
337 EXPECT_EQ(DIALOG_TYPE_REQUEST_AUTOCOMPLETE, metric_logger().dialog_type());
338 } 329 }
339 330
340 // Cancel out of the dialog. 331 // Cancel out of the dialog.
341 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) { 332 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) {
342 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 333 InitializeControllerOfType();
343 controller()->GetTestableView()->CancelForTesting(); 334 controller()->GetTestableView()->CancelForTesting();
344 335
345 RunMessageLoop(); 336 RunMessageLoop();
346 337
347 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, 338 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED,
348 metric_logger().dialog_dismissal_action()); 339 metric_logger().dialog_dismissal_action());
349 EXPECT_EQ(DIALOG_TYPE_REQUEST_AUTOCOMPLETE, metric_logger().dialog_type());
350 } 340 }
351 341
352 // Take some other action that dismisses the dialog. 342 // Take some other action that dismisses the dialog.
353 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Hide) { 343 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Hide) {
354 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 344 InitializeControllerOfType();
355 controller()->Hide(); 345 controller()->Hide();
356 346
357 RunMessageLoop(); 347 RunMessageLoop();
358 348
359 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, 349 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED,
360 metric_logger().dialog_dismissal_action()); 350 metric_logger().dialog_dismissal_action());
361 EXPECT_EQ(DIALOG_TYPE_REQUEST_AUTOCOMPLETE, metric_logger().dialog_type());
362 } 351 }
363 352
364 // Ensure that Hide() will only destroy the controller object after the 353 // Ensure that Hide() will only destroy the controller object after the
365 // message loop has run. Otherwise, there may be read-after-free issues 354 // message loop has run. Otherwise, there may be read-after-free issues
366 // during some tests. 355 // during some tests.
367 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, DeferredDestruction) { 356 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, DeferredDestruction) {
368 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 357 InitializeControllerOfType();
369 358
370 base::WeakPtr<TestAutofillDialogController> weak_ptr = 359 base::WeakPtr<TestAutofillDialogController> weak_ptr =
371 controller()->AsWeakPtr(); 360 controller()->AsWeakPtr();
372 EXPECT_TRUE(weak_ptr.get()); 361 EXPECT_TRUE(weak_ptr.get());
373 362
374 controller()->Hide(); 363 controller()->Hide();
375 EXPECT_TRUE(weak_ptr.get()); 364 EXPECT_TRUE(weak_ptr.get());
376 365
377 RunMessageLoop(); 366 RunMessageLoop();
378 EXPECT_FALSE(weak_ptr.get()); 367 EXPECT_FALSE(weak_ptr.get());
379 } 368 }
380 369
381 // Ensure that the expected metric is logged when the dialog is closed during 370 // Ensure that the expected metric is logged when the dialog is closed during
382 // signin. 371 // signin.
383 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, CloseDuringSignin) { 372 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, CloseDuringSignin) {
384 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 373 InitializeControllerOfType();
385 controller()->SignInLinkClicked(); 374 controller()->SignInLinkClicked();
386 375
387 EXPECT_CALL(metric_logger(), 376 EXPECT_CALL(metric_logger(),
388 LogDialogDismissalState( 377 LogDialogDismissalState(
389 DIALOG_TYPE_REQUEST_AUTOCOMPLETE,
390 AutofillMetrics::DIALOG_CANCELED_DURING_SIGNIN)); 378 AutofillMetrics::DIALOG_CANCELED_DURING_SIGNIN));
391 controller()->GetTestableView()->CancelForTesting(); 379 controller()->GetTestableView()->CancelForTesting();
392 380
393 RunMessageLoop(); 381 RunMessageLoop();
394 382
395 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, 383 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED,
396 metric_logger().dialog_dismissal_action()); 384 metric_logger().dialog_dismissal_action());
397 EXPECT_EQ(DIALOG_TYPE_REQUEST_AUTOCOMPLETE, metric_logger().dialog_type());
398 } 385 }
399 386
400 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { 387 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) {
401 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 388 InitializeControllerOfType();
402 389
403 AutofillProfile full_profile(test::GetFullProfile()); 390 AutofillProfile full_profile(test::GetFullProfile());
404 controller()->GetTestingManager()->AddTestingProfile(&full_profile); 391 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
405 392
406 const DetailInputs& inputs = 393 const DetailInputs& inputs =
407 controller()->RequestedFieldsForSection(SECTION_SHIPPING); 394 controller()->RequestedFieldsForSection(SECTION_SHIPPING);
408 const DetailInput& triggering_input = inputs[0]; 395 const DetailInput& triggering_input = inputs[0];
409 string16 value = full_profile.GetRawInfo(triggering_input.type); 396 string16 value = full_profile.GetRawInfo(triggering_input.type);
410 TestableAutofillDialogView* view = controller()->GetTestableView(); 397 TestableAutofillDialogView* view = controller()->GetTestableView();
411 view->SetTextContentsOfInput(triggering_input, 398 view->SetTextContentsOfInput(triggering_input,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314. 439 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314.
453 // TODO(groby): Enable this test on mac once AutofillDialogCocoa handles 440 // TODO(groby): Enable this test on mac once AutofillDialogCocoa handles
454 // comboboxes for GetTextContentsForInput. http://crbug.com/270205 441 // comboboxes for GetTextContentsForInput. http://crbug.com/270205
455 #if defined(OS_MACOSX) || defined(OS_WIN) 442 #if defined(OS_MACOSX) || defined(OS_WIN)
456 #define MAYBE_FillComboboxFromAutofill DISABLED_FillComboboxFromAutofill 443 #define MAYBE_FillComboboxFromAutofill DISABLED_FillComboboxFromAutofill
457 #else 444 #else
458 #define MAYBE_FillComboboxFromAutofill FillComboboxFromAutofill 445 #define MAYBE_FillComboboxFromAutofill FillComboboxFromAutofill
459 #endif 446 #endif
460 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 447 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
461 MAYBE_FillComboboxFromAutofill) { 448 MAYBE_FillComboboxFromAutofill) {
462 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 449 InitializeControllerOfType();
463 450
464 CreditCard card1; 451 CreditCard card1;
465 test::SetCreditCardInfo(&card1, "JJ Smith", "4111111111111111", "12", "2018"); 452 test::SetCreditCardInfo(&card1, "JJ Smith", "4111111111111111", "12", "2018");
466 controller()->GetTestingManager()->AddTestingCreditCard(&card1); 453 controller()->GetTestingManager()->AddTestingCreditCard(&card1);
467 CreditCard card2; 454 CreditCard card2;
468 test::SetCreditCardInfo(&card2, "B Bird", "3111111111111111", "11", "2017"); 455 test::SetCreditCardInfo(&card2, "B Bird", "3111111111111111", "11", "2017");
469 controller()->GetTestingManager()->AddTestingCreditCard(&card2); 456 controller()->GetTestingManager()->AddTestingCreditCard(&card2);
470 AutofillProfile full_profile(test::GetFullProfile()); 457 AutofillProfile full_profile(test::GetFullProfile());
471 controller()->GetTestingManager()->AddTestingProfile(&full_profile); 458 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
472 459
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 EXPECT_TRUE(view->GetTextContentsOfInput(input).empty()); 524 EXPECT_TRUE(view->GetTextContentsOfInput(input).empty());
538 } else { 525 } else {
539 EXPECT_EQ(wrapper1.GetInfo(AutofillType(input.type)), 526 EXPECT_EQ(wrapper1.GetInfo(AutofillType(input.type)),
540 view->GetTextContentsOfInput(input)); 527 view->GetTextContentsOfInput(input));
541 } 528 }
542 } 529 }
543 } 530 }
544 531
545 // Tests that credit card number is disabled while editing a Wallet instrument. 532 // Tests that credit card number is disabled while editing a Wallet instrument.
546 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, WalletCreditCardDisabled) { 533 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, WalletCreditCardDisabled) {
547 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 534 InitializeControllerOfType();
548 controller()->OnUserNameFetchSuccess("user@example.com"); 535 controller()->OnUserNameFetchSuccess("user@example.com");
549 536
550 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 537 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
551 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); 538 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
552 controller()->OnDidGetWalletItems(wallet_items.Pass()); 539 controller()->OnDidGetWalletItems(wallet_items.Pass());
553 540
554 // Click "Edit" in the billing section (while using Wallet). 541 // Click "Edit" in the billing section (while using Wallet).
555 controller()->EditClickedForSection(SECTION_CC_BILLING); 542 controller()->EditClickedForSection(SECTION_CC_BILLING);
556 543
557 const DetailInputs& edit_inputs = 544 const DetailInputs& edit_inputs =
(...skipping 17 matching lines...) Expand all
575 if (add_inputs[i].type == CREDIT_CARD_NUMBER) { 562 if (add_inputs[i].type == CREDIT_CARD_NUMBER) {
576 EXPECT_TRUE(add_inputs[i].editable); 563 EXPECT_TRUE(add_inputs[i].editable);
577 break; 564 break;
578 } 565 }
579 } 566 }
580 ASSERT_LT(i, add_inputs.size()); 567 ASSERT_LT(i, add_inputs.size());
581 } 568 }
582 569
583 // Ensure that expired cards trigger invalid suggestions. 570 // Ensure that expired cards trigger invalid suggestions.
584 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ExpiredCard) { 571 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ExpiredCard) {
585 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 572 InitializeControllerOfType();
586 573
587 CreditCard verified_card(test::GetCreditCard()); 574 CreditCard verified_card(test::GetCreditCard());
588 verified_card.set_origin("Chrome settings"); 575 verified_card.set_origin("Chrome settings");
589 ASSERT_TRUE(verified_card.IsVerified()); 576 ASSERT_TRUE(verified_card.IsVerified());
590 controller()->GetTestingManager()->AddTestingCreditCard(&verified_card); 577 controller()->GetTestingManager()->AddTestingCreditCard(&verified_card);
591 578
592 CreditCard expired_card(test::GetCreditCard()); 579 CreditCard expired_card(test::GetCreditCard());
593 expired_card.set_origin("Chrome settings"); 580 expired_card.set_origin("Chrome settings");
594 expired_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2007")); 581 expired_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2007"));
595 ASSERT_TRUE(expired_card.IsVerified()); 582 ASSERT_TRUE(expired_card.IsVerified());
(...skipping 10 matching lines...) Expand all
606 ASSERT_TRUE(model->IsItemCheckedAt(0)); 593 ASSERT_TRUE(model->IsItemCheckedAt(0));
607 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); 594 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC));
608 595
609 model->ActivatedAt(1); 596 model->ActivatedAt(1);
610 ASSERT_TRUE(model->IsItemCheckedAt(1)); 597 ASSERT_TRUE(model->IsItemCheckedAt(1));
611 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC)); 598 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC));
612 } 599 }
613 600
614 // Notifications with long message text should not make the dialog bigger. 601 // Notifications with long message text should not make the dialog bigger.
615 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) { 602 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) {
616 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 603 InitializeControllerOfType();
617 604
618 const gfx::Size no_notification_size = 605 const gfx::Size no_notification_size =
619 controller()->GetTestableView()->GetSize(); 606 controller()->GetTestableView()->GetSize();
620 ASSERT_GT(no_notification_size.width(), 0); 607 ASSERT_GT(no_notification_size.width(), 0);
621 608
622 std::vector<DialogNotification> notifications; 609 std::vector<DialogNotification> notifications;
623 notifications.push_back( 610 notifications.push_back(
624 DialogNotification(DialogNotification::DEVELOPER_WARNING, ASCIIToUTF16( 611 DialogNotification(DialogNotification::DEVELOPER_WARNING, ASCIIToUTF16(
625 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do " 612 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do "
626 "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim " 613 "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim "
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 } 657 }
671 658
672 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 659 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
673 AutocompleteErrorEventReasonCancel) { 660 AutocompleteErrorEventReasonCancel) {
674 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>")->GetTestableView()-> 661 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>")->GetTestableView()->
675 CancelForTesting(); 662 CancelForTesting();
676 ExpectDomMessage("error: cancel"); 663 ExpectDomMessage("error: cancel");
677 } 664 }
678 665
679 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) { 666 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) {
680 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 667 InitializeControllerOfType();
681 controller()->set_use_validation(true); 668 controller()->set_use_validation(true);
682 669
683 CreditCard credit_card(test::GetVerifiedCreditCard()); 670 CreditCard credit_card(test::GetVerifiedCreditCard());
684 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); 671 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card);
685 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); 672 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC));
686 673
687 ASSERT_NO_FATAL_FAILURE( 674 ASSERT_NO_FATAL_FAILURE(
688 controller()->GetTestableView()->SubmitForTesting()); 675 controller()->GetTestableView()->SubmitForTesting());
689 } 676 }
690 677
691 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314. 678 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314.
692 #if defined(OS_WIN) 679 #if defined(OS_WIN)
693 #define MAYBE_PreservedSections DISABLED_PreservedSections 680 #define MAYBE_PreservedSections DISABLED_PreservedSections
694 #else 681 #else
695 #define MAYBE_PreservedSections PreservedSections 682 #define MAYBE_PreservedSections PreservedSections
696 #endif 683 #endif
697 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_PreservedSections) { 684 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_PreservedSections) {
698 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 685 InitializeControllerOfType();
699 controller()->set_use_validation(true); 686 controller()->set_use_validation(true);
700 687
701 // Set up some Autofill state. 688 // Set up some Autofill state.
702 CreditCard credit_card(test::GetVerifiedCreditCard()); 689 CreditCard credit_card(test::GetVerifiedCreditCard());
703 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); 690 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card);
704 691
705 AutofillProfile profile(test::GetVerifiedProfile()); 692 AutofillProfile profile(test::GetVerifiedProfile());
706 controller()->GetTestingManager()->AddTestingProfile(&profile); 693 controller()->GetTestingManager()->AddTestingProfile(&profile);
707 694
708 EXPECT_TRUE(controller()->SectionIsActive(SECTION_CC)); 695 EXPECT_TRUE(controller()->SectionIsActive(SECTION_CC));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 EXPECT_EQ(cc_number.type, new_cc_number.type); 756 EXPECT_EQ(cc_number.type, new_cc_number.type);
770 EXPECT_EQ(ASCIIToUTF16("4111111111111111"), 757 EXPECT_EQ(ASCIIToUTF16("4111111111111111"),
771 view->GetTextContentsOfInput(new_cc_number)); 758 view->GetTextContentsOfInput(new_cc_number));
772 759
773 EXPECT_NE(ASCIIToUTF16("shipping name"), 760 EXPECT_NE(ASCIIToUTF16("shipping name"),
774 view->GetTextContentsOfInput(shipping_zip)); 761 view->GetTextContentsOfInput(shipping_zip));
775 } 762 }
776 #endif // defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) 763 #endif // defined(TOOLKIT_VIEWS) || defined(OS_MACOSX)
777 764
778 } // namespace autofill 765 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698