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

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

Issue 21668003: Implement newly saved card bubble for realz and update generated card bubble to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile Created 7 years, 4 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 <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.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
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
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<GeneratedCreditCardBubble> CreateBubble() OVERRIDE {
303 return TestAutofillCreditCardBubble::Create(GetWeakPtr()); 312 return TestGeneratedCreditCardBubble::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
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
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 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 controller()->RequestedFieldsForSection(SECTION_EMAIL); 1474 controller()->RequestedFieldsForSection(SECTION_EMAIL);
1464 EXPECT_EQ(kEmail, 1475 EXPECT_EQ(kEmail,
1465 controller()->SuggestionStateForSection(SECTION_EMAIL).text); 1476 controller()->SuggestionStateForSection(SECTION_EMAIL).text);
1466 EXPECT_EQ(string16(), inputs2[0].initial_value); 1477 EXPECT_EQ(string16(), inputs2[0].initial_value);
1467 } 1478 }
1468 1479
1469 // Tests that editing an autofill profile and then submitting works. 1480 // Tests that editing an autofill profile and then submitting works.
1470 TEST_F(AutofillDialogControllerTest, EditAutofillProfile) { 1481 TEST_F(AutofillDialogControllerTest, EditAutofillProfile) {
1471 SwitchToAutofill(); 1482 SwitchToAutofill();
1472 1483
1473 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); 1484 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2);
1474 1485
1475 AutofillProfile full_profile(test::GetVerifiedProfile()); 1486 AutofillProfile full_profile(test::GetVerifiedProfile());
1487 CreditCard credit_card(test::GetVerifiedCreditCard());
1476 controller()->GetTestingManager()->AddTestingProfile(&full_profile); 1488 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
1489 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card);
1477 controller()->EditClickedForSection(SECTION_SHIPPING); 1490 controller()->EditClickedForSection(SECTION_SHIPPING);
1478 1491
1479 DetailOutputMap outputs; 1492 DetailOutputMap outputs;
1480 const DetailInputs& inputs = 1493 const DetailInputs& inputs =
1481 controller()->RequestedFieldsForSection(SECTION_SHIPPING); 1494 controller()->RequestedFieldsForSection(SECTION_SHIPPING);
1482 for (size_t i = 0; i < inputs.size(); ++i) { 1495 for (size_t i = 0; i < inputs.size(); ++i) {
1483 const DetailInput& input = inputs[i]; 1496 const DetailInput& input = inputs[i];
1484 outputs[&input] = input.type == NAME_FULL ? ASCIIToUTF16("Edited Name") : 1497 outputs[&input] = input.type == NAME_FULL ? ASCIIToUTF16("Edited Name") :
1485 input.initial_value; 1498 input.initial_value;
1486 } 1499 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 // profile. 1554 // profile.
1542 string16 original_email = full_profile.GetInfo(EMAIL_ADDRESS, "en-US"); 1555 string16 original_email = full_profile.GetInfo(EMAIL_ADDRESS, "en-US");
1543 EXPECT_FALSE(original_email.empty()); 1556 EXPECT_FALSE(original_email.empty());
1544 EXPECT_EQ(original_email, 1557 EXPECT_EQ(original_email,
1545 added_profile.GetInfo(EMAIL_ADDRESS, "en-US")); 1558 added_profile.GetInfo(EMAIL_ADDRESS, "en-US"));
1546 } 1559 }
1547 1560
1548 // Makes sure that a newly added email address gets added to an existing profile 1561 // Makes sure that a newly added email address gets added to an existing profile
1549 // (as opposed to creating its own profile). http://crbug.com/240926 1562 // (as opposed to creating its own profile). http://crbug.com/240926
1550 TEST_F(AutofillDialogControllerTest, AddEmail) { 1563 TEST_F(AutofillDialogControllerTest, AddEmail) {
1551 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); 1564 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2);
1552 1565
1553 AutofillProfile full_profile(test::GetVerifiedProfile()); 1566 AutofillProfile full_profile(test::GetVerifiedProfile());
1567 CreditCard credit_card(test::GetVerifiedCreditCard());
1554 controller()->GetTestingManager()->AddTestingProfile(&full_profile); 1568 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
1569 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card);
1555 1570
1556 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_EMAIL); 1571 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_EMAIL);
1557 ASSERT_TRUE(model); 1572 ASSERT_TRUE(model);
1558 // Activate the "Add email address" menu item. 1573 // Activate the "Add email address" menu item.
1559 model->ActivatedAt(model->GetItemCount() - 2); 1574 model->ActivatedAt(model->GetItemCount() - 2);
1560 1575
1561 // Fill in the inputs from the profile. 1576 // Fill in the inputs from the profile.
1562 DetailOutputMap outputs; 1577 DetailOutputMap outputs;
1563 const DetailInputs& inputs = 1578 const DetailInputs& inputs =
1564 controller()->RequestedFieldsForSection(SECTION_EMAIL); 1579 controller()->RequestedFieldsForSection(SECTION_EMAIL);
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
2359 controller()->CurrentAutocheckoutSteps()[1].status()); 2374 controller()->CurrentAutocheckoutSteps()[1].status());
2360 EXPECT_EQ(AUTOCHECKOUT_STEP_BILLING, 2375 EXPECT_EQ(AUTOCHECKOUT_STEP_BILLING,
2361 controller()->CurrentAutocheckoutSteps()[2].type()); 2376 controller()->CurrentAutocheckoutSteps()[2].type());
2362 EXPECT_EQ(AUTOCHECKOUT_STEP_UNSTARTED, 2377 EXPECT_EQ(AUTOCHECKOUT_STEP_UNSTARTED,
2363 controller()->CurrentAutocheckoutSteps()[2].status()); 2378 controller()->CurrentAutocheckoutSteps()[2].status());
2364 2379
2365 controller()->ViewClosed(); 2380 controller()->ViewClosed();
2366 EXPECT_FALSE(ReadSetVisuallyDeemphasizedIpc()); 2381 EXPECT_FALSE(ReadSetVisuallyDeemphasizedIpc());
2367 } 2382 }
2368 2383
2369
2370 TEST_F(AutofillDialogControllerTest, NewCardBubbleShown) { 2384 TEST_F(AutofillDialogControllerTest, NewCardBubbleShown) {
2371 EXPECT_CALL(*test_bubble_controller(), 2385 EXPECT_CALL(*test_generated_bubble_controller(), SetupAndShow(_, _)).Times(0);
2372 ShowAsNewCardSavedBubble(ASCIIToUTF16("Visa - 1111"))).Times(1);
2373 EXPECT_CALL(*test_bubble_controller(),
2374 ShowAsGeneratedCardBubble(_, _)).Times(0);
2375 2386
2376 SwitchToAutofill(); 2387 SwitchToAutofill();
2377 FillCreditCardInputs(); 2388 FillCreditCardInputs();
2378 controller()->OnAccept(); 2389 controller()->OnAccept();
2379 controller()->ViewClosed(); 2390 controller()->ViewClosed();
2391
2392 EXPECT_EQ(1, mock_new_card_bubble_controller()->bubbles_shown());
2380 } 2393 }
2381 2394
2382 TEST_F(AutofillDialogControllerTest, GeneratedCardBubbleShown) { 2395 TEST_F(AutofillDialogControllerTest, GeneratedCardBubbleShown) {
2383 EXPECT_CALL(*test_bubble_controller(), 2396 EXPECT_CALL(*test_generated_bubble_controller(), SetupAndShow(_, _)).Times(1);
2384 ShowAsGeneratedCardBubble(_, _)).Times(1);
2385 EXPECT_CALL(*test_bubble_controller(), ShowAsNewCardSavedBubble(_)).Times(0);
2386 2397
2387 SubmitWithWalletItems(CompleteAndValidWalletItems()); 2398 SubmitWithWalletItems(CompleteAndValidWalletItems());
2388 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); 2399 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet());
2389 controller()->ViewClosed(); 2400 controller()->ViewClosed();
2401
2402 EXPECT_EQ(0, mock_new_card_bubble_controller()->bubbles_shown());
2390 } 2403 }
2391 2404
2392 TEST_F(AutofillDialogControllerTest, ReloadWalletItemsOnActivation) { 2405 TEST_F(AutofillDialogControllerTest, ReloadWalletItemsOnActivation) {
2393 // Switch into Wallet mode and initialize some Wallet data. 2406 // Switch into Wallet mode and initialize some Wallet data.
2394 SwitchToWallet(); 2407 SwitchToWallet();
2395 2408
2396 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 2409 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
2397 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); 2410 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
2398 wallet_items->AddInstrument(wallet::GetTestNonDefaultMaskedInstrument()); 2411 wallet_items->AddInstrument(wallet::GetTestNonDefaultMaskedInstrument());
2399 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress()); 2412 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 controller()->TabActivated(); 2468 controller()->TabActivated();
2456 2469
2457 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); 2470 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems());
2458 2471
2459 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING)); 2472 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING));
2460 EXPECT_EQ( 2473 EXPECT_EQ(
2461 3, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); 2474 3, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount());
2462 } 2475 }
2463 2476
2464 TEST_F(AutofillDialogControllerTest, GeneratedCardBubbleNotShown) { 2477 TEST_F(AutofillDialogControllerTest, GeneratedCardBubbleNotShown) {
2465 EXPECT_CALL(*test_bubble_controller(), 2478 EXPECT_CALL(*test_generated_bubble_controller(), SetupAndShow(_, _)).Times(0);
2466 ShowAsGeneratedCardBubble(_, _)).Times(0);
2467 EXPECT_CALL(*test_bubble_controller(), ShowAsNewCardSavedBubble(_)).Times(0);
2468 2479
2469 SubmitWithWalletItems(CompleteAndValidWalletItems()); 2480 SubmitWithWalletItems(CompleteAndValidWalletItems());
2470 controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT); 2481 controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT);
2471 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); 2482 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet());
2472 controller()->OnAutocheckoutError(); 2483 controller()->OnAutocheckoutError();
2473 controller()->ViewClosed(); 2484 controller()->ViewClosed();
2485
2486 EXPECT_EQ(0, mock_new_card_bubble_controller()->bubbles_shown());
2474 } 2487 }
2475 2488
2476 } // namespace autofill 2489 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698