| 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/password_manager/mock_password_store.h" | 6 #include "chrome/browser/password_manager/mock_password_store.h" |
| 7 #include "chrome/browser/password_manager/password_store_factory.h" | 7 #include "chrome/browser/password_manager/password_store_factory.h" |
| 8 #include "chrome/browser/ui/password/password_ui_view.h" | 8 #include "chrome/browser/ui/passwords/password_manager_presenter.h" |
| 9 #include "chrome/browser/ui/webui/options/password_manager_presenter.h" | 9 #include "chrome/browser/ui/passwords/password_ui_view.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 using base::ASCIIToUTF16; | 14 using base::ASCIIToUTF16; |
| 15 using testing::Eq; | 15 using testing::Eq; |
| 16 using testing::Property; | 16 using testing::Property; |
| 17 | 17 |
| 18 class MockPasswordUIView : public passwords_ui::PasswordUIView { | 18 class MockPasswordUIView : public PasswordUIView { |
| 19 public: | 19 public: |
| 20 explicit MockPasswordUIView(Profile* profile) | 20 explicit MockPasswordUIView(Profile* profile) |
| 21 : profile_(profile), password_manager_presenter_(this) { | 21 : profile_(profile), password_manager_presenter_(this) { |
| 22 password_manager_presenter_.Initialize(); | 22 password_manager_presenter_.Initialize(); |
| 23 } | 23 } |
| 24 virtual ~MockPasswordUIView() {} | 24 virtual ~MockPasswordUIView() {} |
| 25 virtual Profile* GetProfile() OVERRIDE; | 25 virtual Profile* GetProfile() OVERRIDE; |
| 26 MOCK_METHOD2(ShowPassword, void(size_t, const string16&)); | 26 MOCK_METHOD2(ShowPassword, void(size_t, const string16&)); |
| 27 MOCK_METHOD2(SetPasswordList, | 27 MOCK_METHOD2(SetPasswordList, |
| 28 void(const ScopedVector<autofill::PasswordForm>&, bool)); | 28 void(const ScopedVector<autofill::PasswordForm>&, bool)); |
| 29 MOCK_METHOD1(SetPasswordExceptionList, | 29 MOCK_METHOD1(SetPasswordExceptionList, |
| 30 void(const ScopedVector<autofill::PasswordForm>&)); | 30 void(const ScopedVector<autofill::PasswordForm>&)); |
| 31 options::PasswordManagerPresenter* GetPasswordManagerPresenter() { | 31 PasswordManagerPresenter* GetPasswordManagerPresenter() { |
| 32 return &password_manager_presenter_; | 32 return &password_manager_presenter_; |
| 33 } | 33 } |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 Profile* profile_; | 36 Profile* profile_; |
| 37 options::PasswordManagerPresenter password_manager_presenter_; | 37 PasswordManagerPresenter password_manager_presenter_; |
| 38 | 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(MockPasswordUIView); | 39 DISALLOW_COPY_AND_ASSIGN(MockPasswordUIView); |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 Profile* MockPasswordUIView::GetProfile() { return profile_; } | 42 Profile* MockPasswordUIView::GetProfile() { return profile_; } |
| 43 | 43 |
| 44 namespace options { | |
| 45 | |
| 46 class PasswordManagerPresenterTest : public testing::Test { | 44 class PasswordManagerPresenterTest : public testing::Test { |
| 47 protected: | 45 protected: |
| 48 PasswordManagerPresenterTest() {} | 46 PasswordManagerPresenterTest() {} |
| 49 | 47 |
| 50 virtual ~PasswordManagerPresenterTest() {} | 48 virtual ~PasswordManagerPresenterTest() {} |
| 51 virtual void SetUp() OVERRIDE { | 49 virtual void SetUp() OVERRIDE { |
| 52 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( | 50 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( |
| 53 &profile_, MockPasswordStore::Build); | 51 &profile_, MockPasswordStore::Build); |
| 54 mock_controller_.reset(new MockPasswordUIView(&profile_)); | 52 mock_controller_.reset(new MockPasswordUIView(&profile_)); |
| 55 } | 53 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 *GetUIController(), | 128 *GetUIController(), |
| 131 SetPasswordList( | 129 SetPasswordList( |
| 132 Property(&ScopedVector<autofill::PasswordForm>::size, Eq(2u)), true)); | 130 Property(&ScopedVector<autofill::PasswordForm>::size, Eq(2u)), true)); |
| 133 EXPECT_CALL(*GetUIController(), | 131 EXPECT_CALL(*GetUIController(), |
| 134 SetPasswordExceptionList(Property( | 132 SetPasswordExceptionList(Property( |
| 135 &ScopedVector<autofill::PasswordForm>::size, Eq(1u)))); | 133 &ScopedVector<autofill::PasswordForm>::size, Eq(1u)))); |
| 136 UpdateLists(); | 134 UpdateLists(); |
| 137 } | 135 } |
| 138 | 136 |
| 139 } // namespace | 137 } // namespace |
| 140 } // namespace options | |
| OLD | NEW |