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/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "components/autofill/core/browser/popup_item_ids.h" | 8 #include "components/autofill/core/browser/popup_item_ids.h" |
9 #include "components/autofill/core/browser/test_autofill_client.h" | 9 #include "components/autofill/core/browser/test_autofill_client.h" |
10 #include "components/autofill/core/browser/test_autofill_driver.h" | 10 #include "components/autofill/core/browser/test_autofill_driver.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 class MockPasswordManagerDriver : public StubPasswordManagerDriver { | 36 class MockPasswordManagerDriver : public StubPasswordManagerDriver { |
37 public: | 37 public: |
38 MOCK_METHOD2(FillSuggestion, | 38 MOCK_METHOD2(FillSuggestion, |
39 void(const base::string16&, const base::string16&)); | 39 void(const base::string16&, const base::string16&)); |
40 MOCK_METHOD2(PreviewSuggestion, | 40 MOCK_METHOD2(PreviewSuggestion, |
41 void(const base::string16&, const base::string16&)); | 41 void(const base::string16&, const base::string16&)); |
42 }; | 42 }; |
43 | 43 |
44 class TestPasswordManagerClient : public StubPasswordManagerClient { | 44 class TestPasswordManagerClient : public StubPasswordManagerClient { |
45 public: | 45 public: |
46 virtual PasswordManagerDriver* GetDriver() override { return &driver_; } | 46 virtual PasswordManagerDriver* GetDriver() OVERRIDE { return &driver_; } |
47 | 47 |
48 MockPasswordManagerDriver* mock_driver() { return &driver_; } | 48 MockPasswordManagerDriver* mock_driver() { return &driver_; } |
49 | 49 |
50 private: | 50 private: |
51 MockPasswordManagerDriver driver_; | 51 MockPasswordManagerDriver driver_; |
52 }; | 52 }; |
53 | 53 |
54 class MockAutofillClient : public autofill::TestAutofillClient { | 54 class MockAutofillClient : public autofill::TestAutofillClient { |
55 public: | 55 public: |
56 MOCK_METHOD7(ShowAutofillPopup, | 56 MOCK_METHOD7(ShowAutofillPopup, |
57 void(const gfx::RectF& element_bounds, | 57 void(const gfx::RectF& element_bounds, |
58 base::i18n::TextDirection text_direction, | 58 base::i18n::TextDirection text_direction, |
59 const std::vector<base::string16>& values, | 59 const std::vector<base::string16>& values, |
60 const std::vector<base::string16>& labels, | 60 const std::vector<base::string16>& labels, |
61 const std::vector<base::string16>& icons, | 61 const std::vector<base::string16>& icons, |
62 const std::vector<int>& identifiers, | 62 const std::vector<int>& identifiers, |
63 base::WeakPtr<autofill::AutofillPopupDelegate> delegate)); | 63 base::WeakPtr<autofill::AutofillPopupDelegate> delegate)); |
64 MOCK_METHOD0(HideAutofillPopup, void()); | 64 MOCK_METHOD0(HideAutofillPopup, void()); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 class PasswordAutofillManagerTest : public testing::Test { | 69 class PasswordAutofillManagerTest : public testing::Test { |
70 protected: | 70 protected: |
71 PasswordAutofillManagerTest() | 71 PasswordAutofillManagerTest() |
72 : test_username_(base::ASCIIToUTF16(kAliceUsername)), | 72 : test_username_(base::ASCIIToUTF16(kAliceUsername)), |
73 test_password_(base::ASCIIToUTF16(kAlicePassword)) {} | 73 test_password_(base::ASCIIToUTF16(kAlicePassword)) {} |
74 | 74 |
75 virtual void SetUp() override { | 75 virtual void SetUp() OVERRIDE { |
76 // Add a preferred login and an additional login to the FillData. | 76 // Add a preferred login and an additional login to the FillData. |
77 username_field_.name = base::ASCIIToUTF16(kUsernameName); | 77 username_field_.name = base::ASCIIToUTF16(kUsernameName); |
78 username_field_.value = test_username_; | 78 username_field_.value = test_username_; |
79 fill_data_.basic_data.fields.push_back(username_field_); | 79 fill_data_.basic_data.fields.push_back(username_field_); |
80 | 80 |
81 autofill::FormFieldData password_field; | 81 autofill::FormFieldData password_field; |
82 password_field.name = base::ASCIIToUTF16(kPasswordName); | 82 password_field.name = base::ASCIIToUTF16(kPasswordName); |
83 password_field.value = test_password_; | 83 password_field.value = test_password_; |
84 fill_data_.basic_data.fields.push_back(password_field); | 84 fill_data_.basic_data.fields.push_back(password_field); |
85 } | 85 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 password_autofill_manager_->OnShowPasswordSuggestions( | 185 password_autofill_manager_->OnShowPasswordSuggestions( |
186 username_field_, element_bounds, suggestions, realms); | 186 username_field_, element_bounds, suggestions, realms); |
187 | 187 |
188 // Accepting a suggestion should trigger a call to hide the popup. | 188 // Accepting a suggestion should trigger a call to hide the popup. |
189 EXPECT_CALL(*autofill_client, HideAutofillPopup()); | 189 EXPECT_CALL(*autofill_client, HideAutofillPopup()); |
190 password_autofill_manager_->DidAcceptSuggestion( | 190 password_autofill_manager_->DidAcceptSuggestion( |
191 suggestions[0], autofill::POPUP_ITEM_ID_PASSWORD_ENTRY); | 191 suggestions[0], autofill::POPUP_ITEM_ID_PASSWORD_ENTRY); |
192 } | 192 } |
193 | 193 |
194 } // namespace password_manager | 194 } // namespace password_manager |
OLD | NEW |