| OLD | NEW |
| 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 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h" | 22 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h" |
| 23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_tabstrip.h" | 24 #include "chrome/browser/ui/browser_tabstrip.h" |
| 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 28 #include "chrome/test/base/in_process_browser_test.h" | 28 #include "chrome/test/base/in_process_browser_test.h" |
| 29 #include "chrome/test/base/ui_test_utils.h" | 29 #include "chrome/test/base/ui_test_utils.h" |
| 30 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" | 30 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" |
| 31 #include "components/autofill/content/browser/wallet/mock_wallet_client.h" | 31 #include "components/autofill/content/browser/wallet/mock_wallet_client.h" |
| 32 #include "components/autofill/content/browser/wallet/wallet_service_url.h" |
| 32 #include "components/autofill/content/browser/wallet/wallet_test_util.h" | 33 #include "components/autofill/content/browser/wallet/wallet_test_util.h" |
| 33 #include "components/autofill/core/browser/autofill_metrics.h" | 34 #include "components/autofill/core/browser/autofill_metrics.h" |
| 34 #include "components/autofill/core/browser/autofill_test_utils.h" | 35 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 35 #include "components/autofill/core/browser/test_personal_data_manager.h" | 36 #include "components/autofill/core/browser/test_personal_data_manager.h" |
| 36 #include "components/autofill/core/browser/validation.h" | 37 #include "components/autofill/core/browser/validation.h" |
| 37 #include "components/autofill/core/common/autofill_switches.h" | 38 #include "components/autofill/core/common/autofill_switches.h" |
| 38 #include "components/autofill/core/common/form_data.h" | 39 #include "components/autofill/core/common/form_data.h" |
| 39 #include "components/autofill/core/common/form_field_data.h" | 40 #include "components/autofill/core/common/form_field_data.h" |
| 40 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
| 41 #include "content/public/browser/interstitial_page.h" | 42 #include "content/public/browser/interstitial_page.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 use_validation_(false), | 124 use_validation_(false), |
| 124 weak_ptr_factory_(this), | 125 weak_ptr_factory_(this), |
| 125 sign_in_user_index_(0U) {} | 126 sign_in_user_index_(0U) {} |
| 126 | 127 |
| 127 virtual ~TestAutofillDialogController() {} | 128 virtual ~TestAutofillDialogController() {} |
| 128 | 129 |
| 129 virtual GURL SignInUrl() const OVERRIDE { | 130 virtual GURL SignInUrl() const OVERRIDE { |
| 130 return GURL(chrome::kChromeUIVersionURL); | 131 return GURL(chrome::kChromeUIVersionURL); |
| 131 } | 132 } |
| 132 | 133 |
| 133 GURL SignInContinueUrl() const { | |
| 134 return GURL(content::kAboutBlankURL); | |
| 135 } | |
| 136 | |
| 137 virtual void ViewClosed() OVERRIDE { | 134 virtual void ViewClosed() OVERRIDE { |
| 138 message_loop_runner_->Quit(); | 135 message_loop_runner_->Quit(); |
| 139 AutofillDialogControllerImpl::ViewClosed(); | 136 AutofillDialogControllerImpl::ViewClosed(); |
| 140 } | 137 } |
| 141 | 138 |
| 142 virtual base::string16 InputValidityMessage( | 139 virtual base::string16 InputValidityMessage( |
| 143 DialogSection section, | 140 DialogSection section, |
| 144 ServerFieldType type, | 141 ServerFieldType type, |
| 145 const base::string16& value) OVERRIDE { | 142 const base::string16& value) OVERRIDE { |
| 146 if (!use_validation_) | 143 if (!use_validation_) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 return &const_cast<TestAutofillDialogController*>(this)->test_manager_; | 211 return &const_cast<TestAutofillDialogController*>(this)->test_manager_; |
| 215 } | 212 } |
| 216 | 213 |
| 217 virtual wallet::WalletClient* GetWalletClient() OVERRIDE { | 214 virtual wallet::WalletClient* GetWalletClient() OVERRIDE { |
| 218 return &mock_wallet_client_; | 215 return &mock_wallet_client_; |
| 219 } | 216 } |
| 220 | 217 |
| 221 virtual bool IsSignInContinueUrl(const GURL& url, size_t* user_index) const | 218 virtual bool IsSignInContinueUrl(const GURL& url, size_t* user_index) const |
| 222 OVERRIDE { | 219 OVERRIDE { |
| 223 *user_index = sign_in_user_index_; | 220 *user_index = sign_in_user_index_; |
| 224 return url == SignInContinueUrl(); | 221 return url == wallet::GetSignInContinueUrl(); |
| 225 } | 222 } |
| 226 | 223 |
| 227 private: | 224 private: |
| 228 // To specify our own metric logger. | 225 // To specify our own metric logger. |
| 229 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { | 226 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { |
| 230 return metric_logger_; | 227 return metric_logger_; |
| 231 } | 228 } |
| 232 | 229 |
| 233 const AutofillMetrics& metric_logger_; | 230 const AutofillMetrics& metric_logger_; |
| 234 TestPersonalDataManager test_manager_; | 231 TestPersonalDataManager test_manager_; |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 controller()->SignInLinkClicked(); | 1076 controller()->SignInLinkClicked(); |
| 1080 EXPECT_TRUE(controller()->ShouldShowSignInWebView()); | 1077 EXPECT_TRUE(controller()->ShouldShowSignInWebView()); |
| 1081 | 1078 |
| 1082 TestableAutofillDialogView* view = controller()->GetTestableView(); | 1079 TestableAutofillDialogView* view = controller()->GetTestableView(); |
| 1083 content::WebContents* sign_in_contents = view->GetSignInWebContents(); | 1080 content::WebContents* sign_in_contents = view->GetSignInWebContents(); |
| 1084 ASSERT_TRUE(sign_in_contents); | 1081 ASSERT_TRUE(sign_in_contents); |
| 1085 | 1082 |
| 1086 sign_in_page_observer.Wait(); | 1083 sign_in_page_observer.Wait(); |
| 1087 | 1084 |
| 1088 NavEntryCommittedObserver continue_page_observer( | 1085 NavEntryCommittedObserver continue_page_observer( |
| 1089 controller()->SignInContinueUrl(), | 1086 wallet::GetSignInContinueUrl(), |
| 1090 content::NotificationService::AllSources()); | 1087 content::NotificationService::AllSources()); |
| 1091 | 1088 |
| 1092 EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); | 1089 EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); |
| 1093 | 1090 |
| 1094 AccountChooserModel* account_chooser_model = | 1091 AccountChooserModel* account_chooser_model = |
| 1095 controller()->AccountChooserModelForTesting(); | 1092 controller()->AccountChooserModelForTesting(); |
| 1096 EXPECT_FALSE(account_chooser_model->WalletIsSelected()); | 1093 EXPECT_FALSE(account_chooser_model->WalletIsSelected()); |
| 1097 | 1094 |
| 1098 sign_in_contents->GetController().LoadURL( | 1095 content::OpenURLParams params(wallet::GetSignInContinueUrl(), |
| 1099 controller()->SignInContinueUrl(), | 1096 content::Referrer(), |
| 1100 content::Referrer(), | 1097 CURRENT_TAB, |
| 1101 content::PAGE_TRANSITION_FORM_SUBMIT, | 1098 content::PAGE_TRANSITION_LINK, |
| 1102 std::string()); | 1099 true); |
| 1100 sign_in_contents->GetDelegate()->OpenURLFromTab(sign_in_contents, params); |
| 1103 | 1101 |
| 1104 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems()); | 1102 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems()); |
| 1105 continue_page_observer.Wait(); | 1103 continue_page_observer.Wait(); |
| 1106 content::RunAllPendingInMessageLoop(); | 1104 content::RunAllPendingInMessageLoop(); |
| 1107 | 1105 |
| 1108 EXPECT_FALSE(controller()->ShouldShowSignInWebView()); | 1106 EXPECT_FALSE(controller()->ShouldShowSignInWebView()); |
| 1109 | 1107 |
| 1110 controller()->OnDidGetWalletItems( | 1108 controller()->OnDidGetWalletItems( |
| 1111 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); | 1109 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); |
| 1112 | 1110 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1139 account_chooser_model->GetItemCount() - 2); | 1137 account_chooser_model->GetItemCount() - 2); |
| 1140 EXPECT_TRUE(controller()->ShouldShowSignInWebView()); | 1138 EXPECT_TRUE(controller()->ShouldShowSignInWebView()); |
| 1141 | 1139 |
| 1142 TestableAutofillDialogView* view = controller()->GetTestableView(); | 1140 TestableAutofillDialogView* view = controller()->GetTestableView(); |
| 1143 content::WebContents* sign_in_contents = view->GetSignInWebContents(); | 1141 content::WebContents* sign_in_contents = view->GetSignInWebContents(); |
| 1144 ASSERT_TRUE(sign_in_contents); | 1142 ASSERT_TRUE(sign_in_contents); |
| 1145 | 1143 |
| 1146 sign_in_page_observer.Wait(); | 1144 sign_in_page_observer.Wait(); |
| 1147 | 1145 |
| 1148 NavEntryCommittedObserver continue_page_observer( | 1146 NavEntryCommittedObserver continue_page_observer( |
| 1149 controller()->SignInContinueUrl(), | 1147 wallet::GetSignInContinueUrl(), |
| 1150 content::NotificationService::AllSources()); | 1148 content::NotificationService::AllSources()); |
| 1151 | 1149 |
| 1152 EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); | 1150 EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); |
| 1153 | 1151 |
| 1154 EXPECT_FALSE(account_chooser_model->WalletIsSelected()); | 1152 EXPECT_FALSE(account_chooser_model->WalletIsSelected()); |
| 1155 | 1153 |
| 1156 // User signs into new account, account 3. | 1154 // User signs into new account, account 3. |
| 1157 controller()->set_sign_in_user_index(3U); | 1155 controller()->set_sign_in_user_index(3U); |
| 1158 sign_in_contents->GetController().LoadURL( | 1156 content::OpenURLParams params(wallet::GetSignInContinueUrl(), |
| 1159 controller()->SignInContinueUrl(), | 1157 content::Referrer(), |
| 1160 content::Referrer(), | 1158 CURRENT_TAB, |
| 1161 content::PAGE_TRANSITION_FORM_SUBMIT, | 1159 content::PAGE_TRANSITION_LINK, |
| 1162 std::string()); | 1160 true); |
| 1161 sign_in_contents->GetDelegate()->OpenURLFromTab(sign_in_contents, params); |
| 1163 | 1162 |
| 1164 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems()); | 1163 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems()); |
| 1165 continue_page_observer.Wait(); | 1164 continue_page_observer.Wait(); |
| 1166 content::RunAllPendingInMessageLoop(); | 1165 content::RunAllPendingInMessageLoop(); |
| 1167 | 1166 |
| 1168 EXPECT_FALSE(controller()->ShouldShowSignInWebView()); | 1167 EXPECT_FALSE(controller()->ShouldShowSignInWebView()); |
| 1169 EXPECT_EQ(3U, controller()->GetTestingWalletClient()->user_index()); | 1168 EXPECT_EQ(3U, controller()->GetTestingWalletClient()->user_index()); |
| 1170 | 1169 |
| 1171 usernames.push_back("user_1@example.com"); | 1170 usernames.push_back("user_1@example.com"); |
| 1172 usernames.push_back("user_2@example.com"); | 1171 usernames.push_back("user_2@example.com"); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 MAYBE_DoesntWorkOnBrokenHttps) { | 1417 MAYBE_DoesntWorkOnBrokenHttps) { |
| 1419 net::SpawnedTestServer https_server( | 1418 net::SpawnedTestServer https_server( |
| 1420 net::SpawnedTestServer::TYPE_HTTPS, | 1419 net::SpawnedTestServer::TYPE_HTTPS, |
| 1421 SSLOptions(SSLOptions::CERT_EXPIRED), | 1420 SSLOptions(SSLOptions::CERT_EXPIRED), |
| 1422 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 1421 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
| 1423 ASSERT_TRUE(https_server.Start()); | 1422 ASSERT_TRUE(https_server.Start()); |
| 1424 EXPECT_FALSE(RunTestPage(https_server)); | 1423 EXPECT_FALSE(RunTestPage(https_server)); |
| 1425 } | 1424 } |
| 1426 | 1425 |
| 1427 } // namespace autofill | 1426 } // namespace autofill |
| OLD | NEW |