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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc

Issue 23717029: Disable submit button briefly when launching rAc dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename number to count 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
index ddb60c24ffcc8757fd6a83245bd67a20e3bc2bf1..c8d692c7279fd31cc7ced3f9a2127313fb7ff0b9 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
@@ -241,7 +241,8 @@ class TestAutofillDialogController
mock_wallet_client_(
Profile::FromBrowserContext(contents->GetBrowserContext())->
GetRequestContext(), this),
- mock_new_card_bubble_controller_(mock_new_card_bubble_controller) {}
+ mock_new_card_bubble_controller_(mock_new_card_bubble_controller),
+ submit_button_delay_count_(0) {}
virtual ~TestAutofillDialogController() {}
@@ -278,6 +279,19 @@ class TestAutofillDialogController
#endif
}
+ void SimulateSubmitButtonDelayBegin() {
+ AutofillDialogControllerImpl::SubmitButtonDelayBegin();
+ }
+
+ void SimulateSubmitButtonDelayEnd() {
+ AutofillDialogControllerImpl::SubmitButtonDelayEndForTesting();
+ }
+
+ // Returns the number of times that the submit button was delayed.
+ int get_submit_button_delay_count() const {
+ return submit_button_delay_count_;
+ }
+
MOCK_METHOD0(LoadRiskFingerprintData, void());
using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData;
using AutofillDialogControllerImpl::IsEditingExistingData;
@@ -308,6 +322,13 @@ class TestAutofillDialogController
billing_profile.Pass());
}
+ // AutofillDialogControllerImpl calls this method before showing the dialog
+ // window.
+ virtual void SubmitButtonDelayBegin() OVERRIDE {
+ // Do not delay enabling the submit button in testing.
+ submit_button_delay_count_++;
+ }
+
private:
// To specify our own metric logger.
virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE {
@@ -320,6 +341,9 @@ class TestAutofillDialogController
GURL open_tab_url_;
MockNewCreditCardBubbleController* mock_new_card_bubble_controller_;
+ // The number of times that the submit button was delayed.
+ int submit_button_delay_count_;
+
DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController);
};
@@ -2379,4 +2403,72 @@ TEST_F(AutofillDialogControllerTest,
EXPECT_FALSE(controller()->ShouldSaveInChrome());
}
+TEST_F(AutofillDialogControllerTest,
+ SubmitButtonIsDisabled_SpinnerFinishesBeforeDelay) {
+ EXPECT_EQ(1, controller()->get_submit_button_delay_count());
+
+ // Begin the submit button delay.
+ controller()->SimulateSubmitButtonDelayBegin();
+
+ EXPECT_TRUE(controller()->ShouldShowSpinner());
+ EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK));
+
+ // Stop the spinner.
+ controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
+
+ EXPECT_FALSE(controller()->ShouldShowSpinner());
+ EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK));
+
+ // End the submit button delay.
+ controller()->SimulateSubmitButtonDelayEnd();
+
+ EXPECT_FALSE(controller()->ShouldShowSpinner());
+ EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK));
+}
+
+TEST_F(AutofillDialogControllerTest,
+ SubmitButtonIsDisabled_SpinnerFinishesAfterDelay) {
+ EXPECT_EQ(1, controller()->get_submit_button_delay_count());
+
+ // Begin the submit button delay.
+ controller()->SimulateSubmitButtonDelayBegin();
+
+ EXPECT_TRUE(controller()->ShouldShowSpinner());
+ EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK));
+
+ // End the submit button delay.
+ controller()->SimulateSubmitButtonDelayEnd();
+
+ EXPECT_TRUE(controller()->ShouldShowSpinner());
+ EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK));
+
+ // Stop the spinner.
+ controller()->OnDidGetWalletItems(CompleteAndValidWalletItems());
+
+ EXPECT_FALSE(controller()->ShouldShowSpinner());
+ EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK));
+}
+
+TEST_F(AutofillDialogControllerTest, SubmitButtonIsDisabled_NoSpinner) {
+ EXPECT_EQ(1, controller()->get_submit_button_delay_count());
+
+ // Begin the submit button delay.
+ controller()->SimulateSubmitButtonDelayBegin();
+
+ EXPECT_TRUE(controller()->ShouldShowSpinner());
+ EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK));
+
+ // There's no spinner in Autofill mode.
+ SwitchToAutofill();
+
+ EXPECT_FALSE(controller()->ShouldShowSpinner());
+ EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK));
+
+ // End the submit button delay.
+ controller()->SimulateSubmitButtonDelayEnd();
+
+ EXPECT_FALSE(controller()->ShouldShowSpinner());
+ EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK));
+}
+
} // namespace autofill
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698