Chromium Code Reviews| 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 passwords_ui::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 passwords_ui::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 passwords_ui::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 { | 44 namespace passwords_ui { |
|
Patrick Dubroy
2013/11/13 11:38:07
I'd drop the namespace here as well.
shashi
2013/11/13 17:44:22
Done.
| |
| 45 | 45 |
| 46 class PasswordManagerPresenterTest : public testing::Test { | 46 class PasswordManagerPresenterTest : public testing::Test { |
| 47 protected: | 47 protected: |
| 48 PasswordManagerPresenterTest() {} | 48 PasswordManagerPresenterTest() {} |
| 49 | 49 |
| 50 virtual ~PasswordManagerPresenterTest() {} | 50 virtual ~PasswordManagerPresenterTest() {} |
| 51 virtual void SetUp() OVERRIDE { | 51 virtual void SetUp() OVERRIDE { |
| 52 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( | 52 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( |
| 53 &profile_, MockPasswordStore::Build); | 53 &profile_, MockPasswordStore::Build); |
| 54 mock_controller_.reset(new MockPasswordUIView(&profile_)); | 54 mock_controller_.reset(new MockPasswordUIView(&profile_)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 *GetUIController(), | 130 *GetUIController(), |
| 131 SetPasswordList( | 131 SetPasswordList( |
| 132 Property(&ScopedVector<autofill::PasswordForm>::size, Eq(2u)), true)); | 132 Property(&ScopedVector<autofill::PasswordForm>::size, Eq(2u)), true)); |
| 133 EXPECT_CALL(*GetUIController(), | 133 EXPECT_CALL(*GetUIController(), |
| 134 SetPasswordExceptionList(Property( | 134 SetPasswordExceptionList(Property( |
| 135 &ScopedVector<autofill::PasswordForm>::size, Eq(1u)))); | 135 &ScopedVector<autofill::PasswordForm>::size, Eq(1u)))); |
| 136 UpdateLists(); | 136 UpdateLists(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace | 139 } // namespace |
| 140 } // namespace options | 140 } // namespace passwords_ui |
| OLD | NEW |