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

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

Issue 663643002: requestAutocomplete (desktop): don't get stuck in infinite loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 6 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_controller_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 sign_in_user_index_(0U), 134 sign_in_user_index_(0U),
135 weak_ptr_factory_(this) { 135 weak_ptr_factory_(this) {
136 test_manager_.Init( 136 test_manager_.Init(
137 NULL, 137 NULL,
138 Profile::FromBrowserContext(contents->GetBrowserContext())->GetPrefs(), 138 Profile::FromBrowserContext(contents->GetBrowserContext())->GetPrefs(),
139 false); 139 false);
140 } 140 }
141 141
142 virtual ~TestAutofillDialogController() {} 142 virtual ~TestAutofillDialogController() {}
143 143
144 virtual GURL SignInUrl() const override { 144 GURL FakeSignInUrl() const {
145 return GURL(chrome::kChromeUIVersionURL); 145 return GURL(chrome::kChromeUIVersionURL);
146 } 146 }
147 147
148 virtual void ShowSignIn(const GURL& url) override {
149 AutofillDialogControllerImpl::ShowSignIn(FakeSignInUrl());
150 }
151
148 virtual void ViewClosed() override { 152 virtual void ViewClosed() override {
149 message_loop_runner_->Quit(); 153 message_loop_runner_->Quit();
150 AutofillDialogControllerImpl::ViewClosed(); 154 AutofillDialogControllerImpl::ViewClosed();
151 } 155 }
152 156
153 virtual base::string16 InputValidityMessage( 157 virtual base::string16 InputValidityMessage(
154 DialogSection section, 158 DialogSection section,
155 ServerFieldType type, 159 ServerFieldType type,
156 const base::string16& value) override { 160 const base::string16& value) override {
157 if (!use_validation_) 161 if (!use_validation_)
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 ::prefs::kAutofillDialogPayWithoutWallet, 1171 ::prefs::kAutofillDialogPayWithoutWallet,
1168 true); 1172 true);
1169 1173
1170 InitializeController(); 1174 InitializeController();
1171 1175
1172 controller()->OnDidFetchWalletCookieValue(std::string()); 1176 controller()->OnDidFetchWalletCookieValue(std::string());
1173 controller()->OnDidGetWalletItems( 1177 controller()->OnDidGetWalletItems(
1174 wallet::GetTestWalletItemsWithRequiredAction(wallet::GAIA_AUTH)); 1178 wallet::GetTestWalletItemsWithRequiredAction(wallet::GAIA_AUTH));
1175 1179
1176 NavEntryCommittedObserver sign_in_page_observer( 1180 NavEntryCommittedObserver sign_in_page_observer(
1177 controller()->SignInUrl(), 1181 controller()->FakeSignInUrl(),
1178 content::NotificationService::AllSources()); 1182 content::NotificationService::AllSources());
1179 1183
1180 // Simulate a user clicking "Sign In" (which loads dialog's web contents). 1184 // Simulate a user clicking "Sign In" (which loads dialog's web contents).
1181 controller()->SignInLinkClicked(); 1185 controller()->SignInLinkClicked();
1182 EXPECT_TRUE(controller()->ShouldShowSignInWebView()); 1186 EXPECT_TRUE(controller()->ShouldShowSignInWebView());
1183 1187
1184 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); 1188 scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
1185 content::WebContents* sign_in_contents = view->GetSignInWebContents(); 1189 content::WebContents* sign_in_contents = view->GetSignInWebContents();
1186 ASSERT_TRUE(sign_in_contents); 1190 ASSERT_TRUE(sign_in_contents);
1187 1191
1188 sign_in_page_observer.Wait(); 1192 sign_in_page_observer.Wait();
1189 1193
1190 NavEntryCommittedObserver continue_page_observer( 1194 NavEntryCommittedObserver continue_page_observer(
1191 wallet::GetSignInContinueUrl(), 1195 wallet::GetSignInContinueUrl(),
1192 content::NotificationService::AllSources()); 1196 content::NotificationService::AllSources());
1193 1197
1194 EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); 1198 EXPECT_EQ(sign_in_contents->GetURL(), controller()->FakeSignInUrl());
1195 1199
1196 AccountChooserModel* account_chooser_model = 1200 AccountChooserModel* account_chooser_model =
1197 controller()->AccountChooserModelForTesting(); 1201 controller()->AccountChooserModelForTesting();
1198 EXPECT_FALSE(account_chooser_model->WalletIsSelected()); 1202 EXPECT_FALSE(account_chooser_model->WalletIsSelected());
1199 1203
1200 content::OpenURLParams params(wallet::GetSignInContinueUrl(), 1204 content::OpenURLParams params(wallet::GetSignInContinueUrl(),
1201 content::Referrer(), 1205 content::Referrer(),
1202 CURRENT_TAB, 1206 CURRENT_TAB,
1203 ui::PAGE_TRANSITION_LINK, 1207 ui::PAGE_TRANSITION_LINK,
1204 true); 1208 true);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 controller()->OnDidGetWalletItems( 1247 controller()->OnDidGetWalletItems(
1244 wallet::GetTestWalletItemsWithUsers(usernames, 0)); 1248 wallet::GetTestWalletItemsWithUsers(usernames, 0));
1245 1249
1246 // Switch to Autofill. 1250 // Switch to Autofill.
1247 AccountChooserModel* account_chooser_model = 1251 AccountChooserModel* account_chooser_model =
1248 controller()->AccountChooserModelForTesting(); 1252 controller()->AccountChooserModelForTesting();
1249 account_chooser_model->ActivatedAt( 1253 account_chooser_model->ActivatedAt(
1250 account_chooser_model->GetItemCount() - 1); 1254 account_chooser_model->GetItemCount() - 1);
1251 1255
1252 NavEntryCommittedObserver sign_in_page_observer( 1256 NavEntryCommittedObserver sign_in_page_observer(
1253 controller()->SignInUrl(), 1257 controller()->FakeSignInUrl(),
1254 content::NotificationService::AllSources()); 1258 content::NotificationService::AllSources());
1255 1259
1256 // Simulate a user clicking "add account". 1260 // Simulate a user clicking "add account".
1257 account_chooser_model->ActivatedAt( 1261 account_chooser_model->ActivatedAt(
1258 account_chooser_model->GetItemCount() - 2); 1262 account_chooser_model->GetItemCount() - 2);
1259 EXPECT_TRUE(controller()->ShouldShowSignInWebView()); 1263 EXPECT_TRUE(controller()->ShouldShowSignInWebView());
1260 1264
1261 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); 1265 scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
1262 content::WebContents* sign_in_contents = view->GetSignInWebContents(); 1266 content::WebContents* sign_in_contents = view->GetSignInWebContents();
1263 ASSERT_TRUE(sign_in_contents); 1267 ASSERT_TRUE(sign_in_contents);
1264 1268
1265 sign_in_page_observer.Wait(); 1269 sign_in_page_observer.Wait();
1266 1270
1267 NavEntryCommittedObserver continue_page_observer( 1271 NavEntryCommittedObserver continue_page_observer(
1268 wallet::GetSignInContinueUrl(), 1272 wallet::GetSignInContinueUrl(),
1269 content::NotificationService::AllSources()); 1273 content::NotificationService::AllSources());
1270 1274
1271 EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); 1275 EXPECT_EQ(sign_in_contents->GetURL(), controller()->FakeSignInUrl());
1272 1276
1273 EXPECT_FALSE(account_chooser_model->WalletIsSelected()); 1277 EXPECT_FALSE(account_chooser_model->WalletIsSelected());
1274 1278
1275 // User signs into new account, account 3. 1279 // User signs into new account, account 3.
1276 controller()->set_sign_in_user_index(3U); 1280 controller()->set_sign_in_user_index(3U);
1277 content::OpenURLParams params(wallet::GetSignInContinueUrl(), 1281 content::OpenURLParams params(wallet::GetSignInContinueUrl(),
1278 content::Referrer(), 1282 content::Referrer(),
1279 CURRENT_TAB, 1283 CURRENT_TAB,
1280 ui::PAGE_TRANSITION_LINK, 1284 ui::PAGE_TRANSITION_LINK,
1281 true); 1285 true);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 EXPECT_EQ(3, tab_strip->GetIndexOfWebContents(blank_tab)); 1404 EXPECT_EQ(3, tab_strip->GetIndexOfWebContents(blank_tab));
1401 } 1405 }
1402 1406
1403 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 1407 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
1404 SignInWebViewOpensLinksInNewTab) { 1408 SignInWebViewOpensLinksInNewTab) {
1405 controller()->OnDidFetchWalletCookieValue(std::string()); 1409 controller()->OnDidFetchWalletCookieValue(std::string());
1406 controller()->OnDidGetWalletItems( 1410 controller()->OnDidGetWalletItems(
1407 wallet::GetTestWalletItemsWithRequiredAction(wallet::GAIA_AUTH)); 1411 wallet::GetTestWalletItemsWithRequiredAction(wallet::GAIA_AUTH));
1408 1412
1409 NavEntryCommittedObserver sign_in_page_observer( 1413 NavEntryCommittedObserver sign_in_page_observer(
1410 controller()->SignInUrl(), 1414 controller()->FakeSignInUrl(),
1411 content::NotificationService::AllSources()); 1415 content::NotificationService::AllSources());
1412 1416
1413 controller()->SignInLinkClicked(); 1417 controller()->SignInLinkClicked();
1414 1418
1415 content::WebContents* sign_in_contents = 1419 content::WebContents* sign_in_contents =
1416 GetViewTester()->GetSignInWebContents(); 1420 GetViewTester()->GetSignInWebContents();
1417 ASSERT_TRUE(sign_in_contents); 1421 ASSERT_TRUE(sign_in_contents);
1418 1422
1419 sign_in_page_observer.Wait(); 1423 sign_in_page_observer.Wait();
1420 1424
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 "<input autocomplete='transaction-currency' value='USD' readonly>" 1785 "<input autocomplete='transaction-currency' value='USD' readonly>"
1782 "<input autocomplete='cc-csc'>"); 1786 "<input autocomplete='cc-csc'>");
1783 AutofillDialogControllerImpl* controller = SetUpHtmlAndInvoke(html); 1787 AutofillDialogControllerImpl* controller = SetUpHtmlAndInvoke(html);
1784 ASSERT_TRUE(controller); 1788 ASSERT_TRUE(controller);
1785 1789
1786 EXPECT_EQ(ASCIIToUTF16("24"), controller->transaction_amount_); 1790 EXPECT_EQ(ASCIIToUTF16("24"), controller->transaction_amount_);
1787 EXPECT_EQ(ASCIIToUTF16("USD"), controller->transaction_currency_); 1791 EXPECT_EQ(ASCIIToUTF16("USD"), controller->transaction_currency_);
1788 } 1792 }
1789 1793
1790 } // namespace autofill 1794 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698