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

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

Issue 18888003: Disabling wallet and mocking out more of WalletClient while testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 5 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/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "chrome/browser/autofill/personal_data_manager_factory.h" 11 #include "chrome/browser/autofill/personal_data_manager_factory.h"
12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 13 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
13 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" 14 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
14 #include "chrome/browser/ui/autofill/data_model_wrapper.h" 15 #include "chrome/browser/ui/autofill/data_model_wrapper.h"
15 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" 16 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h"
16 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h" 17 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h"
17 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
19 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
22 #include "components/autofill/content/browser/wallet/test_wallet_client.h"
21 #include "components/autofill/content/browser/wallet/wallet_test_util.h" 23 #include "components/autofill/content/browser/wallet/wallet_test_util.h"
22 #include "components/autofill/core/browser/autofill_common_test.h" 24 #include "components/autofill/core/browser/autofill_common_test.h"
23 #include "components/autofill/core/browser/autofill_metrics.h" 25 #include "components/autofill/core/browser/autofill_metrics.h"
24 #include "components/autofill/core/browser/test_personal_data_manager.h" 26 #include "components/autofill/core/browser/test_personal_data_manager.h"
25 #include "components/autofill/core/browser/validation.h" 27 #include "components/autofill/core/browser/validation.h"
26 #include "components/autofill/core/common/autofill_switches.h" 28 #include "components/autofill/core/common/autofill_switches.h"
27 #include "components/autofill/core/common/form_data.h" 29 #include "components/autofill/core/common/form_data.h"
28 #include "components/autofill/core/common/form_field_data.h" 30 #include "components/autofill/core/common/form_field_data.h"
29 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/web_contents.h" 32 #include "content/public/browser/web_contents.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 const FormData& form_data, 94 const FormData& form_data,
93 const AutofillMetrics& metric_logger, 95 const AutofillMetrics& metric_logger,
94 scoped_refptr<content::MessageLoopRunner> runner, 96 scoped_refptr<content::MessageLoopRunner> runner,
95 const DialogType dialog_type) 97 const DialogType dialog_type)
96 : AutofillDialogControllerImpl(contents, 98 : AutofillDialogControllerImpl(contents,
97 form_data, 99 form_data,
98 GURL(), 100 GURL(),
99 dialog_type, 101 dialog_type,
100 base::Bind(&MockCallback)), 102 base::Bind(&MockCallback)),
101 metric_logger_(metric_logger), 103 metric_logger_(metric_logger),
104 test_wallet_client_(
105 Profile::FromBrowserContext(contents->GetBrowserContext())->
106 GetRequestContext(), this),
102 message_loop_runner_(runner), 107 message_loop_runner_(runner),
103 use_validation_(false) {} 108 use_validation_(false) {}
104 109
105 virtual ~TestAutofillDialogController() {} 110 virtual ~TestAutofillDialogController() {}
106 111
107 virtual void ViewClosed() OVERRIDE { 112 virtual void ViewClosed() OVERRIDE {
108 message_loop_runner_->Quit(); 113 message_loop_runner_->Quit();
109 AutofillDialogControllerImpl::ViewClosed(); 114 AutofillDialogControllerImpl::ViewClosed();
110 } 115 }
111 116
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 162
158 void set_use_validation(bool use_validation) { 163 void set_use_validation(bool use_validation) {
159 use_validation_ = use_validation; 164 use_validation_ = use_validation;
160 } 165 }
161 166
162 protected: 167 protected:
163 virtual PersonalDataManager* GetManager() OVERRIDE { 168 virtual PersonalDataManager* GetManager() OVERRIDE {
164 return &test_manager_; 169 return &test_manager_;
165 } 170 }
166 171
172 virtual wallet::WalletClient* GetWalletClient() OVERRIDE {
173 return &test_wallet_client_;
174 }
175
167 private: 176 private:
168 // To specify our own metric logger. 177 // To specify our own metric logger.
169 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { 178 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE {
170 return metric_logger_; 179 return metric_logger_;
171 } 180 }
172 181
173 const AutofillMetrics& metric_logger_; 182 const AutofillMetrics& metric_logger_;
174 TestPersonalDataManager test_manager_; 183 TestPersonalDataManager test_manager_;
184 testing::NiceMock<wallet::TestWalletClient> test_wallet_client_;
175 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 185 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
176 bool use_validation_; 186 bool use_validation_;
177 187
178 // A list of notifications to show in the notification area of the dialog. 188 // A list of notifications to show in the notification area of the dialog.
179 // This is used to control what |CurrentNotifications()| returns for testing. 189 // This is used to control what |CurrentNotifications()| returns for testing.
180 std::vector<DialogNotification> notifications_; 190 std::vector<DialogNotification> notifications_;
181 191
182 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController); 192 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController);
183 }; 193 };
184 194
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 ASSERT_EQ(&triggering_input, controller()->input_showing_popup()); 475 ASSERT_EQ(&triggering_input, controller()->input_showing_popup());
466 controller()->DidAcceptSuggestion(string16(), 0); 476 controller()->DidAcceptSuggestion(string16(), 0);
467 477
468 for (size_t i = 0; i < inputs.size(); ++i) { 478 for (size_t i = 0; i < inputs.size(); ++i) {
469 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i])); 479 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i]));
470 } 480 }
471 } 481 }
472 482
473 // Test that Autocheckout steps are shown after submitting the 483 // Test that Autocheckout steps are shown after submitting the
474 // dialog for controller with type DIALOG_TYPE_AUTOCHECKOUT. 484 // dialog for controller with type DIALOG_TYPE_AUTOCHECKOUT.
475 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 485 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocheckoutShowsSteps) {
476 DISABLED_AutocheckoutShowsSteps) {
477 InitializeControllerOfType(DIALOG_TYPE_AUTOCHECKOUT); 486 InitializeControllerOfType(DIALOG_TYPE_AUTOCHECKOUT);
478 controller()->AddAutocheckoutStep(AUTOCHECKOUT_STEP_PROXY_CARD); 487 controller()->AddAutocheckoutStep(AUTOCHECKOUT_STEP_PROXY_CARD);
479 488
480 EXPECT_TRUE(controller()->ShouldShowDetailArea()); 489 EXPECT_TRUE(controller()->ShouldShowDetailArea());
481 EXPECT_TRUE(controller()->CurrentAutocheckoutSteps().empty()); 490 EXPECT_TRUE(controller()->CurrentAutocheckoutSteps().empty());
482 EXPECT_FALSE(controller()->ShouldShowProgressBar()); 491 EXPECT_FALSE(controller()->ShouldShowProgressBar());
483 492
484 controller()->GetTestableView()->SubmitForTesting(); 493 controller()->GetTestableView()->SubmitForTesting();
485 EXPECT_FALSE(controller()->ShouldShowDetailArea()); 494 EXPECT_FALSE(controller()->ShouldShowDetailArea());
486 EXPECT_FALSE(controller()->CurrentAutocheckoutSteps().empty()); 495 EXPECT_FALSE(controller()->CurrentAutocheckoutSteps().empty());
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 681
673 ASSERT_TRUE(model->IsItemCheckedAt(0)); 682 ASSERT_TRUE(model->IsItemCheckedAt(0));
674 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); 683 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC));
675 684
676 model->ActivatedAt(1); 685 model->ActivatedAt(1);
677 ASSERT_TRUE(model->IsItemCheckedAt(1)); 686 ASSERT_TRUE(model->IsItemCheckedAt(1));
678 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC)); 687 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC));
679 } 688 }
680 689
681 // Notifications with long message text should not make the dialog bigger. 690 // Notifications with long message text should not make the dialog bigger.
682 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 691 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) {
683 DISABLED_LongNotifications) {
684 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); 692 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE);
693 controller()->DisableWallet(wallet::WalletClient::UNKNOWN_ERROR);
Ilya Sherman 2013/07/11 01:06:30 Why is this needed in just this one particular tes
Dan Beam 2013/07/11 01:29:36 there's 3 other cases in this file. in theory it
Dan Beam 2013/07/11 01:34:36 and... they're gone.
685 694
686 const gfx::Size no_notification_size = 695 const gfx::Size no_notification_size =
687 controller()->GetTestableView()->GetSize(); 696 controller()->GetTestableView()->GetSize();
688 ASSERT_GT(no_notification_size.width(), 0); 697 ASSERT_GT(no_notification_size.width(), 0);
689 698
690 std::vector<DialogNotification> notifications; 699 std::vector<DialogNotification> notifications;
691 notifications.push_back( 700 notifications.push_back(
692 DialogNotification(DialogNotification::DEVELOPER_WARNING, ASCIIToUTF16( 701 DialogNotification(DialogNotification::DEVELOPER_WARNING, ASCIIToUTF16(
693 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do " 702 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do "
694 "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim " 703 "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim "
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 EXPECT_EQ(cc_number.type, new_cc_number.type); 873 EXPECT_EQ(cc_number.type, new_cc_number.type);
865 EXPECT_EQ(ASCIIToUTF16("4111111111111111"), 874 EXPECT_EQ(ASCIIToUTF16("4111111111111111"),
866 view->GetTextContentsOfInput(new_cc_number)); 875 view->GetTextContentsOfInput(new_cc_number));
867 876
868 EXPECT_NE(ASCIIToUTF16("shipping name"), 877 EXPECT_NE(ASCIIToUTF16("shipping name"),
869 view->GetTextContentsOfInput(shipping_zip)); 878 view->GetTextContentsOfInput(shipping_zip));
870 } 879 }
871 #endif // defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) 880 #endif // defined(TOOLKIT_VIEWS) || defined(OS_MACOSX)
872 881
873 } // namespace autofill 882 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698