| 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 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/tuple.h" | 16 #include "base/tuple.h" |
| 17 #include "chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h" | |
| 18 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" | 17 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
| 19 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" | 18 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
| 20 #include "chrome/browser/ui/autofill/test_autofill_credit_card_bubble.h" | 19 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" |
| 20 #include "chrome/browser/ui/autofill/mock_new_credit_card_bubble_controller.h" |
| 21 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_view.h" |
| 21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/render_messages.h" | 23 #include "chrome/common/render_messages.h" |
| 23 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 24 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 24 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
| 25 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" | 26 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" |
| 26 #include "components/autofill/content/browser/wallet/full_wallet.h" | 27 #include "components/autofill/content/browser/wallet/full_wallet.h" |
| 27 #include "components/autofill/content/browser/wallet/instrument.h" | 28 #include "components/autofill/content/browser/wallet/instrument.h" |
| 28 #include "components/autofill/content/browser/wallet/mock_wallet_client.h" | 29 #include "components/autofill/content/browser/wallet/mock_wallet_client.h" |
| 29 #include "components/autofill/content/browser/wallet/wallet_address.h" | 30 #include "components/autofill/content/browser/wallet/wallet_address.h" |
| 30 #include "components/autofill/content/browser/wallet/wallet_service_url.h" | 31 #include "components/autofill/content/browser/wallet/wallet_service_url.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 : public AutofillDialogControllerImpl, | 187 : public AutofillDialogControllerImpl, |
| 187 public base::SupportsWeakPtr<TestAutofillDialogController> { | 188 public base::SupportsWeakPtr<TestAutofillDialogController> { |
| 188 public: | 189 public: |
| 189 TestAutofillDialogController( | 190 TestAutofillDialogController( |
| 190 content::WebContents* contents, | 191 content::WebContents* contents, |
| 191 const FormData& form_structure, | 192 const FormData& form_structure, |
| 192 const GURL& source_url, | 193 const GURL& source_url, |
| 193 const AutofillMetrics& metric_logger, | 194 const AutofillMetrics& metric_logger, |
| 194 const DialogType dialog_type, | 195 const DialogType dialog_type, |
| 195 const base::Callback<void(const FormStructure*, | 196 const base::Callback<void(const FormStructure*, |
| 196 const std::string&)>& callback) | 197 const std::string&)>& callback, |
| 198 MockNewCreditCardBubbleController* mock_new_card_bubble_controller) |
| 197 : AutofillDialogControllerImpl(contents, | 199 : AutofillDialogControllerImpl(contents, |
| 198 form_structure, | 200 form_structure, |
| 199 source_url, | 201 source_url, |
| 200 dialog_type, | 202 dialog_type, |
| 201 callback), | 203 callback), |
| 202 metric_logger_(metric_logger), | 204 metric_logger_(metric_logger), |
| 203 mock_wallet_client_( | 205 mock_wallet_client_( |
| 204 Profile::FromBrowserContext(contents->GetBrowserContext())-> | 206 Profile::FromBrowserContext(contents->GetBrowserContext())-> |
| 205 GetRequestContext(), this), | 207 GetRequestContext(), this), |
| 206 dialog_type_(dialog_type) {} | 208 dialog_type_(dialog_type), |
| 209 mock_new_card_bubble_controller_(mock_new_card_bubble_controller) {} |
| 210 |
| 207 virtual ~TestAutofillDialogController() {} | 211 virtual ~TestAutofillDialogController() {} |
| 208 | 212 |
| 209 virtual AutofillDialogView* CreateView() OVERRIDE { | 213 virtual AutofillDialogView* CreateView() OVERRIDE { |
| 210 return new testing::NiceMock<TestAutofillDialogView>(); | 214 return new testing::NiceMock<TestAutofillDialogView>(); |
| 211 } | 215 } |
| 212 | 216 |
| 213 void Init(content::BrowserContext* browser_context) { | 217 void Init(content::BrowserContext* browser_context) { |
| 214 test_manager_.Init(browser_context); | 218 test_manager_.Init(browser_context); |
| 215 } | 219 } |
| 216 | 220 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 virtual void OpenTabWithUrl(const GURL& url) OVERRIDE { | 262 virtual void OpenTabWithUrl(const GURL& url) OVERRIDE { |
| 259 open_tab_url_ = url; | 263 open_tab_url_ = url; |
| 260 } | 264 } |
| 261 | 265 |
| 262 // Whether the information input in this dialog will be securely transmitted | 266 // Whether the information input in this dialog will be securely transmitted |
| 263 // to the requesting site. | 267 // to the requesting site. |
| 264 virtual bool TransmissionWillBeSecure() const OVERRIDE { | 268 virtual bool TransmissionWillBeSecure() const OVERRIDE { |
| 265 return true; | 269 return true; |
| 266 } | 270 } |
| 267 | 271 |
| 272 virtual void ShowNewCreditCardBubble( |
| 273 scoped_ptr<CreditCard> new_card, |
| 274 scoped_ptr<AutofillProfile> billing_profile) OVERRIDE { |
| 275 mock_new_card_bubble_controller_->Show(new_card.Pass(), |
| 276 billing_profile.Pass()); |
| 277 } |
| 278 |
| 268 private: | 279 private: |
| 269 // To specify our own metric logger. | 280 // To specify our own metric logger. |
| 270 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { | 281 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { |
| 271 return metric_logger_; | 282 return metric_logger_; |
| 272 } | 283 } |
| 273 | 284 |
| 274 const AutofillMetrics& metric_logger_; | 285 const AutofillMetrics& metric_logger_; |
| 275 TestPersonalDataManager test_manager_; | 286 TestPersonalDataManager test_manager_; |
| 276 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; | 287 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; |
| 277 GURL open_tab_url_; | 288 GURL open_tab_url_; |
| 278 DialogType dialog_type_; | 289 DialogType dialog_type_; |
| 290 MockNewCreditCardBubbleController* mock_new_card_bubble_controller_; |
| 279 | 291 |
| 280 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController); | 292 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController); |
| 281 }; | 293 }; |
| 282 | 294 |
| 283 class TestAutofillCreditCardBubbleController : | 295 class TestGeneratedCreditCardBubbleController : |
| 284 public AutofillCreditCardBubbleController { | 296 public GeneratedCreditCardBubbleController { |
| 285 public: | 297 public: |
| 286 explicit TestAutofillCreditCardBubbleController( | 298 explicit TestGeneratedCreditCardBubbleController( |
| 287 content::WebContents* contents) | 299 content::WebContents* contents) |
| 288 : AutofillCreditCardBubbleController(contents) { | 300 : GeneratedCreditCardBubbleController(contents) { |
| 289 contents->SetUserData(UserDataKey(), this); | 301 contents->SetUserData(UserDataKey(), this); |
| 290 CHECK_EQ(contents->GetUserData(UserDataKey()), this); | 302 CHECK_EQ(contents->GetUserData(UserDataKey()), this); |
| 291 } | 303 } |
| 292 | 304 |
| 293 virtual ~TestAutofillCreditCardBubbleController() {} | 305 virtual ~TestGeneratedCreditCardBubbleController() {} |
| 294 | 306 |
| 295 MOCK_METHOD2(ShowAsGeneratedCardBubble, | 307 MOCK_METHOD2(SetupAndShow, void(const base::string16& backing_card_name, |
| 296 void(const base::string16& backing_card_name, | 308 const base::string16& fronting_card_name)); |
| 297 const base::string16& fronting_card_name)); | |
| 298 MOCK_METHOD1(ShowAsNewCardSavedBubble, | |
| 299 void(const base::string16& newly_saved_card_name)); | |
| 300 | 309 |
| 301 protected: | 310 protected: |
| 302 virtual base::WeakPtr<AutofillCreditCardBubble> CreateBubble() OVERRIDE { | 311 virtual base::WeakPtr<GeneratedCreditCardBubbleView> CreateBubble() OVERRIDE { |
| 303 return TestAutofillCreditCardBubble::Create(GetWeakPtr()); | 312 return TestGeneratedCreditCardBubbleView::Create(GetWeakPtr()); |
| 304 } | 313 } |
| 305 | 314 |
| 306 virtual bool CanShow() const OVERRIDE { | 315 virtual bool CanShow() const OVERRIDE { |
| 307 return true; | 316 return true; |
| 308 } | 317 } |
| 309 | 318 |
| 310 private: | 319 private: |
| 311 DISALLOW_COPY_AND_ASSIGN(TestAutofillCreditCardBubbleController); | 320 DISALLOW_COPY_AND_ASSIGN(TestGeneratedCreditCardBubbleController); |
| 312 }; | 321 }; |
| 313 | 322 |
| 314 class AutofillDialogControllerTest : public ChromeRenderViewHostTestHarness { | 323 class AutofillDialogControllerTest : public ChromeRenderViewHostTestHarness { |
| 315 protected: | 324 protected: |
| 316 AutofillDialogControllerTest(): form_structure_(NULL) {} | 325 AutofillDialogControllerTest(): form_structure_(NULL) {} |
| 317 | 326 |
| 318 // testing::Test implementation: | 327 // testing::Test implementation: |
| 319 virtual void SetUp() OVERRIDE { | 328 virtual void SetUp() OVERRIDE { |
| 320 ChromeRenderViewHostTestHarness::SetUp(); | 329 ChromeRenderViewHostTestHarness::SetUp(); |
| 321 | 330 Reset(); |
| 322 test_bubble_controller_ = | |
| 323 new testing::NiceMock<TestAutofillCreditCardBubbleController>( | |
| 324 web_contents()); | |
| 325 | |
| 326 // Don't get stuck on the first run wallet interstitial. | |
| 327 profile()->GetPrefs()->SetBoolean(::prefs::kAutofillDialogHasPaidWithWallet, | |
| 328 true); | |
| 329 | |
| 330 SetUpControllerWithFormData(DefaultFormData()); | |
| 331 } | 331 } |
| 332 | 332 |
| 333 virtual void TearDown() OVERRIDE { | 333 virtual void TearDown() OVERRIDE { |
| 334 if (controller_) | 334 if (controller_) |
| 335 controller_->ViewClosed(); | 335 controller_->ViewClosed(); |
| 336 ChromeRenderViewHostTestHarness::TearDown(); | 336 ChromeRenderViewHostTestHarness::TearDown(); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void Reset() { | 339 void Reset() { |
| 340 if (controller_) | 340 if (controller_) |
| 341 controller_->ViewClosed(); | 341 controller_->ViewClosed(); |
| 342 | 342 |
| 343 test_bubble_controller_ = | 343 test_generated_bubble_controller_ = |
| 344 new testing::NiceMock<TestAutofillCreditCardBubbleController>( | 344 new testing::NiceMock<TestGeneratedCreditCardBubbleController>( |
| 345 web_contents()); | 345 web_contents()); |
| 346 mock_new_card_bubble_controller_.reset( |
| 347 new MockNewCreditCardBubbleController); |
| 346 | 348 |
| 347 // Don't get stuck on the first run wallet interstitial. | 349 // Don't get stuck on the first run wallet interstitial. |
| 348 profile()->GetPrefs()->SetBoolean(::prefs::kAutofillDialogHasPaidWithWallet, | 350 profile()->GetPrefs()->SetBoolean(::prefs::kAutofillDialogHasPaidWithWallet, |
| 349 true); | 351 true); |
| 350 | 352 |
| 351 SetUpControllerWithFormData(DefaultFormData()); | 353 SetUpControllerWithFormData(DefaultFormData()); |
| 352 } | 354 } |
| 353 | 355 |
| 354 FormData DefaultFormData() { | 356 FormData DefaultFormData() { |
| 355 FormData form_data; | 357 FormData form_data; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 367 | 369 |
| 368 base::Callback<void(const FormStructure*, const std::string&)> callback = | 370 base::Callback<void(const FormStructure*, const std::string&)> callback = |
| 369 base::Bind(&AutofillDialogControllerTest::FinishedCallback, | 371 base::Bind(&AutofillDialogControllerTest::FinishedCallback, |
| 370 base::Unretained(this)); | 372 base::Unretained(this)); |
| 371 controller_ = (new testing::NiceMock<TestAutofillDialogController>( | 373 controller_ = (new testing::NiceMock<TestAutofillDialogController>( |
| 372 web_contents(), | 374 web_contents(), |
| 373 form_data, | 375 form_data, |
| 374 GURL(), | 376 GURL(), |
| 375 metric_logger_, | 377 metric_logger_, |
| 376 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, | 378 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, |
| 377 callback))->AsWeakPtr(); | 379 callback, |
| 380 mock_new_card_bubble_controller_.get()))->AsWeakPtr(); |
| 378 controller_->Init(profile()); | 381 controller_->Init(profile()); |
| 379 controller_->Show(); | 382 controller_->Show(); |
| 380 controller_->OnUserNameFetchSuccess(kFakeEmail); | 383 controller_->OnUserNameFetchSuccess(kFakeEmail); |
| 381 } | 384 } |
| 382 | 385 |
| 383 void FillCreditCardInputs() { | 386 void FillCreditCardInputs() { |
| 384 DetailOutputMap cc_outputs; | 387 DetailOutputMap cc_outputs; |
| 385 const DetailInputs& cc_inputs = | 388 const DetailInputs& cc_inputs = |
| 386 controller()->RequestedFieldsForSection(SECTION_CC); | 389 controller()->RequestedFieldsForSection(SECTION_CC); |
| 387 for (size_t i = 0; i < cc_inputs.size(); ++i) { | 390 for (size_t i = 0; i < cc_inputs.size(); ++i) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 Tuple1<bool> payload; | 457 Tuple1<bool> payload; |
| 455 ChromeViewMsg_SetVisuallyDeemphasized::Read(message, &payload); | 458 ChromeViewMsg_SetVisuallyDeemphasized::Read(message, &payload); |
| 456 process()->sink().ClearMessages(); | 459 process()->sink().ClearMessages(); |
| 457 return payload.a; | 460 return payload.a; |
| 458 } | 461 } |
| 459 | 462 |
| 460 TestAutofillDialogController* controller() { return controller_.get(); } | 463 TestAutofillDialogController* controller() { return controller_.get(); } |
| 461 | 464 |
| 462 const FormStructure* form_structure() { return form_structure_; } | 465 const FormStructure* form_structure() { return form_structure_; } |
| 463 | 466 |
| 464 TestAutofillCreditCardBubbleController* test_bubble_controller() { | 467 TestGeneratedCreditCardBubbleController* test_generated_bubble_controller() { |
| 465 return test_bubble_controller_; | 468 return test_generated_bubble_controller_; |
| 469 } |
| 470 |
| 471 const MockNewCreditCardBubbleController* mock_new_card_bubble_controller() { |
| 472 return mock_new_card_bubble_controller_.get(); |
| 466 } | 473 } |
| 467 | 474 |
| 468 private: | 475 private: |
| 469 void FinishedCallback(const FormStructure* form_structure, | 476 void FinishedCallback(const FormStructure* form_structure, |
| 470 const std::string& google_transaction_id) { | 477 const std::string& google_transaction_id) { |
| 471 form_structure_ = form_structure; | 478 form_structure_ = form_structure; |
| 472 if (controller()->GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT) | 479 if (controller()->GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT) |
| 473 EXPECT_TRUE(controller()->AutocheckoutIsRunning()); | 480 EXPECT_TRUE(controller()->AutocheckoutIsRunning()); |
| 474 } | 481 } |
| 475 | 482 |
| 476 #if defined(OS_WIN) | 483 #if defined(OS_WIN) |
| 477 // http://crbug.com/227221 | 484 // http://crbug.com/227221 |
| 478 ui::ScopedOleInitializer ole_initializer_; | 485 ui::ScopedOleInitializer ole_initializer_; |
| 479 #endif | 486 #endif |
| 480 | 487 |
| 481 // The controller owns itself. | 488 // The controller owns itself. |
| 482 base::WeakPtr<TestAutofillDialogController> controller_; | 489 base::WeakPtr<TestAutofillDialogController> controller_; |
| 483 | 490 |
| 484 // Must outlive the controller. | 491 // Must outlive the controller. |
| 485 AutofillMetrics metric_logger_; | 492 AutofillMetrics metric_logger_; |
| 486 | 493 |
| 487 // Returned when the dialog closes successfully. | 494 // Returned when the dialog closes successfully. |
| 488 const FormStructure* form_structure_; | 495 const FormStructure* form_structure_; |
| 489 | 496 |
| 490 // Used to monitor if the Autofill credit card bubble is shown. Owned by | 497 // Used to monitor if the Autofill credit card bubble is shown. Owned by |
| 491 // |web_contents()|. | 498 // |web_contents()|. |
| 492 TestAutofillCreditCardBubbleController* test_bubble_controller_; | 499 TestGeneratedCreditCardBubbleController* test_generated_bubble_controller_; |
| 500 |
| 501 // Used to record when new card bubbles would show. Created in |Reset()|. |
| 502 scoped_ptr<MockNewCreditCardBubbleController> |
| 503 mock_new_card_bubble_controller_; |
| 493 }; | 504 }; |
| 494 | 505 |
| 495 } // namespace | 506 } // namespace |
| 496 | 507 |
| 497 // This test makes sure nothing falls over when fields are being validity- | 508 // This test makes sure nothing falls over when fields are being validity- |
| 498 // checked. | 509 // checked. |
| 499 TEST_F(AutofillDialogControllerTest, ValidityCheck) { | 510 TEST_F(AutofillDialogControllerTest, ValidityCheck) { |
| 500 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { | 511 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { |
| 501 DialogSection section = static_cast<DialogSection>(i); | 512 DialogSection section = static_cast<DialogSection>(i); |
| 502 const DetailInputs& shipping_inputs = | 513 const DetailInputs& shipping_inputs = |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 controller()->RequestedFieldsForSection(SECTION_EMAIL); | 1492 controller()->RequestedFieldsForSection(SECTION_EMAIL); |
| 1482 EXPECT_EQ(kEmail, | 1493 EXPECT_EQ(kEmail, |
| 1483 controller()->SuggestionStateForSection(SECTION_EMAIL).text); | 1494 controller()->SuggestionStateForSection(SECTION_EMAIL).text); |
| 1484 EXPECT_EQ(string16(), inputs2[0].initial_value); | 1495 EXPECT_EQ(string16(), inputs2[0].initial_value); |
| 1485 } | 1496 } |
| 1486 | 1497 |
| 1487 // Tests that editing an autofill profile and then submitting works. | 1498 // Tests that editing an autofill profile and then submitting works. |
| 1488 TEST_F(AutofillDialogControllerTest, EditAutofillProfile) { | 1499 TEST_F(AutofillDialogControllerTest, EditAutofillProfile) { |
| 1489 SwitchToAutofill(); | 1500 SwitchToAutofill(); |
| 1490 | 1501 |
| 1491 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1502 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2); |
| 1492 | 1503 |
| 1493 AutofillProfile full_profile(test::GetVerifiedProfile()); | 1504 AutofillProfile full_profile(test::GetVerifiedProfile()); |
| 1505 CreditCard credit_card(test::GetVerifiedCreditCard()); |
| 1494 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1506 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 1507 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
| 1495 controller()->EditClickedForSection(SECTION_SHIPPING); | 1508 controller()->EditClickedForSection(SECTION_SHIPPING); |
| 1496 | 1509 |
| 1497 DetailOutputMap outputs; | 1510 DetailOutputMap outputs; |
| 1498 const DetailInputs& inputs = | 1511 const DetailInputs& inputs = |
| 1499 controller()->RequestedFieldsForSection(SECTION_SHIPPING); | 1512 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
| 1500 for (size_t i = 0; i < inputs.size(); ++i) { | 1513 for (size_t i = 0; i < inputs.size(); ++i) { |
| 1501 const DetailInput& input = inputs[i]; | 1514 const DetailInput& input = inputs[i]; |
| 1502 outputs[&input] = input.type == NAME_FULL ? ASCIIToUTF16("Edited Name") : | 1515 outputs[&input] = input.type == NAME_FULL ? ASCIIToUTF16("Edited Name") : |
| 1503 input.initial_value; | 1516 input.initial_value; |
| 1504 } | 1517 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 full_profile.GetInfo(AutofillType(EMAIL_ADDRESS), "en-US"); | 1575 full_profile.GetInfo(AutofillType(EMAIL_ADDRESS), "en-US"); |
| 1563 EXPECT_FALSE(original_email.empty()); | 1576 EXPECT_FALSE(original_email.empty()); |
| 1564 EXPECT_EQ(original_email, | 1577 EXPECT_EQ(original_email, |
| 1565 added_profile.GetInfo(AutofillType(EMAIL_ADDRESS), "en-US")); | 1578 added_profile.GetInfo(AutofillType(EMAIL_ADDRESS), "en-US")); |
| 1566 } | 1579 } |
| 1567 | 1580 |
| 1568 // Makes sure that a newly added email address gets added to an existing profile | 1581 // Makes sure that a newly added email address gets added to an existing profile |
| 1569 // (as opposed to creating its own profile). http://crbug.com/240926 | 1582 // (as opposed to creating its own profile). http://crbug.com/240926 |
| 1570 TEST_F(AutofillDialogControllerTest, AddEmail) { | 1583 TEST_F(AutofillDialogControllerTest, AddEmail) { |
| 1571 SwitchToAutofill(); | 1584 SwitchToAutofill(); |
| 1572 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1585 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2); |
| 1573 | 1586 |
| 1574 AutofillProfile full_profile(test::GetVerifiedProfile()); | 1587 AutofillProfile full_profile(test::GetVerifiedProfile()); |
| 1588 CreditCard credit_card(test::GetVerifiedCreditCard()); |
| 1575 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1589 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 1590 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
| 1576 | 1591 |
| 1577 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_EMAIL); | 1592 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_EMAIL); |
| 1578 ASSERT_TRUE(model); | 1593 ASSERT_TRUE(model); |
| 1579 // Activate the "Add email address" menu item. | 1594 // Activate the "Add email address" menu item. |
| 1580 model->ActivatedAt(model->GetItemCount() - 2); | 1595 model->ActivatedAt(model->GetItemCount() - 2); |
| 1581 | 1596 |
| 1582 // Fill in the inputs from the profile. | 1597 // Fill in the inputs from the profile. |
| 1583 DetailOutputMap outputs; | 1598 DetailOutputMap outputs; |
| 1584 const DetailInputs& inputs = | 1599 const DetailInputs& inputs = |
| 1585 controller()->RequestedFieldsForSection(SECTION_EMAIL); | 1600 controller()->RequestedFieldsForSection(SECTION_EMAIL); |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2388 controller()->CurrentAutocheckoutSteps()[1].status()); | 2403 controller()->CurrentAutocheckoutSteps()[1].status()); |
| 2389 EXPECT_EQ(AUTOCHECKOUT_STEP_BILLING, | 2404 EXPECT_EQ(AUTOCHECKOUT_STEP_BILLING, |
| 2390 controller()->CurrentAutocheckoutSteps()[2].type()); | 2405 controller()->CurrentAutocheckoutSteps()[2].type()); |
| 2391 EXPECT_EQ(AUTOCHECKOUT_STEP_UNSTARTED, | 2406 EXPECT_EQ(AUTOCHECKOUT_STEP_UNSTARTED, |
| 2392 controller()->CurrentAutocheckoutSteps()[2].status()); | 2407 controller()->CurrentAutocheckoutSteps()[2].status()); |
| 2393 | 2408 |
| 2394 controller()->ViewClosed(); | 2409 controller()->ViewClosed(); |
| 2395 EXPECT_FALSE(ReadSetVisuallyDeemphasizedIpc()); | 2410 EXPECT_FALSE(ReadSetVisuallyDeemphasizedIpc()); |
| 2396 } | 2411 } |
| 2397 | 2412 |
| 2398 | |
| 2399 TEST_F(AutofillDialogControllerTest, NewCardBubbleShown) { | 2413 TEST_F(AutofillDialogControllerTest, NewCardBubbleShown) { |
| 2400 EXPECT_CALL(*test_bubble_controller(), | 2414 EXPECT_CALL(*test_generated_bubble_controller(), SetupAndShow(_, _)).Times(0); |
| 2401 ShowAsNewCardSavedBubble(ASCIIToUTF16("Visa - 1111"))).Times(1); | |
| 2402 EXPECT_CALL(*test_bubble_controller(), | |
| 2403 ShowAsGeneratedCardBubble(_, _)).Times(0); | |
| 2404 | 2415 |
| 2405 SwitchToAutofill(); | 2416 SwitchToAutofill(); |
| 2406 FillCreditCardInputs(); | 2417 FillCreditCardInputs(); |
| 2407 controller()->OnAccept(); | 2418 controller()->OnAccept(); |
| 2408 controller()->ViewClosed(); | 2419 controller()->ViewClosed(); |
| 2420 |
| 2421 EXPECT_EQ(1, mock_new_card_bubble_controller()->bubbles_shown()); |
| 2409 } | 2422 } |
| 2410 | 2423 |
| 2411 TEST_F(AutofillDialogControllerTest, GeneratedCardBubbleShown) { | 2424 TEST_F(AutofillDialogControllerTest, GeneratedCardBubbleShown) { |
| 2412 EXPECT_CALL(*test_bubble_controller(), | 2425 EXPECT_CALL(*test_generated_bubble_controller(), SetupAndShow(_, _)).Times(1); |
| 2413 ShowAsGeneratedCardBubble(_, _)).Times(1); | |
| 2414 EXPECT_CALL(*test_bubble_controller(), ShowAsNewCardSavedBubble(_)).Times(0); | |
| 2415 | 2426 |
| 2416 SubmitWithWalletItems(CompleteAndValidWalletItems()); | 2427 SubmitWithWalletItems(CompleteAndValidWalletItems()); |
| 2417 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); | 2428 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); |
| 2418 controller()->ViewClosed(); | 2429 controller()->ViewClosed(); |
| 2430 |
| 2431 EXPECT_EQ(0, mock_new_card_bubble_controller()->bubbles_shown()); |
| 2419 } | 2432 } |
| 2420 | 2433 |
| 2421 TEST_F(AutofillDialogControllerTest, ReloadWalletItemsOnActivation) { | 2434 TEST_F(AutofillDialogControllerTest, ReloadWalletItemsOnActivation) { |
| 2422 // Switch into Wallet mode and initialize some Wallet data. | 2435 // Switch into Wallet mode and initialize some Wallet data. |
| 2423 SwitchToWallet(); | 2436 SwitchToWallet(); |
| 2424 | 2437 |
| 2425 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 2438 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| 2426 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 2439 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 2427 wallet_items->AddInstrument(wallet::GetTestNonDefaultMaskedInstrument()); | 2440 wallet_items->AddInstrument(wallet::GetTestNonDefaultMaskedInstrument()); |
| 2428 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress()); | 2441 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2484 controller()->TabActivated(); | 2497 controller()->TabActivated(); |
| 2485 | 2498 |
| 2486 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); | 2499 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); |
| 2487 | 2500 |
| 2488 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING)); | 2501 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING)); |
| 2489 EXPECT_EQ( | 2502 EXPECT_EQ( |
| 2490 3, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); | 2503 3, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); |
| 2491 } | 2504 } |
| 2492 | 2505 |
| 2493 TEST_F(AutofillDialogControllerTest, GeneratedCardBubbleNotShown) { | 2506 TEST_F(AutofillDialogControllerTest, GeneratedCardBubbleNotShown) { |
| 2494 EXPECT_CALL(*test_bubble_controller(), | 2507 EXPECT_CALL(*test_generated_bubble_controller(), SetupAndShow(_, _)).Times(0); |
| 2495 ShowAsGeneratedCardBubble(_, _)).Times(0); | |
| 2496 EXPECT_CALL(*test_bubble_controller(), ShowAsNewCardSavedBubble(_)).Times(0); | |
| 2497 | 2508 |
| 2498 SubmitWithWalletItems(CompleteAndValidWalletItems()); | 2509 SubmitWithWalletItems(CompleteAndValidWalletItems()); |
| 2499 controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT); | 2510 controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT); |
| 2500 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); | 2511 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); |
| 2501 controller()->OnAutocheckoutError(); | 2512 controller()->OnAutocheckoutError(); |
| 2502 controller()->ViewClosed(); | 2513 controller()->ViewClosed(); |
| 2514 |
| 2515 EXPECT_EQ(0, mock_new_card_bubble_controller()->bubbles_shown()); |
| 2503 } | 2516 } |
| 2504 | 2517 |
| 2505 } // namespace autofill | 2518 } // namespace autofill |
| OLD | NEW |