| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 public: | 40 public: |
| 41 MOCK_METHOD1(OnGetPasswordStoreResultsConstRef, | 41 MOCK_METHOD1(OnGetPasswordStoreResultsConstRef, |
| 42 void(const std::vector<PasswordForm*>&)); | 42 void(const std::vector<PasswordForm*>&)); |
| 43 | 43 |
| 44 // GMock cannot mock methods with move-only args. | 44 // GMock cannot mock methods with move-only args. |
| 45 void OnGetPasswordStoreResults(ScopedVector<PasswordForm> results) override { | 45 void OnGetPasswordStoreResults(ScopedVector<PasswordForm> results) override { |
| 46 OnGetPasswordStoreResultsConstRef(results.get()); | 46 OnGetPasswordStoreResultsConstRef(results.get()); |
| 47 } | 47 } |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class MockPasswordStoreObserver | |
| 51 : public password_manager::PasswordStore::Observer { | |
| 52 public: | |
| 53 MOCK_METHOD1(OnLoginsChanged, | |
| 54 void(const password_manager::PasswordStoreChangeList& changes)); | |
| 55 }; | |
| 56 | |
| 57 class FailingBackend : public PasswordStoreX::NativeBackend { | 50 class FailingBackend : public PasswordStoreX::NativeBackend { |
| 58 public: | 51 public: |
| 59 bool Init() override { return true; } | 52 bool Init() override { return true; } |
| 60 | 53 |
| 61 PasswordStoreChangeList AddLogin(const PasswordForm& form) override { | 54 PasswordStoreChangeList AddLogin(const PasswordForm& form) override { |
| 62 return PasswordStoreChangeList(); | 55 return PasswordStoreChangeList(); |
| 63 } | 56 } |
| 64 bool UpdateLogin(const PasswordForm& form, | 57 bool UpdateLogin(const PasswordForm& form, |
| 65 PasswordStoreChangeList* changes) override { | 58 PasswordStoreChangeList* changes) override { |
| 66 return false; | 59 return false; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 password_manager::PasswordFormData form_data = { | 308 password_manager::PasswordFormData form_data = { |
| 316 PasswordForm::SCHEME_HTML, "http://bar.example.com", | 309 PasswordForm::SCHEME_HTML, "http://bar.example.com", |
| 317 "http://bar.example.com/origin", "http://bar.example.com/action", | 310 "http://bar.example.com/origin", "http://bar.example.com/action", |
| 318 L"submit_element", L"username_element", | 311 L"submit_element", L"username_element", |
| 319 L"password_element", L"username_value", | 312 L"password_element", L"username_value", |
| 320 L"password_value", true, | 313 L"password_value", true, |
| 321 false, 1}; | 314 false, 1}; |
| 322 scoped_ptr<PasswordForm> form = | 315 scoped_ptr<PasswordForm> form = |
| 323 CreatePasswordFormFromDataForTesting(form_data); | 316 CreatePasswordFormFromDataForTesting(form_data); |
| 324 | 317 |
| 325 MockPasswordStoreObserver observer; | 318 password_manager::MockPasswordStoreObserver observer; |
| 326 store->AddObserver(&observer); | 319 store->AddObserver(&observer); |
| 327 | 320 |
| 328 const PasswordStoreChange expected_add_changes[] = { | 321 const PasswordStoreChange expected_add_changes[] = { |
| 329 PasswordStoreChange(PasswordStoreChange::ADD, *form), | 322 PasswordStoreChange(PasswordStoreChange::ADD, *form), |
| 330 }; | 323 }; |
| 331 | 324 |
| 332 EXPECT_CALL( | 325 EXPECT_CALL( |
| 333 observer, | 326 observer, |
| 334 OnLoginsChanged(ElementsAreArray(expected_add_changes))); | 327 OnLoginsChanged(ElementsAreArray(expected_add_changes))); |
| 335 | 328 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 474 |
| 482 INSTANTIATE_TEST_CASE_P(NoBackend, | 475 INSTANTIATE_TEST_CASE_P(NoBackend, |
| 483 PasswordStoreXTest, | 476 PasswordStoreXTest, |
| 484 testing::Values(NO_BACKEND)); | 477 testing::Values(NO_BACKEND)); |
| 485 INSTANTIATE_TEST_CASE_P(FailingBackend, | 478 INSTANTIATE_TEST_CASE_P(FailingBackend, |
| 486 PasswordStoreXTest, | 479 PasswordStoreXTest, |
| 487 testing::Values(FAILING_BACKEND)); | 480 testing::Values(FAILING_BACKEND)); |
| 488 INSTANTIATE_TEST_CASE_P(WorkingBackend, | 481 INSTANTIATE_TEST_CASE_P(WorkingBackend, |
| 489 PasswordStoreXTest, | 482 PasswordStoreXTest, |
| 490 testing::Values(WORKING_BACKEND)); | 483 testing::Values(WORKING_BACKEND)); |
| OLD | NEW |