Chromium Code Reviews| Index: components/password_manager/core/browser/password_store_unittest.cc |
| diff --git a/components/password_manager/core/browser/password_store_unittest.cc b/components/password_manager/core/browser/password_store_unittest.cc |
| index 681d0421ef5b5cf854137a2712a6c78eac0b2b2f..057fbfdb01b0b7a0d6f5d9c78ffd82a9a12ffb7c 100644 |
| --- a/components/password_manager/core/browser/password_store_unittest.cc |
| +++ b/components/password_manager/core/browser/password_store_unittest.cc |
| @@ -27,8 +27,13 @@ namespace { |
| class MockPasswordStoreConsumer : public 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 StartSyncFlareMock { |
| @@ -130,11 +135,10 @@ TEST_F(PasswordStoreTest, IgnoreOldWwwGoogleLogins) { |
| }; |
| // Build the forms vector and add the forms to the store. |
| - std::vector<PasswordForm*> all_forms; |
| + ScopedVector<PasswordForm> all_forms; |
| for (size_t i = 0; i < arraysize(form_data); ++i) { |
| - PasswordForm* form = CreatePasswordFormFromData(form_data[i]); |
| - all_forms.push_back(form); |
| - store->AddLogin(*form); |
| + all_forms.push_back(CreatePasswordFormFromData(form_data[i]).release()); |
| + store->AddLogin(*all_forms.back()); |
| } |
| base::MessageLoop::current()->RunUntilIdle(); |
| @@ -164,20 +168,15 @@ TEST_F(PasswordStoreTest, IgnoreOldWwwGoogleLogins) { |
| bar_example_expected.push_back(all_forms[4]); |
| MockPasswordStoreConsumer consumer; |
| - |
| - // Expect the appropriate replies, as above, in reverse order than we will |
| - // issue the queries. Each retires on saturation to avoid matcher spew. |
| - EXPECT_CALL(consumer, OnGetPasswordStoreResults( |
| - ContainsAllPasswordForms(bar_example_expected))) |
| - .WillOnce(WithArg<0>(STLDeleteElements0())) |
| - .RetiresOnSaturation(); |
| - EXPECT_CALL(consumer, OnGetPasswordStoreResults( |
| - ContainsAllPasswordForms(accounts_google_expected))) |
| - .WillOnce(WithArg<0>(STLDeleteElements0())) |
| + testing::InSequence s; |
| + EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef( |
| + ContainsSamePasswordForms(www_google_expected))) |
| .RetiresOnSaturation(); |
|
vasilii
2015/02/09 10:08:35
I'm not sure if you need it here and below. The ex
vabr (Chromium)
2015/02/09 11:36:06
I do need it. Without the saturation the expectati
|
| - EXPECT_CALL(consumer, OnGetPasswordStoreResults( |
| - ContainsAllPasswordForms(www_google_expected))) |
| - .WillOnce(WithArg<0>(STLDeleteElements0())) |
| + EXPECT_CALL(consumer, |
| + OnGetPasswordStoreResultsConstRef(ContainsSamePasswordForms( |
| + accounts_google_expected))).RetiresOnSaturation(); |
| + EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef( |
| + ContainsSamePasswordForms(bar_example_expected))) |
| .RetiresOnSaturation(); |
| store->GetLogins(www_google, PasswordStore::ALLOW_PROMPT, &consumer); |
| @@ -186,7 +185,6 @@ TEST_F(PasswordStoreTest, IgnoreOldWwwGoogleLogins) { |
| base::MessageLoop::current()->RunUntilIdle(); |
| - STLDeleteElements(&all_forms); |
| store->Shutdown(); |
| base::MessageLoop::current()->RunUntilIdle(); |
| } |