Index: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc |
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc |
index e1bac435d7bd9049bca67d3dff4326050689881c..15e194e5784817edfbfa9d3dedaa8670bcb5a44f 100644 |
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc |
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc |
@@ -22,6 +22,7 @@ |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/tabs/tab_strip_model.h" |
#include "chrome/common/pref_names.h" |
+#include "chrome/common/url_constants.h" |
#include "chrome/test/base/in_process_browser_test.h" |
#include "chrome/test/base/ui_test_utils.h" |
#include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" |
@@ -104,6 +105,10 @@ class TestAutofillDialogController : public AutofillDialogControllerImpl { |
virtual ~TestAutofillDialogController() {} |
virtual GURL SignInUrl() const OVERRIDE { |
+ return GURL(chrome::kChromeUIVersionURL); |
+ } |
+ |
+ GURL SignInContinueUrl() const { |
return GURL(content::kAboutBlankURL); |
} |
@@ -186,7 +191,7 @@ class TestAutofillDialogController : public AutofillDialogControllerImpl { |
} |
virtual bool IsSignInContinueUrl(const GURL& url) const OVERRIDE { |
- return true; |
+ return url == SignInContinueUrl(); |
} |
private: |
@@ -898,37 +903,60 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
EXPECT_EQ(last_four, test_generated_bubble_controller()->backing_card_name()); |
} |
-// Simulates the user successfully signing in to the dialog for the first time. |
-// The controller listens for nav entry commits and should not destroy the web |
-// contents before its post load code runs (which would cause a crash). |
-IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, SignInNoCrash) { |
+// Simulates the user signing in to the dialog from the inline web contents. |
+IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, SimulateSuccessfulSignIn) { |
browser()->profile()->GetPrefs()->SetBoolean( |
::prefs::kAutofillDialogPayWithoutWallet, |
true); |
InitializeController(); |
- const AccountChooserModel& account_chooser_model = |
- controller()->AccountChooserModelForTesting(); |
- EXPECT_FALSE(account_chooser_model.WalletIsSelected()); |
+ controller()->OnDidFetchWalletCookieValue(std::string()); |
+ std::vector<std::string> usernames(1, "user@example.com"); |
+ controller()->OnUserNameFetchSuccess(usernames); |
Evan Stade
2013/11/05 00:02:20
I think it makes more sense to have a username fet
Dan Beam
2013/11/05 00:16:33
Done.
|
+ controller()->OnDidGetWalletItems( |
+ wallet::GetTestWalletItemsWithRequiredAction(wallet::GAIA_AUTH)); |
- ui_test_utils::UrlLoadObserver observer( |
+ ui_test_utils::UrlLoadObserver sign_in_page_observer( |
controller()->SignInUrl(), |
content::NotificationService::AllSources()); |
+ // Simulate a user clicking "Sign In" (which loads dialog's web contents). |
controller()->SignInLinkClicked(); |
- std::vector<std::string> usernames(1, "user@example.com"); |
- controller()->OnUserNameFetchSuccess(usernames); |
- controller()->OnDidFetchWalletCookieValue(std::string()); |
- controller()->OnDidGetWalletItems( |
- wallet::GetTestWalletItemsWithRequiredAction(wallet::GAIA_AUTH)); |
+ EXPECT_TRUE(controller()->ShouldShowSignInWebView()); |
TestableAutofillDialogView* view = controller()->GetTestableView(); |
- EXPECT_TRUE(view->GetSignInWebContents()); |
- EXPECT_TRUE(controller()->ShouldShowSignInWebView()); |
- observer.Wait(); |
+ content::WebContents* sign_in_contents = view->GetSignInWebContents(); |
+ ASSERT_TRUE(sign_in_contents); |
+ |
+ sign_in_page_observer.Wait(); |
+ |
+ ui_test_utils::UrlLoadObserver continue_page_observer( |
+ controller()->SignInContinueUrl(), |
+ content::NotificationService::AllSources()); |
+ |
+ EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); |
+ |
+ const AccountChooserModel& account_chooser_model = |
+ controller()->AccountChooserModelForTesting(); |
+ EXPECT_FALSE(account_chooser_model.WalletIsSelected()); |
+ |
+ sign_in_contents->GetController().LoadURL( |
+ controller()->SignInContinueUrl(), |
+ content::Referrer(), |
+ content::PAGE_TRANSITION_FORM_SUBMIT, |
+ std::string()); |
+ |
+ continue_page_observer.Wait(); |
+ EXPECT_FALSE(controller()->ShouldShowSignInWebView()); |
+ |
+ content::RunAllPendingInMessageLoop(); |
+ |
+ controller()->OnDidGetWalletItems( |
+ wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); |
- // Wallet should now be selected and Chrome shouldn't have crashed. |
+ // Wallet should now be selected and Chrome shouldn't have crashed (which can |
+ // happen if the WebContents is deleted while proccessing a nav entry commit). |
EXPECT_TRUE(account_chooser_model.WalletIsSelected()); |
} |