Chromium Code Reviews| Index: chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc |
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc |
| index 70078fc9cf3eba95b80bec0e29b09a4f7fa14ba8..4aaadbc41b9eec5c77a1dd9a4cda63fcfd88d29a 100644 |
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc |
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc |
| @@ -13,6 +13,7 @@ |
| #include "chrome/test/base/testing_profile.h" |
| #include "components/autofill/browser/autofill_common_test.h" |
| #include "components/autofill/browser/autofill_metrics.h" |
| +#include "components/autofill/browser/risk/proto/fingerprint.pb.h" |
| #include "components/autofill/browser/test_personal_data_manager.h" |
| #include "components/autofill/browser/wallet/full_wallet.h" |
| #include "components/autofill/browser/wallet/instrument.h" |
| @@ -179,7 +180,12 @@ class TestAutofillDialogController |
| return &test_wallet_client_; |
| } |
| + MOCK_METHOD0(LoadRiskFingerprintData, void()); |
| + |
| void set_is_first_run(bool is_first_run) { is_first_run_ = is_first_run; } |
| + void set_fingerprint_data(std::string fingerprint_data) { |
|
Ilya Sherman
2013/05/03 07:38:31
nit: Pass by const-reference.
Dan Beam
2013/05/03 23:02:40
Done.
|
| + fingerprint_data_ = fingerprint_data; |
| + } |
| protected: |
| virtual PersonalDataManager* GetManager() OVERRIDE { |
| @@ -194,6 +200,12 @@ class TestAutofillDialogController |
| return is_first_run_; |
| } |
| + virtual void SerializeFingerprint(risk::Fingerprint* fingerprint, |
| + std::string* data) { |
| + // Ignore |fingerprint|, it's NULL. |
|
Ilya Sherman
2013/05/03 07:38:31
Why? It seems much better not to override this me
Dan Beam
2013/05/03 09:24:47
If it's obvious what the base64 encoded expected t
Ilya Sherman
2013/05/07 00:59:30
It's pretty easy to encode the data and DLOG what
Dan Beam
2013/05/07 05:02:38
Done.
|
| + data->assign(fingerprint_data_); |
| + } |
| + |
| private: |
| // To specify our own metric logger. |
| virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { |
| @@ -204,6 +216,7 @@ class TestAutofillDialogController |
| TestPersonalDataManager test_manager_; |
| testing::NiceMock<TestWalletClient> test_wallet_client_; |
| bool is_first_run_; |
| + std::string fingerprint_data_; |
| DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogController); |
| }; |
| @@ -238,7 +251,7 @@ class AutofillDialogControllerTest : public testing::Test { |
| base::Callback<void(const FormStructure*, const std::string&)> callback = |
| base::Bind(&AutofillDialogControllerTest::FinishedCallback, |
| base::Unretained(this)); |
| - controller_ = (new TestAutofillDialogController( |
| + controller_ = (new testing::NiceMock<TestAutofillDialogController>( |
| test_web_contents_.get(), |
| form_data, |
| GURL(), |
| @@ -942,4 +955,32 @@ TEST_F(AutofillDialogControllerTest, SaveDetailsInChrome) { |
| EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome()); |
| } |
| +TEST_F(AutofillDialogControllerTest, RiskRespectsLegalDocs) { |
| + EXPECT_CALL(*controller(), LoadRiskFingerprintData()).Times(0); |
| + |
| + scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| + wallet_items->AddLegalDocument(wallet::GetTestLegalDocument()); |
| + controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| + |
| + EXPECT_EQ("risky business", controller()->GetRiskData()); |
| +} |
| + |
| +TEST_F(AutofillDialogControllerTest, LoadRiskWhenNoLegalDocs) { |
| + EXPECT_CALL(*controller(), LoadRiskFingerprintData()).Times(1); |
| + |
| + scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
| + wallet_items->AddLegalDocument(wallet::GetTestLegalDocument()); |
| + controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| + controller()->OnDidAcceptLegalDocuments(); |
| + |
| + // No OnRiskFingerprintDataLoaded() has happened yet. |
| + EXPECT_EQ("risky business", controller()->GetRiskData()); |
| + |
| + scoped_ptr<risk::Fingerprint> fake_fingerprint; |
| + |
| + controller()->set_fingerprint_data("hello"); |
| + controller()->OnDidLoadRiskFingerprintData(fake_fingerprint.Pass()); |
| + EXPECT_EQ("aGVsbG8=", controller()->GetRiskData()); |
| +} |
| + |
| } // namespace autofill |