OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/json/json_reader.h" | 5 #include "base/json/json_reader.h" |
6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 "\"upgraded_instrument_id\":\"instrument_id\"," | 574 "\"upgraded_instrument_id\":\"instrument_id\"," |
575 "\"use_minimal_addresses\":false" | 575 "\"use_minimal_addresses\":false" |
576 "}"; | 576 "}"; |
577 | 577 |
578 class MockAutofillMetrics : public AutofillMetrics { | 578 class MockAutofillMetrics : public AutofillMetrics { |
579 public: | 579 public: |
580 MockAutofillMetrics() {} | 580 MockAutofillMetrics() {} |
581 MOCK_CONST_METHOD2(LogWalletApiCallDuration, | 581 MOCK_CONST_METHOD2(LogWalletApiCallDuration, |
582 void(WalletApiCallMetric metric, | 582 void(WalletApiCallMetric metric, |
583 const base::TimeDelta& duration)); | 583 const base::TimeDelta& duration)); |
584 MOCK_CONST_METHOD2(LogWalletErrorMetric, | 584 MOCK_CONST_METHOD1(LogWalletErrorMetric, void(WalletErrorMetric metric)); |
585 void(DialogType dialog_type, WalletErrorMetric metric)); | 585 MOCK_CONST_METHOD1(LogWalletRequiredActionMetric, |
586 MOCK_CONST_METHOD2(LogWalletRequiredActionMetric, | 586 void(WalletRequiredActionMetric action)); |
587 void(DialogType dialog_type, | |
588 WalletRequiredActionMetric action)); | |
589 private: | 587 private: |
590 DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics); | 588 DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics); |
591 }; | 589 }; |
592 | 590 |
593 class MockWalletClientDelegate : public WalletClientDelegate { | 591 class MockWalletClientDelegate : public WalletClientDelegate { |
594 public: | 592 public: |
595 MockWalletClientDelegate() | 593 MockWalletClientDelegate() |
596 : full_wallets_received_(0), | 594 : full_wallets_received_(0), |
597 wallet_items_received_(0), | 595 wallet_items_received_(0), |
598 is_shipping_required_(true) {} | 596 is_shipping_required_(true) {} |
599 ~MockWalletClientDelegate() {} | 597 ~MockWalletClientDelegate() {} |
600 | 598 |
601 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { | 599 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { |
602 return metric_logger_; | 600 return metric_logger_; |
603 } | 601 } |
604 | 602 |
605 virtual DialogType GetDialogType() const OVERRIDE { | |
606 return DIALOG_TYPE_REQUEST_AUTOCOMPLETE; | |
607 } | |
608 | |
609 virtual std::string GetRiskData() const OVERRIDE { | 603 virtual std::string GetRiskData() const OVERRIDE { |
610 return "risky business"; | 604 return "risky business"; |
611 } | 605 } |
612 | 606 |
613 virtual std::string GetWalletCookieValue() const OVERRIDE { | 607 virtual std::string GetWalletCookieValue() const OVERRIDE { |
614 return "gdToken"; | 608 return "gdToken"; |
615 } | 609 } |
616 | 610 |
617 virtual bool IsShippingAddressRequired() const OVERRIDE { | 611 virtual bool IsShippingAddressRequired() const OVERRIDE { |
618 return is_shipping_required_; | 612 return is_shipping_required_; |
619 } | 613 } |
620 | 614 |
621 void SetIsShippingAddressRequired(bool is_shipping_required) { | 615 void SetIsShippingAddressRequired(bool is_shipping_required) { |
622 is_shipping_required_ = is_shipping_required; | 616 is_shipping_required_ = is_shipping_required; |
623 } | 617 } |
624 | 618 |
625 void ExpectLogWalletApiCallDuration( | 619 void ExpectLogWalletApiCallDuration( |
626 AutofillMetrics::WalletApiCallMetric metric, | 620 AutofillMetrics::WalletApiCallMetric metric, |
627 size_t times) { | 621 size_t times) { |
628 EXPECT_CALL(metric_logger_, | 622 EXPECT_CALL(metric_logger_, |
629 LogWalletApiCallDuration(metric, testing::_)).Times(times); | 623 LogWalletApiCallDuration(metric, testing::_)).Times(times); |
630 } | 624 } |
631 | 625 |
632 void ExpectWalletErrorMetric(AutofillMetrics::WalletErrorMetric metric) { | 626 void ExpectWalletErrorMetric(AutofillMetrics::WalletErrorMetric metric) { |
633 EXPECT_CALL( | 627 EXPECT_CALL(metric_logger_, LogWalletErrorMetric(metric)).Times(1); |
634 metric_logger_, | |
635 LogWalletErrorMetric( | |
636 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, metric)).Times(1); | |
637 } | 628 } |
638 | 629 |
639 void ExpectWalletRequiredActionMetric( | 630 void ExpectWalletRequiredActionMetric( |
640 AutofillMetrics::WalletRequiredActionMetric metric) { | 631 AutofillMetrics::WalletRequiredActionMetric metric) { |
641 EXPECT_CALL( | 632 EXPECT_CALL(metric_logger_, |
642 metric_logger_, | 633 LogWalletRequiredActionMetric(metric)).Times(1); |
643 LogWalletRequiredActionMetric( | |
644 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, metric)).Times(1); | |
645 } | 634 } |
646 | 635 |
647 void ExpectBaselineMetrics() { | 636 void ExpectBaselineMetrics() { |
648 EXPECT_CALL( | 637 EXPECT_CALL( |
649 metric_logger_, | 638 metric_logger_, |
650 LogWalletErrorMetric( | 639 LogWalletErrorMetric( |
651 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, | |
652 AutofillMetrics::WALLET_ERROR_BASELINE_ISSUED_REQUEST)) | 640 AutofillMetrics::WALLET_ERROR_BASELINE_ISSUED_REQUEST)) |
653 .Times(1); | 641 .Times(1); |
654 ExpectWalletRequiredActionMetric( | 642 ExpectWalletRequiredActionMetric( |
655 AutofillMetrics::WALLET_REQUIRED_ACTION_BASELINE_ISSUED_REQUEST); | 643 AutofillMetrics::WALLET_REQUIRED_ACTION_BASELINE_ISSUED_REQUEST); |
656 } | 644 } |
657 | 645 |
658 MockAutofillMetrics* metric_logger() { | 646 MockAutofillMetrics* metric_logger() { |
659 return &metric_logger_; | 647 return &metric_logger_; |
660 } | 648 } |
661 | 649 |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 wallet_client_->GetWalletItems(GURL(kMerchantUrl)); | 1702 wallet_client_->GetWalletItems(GURL(kMerchantUrl)); |
1715 EXPECT_EQ(2U, wallet_client_->pending_requests_.size()); | 1703 EXPECT_EQ(2U, wallet_client_->pending_requests_.size()); |
1716 | 1704 |
1717 wallet_client_->CancelRequests(); | 1705 wallet_client_->CancelRequests(); |
1718 EXPECT_EQ(0U, wallet_client_->pending_requests_.size()); | 1706 EXPECT_EQ(0U, wallet_client_->pending_requests_.size()); |
1719 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); | 1707 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); |
1720 } | 1708 } |
1721 | 1709 |
1722 } // namespace wallet | 1710 } // namespace wallet |
1723 } // namespace autofill | 1711 } // namespace autofill |
OLD | NEW |