Chromium Code Reviews| Index: chrome/browser/password_manager/password_store_x_unittest.cc |
| diff --git a/chrome/browser/password_manager/password_store_x_unittest.cc b/chrome/browser/password_manager/password_store_x_unittest.cc |
| index 80b8b9a257c799acbf27512fa96c22fd3cf1c0fb..704df06cfca0724c8e7bd85199e4f15671dc3d50 100644 |
| --- a/chrome/browser/password_manager/password_store_x_unittest.cc |
| +++ b/chrome/browser/password_manager/password_store_x_unittest.cc |
| @@ -26,10 +26,11 @@ |
| #include "testing/gtest/include/gtest/gtest.h" |
| using autofill::PasswordForm; |
| -using password_manager::ContainsAllPasswordForms; |
| +using password_manager::ContainsSamePasswordForms; |
| using password_manager::PasswordStoreChange; |
| using password_manager::PasswordStoreChangeList; |
| using testing::_; |
| +using testing::ElementsAre; |
| using testing::ElementsAreArray; |
| using testing::WithArg; |
| @@ -38,8 +39,13 @@ namespace { |
| class MockPasswordStoreConsumer |
| : public password_manager::PasswordStoreConsumer { |
| public: |
| - MOCK_METHOD1(OnGetPasswordStoreResults, |
| + MOCK_METHOD1(OnGetPasswordStoreResultsConstRef, |
| void(const std::vector<PasswordForm*>&)); |
| + |
| + // GMock cannot mock methods with move-only args. |
| + void OnGetPasswordStoreResults(ScopedVector<PasswordForm> results) override { |
| + OnGetPasswordStoreResultsConstRef(results.get()); |
| + } |
| }; |
| class MockPasswordStoreObserver |
| @@ -233,7 +239,7 @@ void InitExpectedForms(bool autofillable, |
| autofillable, |
| false, |
| static_cast<double>(i + 1)}; |
| - forms->push_back(CreatePasswordFormFromData(data)); |
| + forms->push_back(CreatePasswordFormFromData(data).release()); |
| } |
| } |
| @@ -292,7 +298,7 @@ TEST_P(PasswordStoreXTest, Notifications) { |
| L"password_element", L"username_value", |
| L"password_value", true, |
| false, 1}; |
| - scoped_ptr<PasswordForm> form(CreatePasswordFormFromData(form_data)); |
| + scoped_ptr<PasswordForm> form = CreatePasswordFormFromData(form_data); |
| MockPasswordStoreObserver observer; |
| store->AddObserver(&observer); |
| @@ -388,31 +394,29 @@ TEST_P(PasswordStoreXTest, NativeMigration) { |
| MockPasswordStoreConsumer consumer; |
| // The autofillable forms should have been migrated to the native backend. |
| - EXPECT_CALL(consumer, OnGetPasswordStoreResults(ContainsAllPasswordForms( |
| - expected_autofillable.get()))) |
| - .WillOnce(WithArg<0>(STLDeleteElements0())); |
| + EXPECT_CALL(consumer, |
| + OnGetPasswordStoreResultsConstRef( |
| + ContainsSamePasswordForms(expected_autofillable.get()))); |
| store->GetAutofillableLogins(&consumer); |
| base::RunLoop().RunUntilIdle(); |
| // The blacklisted forms should have been migrated to the native backend. |
| - EXPECT_CALL(consumer, OnGetPasswordStoreResults(ContainsAllPasswordForms( |
| - expected_blacklisted.get()))) |
| - .WillOnce(WithArg<0>(STLDeleteElements0())); |
| + EXPECT_CALL(consumer, |
| + OnGetPasswordStoreResultsConstRef( |
| + ContainsSamePasswordForms(expected_blacklisted.get()))); |
| store->GetBlacklistLogins(&consumer); |
| base::RunLoop().RunUntilIdle(); |
| - ScopedVector<autofill::PasswordForm> empty; |
| MockLoginDatabaseReturn ld_return; |
| if (GetParam() == WORKING_BACKEND) { |
| // No autofillable logins should be left in the login DB. |
| - EXPECT_CALL(ld_return, OnLoginDatabaseQueryDone( |
| - ContainsAllPasswordForms(empty.get()))); |
| + EXPECT_CALL(ld_return, OnLoginDatabaseQueryDone(ElementsAre())); |
|
vasilii
2015/02/05 19:23:27
IsEmpty() here and below.
vabr (Chromium)
2015/02/06 14:16:05
Done.
|
| } else { |
| // The autofillable logins should still be in the login DB. |
| - EXPECT_CALL(ld_return, OnLoginDatabaseQueryDone(ContainsAllPasswordForms( |
| + EXPECT_CALL(ld_return, OnLoginDatabaseQueryDone(ContainsSamePasswordForms( |
| expected_autofillable.get()))); |
| } |
| @@ -423,11 +427,10 @@ TEST_P(PasswordStoreXTest, NativeMigration) { |
| if (GetParam() == WORKING_BACKEND) { |
| // Likewise, no blacklisted logins should be left in the login DB. |
| - EXPECT_CALL(ld_return, OnLoginDatabaseQueryDone( |
| - ContainsAllPasswordForms(empty.get()))); |
| + EXPECT_CALL(ld_return, OnLoginDatabaseQueryDone(ElementsAre())); |
| } else { |
| // The blacklisted logins should still be in the login DB. |
| - EXPECT_CALL(ld_return, OnLoginDatabaseQueryDone(ContainsAllPasswordForms( |
| + EXPECT_CALL(ld_return, OnLoginDatabaseQueryDone(ContainsSamePasswordForms( |
| expected_blacklisted.get()))); |
| } |