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

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

Issue 124533003: Add country combobox to change country and rebuild address inputs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 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/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"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/browser/autofill/personal_data_manager_factory.h" 14 #include "chrome/browser/autofill/personal_data_manager_factory.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/autofill/account_chooser_model.h" 16 #include "chrome/browser/ui/autofill/account_chooser_model.h"
17 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 17 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
18 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
18 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" 19 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
19 #include "chrome/browser/ui/autofill/data_model_wrapper.h" 20 #include "chrome/browser/ui/autofill/data_model_wrapper.h"
20 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" 21 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h"
21 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controlle r.h" 22 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controlle r.h"
22 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h" 23 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h"
23 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_tabstrip.h" 25 #include "chrome/browser/ui/browser_tabstrip.h"
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" 26 #include "chrome/browser/ui/tabs/tab_strip_model.h"
27 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
28 #include "chrome/test/base/in_process_browser_test.h" 30 #include "chrome/test/base/in_process_browser_test.h"
29 #include "chrome/test/base/ui_test_utils.h" 31 #include "chrome/test/base/ui_test_utils.h"
30 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" 32 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h"
31 #include "components/autofill/content/browser/wallet/mock_wallet_client.h" 33 #include "components/autofill/content/browser/wallet/mock_wallet_client.h"
32 #include "components/autofill/content/browser/wallet/wallet_service_url.h" 34 #include "components/autofill/content/browser/wallet/wallet_service_url.h"
33 #include "components/autofill/content/browser/wallet/wallet_test_util.h" 35 #include "components/autofill/content/browser/wallet/wallet_test_util.h"
34 #include "components/autofill/core/browser/autofill_metrics.h" 36 #include "components/autofill/core/browser/autofill_metrics.h"
35 #include "components/autofill/core/browser/autofill_test_utils.h" 37 #include "components/autofill/core/browser/autofill_test_utils.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 178
177 void set_notifications(const std::vector<DialogNotification>& notifications) { 179 void set_notifications(const std::vector<DialogNotification>& notifications) {
178 notifications_ = notifications; 180 notifications_ = notifications;
179 } 181 }
180 182
181 TestPersonalDataManager* GetTestingManager() { 183 TestPersonalDataManager* GetTestingManager() {
182 return &test_manager_; 184 return &test_manager_;
183 } 185 }
184 186
185 using AutofillDialogControllerImpl::IsEditingExistingData; 187 using AutofillDialogControllerImpl::IsEditingExistingData;
188 using AutofillDialogControllerImpl::IsManuallyEditingSection;
186 using AutofillDialogControllerImpl::IsPayingWithWallet; 189 using AutofillDialogControllerImpl::IsPayingWithWallet;
187 using AutofillDialogControllerImpl::IsSubmitPausedOn; 190 using AutofillDialogControllerImpl::IsSubmitPausedOn;
188 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; 191 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData;
189 using AutofillDialogControllerImpl::AccountChooserModelForTesting; 192 using AutofillDialogControllerImpl::AccountChooserModelForTesting;
190 using AutofillDialogControllerImpl:: 193 using AutofillDialogControllerImpl::
191 ClearLastWalletItemsFetchTimestampForTesting; 194 ClearLastWalletItemsFetchTimestampForTesting;
192 195
193 void set_use_validation(bool use_validation) { 196 void set_use_validation(bool use_validation) {
194 use_validation_ = use_validation; 197 use_validation_ = use_validation;
195 } 198 }
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 1086
1084 controller()->OnDidGetWalletItems( 1087 controller()->OnDidGetWalletItems(
1085 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); 1088 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED));
1086 1089
1087 // Wallet should now be selected and Chrome shouldn't have crashed (which can 1090 // Wallet should now be selected and Chrome shouldn't have crashed (which can
1088 // happen if the WebContents is deleted while proccessing a nav entry commit). 1091 // happen if the WebContents is deleted while proccessing a nav entry commit).
1089 EXPECT_TRUE(account_chooser_model->WalletIsSelected()); 1092 EXPECT_TRUE(account_chooser_model->WalletIsSelected());
1090 } 1093 }
1091 1094
1092 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddAccount) { 1095 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddAccount) {
1093 InitializeController();
1094
1095 controller()->OnDidFetchWalletCookieValue(std::string()); 1096 controller()->OnDidFetchWalletCookieValue(std::string());
1096 std::vector<std::string> usernames; 1097 std::vector<std::string> usernames;
1097 usernames.push_back("user_0@example.com"); 1098 usernames.push_back("user_0@example.com");
1098 controller()->OnDidGetWalletItems( 1099 controller()->OnDidGetWalletItems(
1099 wallet::GetTestWalletItemsWithUsers(usernames, 0)); 1100 wallet::GetTestWalletItemsWithUsers(usernames, 0));
1100 1101
1101 // Switch to Autofill. 1102 // Switch to Autofill.
1102 AccountChooserModel* account_chooser_model = 1103 AccountChooserModel* account_chooser_model =
1103 controller()->AccountChooserModelForTesting(); 1104 controller()->AccountChooserModelForTesting();
1104 account_chooser_model->ActivatedAt( 1105 account_chooser_model->ActivatedAt(
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 1325 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
1325 MAYBE_DoesWorkOnHttpWithFlag) { 1326 MAYBE_DoesWorkOnHttpWithFlag) {
1326 net::SpawnedTestServer http_server( 1327 net::SpawnedTestServer http_server(
1327 net::SpawnedTestServer::TYPE_HTTP, 1328 net::SpawnedTestServer::TYPE_HTTP,
1328 net::SpawnedTestServer::kLocalhost, 1329 net::SpawnedTestServer::kLocalhost,
1329 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 1330 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
1330 ASSERT_TRUE(http_server.Start()); 1331 ASSERT_TRUE(http_server.Start());
1331 EXPECT_TRUE(RunTestPage(http_server)); 1332 EXPECT_TRUE(RunTestPage(http_server));
1332 } 1333 }
1333 1334
1335 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
1336 CountryChangeRebuildsSection) {
1337 CommandLine* command_line = CommandLine::ForCurrentProcess();
1338 command_line->AppendSwitch(::switches::kEnableAutofillAddressI18n);
1339 ASSERT_TRUE(i18ninput::Enabled());
1340
1341 InitializeController();
1342
1343 // Select "Add new shipping address...".
1344 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1);
1345 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING));
1346
1347 TestableAutofillDialogView* view = controller()->GetTestableView();
1348 ASSERT_EQ(ASCIIToUTF16("United States"),
1349 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY));
1350
1351 const DetailInputs& us_inputs =
1352 controller()->RequestedFieldsForSection(SECTION_SHIPPING);
1353 EXPECT_EQ(8U, us_inputs.size());
1354
1355 for (size_t i = 0; i < us_inputs.size(); ++i) {
1356 EXPECT_NE(us_inputs[i].type, ADDRESS_HOME_DEPENDENT_LOCALITY);
1357 }
1358
1359 view->SetTextContentsOfInput(NAME_FULL, ASCIIToUTF16("B. Loblaw"));
1360
1361 // Switch country combobox from United States to China.
1362 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("China"));
1363 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING));
1364
1365 EXPECT_EQ(ASCIIToUTF16("China"),
1366 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY));
1367 EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL));
1368
1369 const DetailInputs& cn_inputs =
1370 controller()->RequestedFieldsForSection(SECTION_SHIPPING);
1371 ASSERT_NE(&cn_inputs[0], &us_inputs[0]);
1372 EXPECT_EQ(9U, cn_inputs.size());
1373
1374 size_t i = 0;
1375 for (; i < cn_inputs.size(); ++i) {
1376 if (cn_inputs[i].type == ADDRESS_HOME_DEPENDENT_LOCALITY)
1377 break;
1378 }
1379 EXPECT_LT(i, cn_inputs.size());
1380 }
1381
1334 // Like the parent test, but doesn't add the --reduce-security-for-testing flag. 1382 // Like the parent test, but doesn't add the --reduce-security-for-testing flag.
1335 class AutofillDialogControllerSecurityTest : 1383 class AutofillDialogControllerSecurityTest :
1336 public AutofillDialogControllerTest { 1384 public AutofillDialogControllerTest {
1337 public: 1385 public:
1338 AutofillDialogControllerSecurityTest() {} 1386 AutofillDialogControllerSecurityTest() {}
1339 virtual ~AutofillDialogControllerSecurityTest() {} 1387 virtual ~AutofillDialogControllerSecurityTest() {}
1340 1388
1341 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 1389 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
1342 CHECK(!command_line->HasSwitch(::switches::kReduceSecurityForTesting)); 1390 CHECK(!command_line->HasSwitch(::switches::kReduceSecurityForTesting));
1343 } 1391 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 MAYBE_DoesntWorkOnBrokenHttps) { 1438 MAYBE_DoesntWorkOnBrokenHttps) {
1391 net::SpawnedTestServer https_server( 1439 net::SpawnedTestServer https_server(
1392 net::SpawnedTestServer::TYPE_HTTPS, 1440 net::SpawnedTestServer::TYPE_HTTPS,
1393 SSLOptions(SSLOptions::CERT_EXPIRED), 1441 SSLOptions(SSLOptions::CERT_EXPIRED),
1394 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 1442 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
1395 ASSERT_TRUE(https_server.Start()); 1443 ASSERT_TRUE(https_server.Start());
1396 EXPECT_FALSE(RunTestPage(https_server)); 1444 EXPECT_FALSE(RunTestPage(https_server));
1397 } 1445 }
1398 1446
1399 } // namespace autofill 1447 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698