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 <map> | 5 #include <map> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 const ValidityMessage& message = messages.GetMessageOrDefault(field); | 149 const ValidityMessage& message = messages.GetMessageOrDefault(field); |
150 return !message.text.empty() && !message.sure; | 150 return !message.text.empty() && !message.sure; |
151 } | 151 } |
152 | 152 |
153 class TestAutofillDialogView : public AutofillDialogView { | 153 class TestAutofillDialogView : public AutofillDialogView { |
154 public: | 154 public: |
155 TestAutofillDialogView() | 155 TestAutofillDialogView() |
156 : updates_started_(0), save_details_locally_checked_(true) {} | 156 : updates_started_(0), save_details_locally_checked_(true) {} |
157 virtual ~TestAutofillDialogView() {} | 157 virtual ~TestAutofillDialogView() {} |
158 | 158 |
159 virtual void Show() OVERRIDE {} | 159 virtual void Show() override {} |
160 virtual void Hide() OVERRIDE {} | 160 virtual void Hide() override {} |
161 | 161 |
162 virtual void UpdatesStarted() OVERRIDE { | 162 virtual void UpdatesStarted() override { |
163 updates_started_++; | 163 updates_started_++; |
164 } | 164 } |
165 | 165 |
166 virtual void UpdatesFinished() OVERRIDE { | 166 virtual void UpdatesFinished() override { |
167 updates_started_--; | 167 updates_started_--; |
168 EXPECT_GE(updates_started_, 0); | 168 EXPECT_GE(updates_started_, 0); |
169 } | 169 } |
170 | 170 |
171 virtual void UpdateNotificationArea() OVERRIDE { | 171 virtual void UpdateNotificationArea() override { |
172 EXPECT_GE(updates_started_, 1); | 172 EXPECT_GE(updates_started_, 1); |
173 } | 173 } |
174 | 174 |
175 virtual void UpdateAccountChooser() OVERRIDE { | 175 virtual void UpdateAccountChooser() override { |
176 EXPECT_GE(updates_started_, 1); | 176 EXPECT_GE(updates_started_, 1); |
177 } | 177 } |
178 | 178 |
179 virtual void UpdateButtonStrip() OVERRIDE { | 179 virtual void UpdateButtonStrip() override { |
180 EXPECT_GE(updates_started_, 1); | 180 EXPECT_GE(updates_started_, 1); |
181 } | 181 } |
182 | 182 |
183 virtual void UpdateOverlay() OVERRIDE { | 183 virtual void UpdateOverlay() override { |
184 EXPECT_GE(updates_started_, 1); | 184 EXPECT_GE(updates_started_, 1); |
185 } | 185 } |
186 | 186 |
187 virtual void UpdateDetailArea() OVERRIDE { | 187 virtual void UpdateDetailArea() override { |
188 EXPECT_GE(updates_started_, 1); | 188 EXPECT_GE(updates_started_, 1); |
189 } | 189 } |
190 | 190 |
191 virtual void UpdateSection(DialogSection section) OVERRIDE { | 191 virtual void UpdateSection(DialogSection section) override { |
192 section_updates_[section]++; | 192 section_updates_[section]++; |
193 EXPECT_GE(updates_started_, 1); | 193 EXPECT_GE(updates_started_, 1); |
194 } | 194 } |
195 | 195 |
196 virtual void UpdateErrorBubble() OVERRIDE { | 196 virtual void UpdateErrorBubble() override { |
197 EXPECT_GE(updates_started_, 1); | 197 EXPECT_GE(updates_started_, 1); |
198 } | 198 } |
199 | 199 |
200 virtual void FillSection(DialogSection section, | 200 virtual void FillSection(DialogSection section, |
201 ServerFieldType originating_type) OVERRIDE {} | 201 ServerFieldType originating_type) override {} |
202 virtual void GetUserInput(DialogSection section, FieldValueMap* output) | 202 virtual void GetUserInput(DialogSection section, FieldValueMap* output) |
203 OVERRIDE { | 203 override { |
204 *output = outputs_[section]; | 204 *output = outputs_[section]; |
205 } | 205 } |
206 | 206 |
207 virtual base::string16 GetCvc() OVERRIDE { return base::string16(); } | 207 virtual base::string16 GetCvc() override { return base::string16(); } |
208 | 208 |
209 virtual bool SaveDetailsLocally() OVERRIDE { | 209 virtual bool SaveDetailsLocally() override { |
210 return save_details_locally_checked_; | 210 return save_details_locally_checked_; |
211 } | 211 } |
212 | 212 |
213 virtual const content::NavigationController* ShowSignIn() OVERRIDE { | 213 virtual const content::NavigationController* ShowSignIn() override { |
214 return NULL; | 214 return NULL; |
215 } | 215 } |
216 virtual void HideSignIn() OVERRIDE {} | 216 virtual void HideSignIn() override {} |
217 | 217 |
218 MOCK_METHOD0(ModelChanged, void()); | 218 MOCK_METHOD0(ModelChanged, void()); |
219 MOCK_METHOD0(UpdateForErrors, void()); | 219 MOCK_METHOD0(UpdateForErrors, void()); |
220 | 220 |
221 virtual void OnSignInResize(const gfx::Size& pref_size) OVERRIDE {} | 221 virtual void OnSignInResize(const gfx::Size& pref_size) override {} |
222 virtual void ValidateSection(DialogSection) OVERRIDE {} | 222 virtual void ValidateSection(DialogSection) override {} |
223 | 223 |
224 void SetUserInput(DialogSection section, const FieldValueMap& map) { | 224 void SetUserInput(DialogSection section, const FieldValueMap& map) { |
225 outputs_[section] = map; | 225 outputs_[section] = map; |
226 } | 226 } |
227 | 227 |
228 void CheckSaveDetailsLocallyCheckbox(bool checked) { | 228 void CheckSaveDetailsLocallyCheckbox(bool checked) { |
229 save_details_locally_checked_ = checked; | 229 save_details_locally_checked_ = checked; |
230 } | 230 } |
231 | 231 |
232 void ClearSectionUpdates() { | 232 void ClearSectionUpdates() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 mock_wallet_client_( | 266 mock_wallet_client_( |
267 Profile::FromBrowserContext(contents->GetBrowserContext()) | 267 Profile::FromBrowserContext(contents->GetBrowserContext()) |
268 ->GetRequestContext(), | 268 ->GetRequestContext(), |
269 this, | 269 this, |
270 source_url), | 270 source_url), |
271 mock_new_card_bubble_controller_(mock_new_card_bubble_controller), | 271 mock_new_card_bubble_controller_(mock_new_card_bubble_controller), |
272 submit_button_delay_count_(0) {} | 272 submit_button_delay_count_(0) {} |
273 | 273 |
274 virtual ~TestAutofillDialogController() {} | 274 virtual ~TestAutofillDialogController() {} |
275 | 275 |
276 virtual AutofillDialogView* CreateView() OVERRIDE { | 276 virtual AutofillDialogView* CreateView() override { |
277 return new testing::NiceMock<TestAutofillDialogView>(); | 277 return new testing::NiceMock<TestAutofillDialogView>(); |
278 } | 278 } |
279 | 279 |
280 void Init(content::BrowserContext* browser_context) { | 280 void Init(content::BrowserContext* browser_context) { |
281 test_manager_.Init( | 281 test_manager_.Init( |
282 WebDataServiceFactory::GetAutofillWebDataForProfile( | 282 WebDataServiceFactory::GetAutofillWebDataForProfile( |
283 Profile::FromBrowserContext(browser_context), | 283 Profile::FromBrowserContext(browser_context), |
284 Profile::EXPLICIT_ACCESS), | 284 Profile::EXPLICIT_ACCESS), |
285 user_prefs::UserPrefs::Get(browser_context), | 285 user_prefs::UserPrefs::Get(browser_context), |
286 browser_context->IsOffTheRecord()); | 286 browser_context->IsOffTheRecord()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; | 334 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; |
335 using AutofillDialogControllerImpl::IsEditingExistingData; | 335 using AutofillDialogControllerImpl::IsEditingExistingData; |
336 using AutofillDialogControllerImpl::IsManuallyEditingSection; | 336 using AutofillDialogControllerImpl::IsManuallyEditingSection; |
337 using AutofillDialogControllerImpl::IsPayingWithWallet; | 337 using AutofillDialogControllerImpl::IsPayingWithWallet; |
338 using AutofillDialogControllerImpl::IsSubmitPausedOn; | 338 using AutofillDialogControllerImpl::IsSubmitPausedOn; |
339 using AutofillDialogControllerImpl::NOT_CHECKED; | 339 using AutofillDialogControllerImpl::NOT_CHECKED; |
340 using AutofillDialogControllerImpl::popup_input_type; | 340 using AutofillDialogControllerImpl::popup_input_type; |
341 using AutofillDialogControllerImpl::SignedInState; | 341 using AutofillDialogControllerImpl::SignedInState; |
342 | 342 |
343 protected: | 343 protected: |
344 virtual PersonalDataManager* GetManager() const OVERRIDE { | 344 virtual PersonalDataManager* GetManager() const override { |
345 return const_cast<TestAutofillDialogController*>(this)-> | 345 return const_cast<TestAutofillDialogController*>(this)-> |
346 GetTestingManager(); | 346 GetTestingManager(); |
347 } | 347 } |
348 | 348 |
349 virtual AddressValidator* GetValidator() OVERRIDE { | 349 virtual AddressValidator* GetValidator() override { |
350 return &mock_validator_; | 350 return &mock_validator_; |
351 } | 351 } |
352 | 352 |
353 virtual wallet::WalletClient* GetWalletClient() OVERRIDE { | 353 virtual wallet::WalletClient* GetWalletClient() override { |
354 return &mock_wallet_client_; | 354 return &mock_wallet_client_; |
355 } | 355 } |
356 | 356 |
357 virtual void OpenTabWithUrl(const GURL& url) OVERRIDE { | 357 virtual void OpenTabWithUrl(const GURL& url) override { |
358 open_tab_url_ = url; | 358 open_tab_url_ = url; |
359 } | 359 } |
360 | 360 |
361 virtual void ShowNewCreditCardBubble( | 361 virtual void ShowNewCreditCardBubble( |
362 scoped_ptr<CreditCard> new_card, | 362 scoped_ptr<CreditCard> new_card, |
363 scoped_ptr<AutofillProfile> billing_profile) OVERRIDE { | 363 scoped_ptr<AutofillProfile> billing_profile) override { |
364 mock_new_card_bubble_controller_->Show(new_card.Pass(), | 364 mock_new_card_bubble_controller_->Show(new_card.Pass(), |
365 billing_profile.Pass()); | 365 billing_profile.Pass()); |
366 } | 366 } |
367 | 367 |
368 // AutofillDialogControllerImpl calls this method before showing the dialog | 368 // AutofillDialogControllerImpl calls this method before showing the dialog |
369 // window. | 369 // window. |
370 virtual void SubmitButtonDelayBegin() OVERRIDE { | 370 virtual void SubmitButtonDelayBegin() override { |
371 // Do not delay enabling the submit button in testing. | 371 // Do not delay enabling the submit button in testing. |
372 submit_button_delay_count_++; | 372 submit_button_delay_count_++; |
373 } | 373 } |
374 | 374 |
375 private: | 375 private: |
376 // To specify our own metric logger. | 376 // To specify our own metric logger. |
377 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { | 377 virtual const AutofillMetrics& GetMetricLogger() const override { |
378 return metric_logger_; | 378 return metric_logger_; |
379 } | 379 } |
380 | 380 |
381 const AutofillMetrics& metric_logger_; | 381 const AutofillMetrics& metric_logger_; |
382 TestPersonalDataManager test_manager_; | 382 TestPersonalDataManager test_manager_; |
383 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; | 383 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; |
384 | 384 |
385 // A mock validator object to prevent network requests and track when | 385 // A mock validator object to prevent network requests and track when |
386 // validation rules are loaded or validation attempts occur. | 386 // validation rules are loaded or validation attempts occur. |
387 testing::NiceMock<MockAddressValidator> mock_validator_; | 387 testing::NiceMock<MockAddressValidator> mock_validator_; |
388 | 388 |
389 GURL open_tab_url_; | 389 GURL open_tab_url_; |
390 MockNewCreditCardBubbleController* mock_new_card_bubble_controller_; | 390 MockNewCreditCardBubbleController* mock_new_card_bubble_controller_; |
391 | 391 |
392 // The number of times that the submit button was delayed. | 392 // The number of times that the submit button was delayed. |
393 int submit_button_delay_count_; | 393 int submit_button_delay_count_; |
394 | 394 |
395 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController); | 395 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController); |
396 }; | 396 }; |
397 | 397 |
398 class AutofillDialogControllerTest : public ChromeRenderViewHostTestHarness { | 398 class AutofillDialogControllerTest : public ChromeRenderViewHostTestHarness { |
399 protected: | 399 protected: |
400 AutofillDialogControllerTest(): form_structure_(NULL) {} | 400 AutofillDialogControllerTest(): form_structure_(NULL) {} |
401 | 401 |
402 // testing::Test implementation: | 402 // testing::Test implementation: |
403 virtual void SetUp() OVERRIDE { | 403 virtual void SetUp() override { |
404 ChromeRenderViewHostTestHarness::SetUp(); | 404 ChromeRenderViewHostTestHarness::SetUp(); |
405 Reset(); | 405 Reset(); |
406 } | 406 } |
407 | 407 |
408 virtual void TearDown() OVERRIDE { | 408 virtual void TearDown() override { |
409 if (controller_) | 409 if (controller_) |
410 controller_->ViewClosed(); | 410 controller_->ViewClosed(); |
411 ChromeRenderViewHostTestHarness::TearDown(); | 411 ChromeRenderViewHostTestHarness::TearDown(); |
412 } | 412 } |
413 | 413 |
414 void Reset() { | 414 void Reset() { |
415 if (controller_) | 415 if (controller_) |
416 controller_->ViewClosed(); | 416 controller_->ViewClosed(); |
417 | 417 |
418 test_generated_bubble_controller_ = | 418 test_generated_bubble_controller_ = |
(...skipping 3242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3661 EXPECT_EQ(ASCIIToUTF16("United States"), form_structure()->field(2)->value); | 3661 EXPECT_EQ(ASCIIToUTF16("United States"), form_structure()->field(2)->value); |
3662 EXPECT_EQ(ADDRESS_HOME_COUNTRY, | 3662 EXPECT_EQ(ADDRESS_HOME_COUNTRY, |
3663 form_structure()->field(3)->Type().GetStorableType()); | 3663 form_structure()->field(3)->Type().GetStorableType()); |
3664 EXPECT_EQ(ASCIIToUTF16("US"), form_structure()->field(3)->value); | 3664 EXPECT_EQ(ASCIIToUTF16("US"), form_structure()->field(3)->value); |
3665 EXPECT_EQ(ADDRESS_HOME_COUNTRY, | 3665 EXPECT_EQ(ADDRESS_HOME_COUNTRY, |
3666 form_structure()->field(4)->Type().GetStorableType()); | 3666 form_structure()->field(4)->Type().GetStorableType()); |
3667 EXPECT_EQ(ASCIIToUTF16("United States"), form_structure()->field(4)->value); | 3667 EXPECT_EQ(ASCIIToUTF16("United States"), form_structure()->field(4)->value); |
3668 } | 3668 } |
3669 | 3669 |
3670 } // namespace autofill | 3670 } // namespace autofill |
OLD | NEW |